diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-06-03 01:34:44 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-09 01:38:31 +0200 |
commit | 6b3d1101cb801367edef8f35b3eee4499e04866b (patch) | |
tree | 22f223c016fd0b4999dc7c704bd6f7b7583269d1 /gui | |
parent | f485885757e287546bb27bda5906bfa4adc5494a (diff) | |
download | MultiMC-6b3d1101cb801367edef8f35b3eee4499e04866b.tar MultiMC-6b3d1101cb801367edef8f35b3eee4499e04866b.tar.gz MultiMC-6b3d1101cb801367edef8f35b3eee4499e04866b.tar.lz MultiMC-6b3d1101cb801367edef8f35b3eee4499e04866b.tar.xz MultiMC-6b3d1101cb801367edef8f35b3eee4499e04866b.zip |
Tweaks to page dialog and version page.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/pagedialog/PageDialog.cpp | 46 | ||||
-rw-r--r-- | gui/pagedialog/PageDialog.h | 3 | ||||
-rw-r--r-- | gui/pages/BasePage.h | 12 | ||||
-rw-r--r-- | gui/pages/VersionPage.cpp | 1 | ||||
-rw-r--r-- | gui/pages/VersionPage.ui | 88 | ||||
-rw-r--r-- | gui/widgets/LineSeparator.h | 4 | ||||
-rw-r--r-- | gui/widgets/ServerStatus.cpp | 2 |
7 files changed, 121 insertions, 35 deletions
diff --git a/gui/pagedialog/PageDialog.cpp b/gui/pagedialog/PageDialog.cpp index 0dda7c1f..f71cfdcc 100644 --- a/gui/pagedialog/PageDialog.cpp +++ b/gui/pagedialog/PageDialog.cpp @@ -25,6 +25,7 @@ #include <QLabel> #include <QDialogButtonBox> #include <QGridLayout> +#include <settingsobject.h> #include "PageDialog_p.h" #include <gui/widgets/IconLabel.h> @@ -55,6 +56,7 @@ PageDialog::PageDialog(BasePageProviderPtr pageProvider, QWidget *parent) : QDia MultiMCPlatform::fixWM_CLASS(this); createUI(); setWindowTitle(pageProvider->dialogTitle()); + restoreGeometry(QByteArray::fromBase64(MMC->settings()->get("PagedGeometry").toByteArray())); m_model = new PageModel(this); m_proxyModel = new PageEntryFilterModel(this); @@ -111,8 +113,9 @@ void PageDialog::createUI() m_pageStack->setMargin(0); m_pageStack->addWidget(new QWidget(this)); - QDialogButtonBox *buttons = new QDialogButtonBox( - QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel); + QDialogButtonBox *buttons = + new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Ok | + QDialogButtonBox::Apply | QDialogButtonBox::Cancel); buttons->button(QDialogButtonBox::Ok)->setDefault(true); connect(buttons->button(QDialogButtonBox::Apply), SIGNAL(clicked()), this, SLOT(apply())); connect(buttons, SIGNAL(accepted()), this, SLOT(accept())); @@ -149,6 +152,45 @@ void PageDialog::currentChanged(const QModelIndex ¤t) } } +void PageDialog::accept() +{ + bool accepted = true; + for(auto page: m_model->pages()) + { + accepted &= page->accept(); + } + if(accepted) + { + MMC->settings()->set("PagedGeometry", saveGeometry().toBase64()); + QDialog::accept(); + } +} + +void PageDialog::reject() +{ + bool rejected = true; + for(auto page: m_model->pages()) + { + rejected &= page->reject(); + } + if(rejected) + { + MMC->settings()->set("PagedGeometry", saveGeometry().toBase64()); + QDialog::reject(); + } +} + void PageDialog::apply() { + for(auto page: m_model->pages()) + { + page->apply(); + } +} + + +void PageDialog::closeEvent(QCloseEvent * event) +{ + MMC->settings()->set("PagedGeometry", saveGeometry().toBase64()); + QDialog::closeEvent(event); } diff --git a/gui/pagedialog/PageDialog.h b/gui/pagedialog/PageDialog.h index 880b7df4..fd97fc3b 100644 --- a/gui/pagedialog/PageDialog.h +++ b/gui/pagedialog/PageDialog.h @@ -36,8 +36,11 @@ private: void createUI(); private slots: void apply(); + virtual void reject(); + virtual void accept(); void currentChanged(const QModelIndex ¤t); void showPage(int row); + virtual void closeEvent(QCloseEvent *event); private: QSortFilterProxyModel *m_proxyModel; diff --git a/gui/pages/BasePage.h b/gui/pages/BasePage.h index 90e27d6f..d057d8f7 100644 --- a/gui/pages/BasePage.h +++ b/gui/pages/BasePage.h @@ -25,6 +25,18 @@ public: virtual QString id() = 0; virtual QString displayName() = 0; virtual QIcon icon() = 0; + virtual bool accept() + { + return true; + } + virtual bool reject() + { + return true; + } + virtual bool apply() + { + return true; + } virtual bool shouldDisplay() { return true; diff --git a/gui/pages/VersionPage.cpp b/gui/pages/VersionPage.cpp index 34b959e0..99232a25 100644 --- a/gui/pages/VersionPage.cpp +++ b/gui/pages/VersionPage.cpp @@ -79,6 +79,7 @@ VersionPage::VersionPage(OneSixInstance *inst, QWidget *parent) main_model->setSourceModel(m_version.get()); ui->libraryTreeView->setModel(main_model); ui->libraryTreeView->installEventFilter(this); + ui->libraryTreeView->setSelectionMode(QAbstractItemView::SingleSelection); connect(ui->libraryTreeView->selectionModel(), &QItemSelectionModel::currentChanged, this, &VersionPage::versionCurrent); updateVersionControls(); diff --git a/gui/pages/VersionPage.ui b/gui/pages/VersionPage.ui index 036295f0..f770df55 100644 --- a/gui/pages/VersionPage.ui +++ b/gui/pages/VersionPage.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>400</width> - <height>326</height> + <height>475</height> </rect> </property> <property name="windowTitle"> @@ -52,6 +52,16 @@ <item> <layout class="QVBoxLayout" name="verticalLayout_4"> <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Selection</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> + <item> <widget class="QPushButton" name="changeMCVersionBtn"> <property name="text"> <string>Change version</string> @@ -59,74 +69,79 @@ </widget> </item> <item> - <widget class="QPushButton" name="forgeBtn"> + <widget class="QPushButton" name="moveLibraryUpBtn"> <property name="toolTip"> - <string>Replace any current custom version with Minecraft Forge</string> + <string>This isn't implemented yet.</string> </property> <property name="text"> - <string>Install Forge</string> + <string>Move up</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="liteloaderBtn"> + <widget class="QPushButton" name="moveLibraryDownBtn"> + <property name="toolTip"> + <string>This isn't implemented yet.</string> + </property> <property name="text"> - <string>Install LiteLoader</string> + <string>Move down</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="jarmodBtn"> + <widget class="QPushButton" name="removeLibraryBtn"> <property name="text"> - <string>Add jar mod</string> + <string>Remove</string> </property> </widget> </item> <item> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> + <widget class="LineSeparator" name="separator" native="true"/> </item> <item> - <widget class="QPushButton" name="reloadLibrariesBtn"> + <widget class="QLabel" name="label_2"> <property name="text"> - <string>Reload</string> + <string>Install</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> </property> </widget> </item> <item> - <widget class="QPushButton" name="removeLibraryBtn"> + <widget class="QPushButton" name="forgeBtn"> + <property name="toolTip"> + <string>Replace any current custom version with Minecraft Forge</string> + </property> <property name="text"> - <string>Remove</string> + <string>Install Forge</string> </property> </widget> </item> <item> - <widget class="Line" name="line_2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <widget class="QPushButton" name="liteloaderBtn"> + <property name="text"> + <string>Install LiteLoader</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="moveLibraryUpBtn"> - <property name="toolTip"> - <string>This isn't implemented yet.</string> - </property> + <widget class="QPushButton" name="jarmodBtn"> <property name="text"> - <string>Move up</string> + <string>Add jar mod</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="moveLibraryDownBtn"> - <property name="toolTip"> - <string>This isn't implemented yet.</string> - </property> + <widget class="LineSeparator" name="widget" native="true"/> + </item> + <item> + <widget class="QLabel" name="label_5"> <property name="text"> - <string>Move down</string> + <string>List</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> </property> </widget> </item> @@ -141,6 +156,13 @@ </widget> </item> <item> + <widget class="QPushButton" name="reloadLibrariesBtn"> + <property name="text"> + <string>Reload</string> + </property> + </widget> + </item> + <item> <spacer name="verticalSpacer_7"> <property name="orientation"> <enum>Qt::Vertical</enum> @@ -163,6 +185,12 @@ <extends>QTreeView</extends> <header>gui/widgets/ModListView.h</header> </customwidget> + <customwidget> + <class>LineSeparator</class> + <extends>QWidget</extends> + <header>gui/widgets/LineSeparator.h</header> + <container>1</container> + </customwidget> </customwidgets> <resources/> <connections/> diff --git a/gui/widgets/LineSeparator.h b/gui/widgets/LineSeparator.h index 376f2056..9546e747 100644 --- a/gui/widgets/LineSeparator.h +++ b/gui/widgets/LineSeparator.h @@ -9,10 +9,10 @@ class LineSeparator : public QWidget public: /// Create a line separator. orientation is the orientation of the line. - explicit LineSeparator(QWidget *parent, Qt::Orientation orientation = Qt::Vertical); + explicit LineSeparator(QWidget *parent, Qt::Orientation orientation = Qt::Horizontal); QSize sizeHint() const; void paintEvent(QPaintEvent *); void initStyleOption(QStyleOption *option) const; private: - Qt::Orientation m_orientation = Qt::Vertical; + Qt::Orientation m_orientation = Qt::Horizontal; }; diff --git a/gui/widgets/ServerStatus.cpp b/gui/widgets/ServerStatus.cpp index e540a301..10ed79fb 100644 --- a/gui/widgets/ServerStatus.cpp +++ b/gui/widgets/ServerStatus.cpp @@ -59,7 +59,7 @@ void ServerStatus::reloadStatus() void ServerStatus::addLine() { - layout->addWidget(new LineSeparator(this)); + layout->addWidget(new LineSeparator(this, Qt::Vertical)); } void ServerStatus::addStatus(QString key, QString name) |