diff options
author | Petr Mrázek <peterix@gmail.com> | 2014-06-18 01:15:01 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2014-06-18 01:15:01 +0200 |
commit | d911c9908c11c42144084c862c64b740cfb0c02f (patch) | |
tree | 974bafaf530afe4076850a21f91a1b4b911c32f1 /gui/MainWindow.cpp | |
parent | 702e00e0593b03603690717646dac5e4fae504d3 (diff) | |
download | MultiMC-d911c9908c11c42144084c862c64b740cfb0c02f.tar MultiMC-d911c9908c11c42144084c862c64b740cfb0c02f.tar.gz MultiMC-d911c9908c11c42144084c862c64b740cfb0c02f.tar.lz MultiMC-d911c9908c11c42144084c862c64b740cfb0c02f.tar.xz MultiMC-d911c9908c11c42144084c862c64b740cfb0c02f.zip |
Replace notes dialog with a page.
Diffstat (limited to 'gui/MainWindow.cpp')
-rw-r--r-- | gui/MainWindow.cpp | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index e9cfd361..35ac541d 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -57,7 +57,6 @@ #include "gui/dialogs/CustomMessageBox.h" #include "gui/dialogs/LwjglSelectDialog.h" #include "gui/dialogs/IconPickerDialog.h" -#include "gui/dialogs/EditNotesDialog.h" #include "gui/dialogs/CopyInstanceDialog.h" #include "gui/dialogs/AccountListDialog.h" #include "gui/dialogs/AccountSelectDialog.h" @@ -941,17 +940,31 @@ void MainWindow::on_actionSettings_triggered() updateToolsMenu(); } -void MainWindow::on_actionInstanceSettings_triggered() +template <typename T> +void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QString()) { - if (!m_selectedInstance) - return; - auto provider = std::dynamic_pointer_cast<BasePageProvider>(m_selectedInstance); + auto provider = std::dynamic_pointer_cast<BasePageProvider>(raw_provider); if(!provider) return; - PageDialog dlg(provider, "settings" , this); + PageDialog dlg(provider, open_page, parent); dlg.exec(); } +void MainWindow::on_actionInstanceSettings_triggered() +{ + ShowPageDialog(m_selectedInstance, this, "settings"); +} + +void MainWindow::on_actionEditInstNotes_triggered() +{ + ShowPageDialog(m_selectedInstance, this, "notes"); +} + +void MainWindow::on_actionEditInstance_triggered() +{ + ShowPageDialog(m_selectedInstance, this); +} + void MainWindow::on_actionManageAccounts_triggered() { AccountListDialog dialog(this); @@ -1040,17 +1053,6 @@ void MainWindow::on_actionViewSelectedInstFolder_triggered() } } -void MainWindow::on_actionEditInstance_triggered() -{ - if (!m_selectedInstance) - return; - auto provider = std::dynamic_pointer_cast<BasePageProvider>(m_selectedInstance); - if(!provider) - return; - PageDialog dlg(provider, "" , this); - dlg.exec(); -} - void MainWindow::closeEvent(QCloseEvent *event) { // Save the window state and geometry. @@ -1398,20 +1400,6 @@ void MainWindow::selectionBad() setSelectedInstanceById(MMC->settings()->get("SelectedInstance").toString()); } -void MainWindow::on_actionEditInstNotes_triggered() -{ - if (!m_selectedInstance) - return; - - EditNotesDialog noteedit(m_selectedInstance->notes(), m_selectedInstance->name(), this); - noteedit.exec(); - if (noteedit.result() == QDialog::Accepted) - { - - m_selectedInstance->setNotes(noteedit.getText()); - } -} - void MainWindow::instanceEnded() { this->show(); |