diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-06-10 00:46:05 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-10 00:46:05 +0200 |
commit | 9ec6deea848f8cdbebeb5c6be8b042c754ad9de7 (patch) | |
tree | fe6f72f3575ae9eb03cdb859e0d747e0fadd245c /gui/pagedialog/PageDialog.cpp | |
parent | 0bccc94471d0223cf493ad860fa890614480433d (diff) | |
download | MultiMC-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/PageDialog.cpp')
-rw-r--r-- | gui/pagedialog/PageDialog.cpp | 83 |
1 files changed, 35 insertions, 48 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 ¤t) -{ - 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 ¤t) } } -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 ¤t) { - 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); } |