From decd4ae7ab66c8ce1deb8f84392e048cd5c64cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 16 Jul 2019 01:30:53 +0200 Subject: [PATCH] NOISSUE Make mod folder pages use toolbars instead of button layouts --- application/pages/instance/ModFolderPage.cpp | 35 ++- application/pages/instance/ModFolderPage.h | 29 +- application/pages/instance/ModFolderPage.ui | 268 ++++++++---------- application/pages/instance/ResourcePackPage.h | 2 +- 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 #include #include +#include #include "MultiMC.h" #include "dialogs/CustomMessageBox.h" @@ -34,10 +35,9 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr 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 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 +#include #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 mods, QString id, - QString iconName, QString displayName, QString helpPage = "", - QWidget *parent = 0); + explicit ModFolderPage( + BaseInstance *inst, + std::shared_ptr 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 @@ ModFolderPage - + 0 0 - 723 - 532 + 1042 + 501 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - 0 - - + + MainWindow + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + true + + + + + + + Filter: + + + + + + + - + 0 0 - - Tab 1 - - - - - - - - &Add - - - - - - - &Remove - - - - - - - Enable - - - - - - - Disable - - - - - - - Open the 'config' folder in the system file manager. - - - View configs - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - &View Folder - - - - - - - - - - 0 - 0 - - - - - - - - - - true - - - - - - - Filter: - - - - - - - - 0 - 0 - - - - true - - - QAbstractItemView::DropOnly - - - - - - - - - + + + + + + 0 + 0 + + + + true + + + QAbstractItemView::DropOnly + + + + + + + + Actions + + + Qt::LeftToolBarArea|Qt::RightToolBarArea + + + Qt::ToolButtonTextOnly + + + false + + + RightToolBarArea + + + false + + + + + + + + + + + + Add + + + + + Remove + + + + + Enable + + + + + Disable + + + + + View configs + + + Open the 'config' folder in the system file manager. + + + + + View Folder + + @@ -164,17 +147,6 @@ 1 - - tabWidget - modTreeView - filterEdit - addModBtn - rmModBtn - enableModBtn - disableModBtn - configFolderBtn - viewModBtn - 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