NOISSUE convert rest of the instance pages to use toolbars for side menus

This commit is contained in:
Petr Mrázek 2019-07-17 02:01:29 +02:00
parent 5b153a5165
commit 95febe5436
13 changed files with 460 additions and 515 deletions

View File

@ -45,7 +45,7 @@ public:
values.append(new ResourcePackPage(onesix.get())); values.append(new ResourcePackPage(onesix.get()));
values.append(new TexturePackPage(onesix.get())); values.append(new TexturePackPage(onesix.get()));
values.append(new NotesPage(onesix.get())); values.append(new NotesPage(onesix.get()));
values.append(new WorldListPage(onesix.get(), onesix->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); values.append(new WorldListPage(onesix.get(), onesix->worldList()));
values.append(new ServersPage(onesix.get())); values.append(new ServersPage(onesix.get()));
// values.append(new GameOptionsPage(onesix.get())); // values.append(new GameOptionsPage(onesix.get()));
values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots"))); values.append(new ScreenshotsPage(FS::PathCombine(onesix->gameRoot(), "screenshots")));
@ -56,7 +56,7 @@ public:
{ {
values.append(new LegacyUpgradePage(legacy)); values.append(new LegacyUpgradePage(legacy));
values.append(new NotesPage(legacy.get())); values.append(new NotesPage(legacy.get()));
values.append(new WorldListPage(legacy.get(), legacy->worldList(), "worlds", "worlds", tr("Worlds"), "Worlds")); values.append(new WorldListPage(legacy.get(), legacy->worldList()));
values.append(new ScreenshotsPage(FS::PathCombine(legacy->gameRoot(), "screenshots"))); values.append(new ScreenshotsPage(FS::PathCombine(legacy->gameRoot(), "screenshots")));
} }
auto logMatcher = inst->getLogFileMatcher(); auto logMatcher = inst->getLogFileMatcher();

View File

@ -38,6 +38,12 @@ ModFolderPage::ModFolderPage(BaseInstance *inst, std::shared_ptr<SimpleModList>
: QMainWindow(parent), ui(new Ui::ModFolderPage) : QMainWindow(parent), ui(new Ui::ModFolderPage)
{ {
ui->setupUi(this); 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; m_inst = inst;
on_RunningState_changed(m_inst && m_inst->isRunning()); on_RunningState_changed(m_inst && m_inst->isRunning());
m_mods = mods; m_mods = mods;

View File

@ -96,7 +96,6 @@
<addaction name="actionRemove"/> <addaction name="actionRemove"/>
<addaction name="actionEnable"/> <addaction name="actionEnable"/>
<addaction name="actionDisable"/> <addaction name="actionDisable"/>
<addaction name="separator"/>
<addaction name="actionView_configs"/> <addaction name="actionView_configs"/>
<addaction name="actionView_Folder"/> <addaction name="actionView_Folder"/>
</widget> </widget>

View File

@ -13,6 +13,7 @@
#include <QPainter> #include <QPainter>
#include <QClipboard> #include <QClipboard>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMenu>
#include <MultiMC.h> #include <MultiMC.h>
@ -209,7 +210,7 @@ public:
}; };
ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent) ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
: QWidget(parent), ui(new Ui::ScreenshotsPage) : QMainWindow(parent), ui(new Ui::ScreenshotsPage)
{ {
m_model.reset(new QFileSystemModel()); m_model.reset(new QFileSystemModel());
m_filterModel.reset(new FilterModel()); m_filterModel.reset(new FilterModel());
@ -222,7 +223,6 @@ ScreenshotsPage::ScreenshotsPage(QString path, QWidget *parent)
m_valid = FS::ensureFolderPathExists(m_folder); m_valid = FS::ensureFolderPathExists(m_folder);
ui->setupUi(this); ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
ui->listView->setIconSize(QSize(128, 128)); ui->listView->setIconSize(QSize(128, 128));
ui->listView->setGridSize(QSize(192, 160)); ui->listView->setGridSize(QSize(192, 160));
ui->listView->setSpacing(9); ui->listView->setSpacing(9);
@ -248,10 +248,10 @@ bool ScreenshotsPage::eventFilter(QObject *obj, QEvent *evt)
switch (keyEvent->key()) switch (keyEvent->key())
{ {
case Qt::Key_Delete: case Qt::Key_Delete:
on_deleteBtn_clicked(); on_actionDelete_triggered();
return true; return true;
case Qt::Key_F2: case Qt::Key_F2:
on_renameBtn_clicked(); on_actionRename_triggered();
return true; return true;
default: default:
break; break;
@ -264,6 +264,13 @@ ScreenshotsPage::~ScreenshotsPage()
delete ui; delete ui;
} }
QMenu * ScreenshotsPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
filteredMenu->removeAction( ui->toolBar->toggleViewAction() );
return filteredMenu;
}
void ScreenshotsPage::onItemActivated(QModelIndex index) void ScreenshotsPage::onItemActivated(QModelIndex index)
{ {
if (!index.isValid()) if (!index.isValid())
@ -273,12 +280,12 @@ void ScreenshotsPage::onItemActivated(QModelIndex index)
DesktopServices::openFile(info.absoluteFilePath()); DesktopServices::openFile(info.absoluteFilePath());
} }
void ScreenshotsPage::on_viewFolderBtn_clicked() void ScreenshotsPage::on_actionView_Folder_triggered()
{ {
DesktopServices::openDirectory(m_folder, true); DesktopServices::openDirectory(m_folder, true);
} }
void ScreenshotsPage::on_uploadBtn_clicked() void ScreenshotsPage::on_actionUpload_triggered()
{ {
auto selection = ui->listView->selectionModel()->selectedRows(); auto selection = ui->listView->selectionModel()->selectedRows();
if (selection.isEmpty()) if (selection.isEmpty())
@ -353,7 +360,7 @@ void ScreenshotsPage::on_uploadBtn_clicked()
m_uploadActive = false; m_uploadActive = false;
} }
void ScreenshotsPage::on_deleteBtn_clicked() void ScreenshotsPage::on_actionDelete_triggered()
{ {
auto mbox = CustomMessageBox::selectable( auto mbox = CustomMessageBox::selectable(
this, tr("Are you sure?"), tr("This will delete all selected screenshots."), 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(); auto selection = ui->listView->selectionModel()->selectedIndexes();
if (selection.isEmpty()) if (selection.isEmpty())

View File

@ -15,7 +15,7 @@
#pragma once #pragma once
#include <QWidget> #include <QMainWindow>
#include "pages/BasePage.h" #include "pages/BasePage.h"
#include <MultiMC.h> #include <MultiMC.h>
@ -31,7 +31,7 @@ struct ScreenShot;
class ScreenshotList; class ScreenshotList;
class ImgurAlbumCreation; class ImgurAlbumCreation;
class ScreenshotsPage : public QWidget, public BasePage class ScreenshotsPage : public QMainWindow, public BasePage
{ {
Q_OBJECT Q_OBJECT
@ -67,11 +67,15 @@ public:
{ {
return !m_uploadActive; return !m_uploadActive;
} }
protected:
QMenu * createPopupMenu() override;
private slots: private slots:
void on_uploadBtn_clicked(); void on_actionUpload_triggered();
void on_deleteBtn_clicked(); void on_actionDelete_triggered();
void on_renameBtn_clicked(); void on_actionRename_triggered();
void on_viewFolderBtn_clicked(); void on_actionView_Folder_triggered();
void onItemActivated(QModelIndex); void onItemActivated(QModelIndex);
private: private:

View File

@ -1,106 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ScreenshotsPage</class> <class>ScreenshotsPage</class>
<widget class="QWidget" name="ScreenshotsPage"> <widget class="QMainWindow" name="ScreenshotsPage">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>723</width> <width>800</width>
<height>532</height> <height>600</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="windowTitle">
<property name="leftMargin"> <string>MainWindow</string>
<number>0</number> </property>
</property> <widget class="QWidget" name="centralwidget">
<property name="topMargin"> <layout class="QHBoxLayout" name="horizontalLayout">
<number>0</number> <property name="leftMargin">
</property> <number>0</number>
<property name="rightMargin"> </property>
<number>0</number> <property name="topMargin">
</property> <number>0</number>
<property name="bottomMargin"> </property>
<number>0</number> <property name="rightMargin">
</property> <number>0</number>
<item> </property>
<widget class="QTabWidget" name="tabWidget"> <property name="bottomMargin">
<property name="currentIndex"> <number>0</number>
<number>0</number> </property>
</property> <item>
<widget class="QWidget" name="tab"> <widget class="QListView" name="listView">
<attribute name="title"> <property name="selectionMode">
<string notr="true">Tab 1</string> <enum>QAbstractItemView::ExtendedSelection</enum>
</attribute> </property>
<layout class="QHBoxLayout" name="horizontalLayout"> <property name="selectionBehavior">
<item> <enum>QAbstractItemView::SelectRows</enum>
<widget class="QListView" name="listView"> </property>
<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>&amp;Upload</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="deleteBtn">
<property name="text">
<string>&amp;Delete</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="renameBtn">
<property name="text">
<string>&amp;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>&amp;View Folder</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget> </widget>
</widget> </item>
</item> </layout>
</layout> </widget>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<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>
</action>
<action name="actionDelete">
<property name="text">
<string>Delete</string>
</property>
</action>
<action name="actionRename">
<property name="text">
<string>Rename</string>
</property>
</action>
<action name="actionView_Folder">
<property name="text">
<string>View Folder</string>
</property>
</action>
</widget> </widget>
<tabstops>
<tabstop>listView</tabstop>
<tabstop>uploadBtn</tabstop>
<tabstop>deleteBtn</tabstop>
<tabstop>renameBtn</tabstop>
<tabstop>viewFolderBtn</tabstop>
</tabstops>
<resources/> <resources/>
<connections/> <connections/>
</ui> </ui>

View File

@ -11,6 +11,7 @@
#include <minecraft/MinecraftInstance.h> #include <minecraft/MinecraftInstance.h>
#include <QFileSystemWatcher> #include <QFileSystemWatcher>
#include <QMenu>
static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things. static const int COLUMN_COUNT = 2; // 3 , TBD: latency and other nice things.
@ -556,10 +557,9 @@ private:
}; };
ServersPage::ServersPage(MinecraftInstance * inst, QWidget* parent) ServersPage::ServersPage(MinecraftInstance * inst, QWidget* parent)
: QWidget(parent), ui(new Ui::ServersPage) : QMainWindow(parent), ui(new Ui::ServersPage)
{ {
ui->setupUi(this); ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
m_inst = inst; m_inst = inst;
m_model = new ServersModel(inst->gameRoot(), this); m_model = new ServersModel(inst->gameRoot(), this);
ui->serversView->setIconSize(QSize(64,64)); ui->serversView->setIconSize(QSize(64,64));
@ -596,6 +596,13 @@ ServersPage::~ServersPage()
m_model->saveNow(); m_model->saveNow();
} }
QMenu * ServersPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
filteredMenu->removeAction( ui->toolBar->toggleViewAction() );
return filteredMenu;
}
void ServersPage::on_RunningState_changed(bool running) void ServersPage::on_RunningState_changed(bool running)
{ {
if(m_locked == running) if(m_locked == running)
@ -674,9 +681,9 @@ void ServersPage::updateState()
ui->addressLine->setEnabled(serverEditEnabled); ui->addressLine->setEnabled(serverEditEnabled);
ui->nameLine->setEnabled(serverEditEnabled); ui->nameLine->setEnabled(serverEditEnabled);
ui->resourceComboBox->setEnabled(serverEditEnabled); ui->resourceComboBox->setEnabled(serverEditEnabled);
ui->moveDownBtn->setEnabled(serverEditEnabled); ui->actionMove_Down->setEnabled(serverEditEnabled);
ui->moveUpBtn->setEnabled(serverEditEnabled); ui->actionMove_Up->setEnabled(serverEditEnabled);
ui->removeBtn->setEnabled(serverEditEnabled); ui->actionRemove->setEnabled(serverEditEnabled);
if(server) if(server)
{ {
@ -691,7 +698,7 @@ void ServersPage::updateState()
ui->resourceComboBox->setCurrentIndex(0); ui->resourceComboBox->setCurrentIndex(0);
} }
ui->addBtn->setDisabled(m_locked); ui->actionAdd->setDisabled(m_locked);
} }
void ServersPage::openedImpl() void ServersPage::openedImpl()
@ -704,7 +711,7 @@ void ServersPage::closedImpl()
m_model->unobserve(); m_model->unobserve();
} }
void ServersPage::on_addBtn_clicked() void ServersPage::on_actionAdd_triggered()
{ {
int position = m_model->addEmptyRow(currentServer + 1); int position = m_model->addEmptyRow(currentServer + 1);
if(position < 0) if(position < 0)
@ -719,12 +726,12 @@ void ServersPage::on_addBtn_clicked()
currentServer = position; currentServer = position;
} }
void ServersPage::on_removeBtn_clicked() void ServersPage::on_actionRemove_triggered()
{ {
m_model->removeRow(currentServer); m_model->removeRow(currentServer);
} }
void ServersPage::on_moveUpBtn_clicked() void ServersPage::on_actionMove_Up_triggered()
{ {
if(m_model->moveUp(currentServer)) 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)) if(m_model->moveDown(currentServer))
{ {

View File

@ -15,7 +15,7 @@
#pragma once #pragma once
#include <QWidget> #include <QMainWindow>
#include <QString> #include <QString>
#include "pages/BasePage.h" #include "pages/BasePage.h"
@ -30,7 +30,7 @@ struct Server;
class ServersModel; class ServersModel;
class MinecraftInstance; class MinecraftInstance;
class ServersPage : public QWidget, public BasePage class ServersPage : public QMainWindow, public BasePage
{ {
Q_OBJECT Q_OBJECT
@ -57,6 +57,10 @@ public:
{ {
return "Servers-management"; return "Servers-management";
} }
protected:
QMenu * createPopupMenu() override;
private: private:
void updateState(); void updateState();
void scheduleSave(); void scheduleSave();
@ -66,10 +70,11 @@ private slots:
void currentChanged(const QModelIndex &current, const QModelIndex &previous); void currentChanged(const QModelIndex &current, const QModelIndex &previous);
void rowsRemoved(const QModelIndex &parent, int first, int last); void rowsRemoved(const QModelIndex &parent, int first, int last);
void on_addBtn_clicked(); void on_actionAdd_triggered();
void on_removeBtn_clicked(); void on_actionRemove_triggered();
void on_moveUpBtn_clicked(); void on_actionMove_Up_triggered();
void on_moveDownBtn_clicked(); void on_actionMove_Down_triggered();
void on_RunningState_changed(bool running); void on_RunningState_changed(bool running);
void nameEdited(const QString & name); void nameEdited(const QString & name);

View File

@ -1,198 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ServersPage</class> <class>ServersPage</class>
<widget class="QWidget" name="ServersPage"> <widget class="QMainWindow" name="ServersPage">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>706</width> <width>1318</width>
<height>575</height> <height>879</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="windowTitle">
<property name="leftMargin"> <string>MainWindow</string>
<number>0</number> </property>
</property> <widget class="QWidget" name="centralwidget">
<property name="topMargin"> <layout class="QVBoxLayout" name="verticalLayout">
<number>0</number> <property name="leftMargin">
</property> <number>0</number>
<property name="rightMargin"> </property>
<number>0</number> <property name="topMargin">
</property> <number>0</number>
<property name="bottomMargin"> </property>
<number>0</number> <property name="rightMargin">
</property> <number>0</number>
<item> </property>
<widget class="QTabWidget" name="tabWidget"> <property name="bottomMargin">
<property name="currentIndex"> <number>0</number>
<number>0</number> </property>
</property> <item>
<widget class="QWidget" name="tab"> <widget class="QTreeView" name="serversView">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<attribute name="title"> <property name="acceptDrops">
<string notr="true">Tab 1</string> <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> </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&amp;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>&amp;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>&amp;Add</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeBtn">
<property name="text">
<string>&amp;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>
</widget> </item>
</item> <item>
</layout> <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>&amp;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&amp;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> </widget>
<tabstops> <tabstops>
<tabstop>tabWidget</tabstop>
<tabstop>serversView</tabstop> <tabstop>serversView</tabstop>
<tabstop>nameLine</tabstop> <tabstop>nameLine</tabstop>
<tabstop>addressLine</tabstop> <tabstop>addressLine</tabstop>
<tabstop>resourceComboBox</tabstop> <tabstop>resourceComboBox</tabstop>
<tabstop>addBtn</tabstop>
<tabstop>removeBtn</tabstop>
<tabstop>moveUpBtn</tabstop>
<tabstop>moveDownBtn</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

View File

@ -111,23 +111,11 @@ VersionPage::VersionPage(MinecraftInstance *inst, QWidget *parent)
: QMainWindow(parent), ui(new Ui::VersionPage), m_inst(inst) : QMainWindow(parent), ui(new Ui::VersionPage), m_inst(inst)
{ {
ui->setupUi(this); 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")); QWidget* spacer = new QWidget();
labelEdit->setAlignment(Qt::AlignHCenter); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
ui->toolBar->insertWidget(ui->actionCustomize, labelEdit); // toolBar is a pointer to an existing toolbar
ui->toolBar->insertWidget(ui->actionReload, spacer);
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);
*/
m_profile = m_inst->getComponentList(); m_profile = m_inst->getComponentList();

View File

@ -19,6 +19,7 @@
#include <DesktopServices.h> #include <DesktopServices.h>
#include "dialogs/ModEditDialogCommon.h" #include "dialogs/ModEditDialogCommon.h"
#include <QEvent> #include <QEvent>
#include <QMenu>
#include <QKeyEvent> #include <QKeyEvent>
#include <QClipboard> #include <QClipboard>
#include <QMessageBox> #include <QMessageBox>
@ -31,13 +32,16 @@
#include <QProcess> #include <QProcess>
#include <FileSystem.h> #include <FileSystem.h>
WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id, WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QWidget *parent)
QString iconName, QString displayName, QString helpPage, : QMainWindow(parent), m_inst(inst), ui(new Ui::WorldListPage), m_worlds(worlds)
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)
{ {
ui->setupUi(this); 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); QSortFilterProxyModel * proxy = new QSortFilterProxyModel(this);
proxy->setSortCaseSensitivity(Qt::CaseInsensitive); proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
proxy->setSourceModel(m_worlds.get()); proxy->setSourceModel(m_worlds.get());
@ -46,12 +50,10 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
ui->worldTreeView->installEventFilter(this); ui->worldTreeView->installEventFilter(this);
auto head = ui->worldTreeView->header(); auto head = ui->worldTreeView->header();
head->setSectionResizeMode(0, QHeaderView::Stretch); head->setSectionResizeMode(0, QHeaderView::Stretch);
head->setSectionResizeMode(1, QHeaderView::ResizeToContents); head->setSectionResizeMode(1, QHeaderView::ResizeToContents);
connect(ui->worldTreeView->selectionModel(),
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, connect(ui->worldTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &WorldListPage::worldChanged);
SLOT(worldChanged(const QModelIndex &, const QModelIndex &)));
worldChanged(QModelIndex(), QModelIndex()); worldChanged(QModelIndex(), QModelIndex());
} }
@ -71,6 +73,13 @@ WorldListPage::~WorldListPage()
delete ui; delete ui;
} }
QMenu * WorldListPage::createPopupMenu()
{
QMenu* filteredMenu = QMainWindow::createPopupMenu();
filteredMenu->removeAction( ui->toolBar->toggleViewAction() );
return filteredMenu;
}
bool WorldListPage::shouldDisplay() const bool WorldListPage::shouldDisplay() const
{ {
return true; return true;
@ -81,7 +90,7 @@ bool WorldListPage::worldListFilter(QKeyEvent *keyEvent)
switch (keyEvent->key()) switch (keyEvent->key())
{ {
case Qt::Key_Delete: case Qt::Key_Delete:
on_rmWorldBtn_clicked(); on_actionRemove_triggered();
return true; return true;
default: default:
break; break;
@ -101,7 +110,7 @@ bool WorldListPage::eventFilter(QObject *obj, QEvent *ev)
return QWidget::eventFilter(obj, ev); return QWidget::eventFilter(obj, ev);
} }
void WorldListPage::on_rmWorldBtn_clicked() void WorldListPage::on_actionRemove_triggered()
{ {
auto proxiedIndex = getSelectedWorld(); auto proxiedIndex = getSelectedWorld();
@ -123,7 +132,7 @@ void WorldListPage::on_rmWorldBtn_clicked()
m_worlds->startWatching(); m_worlds->startWatching();
} }
void WorldListPage::on_viewFolderBtn_clicked() void WorldListPage::on_actionView_Folder_triggered()
{ {
DesktopServices::openDirectory(m_worlds->dir().absolutePath(), true); DesktopServices::openDirectory(m_worlds->dir().absolutePath(), true);
} }
@ -136,7 +145,7 @@ QModelIndex WorldListPage::getSelectedWorld()
return proxy->mapToSource(index); return proxy->mapToSource(index);
} }
void WorldListPage::on_copySeedBtn_clicked() void WorldListPage::on_actionCopy_Seed_triggered()
{ {
QModelIndex index = getSelectedWorld(); QModelIndex index = getSelectedWorld();
@ -148,7 +157,7 @@ void WorldListPage::on_copySeedBtn_clicked()
MMC->clipboard()->setText(QString::number(seed)); MMC->clipboard()->setText(QString::number(seed));
} }
void WorldListPage::on_mcEditBtn_clicked() void WorldListPage::on_actionMCEdit_triggered()
{ {
if(m_mceditStarting) if(m_mceditStarting)
return; return;
@ -236,17 +245,17 @@ void WorldListPage::worldChanged(const QModelIndex &current, const QModelIndex &
{ {
QModelIndex index = getSelectedWorld(); QModelIndex index = getSelectedWorld();
bool enable = index.isValid(); bool enable = index.isValid();
ui->copySeedBtn->setEnabled(enable); ui->actionCopy_Seed->setEnabled(enable);
ui->mcEditBtn->setEnabled(enable); ui->actionMCEdit->setEnabled(enable);
ui->rmWorldBtn->setEnabled(enable); ui->actionRemove->setEnabled(enable);
ui->copyBtn->setEnabled(enable); ui->actionCopy->setEnabled(enable);
ui->renameBtn->setEnabled(enable); ui->actionRename->setEnabled(enable);
} }
void WorldListPage::on_addBtn_clicked() void WorldListPage::on_actionAdd_triggered()
{ {
auto list = GuiUtil::BrowseForFiles( auto list = GuiUtil::BrowseForFiles(
m_helpName, displayName(),
tr("Select a Minecraft world zip"), tr("Select a Minecraft world zip"),
tr("Minecraft World Zip File (*.zip)"), QString(), this->parentWidget()); tr("Minecraft World Zip File (*.zip)"), QString(), this->parentWidget());
if (!list.empty()) if (!list.empty())
@ -279,7 +288,7 @@ bool WorldListPage::worldSafetyNagQuestion()
} }
void WorldListPage::on_copyBtn_clicked() void WorldListPage::on_actionCopy_triggered()
{ {
QModelIndex index = getSelectedWorld(); QModelIndex index = getSelectedWorld();
if (!index.isValid()) 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(); QModelIndex index = getSelectedWorld();
if (!index.isValid()) 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(); m_worlds->update();
} }

View File

@ -15,7 +15,7 @@
#pragma once #pragma once
#include <QWidget> #include <QMainWindow>
#include "minecraft/MinecraftInstance.h" #include "minecraft/MinecraftInstance.h"
#include "pages/BasePage.h" #include "pages/BasePage.h"
@ -28,31 +28,33 @@ namespace Ui
class WorldListPage; class WorldListPage;
} }
class WorldListPage : public QWidget, public BasePage class WorldListPage : public QMainWindow, public BasePage
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id, explicit WorldListPage(
QString iconName, QString displayName, QString helpPage = "", BaseInstance *inst,
QWidget *parent = 0); std::shared_ptr<WorldList> worlds,
QWidget *parent = 0
);
virtual ~WorldListPage(); virtual ~WorldListPage();
virtual QString displayName() const override virtual QString displayName() const override
{ {
return m_displayName; return tr("Worlds");
} }
virtual QIcon icon() const override virtual QIcon icon() const override
{ {
return MMC->getThemedIcon(m_iconName); return MMC->getThemedIcon("worlds");
} }
virtual QString id() const override virtual QString id() const override
{ {
return m_id; return "worlds";
} }
virtual QString helpPage() const override virtual QString helpPage() const override
{ {
return m_helpName; return "Worlds";
} }
virtual bool shouldDisplay() const override; virtual bool shouldDisplay() const override;
@ -62,6 +64,7 @@ public:
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev) override; bool eventFilter(QObject *obj, QEvent *ev) override;
bool worldListFilter(QKeyEvent *ev); bool worldListFilter(QKeyEvent *ev);
QMenu * createPopupMenu() override;
protected: protected:
BaseInstance *m_inst; BaseInstance *m_inst;
@ -77,20 +80,16 @@ private:
std::shared_ptr<WorldList> m_worlds; std::shared_ptr<WorldList> m_worlds;
unique_qobject_ptr<LoggedProcess> m_mceditProcess; unique_qobject_ptr<LoggedProcess> m_mceditProcess;
bool m_mceditStarting = false; bool m_mceditStarting = false;
QString m_iconName;
QString m_id;
QString m_displayName;
QString m_helpName;
private slots: private slots:
void on_copySeedBtn_clicked(); void on_actionCopy_Seed_triggered();
void on_mcEditBtn_clicked(); void on_actionMCEdit_triggered();
void on_rmWorldBtn_clicked(); void on_actionRemove_triggered();
void on_addBtn_clicked(); void on_actionAdd_triggered();
void on_copyBtn_clicked(); void on_actionCopy_triggered();
void on_renameBtn_clicked(); void on_actionRename_triggered();
void on_refreshBtn_clicked(); void on_actionRefresh_triggered();
void on_viewFolderBtn_clicked(); void on_actionView_Folder_triggered();
void worldChanged(const QModelIndex &current, const QModelIndex &previous); void worldChanged(const QModelIndex &current, const QModelIndex &previous);
void mceditState(LoggedProcess::State state); void mceditState(LoggedProcess::State state);
}; };

View File

@ -1,171 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>WorldListPage</class> <class>WorldListPage</class>
<widget class="QWidget" name="WorldListPage"> <widget class="QMainWindow" name="WorldListPage">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>723</width> <width>800</width>
<height>532</height> <height>600</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <property name="windowTitle">
<property name="leftMargin"> <string>MainWindow</string>
<number>0</number> </property>
</property> <widget class="QWidget" name="centralwidget">
<property name="topMargin"> <layout class="QHBoxLayout" name="horizontalLayout">
<number>0</number> <property name="leftMargin">
</property> <number>0</number>
<property name="rightMargin"> </property>
<number>0</number> <property name="topMargin">
</property> <number>0</number>
<property name="bottomMargin"> </property>
<number>0</number> <property name="rightMargin">
</property> <number>0</number>
<item> </property>
<widget class="QTabWidget" name="tabWidget"> <property name="bottomMargin">
<property name="currentIndex"> <number>0</number>
<number>0</number> </property>
</property> <item>
<widget class="QWidget" name="tab"> <widget class="QTreeView" name="worldTreeView">
<attribute name="title"> <property name="sizePolicy">
<string notr="true">Tab 1</string> <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> </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>&amp;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>&amp;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>
</widget> </item>
</item> </layout>
</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="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> </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/> <resources/>
<connections/> <connections/>
</ui> </ui>