summaryrefslogtreecommitdiffstats
path: root/gui/pagedialog
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2014-06-10 00:46:05 +0200
committerPetr Mrázek <peterix@gmail.com>2014-06-10 00:46:05 +0200
commit9ec6deea848f8cdbebeb5c6be8b042c754ad9de7 (patch)
treefe6f72f3575ae9eb03cdb859e0d747e0fadd245c /gui/pagedialog
parent0bccc94471d0223cf493ad860fa890614480433d (diff)
downloadMultiMC-9ec6deea848f8cdbebeb5c6be8b042c754ad9de7.tar
MultiMC-9ec6deea848f8cdbebeb5c6be8b042c754ad9de7.tar.gz
MultiMC-9ec6deea848f8cdbebeb5c6be8b042c754ad9de7.tar.lz
MultiMC-9ec6deea848f8cdbebeb5c6be8b042c754ad9de7.tar.xz
MultiMC-9ec6deea848f8cdbebeb5c6be8b042c754ad9de7.zip
Add close button to page dialog. Add help button to page dialog.
Smile.
Diffstat (limited to 'gui/pagedialog')
-rw-r--r--gui/pagedialog/PageDialog.cpp83
-rw-r--r--gui/pagedialog/PageDialog.h6
2 files changed, 38 insertions, 51 deletions
diff --git a/gui/pagedialog/PageDialog.cpp b/gui/pagedialog/PageDialog.cpp
index 450f2b08..4db5cd28 100644
--- a/gui/pagedialog/PageDialog.cpp
+++ b/gui/pagedialog/PageDialog.cpp
@@ -18,6 +18,7 @@
#include <QStackedLayout>
#include <QPushButton>
#include <QSortFilterProxyModel>
+#include <QUrl>
#include "MultiMC.h"
#include <QStyledItemDelegate>
#include <QListView>
@@ -25,6 +26,7 @@
#include <QLabel>
#include <QDialogButtonBox>
#include <QGridLayout>
+#include <QDesktopServices>
#include <settingsobject.h>
#include "PageDialog_p.h"
@@ -127,38 +129,36 @@ void PageDialog::createUI()
m_pageStack->setMargin(0);
m_pageStack->addWidget(new QWidget(this));
- /*
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()));
- connect(buttons, SIGNAL(rejected()), this, SLOT(reject()));
- */
+ new QDialogButtonBox(QDialogButtonBox::Help | QDialogButtonBox::Close);
+ buttons->button(QDialogButtonBox::Close)->setDefault(true);
+ connect(buttons->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SLOT(close()));
+ connect(buttons->button(QDialogButtonBox::Help), SIGNAL(clicked()), this, SLOT(help()));
QGridLayout *mainGridLayout = new QGridLayout;
mainGridLayout->addLayout(headerHLayout, 0, 1, 1, 1);
mainGridLayout->addWidget(m_pageList, 0, 0, 2, 1);
mainGridLayout->addLayout(m_pageStack, 1, 1, 1, 1);
- //mainGridLayout->addWidget(buttons, 2, 0, 1, 2);
+ mainGridLayout->addWidget(buttons, 2, 0, 1, 2);
mainGridLayout->setColumnStretch(1, 4);
setLayout(mainGridLayout);
}
void PageDialog::showPage(int row)
{
- auto page = m_model->pages().at(row);
- m_pageStack->setCurrentIndex(page->stackIndex);
- m_header->setText(page->displayName());
- m_iconHeader->setIcon(page->icon());
-}
-
-void PageDialog::currentChanged(const QModelIndex &current)
-{
- if (current.isValid())
+ if(row != -1)
+ {
+ m_currentPage = m_model->pages().at(row);
+ }
+ else
+ {
+ m_currentPage = nullptr;
+ }
+ if(m_currentPage)
{
- showPage(m_proxyModel->mapToSource(current).row());
+ m_pageStack->setCurrentIndex(m_currentPage->stackIndex);
+ m_header->setText(m_currentPage->displayName());
+ m_iconHeader->setIcon(m_currentPage->icon());
}
else
{
@@ -168,45 +168,32 @@ void PageDialog::currentChanged(const QModelIndex &current)
}
}
-void PageDialog::accept()
+void PageDialog::help()
{
- bool accepted = true;
- for(auto page: m_model->pages())
- {
- accepted &= page->accept();
- }
- if(accepted)
+ if(m_currentPage)
{
- MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
- QDialog::accept();
+ QString pageId = m_currentPage->helpPage();
+ if(pageId.isEmpty())
+ return;
+ QDesktopServices::openUrl(QUrl("https://github.com/MultiMC/MultiMC5/wiki/" + pageId));
}
}
-void PageDialog::reject()
+void PageDialog::currentChanged(const QModelIndex &current)
{
- bool rejected = true;
- for(auto page: m_model->pages())
- {
- rejected &= page->reject();
- }
- if(rejected)
- {
- MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
- QDialog::reject();
- }
+ showPage(current.isValid() ? m_proxyModel->mapToSource(current).row() : -1);
}
-void PageDialog::apply()
+void PageDialog::closeEvent(QCloseEvent * event)
{
+ bool accepted = true;
for(auto page: m_model->pages())
{
- page->apply();
+ accepted &= page->apply();
+ }
+ if(accepted)
+ {
+ MMC->settings()->set("PagedGeometry", saveGeometry().toBase64());
+ QDialog::closeEvent(event);
}
-}
-
-
-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 bb31a607..88926ef1 100644
--- a/gui/pagedialog/PageDialog.h
+++ b/gui/pagedialog/PageDialog.h
@@ -38,14 +38,14 @@ private:
void createUI();
private
slots:
- void apply();
- virtual void reject();
- virtual void accept();
void currentChanged(const QModelIndex &current);
void showPage(int row);
+ void help();
virtual void closeEvent(QCloseEvent *event);
+
private:
+ BasePage * m_currentPage;
QSortFilterProxyModel *m_proxyModel;
PageModel *m_model;
QStackedLayout *m_pageStack;