diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-07-17 02:01:29 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-07-17 02:01:29 +0200 |
commit | 95febe543615c16d5b97cdd6f379c9a62102321d (patch) | |
tree | 60c3cf31de93e0be96e28c85297e3440b1325e4c /application/pages/instance | |
parent | 5b153a516566446b88cca73afac34f9abfdd82e2 (diff) | |
download | MultiMC-95febe543615c16d5b97cdd6f379c9a62102321d.tar MultiMC-95febe543615c16d5b97cdd6f379c9a62102321d.tar.gz MultiMC-95febe543615c16d5b97cdd6f379c9a62102321d.tar.lz MultiMC-95febe543615c16d5b97cdd6f379c9a62102321d.tar.xz MultiMC-95febe543615c16d5b97cdd6f379c9a62102321d.zip |
NOISSUE convert rest of the instance pages to use toolbars for side menus
Diffstat (limited to 'application/pages/instance')
-rw-r--r-- | application/pages/instance/ModFolderPage.cpp | 6 | ||||
-rw-r--r-- | application/pages/instance/ModFolderPage.ui | 1 | ||||
-rw-r--r-- | application/pages/instance/ScreenshotsPage.cpp | 23 | ||||
-rw-r--r-- | application/pages/instance/ScreenshotsPage.h | 16 | ||||
-rw-r--r-- | application/pages/instance/ScreenshotsPage.ui | 152 | ||||
-rw-r--r-- | application/pages/instance/ServersPage.cpp | 27 | ||||
-rw-r--r-- | application/pages/instance/ServersPage.h | 17 | ||||
-rw-r--r-- | application/pages/instance/ServersPage.ui | 331 | ||||
-rw-r--r-- | application/pages/instance/VersionPage.cpp | 22 | ||||
-rw-r--r-- | application/pages/instance/WorldListPage.cpp | 57 | ||||
-rw-r--r-- | application/pages/instance/WorldListPage.h | 41 | ||||
-rw-r--r-- | application/pages/instance/WorldListPage.ui | 270 |
12 files changed, 454 insertions, 509 deletions
diff --git a/application/pages/instance/ModFolderPage.cpp b/application/pages/instance/ModFolderPage.cpp index f70166e4..bd070b94 100644 --- a/application/pages/instance/ModFolderPage.cpp +++ b/application/pages/instance/ModFolderPage.cpp @@ -38,6 +38,12 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList> : QMainWindow(parent), ui(new Ui::ModFolderPage) { ui->setupUi(this); + + QWidget* spacer = new QWidget(); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + // toolBar is a pointer to an existing toolbar + ui->actionsToolbar->insertWidget(ui->actionView_configs, spacer); + m_inst = inst; on_RunningState_changed(m_inst && m_inst->isRunning()); m_mods = mods; diff --git a/application/pages/instance/ModFolderPage.ui b/application/pages/instance/ModFolderPage.ui index 7f371100..1fcaa4d9 100644 --- a/application/pages/instance/ModFolderPage.ui +++ b/application/pages/instance/ModFolderPage.ui @@ -96,7 +96,6 @@ <addaction name="actionRemove"/> <addaction name="actionEnable"/> <addaction name="actionDisable"/> - <addaction name="separator"/> <addaction name="actionView_configs"/> <addaction name="actionView_Folder"/> </widget> diff --git a/application/pages/instance/ScreenshotsPage.cpp b/application/pages/instance/ScreenshotsPage.cpp index e61bf5c1..0c00d1c4 100644 --- a/application/pages/instance/ScreenshotsPage.cpp +++ b/application/pages/instance/ScreenshotsPage.cpp @@ -13,6 +13,7 @@ #include <QPainter> #include <QClipboard> #include <QKeyEvent> +#include <QMenu> #include <MultiMC.h> @@ -209,7 +210,7 @@ public: }; ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent) - : QWidget(parent), ui(new Ui::ScreenshotsPage) + : QMainWindow(parent), ui(new Ui::ScreenshotsPage) { m_model.reset(new QFileSystemModel()); m_filterModel.reset(new FilterModel()); @@ -222,7 +223,6 @@ ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent) m_valid = FS::ensureFolderPathExists(m_folder); ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); ui->listView->setIconSize(QSize(128, 128)); ui->listView->setGridSize(QSize(192, 160)); ui->listView->setSpacing(9); @@ -248,10 +248,10 @@ bool ScreenshotsPage::eventFilter(QObject *obj, QEvent *evt) switch (keyEvent->key()) { case Qt::Key_Delete: - on_deleteBtn_clicked(); + on_actionDelete_triggered(); return true; case Qt::Key_F2: - on_renameBtn_clicked(); + on_actionRename_triggered(); return true; default: break; @@ -264,6 +264,13 @@ ScreenshotsPage::~ScreenshotsPage() delete ui; } +QMenu * ScreenshotsPage::createPopupMenu() +{ + QMenu* filteredMenu = QMainWindow::createPopupMenu(); + filteredMenu->removeAction( ui->toolBar->toggleViewAction() ); + return filteredMenu; +} + void ScreenshotsPage::onItemActivated(QModelIndex index) { if (!index.isValid()) @@ -273,12 +280,12 @@ void ScreenshotsPage::onItemActivated(QModelIndex index) DesktopServices::openFile(info.absoluteFilePath()); } -void ScreenshotsPage::on_viewFolderBtn_clicked() +void ScreenshotsPage::on_actionView_Folder_triggered() { DesktopServices::openDirectory(m_folder, true); } -void ScreenshotsPage::on_uploadBtn_clicked() +void ScreenshotsPage::on_actionUpload_triggered() { auto selection = ui->listView->selectionModel()->selectedRows(); if (selection.isEmpty()) @@ -353,7 +360,7 @@ void ScreenshotsPage::on_uploadBtn_clicked() m_uploadActive = false; } -void ScreenshotsPage::on_deleteBtn_clicked() +void ScreenshotsPage::on_actionDelete_triggered() { auto mbox = CustomMessageBox::selectable( this, tr("Are you sure?"), tr("This will delete all selected screenshots."), @@ -370,7 +377,7 @@ void ScreenshotsPage::on_deleteBtn_clicked() } } -void ScreenshotsPage::on_renameBtn_clicked() +void ScreenshotsPage::on_actionRename_triggered() { auto selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.isEmpty()) diff --git a/application/pages/instance/ScreenshotsPage.h b/application/pages/instance/ScreenshotsPage.h index 928f134c..22ead49a 100644 --- a/application/pages/instance/ScreenshotsPage.h +++ b/application/pages/instance/ScreenshotsPage.h @@ -15,7 +15,7 @@ #pragma once -#include <QWidget> +#include <QMainWindow> #include "pages/BasePage.h" #include <MultiMC.h> @@ -31,7 +31,7 @@ struct ScreenShot; class ScreenshotList; class ImgurAlbumCreation; -class ScreenshotsPage : public QWidget, public BasePage +class ScreenshotsPage : public QMainWindow, public BasePage { Q_OBJECT @@ -67,11 +67,15 @@ public: { return !m_uploadActive; } + +protected: + QMenu * createPopupMenu() override; + private slots: - void on_uploadBtn_clicked(); - void on_deleteBtn_clicked(); - void on_renameBtn_clicked(); - void on_viewFolderBtn_clicked(); + void on_actionUpload_triggered(); + void on_actionDelete_triggered(); + void on_actionRename_triggered(); + void on_actionView_Folder_triggered(); void onItemActivated(QModelIndex); private: diff --git a/application/pages/instance/ScreenshotsPage.ui b/application/pages/instance/ScreenshotsPage.ui index d05c4384..a669e292 100644 --- a/application/pages/instance/ScreenshotsPage.ui +++ b/application/pages/instance/ScreenshotsPage.ui @@ -1,106 +1,80 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ScreenshotsPage</class> - <widget class="QWidget" name="ScreenshotsPage"> + <widget class="QMainWindow" name="ScreenshotsPage"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>723</width> - <height>532</height> + <width>800</width> + <height>600</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>0</number> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <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="QListView" name="listView"> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectRows</enum> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QToolBar" name="toolBar"> + <property name="windowTitle"> + <string>toolBar</string> </property> - <property name="topMargin"> - <number>0</number> + <attribute name="toolBarArea"> + <enum>RightToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + <addaction name="actionUpload"/> + <addaction name="actionDelete"/> + <addaction name="actionRename"/> + <addaction name="actionView_Folder"/> + </widget> + <action name="actionUpload"> + <property name="text"> + <string>Upload</string> </property> - <property name="rightMargin"> - <number>0</number> + </action> + <action name="actionDelete"> + <property name="text"> + <string>Delete</string> </property> - <property name="bottomMargin"> - <number>0</number> + </action> + <action name="actionRename"> + <property name="text"> + <string>Rename</string> </property> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string notr="true">Tab 1</string> - </attribute> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QListView" name="listView"> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - </widget> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="uploadBtn"> - <property name="text"> - <string>&Upload</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="deleteBtn"> - <property name="text"> - <string>&Delete</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="renameBtn"> - <property name="text"> - <string>&Rename</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="viewFolderBtn"> - <property name="text"> - <string>&View Folder</string> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </widget> - </item> - </layout> + </action> + <action name="actionView_Folder"> + <property name="text"> + <string>View Folder</string> + </property> + </action> </widget> - <tabstops> - <tabstop>listView</tabstop> - <tabstop>uploadBtn</tabstop> - <tabstop>deleteBtn</tabstop> - <tabstop>renameBtn</tabstop> - <tabstop>viewFolderBtn</tabstop> - </tabstops> <resources/> <connections/> </ui> diff --git a/application/pages/instance/ServersPage.cpp b/application/pages/instance/ServersPage.cpp index eb4757ac..44ede664 100644 --- a/application/pages/instance/ServersPage.cpp +++ b/application/pages/instance/ServersPage.cpp @@ -11,6 +11,7 @@ #include <minecraft/MinecraftInstance.h> #include <QFileSystemWatcher> +#include <QMenu> static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things. @@ -556,10 +557,9 @@ private: }; ServersPage::ServersPage(MinecraftInstance * inst, QWidget* parent) - : QWidget(parent), ui(new Ui::ServersPage) + : QMainWindow(parent), ui(new Ui::ServersPage) { ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); m_inst = inst; m_model = new ServersModel(inst->gameRoot(), this); ui->serversView->setIconSize(QSize(64,64)); @@ -596,6 +596,13 @@ ServersPage::~ServersPage() m_model->saveNow(); } +QMenu * ServersPage::createPopupMenu() +{ + QMenu* filteredMenu = QMainWindow::createPopupMenu(); + filteredMenu->removeAction( ui->toolBar->toggleViewAction() ); + return filteredMenu; +} + void ServersPage::on_RunningState_changed(bool running) { if(m_locked == running) @@ -674,9 +681,9 @@ void ServersPage::updateState() ui->addressLine->setEnabled(serverEditEnabled); ui->nameLine->setEnabled(serverEditEnabled); ui->resourceComboBox->setEnabled(serverEditEnabled); - ui->moveDownBtn->setEnabled(serverEditEnabled); - ui->moveUpBtn->setEnabled(serverEditEnabled); - ui->removeBtn->setEnabled(serverEditEnabled); + ui->actionMove_Down->setEnabled(serverEditEnabled); + ui->actionMove_Up->setEnabled(serverEditEnabled); + ui->actionRemove->setEnabled(serverEditEnabled); if(server) { @@ -691,7 +698,7 @@ void ServersPage::updateState() ui->resourceComboBox->setCurrentIndex(0); } - ui->addBtn->setDisabled(m_locked); + ui->actionAdd->setDisabled(m_locked); } void ServersPage::openedImpl() @@ -704,7 +711,7 @@ void ServersPage::closedImpl() m_model->unobserve(); } -void ServersPage::on_addBtn_clicked() +void ServersPage::on_actionAdd_triggered() { int position = m_model->addEmptyRow(currentServer + 1); if(position < 0) @@ -719,12 +726,12 @@ void ServersPage::on_addBtn_clicked() currentServer = position; } -void ServersPage::on_removeBtn_clicked() +void ServersPage::on_actionRemove_triggered() { m_model->removeRow(currentServer); } -void ServersPage::on_moveUpBtn_clicked() +void ServersPage::on_actionMove_Up_triggered() { if(m_model->moveUp(currentServer)) { @@ -732,7 +739,7 @@ void ServersPage::on_moveUpBtn_clicked() } } -void ServersPage::on_moveDownBtn_clicked() +void ServersPage::on_actionMove_Down_triggered() { if(m_model->moveDown(currentServer)) { diff --git a/application/pages/instance/ServersPage.h b/application/pages/instance/ServersPage.h index 96356002..9c9cc388 100644 --- a/application/pages/instance/ServersPage.h +++ b/application/pages/instance/ServersPage.h @@ -15,7 +15,7 @@ #pragma once -#include <QWidget> +#include <QMainWindow> #include <QString> #include "pages/BasePage.h" @@ -30,7 +30,7 @@ struct Server; class ServersModel; class MinecraftInstance; -class ServersPage : public QWidget, public BasePage +class ServersPage : public QMainWindow, public BasePage { Q_OBJECT @@ -57,6 +57,10 @@ public: { return "Servers-management"; } + +protected: + QMenu * createPopupMenu() override; + private: void updateState(); void scheduleSave(); @@ -66,10 +70,11 @@ private slots: void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); void rowsRemoved(const QModelIndex &parent, int first, int last); - void on_addBtn_clicked(); - void on_removeBtn_clicked(); - void on_moveUpBtn_clicked(); - void on_moveDownBtn_clicked(); + void on_actionAdd_triggered(); + void on_actionRemove_triggered(); + void on_actionMove_Up_triggered(); + void on_actionMove_Down_triggered(); + void on_RunningState_changed(bool running); void nameEdited(const QString & name); diff --git a/application/pages/instance/ServersPage.ui b/application/pages/instance/ServersPage.ui index faa918f4..5023cd73 100644 --- a/application/pages/instance/ServersPage.ui +++ b/application/pages/instance/ServersPage.ui @@ -1,198 +1,183 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ServersPage</class> - <widget class="QWidget" name="ServersPage"> + <widget class="QMainWindow" name="ServersPage"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>706</width> - <height>575</height> + <width>1318</width> + <height>879</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="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="QTreeView" name="serversView"> <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> + <property name="acceptDrops"> + <bool>true</bool> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="selectionMode"> + <enum>QAbstractItemView::SingleSelection</enum> + </property> + <property name="selectionBehavior"> + <enum>QAbstractItemView::SelectRows</enum> + </property> + <property name="iconSize"> + <size> + <width>64</width> + <height>64</height> + </size> + </property> + <property name="rootIsDecorated"> + <bool>false</bool> + </property> + <attribute name="headerStretchLastSection"> + <bool>false</bool> </attribute> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <layout class="QGridLayout" name="gridLayout"> - <item row="3" column="1"> - <widget class="QComboBox" name="resourceComboBox"> - <item> - <property name="text"> - <string>Ask to download</string> - </property> - </item> - <item> - <property name="text"> - <string>Always download</string> - </property> - </item> - <item> - <property name="text"> - <string>Never download</string> - </property> - </item> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="resourcesLabel"> - <property name="text"> - <string>Reso&urces</string> - </property> - <property name="buddy"> - <cstring>resourceComboBox</cstring> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="addressLine"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="nameLabel"> - <property name="text"> - <string>&Name</string> - </property> - <property name="buddy"> - <cstring>nameLine</cstring> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="nameLine"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="addressLabel"> - <property name="text"> - <string>Address</string> - </property> - <property name="buddy"> - <cstring>addressLine</cstring> - </property> - </widget> - </item> - <item row="0" column="0" colspan="2"> - <widget class="QTreeView" name="serversView"> - <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="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="selectionMode"> - <enum>QAbstractItemView::SingleSelection</enum> - </property> - <property name="selectionBehavior"> - <enum>QAbstractItemView::SelectRows</enum> - </property> - <property name="iconSize"> - <size> - <width>64</width> - <height>64</height> - </size> - </property> - <property name="rootIsDecorated"> - <bool>false</bool> - </property> - <attribute name="headerStretchLastSection"> - <bool>false</bool> - </attribute> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="addBtn"> - <property name="text"> - <string>&Add</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="removeBtn"> - <property name="text"> - <string>&Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="moveUpBtn"> - <property name="text"> - <string>Move Up</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="moveDownBtn"> - <property name="text"> - <string>Move Down</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> - </layout> - </item> - </layout> </widget> - </widget> - </item> - </layout> + </item> + <item> + <layout class="QGridLayout" name="gridLayout_2"> + <property name="leftMargin"> + <number>6</number> + </property> + <property name="rightMargin"> + <number>6</number> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="nameLabel"> + <property name="text"> + <string>&Name</string> + </property> + <property name="buddy"> + <cstring>nameLine</cstring> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="nameLine"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="addressLabel"> + <property name="text"> + <string>Address</string> + </property> + <property name="buddy"> + <cstring>addressLine</cstring> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="addressLine"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="resourcesLabel"> + <property name="text"> + <string>Reso&urces</string> + </property> + <property name="buddy"> + <cstring>resourceComboBox</cstring> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QComboBox" name="resourceComboBox"> + <item> + <property name="text"> + <string>Ask to download</string> + </property> + </item> + <item> + <property name="text"> + <string>Always download</string> + </property> + </item> + <item> + <property name="text"> + <string>Never download</string> + </property> + </item> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QToolBar" name="toolBar"> + <property name="windowTitle"> + <string>toolBar</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="actionMove_Up"/> + <addaction name="actionMove_Down"/> + </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="actionMove_Up"> + <property name="text"> + <string>Move Up</string> + </property> + </action> + <action name="actionMove_Down"> + <property name="text"> + <string>Move Down</string> + </property> + </action> </widget> <tabstops> - <tabstop>tabWidget</tabstop> <tabstop>serversView</tabstop> <tabstop>nameLine</tabstop> <tabstop>addressLine</tabstop> <tabstop>resourceComboBox</tabstop> - <tabstop>addBtn</tabstop> - <tabstop>removeBtn</tabstop> - <tabstop>moveUpBtn</tabstop> - <tabstop>moveDownBtn</tabstop> </tabstops> <resources/> <connections/> diff --git a/application/pages/instance/VersionPage.cpp b/application/pages/instance/VersionPage.cpp index 4195f416..a34f564c 100644 --- a/application/pages/instance/VersionPage.cpp +++ b/application/pages/instance/VersionPage.cpp @@ -111,23 +111,11 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent) : QMainWindow(parent), ui(new Ui::VersionPage), m_inst(inst) { ui->setupUi(this); -/* - auto labelSelection = new QLabel(tr("Selection")); - labelSelection->setAlignment(Qt::AlignHCenter); - ui->toolBar->insertWidget(ui->actionChange_version, labelSelection); - - auto labelEdit = new QLabel(tr("Edit")); - labelEdit->setAlignment(Qt::AlignHCenter); - ui->toolBar->insertWidget(ui->actionCustomize, labelEdit); - - auto labelInstall = new QLabel(tr("Install")); - labelInstall->setAlignment(Qt::AlignHCenter); - ui->toolBar->insertWidget(ui->actionInstall_Forge, labelInstall); - - auto labelAdvanced = new QLabel(tr("Advanced")); - labelAdvanced->setAlignment(Qt::AlignHCenter); - ui->toolBar->insertWidget(ui->actionAdd_to_Minecraft_jar, labelAdvanced); -*/ + + QWidget* spacer = new QWidget(); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + // toolBar is a pointer to an existing toolbar + ui->toolBar->insertWidget(ui->actionReload, spacer); m_profile = m_inst->getComponentList(); diff --git a/application/pages/instance/WorldListPage.cpp b/application/pages/instance/WorldListPage.cpp index be72af22..bd559991 100644 --- a/application/pages/instance/WorldListPage.cpp +++ b/application/pages/instance/WorldListPage.cpp @@ -19,6 +19,7 @@ #include <DesktopServices.h> #include "dialogs/ModEditDialogCommon.h" #include <QEvent> +#include <QMenu> #include <QKeyEvent> #include <QClipboard> #include <QMessageBox> @@ -31,13 +32,16 @@ #include <QProcess> #include <FileSystem.h> -WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id, - QString iconName, QString displayName, QString helpPage, - QWidget *parent) - : QWidget(parent), m_inst(inst), ui(new Ui::WorldListPage), m_worlds(worlds), m_iconName(iconName), m_id(id), m_displayName(displayName), m_helpName(helpPage) +WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QWidget *parent) + : QMainWindow(parent), m_inst(inst), ui(new Ui::WorldListPage), m_worlds(worlds) { ui->setupUi(this); - ui->tabWidget->tabBar()->hide(); + + QWidget* spacer = new QWidget(); + spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + // toolBar is a pointer to an existing toolbar + ui->toolBar->insertWidget(ui->actionRefresh, spacer); + QSortFilterProxyModel * proxy = new QSortFilterProxyModel(this); proxy->setSortCaseSensitivity(Qt::CaseInsensitive); proxy->setSourceModel(m_worlds.get()); @@ -46,12 +50,10 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl ui->worldTreeView->installEventFilter(this); auto head = ui->worldTreeView->header(); - head->setSectionResizeMode(0, QHeaderView::Stretch); head->setSectionResizeMode(1, QHeaderView::ResizeToContents); - connect(ui->worldTreeView->selectionModel(), - SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, - SLOT(worldChanged(const QModelIndex &, const QModelIndex &))); + + connect(ui->worldTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &WorldListPage::worldChanged); worldChanged(QModelIndex(), QModelIndex()); } @@ -71,6 +73,13 @@ WorldListPage::~WorldListPage() delete ui; } +QMenu * WorldListPage::createPopupMenu() +{ + QMenu* filteredMenu = QMainWindow::createPopupMenu(); + filteredMenu->removeAction( ui->toolBar->toggleViewAction() ); + return filteredMenu; +} + bool WorldListPage::shouldDisplay() const { return true; @@ -81,7 +90,7 @@ bool WorldListPage::worldListFilter(QKeyEvent *keyEvent) switch (keyEvent->key()) { case Qt::Key_Delete: - on_rmWorldBtn_clicked(); + on_actionRemove_triggered(); return true; default: break; @@ -101,7 +110,7 @@ bool WorldListPage::eventFilter(QObject *obj, QEvent *ev) return QWidget::eventFilter(obj, ev); } -void WorldListPage::on_rmWorldBtn_clicked() +void WorldListPage::on_actionRemove_triggered() { auto proxiedIndex = getSelectedWorld(); @@ -123,7 +132,7 @@ void WorldListPage::on_rmWorldBtn_clicked() m_worlds->startWatching(); } -void WorldListPage::on_viewFolderBtn_clicked() +void WorldListPage::on_actionView_Folder_triggered() { DesktopServices::openDirectory(m_worlds->dir().absolutePath(), true); } @@ -136,7 +145,7 @@ QModelIndex WorldListPage::getSelectedWorld() return proxy->mapToSource(index); } -void WorldListPage::on_copySeedBtn_clicked() +void WorldListPage::on_actionCopy_Seed_triggered() { QModelIndex index = getSelectedWorld(); @@ -148,7 +157,7 @@ void WorldListPage::on_copySeedBtn_clicked() MMC->clipboard()->setText(QString::number(seed)); } -void WorldListPage::on_mcEditBtn_clicked() +void WorldListPage::on_actionMCEdit_triggered() { if(m_mceditStarting) return; @@ -236,17 +245,17 @@ void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex & { QModelIndex index = getSelectedWorld(); bool enable = index.isValid(); - ui->copySeedBtn->setEnabled(enable); - ui->mcEditBtn->setEnabled(enable); - ui->rmWorldBtn->setEnabled(enable); - ui->copyBtn->setEnabled(enable); - ui->renameBtn->setEnabled(enable); + ui->actionCopy_Seed->setEnabled(enable); + ui->actionMCEdit->setEnabled(enable); + ui->actionRemove->setEnabled(enable); + ui->actionCopy->setEnabled(enable); + ui->actionRename->setEnabled(enable); } -void WorldListPage::on_addBtn_clicked() +void WorldListPage::on_actionAdd_triggered() { auto list = GuiUtil::BrowseForFiles( - m_helpName, + displayName(), tr("Select a Minecraft world zip"), tr("Minecraft World Zip File (*.zip)"), QString(), this->parentWidget()); if (!list.empty()) @@ -279,7 +288,7 @@ bool WorldListPage::worldSafetyNagQuestion() } -void WorldListPage::on_copyBtn_clicked() +void WorldListPage::on_actionCopy_triggered() { QModelIndex index = getSelectedWorld(); if (!index.isValid()) @@ -301,7 +310,7 @@ void WorldListPage::on_copyBtn_clicked() } } -void WorldListPage::on_renameBtn_clicked() +void WorldListPage::on_actionRename_triggered() { QModelIndex index = getSelectedWorld(); if (!index.isValid()) @@ -324,7 +333,7 @@ void WorldListPage::on_renameBtn_clicked() } } -void WorldListPage::on_refreshBtn_clicked() +void WorldListPage::on_actionRefresh_triggered() { m_worlds->update(); } diff --git a/application/pages/instance/WorldListPage.h b/application/pages/instance/WorldListPage.h index 15f98119..d07f8d9f 100644 --- a/application/pages/instance/WorldListPage.h +++ b/application/pages/instance/WorldListPage.h @@ -15,7 +15,7 @@ #pragma once -#include <QWidget> +#include <QMainWindow> #include "minecraft/MinecraftInstance.h" #include "pages/BasePage.h" @@ -28,31 +28,33 @@ namespace Ui class WorldListPage; } -class WorldListPage : public QWidget, public BasePage +class WorldListPage : public QMainWindow, public BasePage { Q_OBJECT public: - explicit WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id, - QString iconName, QString displayName, QString helpPage = "", - QWidget *parent = 0); + explicit WorldListPage( + BaseInstance *inst, + std::shared_ptr<WorldList> worlds, + QWidget *parent = 0 + ); virtual ~WorldListPage(); virtual QString displayName() const override { - return m_displayName; + return tr("Worlds"); } virtual QIcon icon() const override { - return MMC->getThemedIcon(m_iconName); + return MMC->getThemedIcon("worlds"); } virtual QString id() const override { - return m_id; + return "worlds"; } virtual QString helpPage() const override { - return m_helpName; + return "Worlds"; } virtual bool shouldDisplay() const override; @@ -62,6 +64,7 @@ public: protected: bool eventFilter(QObject *obj, QEvent *ev) override; bool worldListFilter(QKeyEvent *ev); + QMenu * createPopupMenu() override; protected: BaseInstance *m_inst; @@ -77,20 +80,16 @@ private: std::shared_ptr<WorldList> m_worlds; unique_qobject_ptr<LoggedProcess> m_mceditProcess; bool m_mceditStarting = false; - QString m_iconName; - QString m_id; - QString m_displayName; - QString m_helpName; private slots: - void on_copySeedBtn_clicked(); - void on_mcEditBtn_clicked(); - void on_rmWorldBtn_clicked(); - void on_addBtn_clicked(); - void on_copyBtn_clicked(); - void on_renameBtn_clicked(); - void on_refreshBtn_clicked(); - void on_viewFolderBtn_clicked(); + void on_actionCopy_Seed_triggered(); + void on_actionMCEdit_triggered(); + void on_actionRemove_triggered(); + void on_actionAdd_triggered(); + void on_actionCopy_triggered(); + void on_actionRename_triggered(); + void on_actionRefresh_triggered(); + void on_actionView_Folder_triggered(); void worldChanged(const QModelIndex ¤t, const QModelIndex &previous); void mceditState(LoggedProcess::State state); }; diff --git a/application/pages/instance/WorldListPage.ui b/application/pages/instance/WorldListPage.ui index bc104854..37721ae0 100644 --- a/application/pages/instance/WorldListPage.ui +++ b/application/pages/instance/WorldListPage.ui @@ -1,171 +1,133 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>WorldListPage</class> - <widget class="QWidget" name="WorldListPage"> + <widget class="QMainWindow" name="WorldListPage"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>723</width> - <height>532</height> + <width>800</width> + <height>600</height> </rect> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>0</number> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <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="QTreeView" name="worldTreeView"> + <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::DragDrop</enum> + </property> + <property name="alternatingRowColors"> + <bool>true</bool> + </property> + <property name="sortingEnabled"> + <bool>true</bool> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <attribute name="headerStretchLastSection"> + <bool>false</bool> + </attribute> + </widget> + </item> + </layout> + </widget> + <widget class="QToolBar" name="toolBar"> + <property name="windowTitle"> + <string>toolBar</string> </property> - <property name="topMargin"> - <number>0</number> + <property name="allowedAreas"> + <set>Qt::LeftToolBarArea|Qt::RightToolBarArea</set> </property> - <property name="rightMargin"> - <number>0</number> + <property name="toolButtonStyle"> + <enum>Qt::ToolButtonTextOnly</enum> </property> - <property name="bottomMargin"> - <number>0</number> + <property name="floatable"> + <bool>false</bool> </property> - <item> - <widget class="QTabWidget" name="tabWidget"> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string notr="true">Tab 1</string> - </attribute> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="2"> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QPushButton" name="addBtn"> - <property name="text"> - <string>Add</string> - </property> - </widget> - </item> - <item> - <widget class="LineSeparator" name="separator" native="true"/> - </item> - <item> - <widget class="QPushButton" name="renameBtn"> - <property name="text"> - <string>Rename</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="copyBtn"> - <property name="text"> - <string>Copy</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="rmWorldBtn"> - <property name="text"> - <string>&Remove</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="mcEditBtn"> - <property name="text"> - <string notr="true">MCEdit</string> - </property> - </widget> - </item> - <item> - <widget class="LineSeparator" name="separator_2" native="true"/> - </item> - <item> - <widget class="QPushButton" name="copySeedBtn"> - <property name="text"> - <string>Copy Seed</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="refreshBtn"> - <property name="text"> - <string>Refresh</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="viewFolderBtn"> - <property name="text"> - <string>&View Folder</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="0" column="1"> - <widget class="QTreeView" name="worldTreeView"> - <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::DragDrop</enum> - </property> - <property name="alternatingRowColors"> - <bool>true</bool> - </property> - <property name="sortingEnabled"> - <bool>true</bool> - </property> - <property name="allColumnsShowFocus"> - <bool>true</bool> - </property> - <attribute name="headerStretchLastSection"> - <bool>false</bool> - </attribute> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - </layout> + <attribute name="toolBarArea"> + <enum>RightToolBarArea</enum> + </attribute> + <attribute name="toolBarBreak"> + <bool>false</bool> + </attribute> + <addaction name="actionAdd"/> + <addaction name="separator"/> + <addaction name="actionRename"/> + <addaction name="actionCopy"/> + <addaction name="actionRemove"/> + <addaction name="actionMCEdit"/> + <addaction name="separator"/> + <addaction name="actionCopy_Seed"/> + <addaction name="actionRefresh"/> + <addaction name="actionView_Folder"/> + </widget> + <action name="actionAdd"> + <property name="text"> + <string>Add</string> + </property> + </action> + <action name="actionRename"> + <property name="text"> + <string>Rename</string> + </property> + </action> + <action name="actionCopy"> + <property name="text"> + <string>Copy</string> + </property> + </action> + <action name="actionRemove"> + <property name="text"> + <string>Remove</string> + </property> + </action> + <action name="actionMCEdit"> + <property name="text"> + <string>MCEdit</string> + </property> + </action> + <action name="actionCopy_Seed"> + <property name="text"> + <string>Copy Seed</string> + </property> + </action> + <action name="actionRefresh"> + <property name="text"> + <string>Refresh</string> + </property> + </action> + <action name="actionView_Folder"> + <property name="text"> + <string>View Folder</string> + </property> + </action> </widget> - <customwidgets> - <customwidget> - <class>LineSeparator</class> - <extends>QWidget</extends> - <header>widgets/LineSeparator.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <tabstops> - <tabstop>tabWidget</tabstop> - <tabstop>worldTreeView</tabstop> - <tabstop>addBtn</tabstop> - <tabstop>renameBtn</tabstop> - <tabstop>copyBtn</tabstop> - <tabstop>rmWorldBtn</tabstop> - <tabstop>mcEditBtn</tabstop> - <tabstop>copySeedBtn</tabstop> - <tabstop>refreshBtn</tabstop> - <tabstop>viewFolderBtn</tabstop> - </tabstops> <resources/> <connections/> </ui> |