From 6b3d1101cb801367edef8f35b3eee4499e04866b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 3 Jun 2014 01:34:44 +0200 Subject: Tweaks to page dialog and version page. --- MultiMC.cpp | 2 + gui/pagedialog/PageDialog.cpp | 46 +++++++++++++++++++++- gui/pagedialog/PageDialog.h | 3 ++ gui/pages/BasePage.h | 12 ++++++ gui/pages/VersionPage.cpp | 1 + gui/pages/VersionPage.ui | 88 ++++++++++++++++++++++++++++--------------- gui/widgets/LineSeparator.h | 4 +- gui/widgets/ServerStatus.cpp | 2 +- 8 files changed, 123 insertions(+), 35 deletions(-) diff --git a/MultiMC.cpp b/MultiMC.cpp index 5b0e411a..6d01e4af 100644 --- a/MultiMC.cpp +++ b/MultiMC.cpp @@ -507,6 +507,8 @@ void MultiMC::initGlobalSettings() m_settings->registerSetting("ConsoleWindowGeometry", ""); m_settings->registerSetting("SettingsGeometry", ""); + + m_settings->registerSetting("PagedGeometry", ""); } void MultiMC::initHttpMetaCache() 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 #include #include +#include #include "PageDialog_p.h" #include @@ -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 @@ 0 0 400 - 326 + 475 @@ -51,6 +51,16 @@ + + + + Selection + + + Qt::AlignCenter + + + @@ -59,74 +69,79 @@ - + - Replace any current custom version with Minecraft Forge + This isn't implemented yet. - Install Forge + Move up - + + + This isn't implemented yet. + - Install LiteLoader + Move down - + - Add jar mod + Remove - - - Qt::Horizontal - - + - + - Reload + Install + + + Qt::AlignCenter - + + + Replace any current custom version with Minecraft Forge + - Remove + Install Forge - - - Qt::Horizontal + + + Install LiteLoader - - - This isn't implemented yet. - + - Move up + Add jar mod - - - This isn't implemented yet. - + + + + - Move down + List + + + Qt::AlignCenter @@ -140,6 +155,13 @@ + + + + Reload + + + @@ -163,6 +185,12 @@ QTreeView
gui/widgets/ModListView.h
+ + LineSeparator + QWidget +
gui/widgets/LineSeparator.h
+ 1 +
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) -- cgit v1.2.3