diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/pages/instance/ModFolderPage.cpp | 35 | ||||
-rw-r--r-- | application/pages/instance/ModFolderPage.h | 29 | ||||
-rw-r--r-- | application/pages/instance/ModFolderPage.ui | 268 | ||||
-rw-r--r-- | application/pages/instance/ResourcePackPage.h | 2 | ||||
-rw-r--r-- | application/pages/instance/TexturePackPage.h | 2 |
5 files changed, 161 insertions, 175 deletions
diff --git a/application/pages/instance/ModFolderPage.cpp b/application/pages/instance/ModFolderPage.cpp index 590a65b1..f70166e4 100644 --- a/application/pages/instance/ModFolderPage.cpp +++ b/application/pages/instance/ModFolderPage.cpp @@ -20,6 +20,7 @@ #include <QEvent> #include <QKeyEvent> #include <QAbstractItemModel> +#include <QMenu> #include "MultiMC.h" #include "dialogs/CustomMessageBox.h" @@ -34,10 +35,9 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList> mods, QString id, QString iconName, QString displayName, QString helpPage, QWidget *parent) - : QWidget(parent), ui(new Ui::ModFolderPage) + : QMainWindow(parent), ui(new Ui::ModFolderPage) { ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); m_inst = inst; on_RunningState_changed(m_inst && m_inst->isRunning()); m_mods = mods; @@ -61,6 +61,13 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList> connect(m_inst, &BaseInstance::runningStatusChanged, this, &ModFolderPage::on_RunningState_changed); } +QMenu * ModFolderPage::createPopupMenu() +{ + QMenu* filteredMenu = QMainWindow::createPopupMenu(); + filteredMenu->removeAction(ui->actionsToolbar->toggleViewAction() ); + return filteredMenu; +} + void ModFolderPage::openedImpl() { m_mods->startWatching(); @@ -97,10 +104,10 @@ void ModFolderPage::on_RunningState_changed(bool running) return; } m_controlsEnabled = !running; - ui->addModBtn->setEnabled(m_controlsEnabled); - ui->disableModBtn->setEnabled(m_controlsEnabled); - ui->enableModBtn->setEnabled(m_controlsEnabled); - ui->rmModBtn->setEnabled(m_controlsEnabled); + ui->actionAdd->setEnabled(m_controlsEnabled); + ui->actionDisable->setEnabled(m_controlsEnabled); + ui->actionEnable->setEnabled(m_controlsEnabled); + ui->actionRemove->setEnabled(m_controlsEnabled); } bool ModFolderPage::shouldDisplay() const @@ -139,10 +146,10 @@ bool ModFolderPage::modListFilter(QKeyEvent *keyEvent) switch (keyEvent->key()) { case Qt::Key_Delete: - on_rmModBtn_clicked(); + on_actionRemove_triggered(); return true; case Qt::Key_Plus: - on_addModBtn_clicked(); + on_actionAdd_triggered(); return true; default: break; @@ -162,7 +169,7 @@ bool ModFolderPage::eventFilter(QObject *obj, QEvent *ev) return QWidget::eventFilter(obj, ev); } -void ModFolderPage::on_addModBtn_clicked() +void ModFolderPage::on_actionAdd_triggered() { if(!m_controlsEnabled) { return; @@ -183,7 +190,7 @@ void ModFolderPage::on_addModBtn_clicked() } } -void ModFolderPage::on_enableModBtn_clicked() +void ModFolderPage::on_actionEnable_triggered() { if(!m_controlsEnabled) { return; @@ -192,7 +199,7 @@ void ModFolderPage::on_enableModBtn_clicked() m_mods->enableMods(selection.indexes(), true); } -void ModFolderPage::on_disableModBtn_clicked() +void ModFolderPage::on_actionDisable_triggered() { if(!m_controlsEnabled) { return; @@ -201,7 +208,7 @@ void ModFolderPage::on_disableModBtn_clicked() m_mods->enableMods(selection.indexes(), false); } -void ModFolderPage::on_rmModBtn_clicked() +void ModFolderPage::on_actionRemove_triggered() { if(!m_controlsEnabled) { return; @@ -210,12 +217,12 @@ void ModFolderPage::on_rmModBtn_clicked() m_mods->deleteMods(selection.indexes()); } -void ModFolderPage::on_configFolderBtn_clicked() +void ModFolderPage::on_actionView_configs_triggered() { DesktopServices::openDirectory(m_inst->instanceConfigFolder(), true); } -void ModFolderPage::on_viewModBtn_clicked() +void ModFolderPage::on_actionView_Folder_triggered() { DesktopServices::openDirectory(m_mods->dir().absolutePath(), true); } diff --git a/application/pages/instance/ModFolderPage.h b/application/pages/instance/ModFolderPage.h index 77fe877d..1bdf03a2 100644 --- a/application/pages/instance/ModFolderPage.h +++ b/application/pages/instance/ModFolderPage.h @@ -15,7 +15,7 @@ #pragma once -#include <QWidget> +#include <QMainWindow> #include "minecraft/MinecraftInstance.h" #include "pages/BasePage.h" @@ -27,14 +27,20 @@ namespace Ui class ModFolderPage; } -class ModFolderPage : public QWidget, public BasePage +class ModFolderPage : public QMainWindow, public BasePage { Q_OBJECT public: - explicit ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList> mods, QString id, - QString iconName, QString displayName, QString helpPage = "", - QWidget *parent = 0); + explicit ModFolderPage( + BaseInstance *inst, + std::shared_ptr<SimpleModList> mods, + QString id, + QString iconName, + QString displayName, + QString helpPage = "", + QWidget *parent = 0 + ); virtual ~ModFolderPage(); void setFilter(const QString & filter) @@ -65,6 +71,7 @@ public: protected: bool eventFilter(QObject *obj, QEvent *ev) override; bool modListFilter(QKeyEvent *ev); + QMenu * createPopupMenu() override; protected: BaseInstance *m_inst = nullptr; @@ -89,12 +96,12 @@ private slots: void on_filterTextChanged(const QString & newContents); void on_RunningState_changed(bool running); - void on_addModBtn_clicked(); - void on_rmModBtn_clicked(); - void on_viewModBtn_clicked(); - void on_enableModBtn_clicked(); - void on_disableModBtn_clicked(); - void on_configFolderBtn_clicked(); + void on_actionAdd_triggered(); + void on_actionRemove_triggered(); + void on_actionEnable_triggered(); + void on_actionDisable_triggered(); + void on_actionView_Folder_triggered(); + void on_actionView_configs_triggered(); }; class CoreModFolderPage : public ModFolderPage diff --git a/application/pages/instance/ModFolderPage.ui b/application/pages/instance/ModFolderPage.ui index b5597bdc..7f371100 100644 --- a/application/pages/instance/ModFolderPage.ui +++ b/application/pages/instance/ModFolderPage.ui @@ -1,155 +1,138 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ModFolderPage</class> - <widget class="QWidget" name="ModFolderPage"> + <widget class="QMainWindow" name="ModFolderPage"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>723</width> - <height>532</height> + <width>1042</width> + <height>501</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QGridLayout" name="gridLayout"> + <property name="leftMargin"> + <number>0</number> + </property> + <property name="topMargin"> + <number>0</number> + </property> + <property name="rightMargin"> + <number>0</number> + </property> + <property name="bottomMargin"> + <number>0</number> + </property> + <item row="4" column="1" colspan="3"> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="1"> + <widget class="QLineEdit" name="filterEdit"> + <property name="clearButtonEnabled"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="filterLabel"> + <property name="text"> + <string>Filter:</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="1" colspan="3"> + <widget class="MCModInfoFrame" name="frame"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + <item row="1" column="1" colspan="3"> + <widget class="ModListView" name="modTreeView"> <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <attribute name="title"> - <string notr="true">Tab 1</string> - </attribute> - <layout class="QGridLayout" name="gridLayout" columnstretch="0,1,0"> - <item row="0" column="2"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="addModBtn"> - <property name="text"> - <string>&Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="rmModBtn"> - <property name="text"> - <string>&Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="enableModBtn"> - <property name="text"> - <string>Enable</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="disableModBtn"> - <property name="text"> - <string>Disable</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="configFolderBtn"> - <property name="toolTip"> - <string>Open the 'config' folder in the system file manager.</string> - </property> - <property name="text"> - <string>View configs</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="viewModBtn"> - <property name="text"> - <string>&View Folder</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="1" column="0" colspan="3"> - <widget class="MCModInfoFrame" name="frame"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Minimum"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="1"> - <widget class="QLineEdit" name="filterEdit"> - <property name="clearButtonEnabled"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="filterLabel"> - <property name="text"> - <string>Filter:</string> - </property> - </widget> - </item> - <item row="0" column="0" colspan="3"> - <widget class="ModListView" name="modTreeView"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="acceptDrops"> - <bool>true</bool> - </property> - <property name="dragDropMode"> - <enum>QAbstractItemView::DropOnly</enum> - </property> - </widget> - </item> - </layout> - </item> - </layout> + <property name="acceptDrops"> + <bool>true</bool> + </property> + <property name="dragDropMode"> + <enum>QAbstractItemView::DropOnly</enum> + </property> </widget> - </widget> - </item> - </layout> + </item> + </layout> + </widget> + <widget class="QToolBar" name="actionsToolbar"> + <property name="windowTitle"> + <string>Actions</string> + </property> + <property name="allowedAreas"> + <set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set> + </property> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextOnly</enum> + </property> + <property name="floatable"> + <bool>false</bool> + </property> + <attribute name="toolBarArea"> + <enum>RightToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + <addaction name="actionAdd"/> + <addaction name="actionRemove"/> + <addaction name="actionEnable"/> + <addaction name="actionDisable"/> + <addaction name="separator"/> + <addaction name="actionView_configs"/> + <addaction name="actionView_Folder"/> + </widget> + <action name="actionAdd"> + <property name="text"> + <string>Add</string> + </property> + </action> + <action name="actionRemove"> + <property name="text"> + <string>Remove</string> + </property> + </action> + <action name="actionEnable"> + <property name="text"> + <string>Enable</string> + </property> + </action> + <action name="actionDisable"> + <property name="text"> + <string>Disable</string> + </property> + </action> + <action name="actionView_configs"> + <property name="text"> + <string>View configs</string> + </property> + <property name="toolTip"> + <string>Open the 'config' folder in the system file manager.</string> + </property> + </action> + <action name="actionView_Folder"> + <property name="text"> + <string>View Folder</string> + </property> + </action> </widget> <customwidgets> <customwidget> @@ -164,17 +147,6 @@ <container>1</container> </customwidget> </customwidgets> - <tabstops> - <tabstop>tabWidget</tabstop> - <tabstop>modTreeView</tabstop> - <tabstop>filterEdit</tabstop> - <tabstop>addModBtn</tabstop> - <tabstop>rmModBtn</tabstop> - <tabstop>enableModBtn</tabstop> - <tabstop>disableModBtn</tabstop> - <tabstop>configFolderBtn</tabstop> - <tabstop>viewModBtn</tabstop> - </tabstops> <resources/> <connections/> </ui> diff --git a/application/pages/instance/ResourcePackPage.h b/application/pages/instance/ResourcePackPage.h index 409c9e7d..e11c78a3 100644 --- a/application/pages/instance/ResourcePackPage.h +++ b/application/pages/instance/ResourcePackPage.h @@ -10,7 +10,7 @@ public: : ModFolderPage(instance, instance->resourcePackList(), "resourcepacks", "resourcepacks", tr("Resource packs"), "Resource-packs", parent) { - ui->configFolderBtn->setHidden(true); + ui->actionView_configs->setVisible(false); } virtual ~ResourcePackPage() {} diff --git a/application/pages/instance/TexturePackPage.h b/application/pages/instance/TexturePackPage.h index 2ba5b866..a792ba07 100644 --- a/application/pages/instance/TexturePackPage.h +++ b/application/pages/instance/TexturePackPage.h @@ -10,7 +10,7 @@ public: : ModFolderPage(instance, instance->texturePackList(), "texturepacks", "resourcepacks", tr("Texture packs"), "Texture-packs", parent) { - ui->configFolderBtn->setHidden(true); + ui->actionView_configs->setVisible(false); } virtual ~TexturePackPage() {} virtual bool shouldDisplay() const override |