summaryrefslogtreecommitdiffstats
path: root/gui/pagedialog
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-06-03 01:34:44 +0200
committerPetr Mrázek <peterix@gmail.com>2014-06-09 01:38:31 +0200
commit6b3d1101cb801367edef8f35b3eee4499e04866b (patch)
tree22f223c016fd0b4999dc7c704bd6f7b7583269d1 /gui/pagedialog
parentf485885757e287546bb27bda5906bfa4adc5494a (diff)
downloadMultiMC-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/pagedialog')
-rw-r--r--gui/pagedialog/PageDialog.cpp46
-rw-r--r--gui/pagedialog/PageDialog.h3
2 files changed, 47 insertions, 2 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 &current)
}
}
+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 &current);
void showPage(int row);
+ virtual void closeEvent(QCloseEvent *event);
private:
QSortFilterProxyModel *m_proxyModel;