summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-07-05 02:29:41 +0200
committerPetr Mrázek <peterix@gmail.com>2015-07-05 02:29:41 +0200
commit5f41886d76c11fe8befe8d059c75dcb5bc11f78d (patch)
tree1d5917d7492014c52276528f5aafc6f7e7665872
parent7f1320390c55e408a4b0081b2606eab3892a8148 (diff)
downloadMultiMC-5f41886d76c11fe8befe8d059c75dcb5bc11f78d.tar
MultiMC-5f41886d76c11fe8befe8d059c75dcb5bc11f78d.tar.gz
MultiMC-5f41886d76c11fe8befe8d059c75dcb5bc11f78d.tar.lz
MultiMC-5f41886d76c11fe8befe8d059c75dcb5bc11f78d.tar.xz
MultiMC-5f41886d76c11fe8befe8d059c75dcb5bc11f78d.zip
GH-1053 split settings dialog creation to its own namespace
-rw-r--r--application/CMakeLists.txt4
-rw-r--r--application/LaunchController.cpp3
-rw-r--r--application/MainWindow.cpp52
-rw-r--r--application/MainWindow.h2
-rw-r--r--application/MultiMC.cpp19
-rw-r--r--application/MultiMC.h7
-rw-r--r--application/SettingsUI.cpp9
-rw-r--r--application/SettingsUI.h28
8 files changed, 76 insertions, 48 deletions
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt
index 08099cae..281f402a 100644
--- a/application/CMakeLists.txt
+++ b/application/CMakeLists.txt
@@ -136,6 +136,10 @@ SET(MULTIMC_SOURCES
ConsoleWindow.h
ConsoleWindow.cpp
+ # GUI - settings-specific wrappers for paged dialog
+ SettingsUI.h
+ SettingsUI.cpp
+
# Processes
LaunchController.h
LaunchController.cpp
diff --git a/application/LaunchController.cpp b/application/LaunchController.cpp
index 8680e557..fdda75ef 100644
--- a/application/LaunchController.cpp
+++ b/application/LaunchController.cpp
@@ -8,6 +8,7 @@
#include "ConsoleWindow.h"
#include "BuildConfig.h"
#include "JavaCommon.h"
+#include "SettingsUI.h"
#include <QLineEdit>
#include <QInputDialog>
#include <tasks/Task.h>
@@ -45,7 +46,7 @@ void LaunchController::login()
if (reply == QMessageBox::Yes)
{
// Open the account manager.
- //on_actionManageAccounts_triggered();
+ SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), m_parentWidget, "accounts");
}
}
else if (account.get() == nullptr)
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index e5961693..4b18dd2e 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -350,15 +350,6 @@ namespace Ui {
#include "dialogs/NotificationDialog.h"
#include "dialogs/ExportInstanceDialog.h"
-#include "pages/global/MultiMCPage.h"
-#include "pages/global/ExternalToolsPage.h"
-#include "pages/global/AccountListPage.h"
-#include "pages/global/ProxyPage.h"
-#include "pages/global/JavaPage.h"
-#include "pages/global/MinecraftPage.h"
-
-#include "pagedialog/PageDialog.h"
-
#include "InstanceList.h"
#include "minecraft/MinecraftVersionList.h"
#include "minecraft/LwjglVersionList.h"
@@ -382,6 +373,7 @@ namespace Ui {
#include "JavaCommon.h"
#include "InstancePageProvider.h"
#include "LaunchController.h"
+#include "SettingsUI.h"
#include "minecraft/SkinUtils.h"
#include "resources/Resource.h"
@@ -541,17 +533,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
ui->mainToolBar->addAction(accountMenuButtonAction);
- // set up global pages dialog
- {
- m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
- m_globalSettingsProvider->addPage<MultiMCPage>();
- m_globalSettingsProvider->addPage<MinecraftPage>();
- m_globalSettingsProvider->addPage<JavaPage>();
- m_globalSettingsProvider->addPage<ProxyPage>();
- m_globalSettingsProvider->addPage<ExternalToolsPage>();
- m_globalSettingsProvider->addPage<AccountListPage>();
- }
-
// Update the menu when the active account changes.
// Shouldn't have to use lambdas here like this, but if I don't, the compiler throws a fit.
// Template hell sucks...
@@ -1388,28 +1369,9 @@ void MainWindow::on_actionCheckUpdate_triggered()
updater->checkForUpdate(MMC->settings()->get("UpdateChannel").toString(), true);
}
-template <typename T>
-void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QString())
-{
- auto provider = std::dynamic_pointer_cast<BasePageProvider>(raw_provider);
- if(!provider)
- return;
- {
- SettingsObject::Lock lock(MMC->settings());
- PageDialog dlg(provider, open_page, parent);
- dlg.exec();
- }
-}
-
-void ShowInstancePageDialog(InstancePtr instance, QWidget * parent, QString open_page = QString())
-{
- auto provider = std::make_shared<InstancePageProvider>(instance);
- ShowPageDialog(provider, parent, open_page);
-}
-
void MainWindow::on_actionSettings_triggered()
{
- ShowPageDialog(m_globalSettingsProvider, this, "global-settings");
+ SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), this, "global-settings");
// FIXME: quick HACK to make this work. improve, optimize.
proxymodel->invalidate();
proxymodel->sort(0);
@@ -1419,28 +1381,28 @@ void MainWindow::on_actionSettings_triggered()
void MainWindow::on_actionInstanceSettings_triggered()
{
- ShowInstancePageDialog(m_selectedInstance, this, "settings");
+ SettingsUI::ShowInstancePageDialog(m_selectedInstance, this, "settings");
}
void MainWindow::on_actionEditInstNotes_triggered()
{
- ShowInstancePageDialog(m_selectedInstance, this, "notes");
+ SettingsUI::ShowInstancePageDialog(m_selectedInstance, this, "notes");
}
void MainWindow::on_actionEditInstance_triggered()
{
- ShowInstancePageDialog(m_selectedInstance, this);
+ SettingsUI::ShowInstancePageDialog(m_selectedInstance, this);
}
void MainWindow::on_actionScreenshots_triggered()
{
- ShowInstancePageDialog(m_selectedInstance, this, "screenshots");
+ SettingsUI::ShowInstancePageDialog(m_selectedInstance, this, "screenshots");
}
void MainWindow::on_actionManageAccounts_triggered()
{
- ShowPageDialog(m_globalSettingsProvider, this, "accounts");
+ SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), this, "accounts");
}
void MainWindow::on_actionReportBug_triggered()
diff --git a/application/MainWindow.h b/application/MainWindow.h
index 505e5f13..7ef277db 100644
--- a/application/MainWindow.h
+++ b/application/MainWindow.h
@@ -33,7 +33,6 @@ class LabeledToolButton;
class QLabel;
class MinecraftLauncher;
class BaseProfilerFactory;
-class GenericPageProvider;
namespace Ui
{
@@ -180,7 +179,6 @@ private:
QToolButton *changeIconButton;
QToolButton *newsLabel;
- std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
std::shared_ptr<NewsChecker> m_newsChecker;
std::shared_ptr<NotificationChecker> m_notificationChecker;
std::shared_ptr<LaunchController> m_launchController;
diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp
index 0319ea75..605e3763 100644
--- a/application/MultiMC.cpp
+++ b/application/MultiMC.cpp
@@ -1,5 +1,12 @@
#include "MultiMC.h"
#include "BuildConfig.h"
+#include "pages/BasePageProvider.h"
+#include "pages/global/MultiMCPage.h"
+#include "pages/global/MinecraftPage.h"
+#include "pages/global/JavaPage.h"
+#include "pages/global/ProxyPage.h"
+#include "pages/global/ExternalToolsPage.h"
+#include "pages/global/AccountListPage.h"
#include <iostream>
#include <QDir>
@@ -533,6 +540,18 @@ void MultiMC::initGlobalSettings(bool test_mode)
// Jar mod nag dialog in version page
m_settings->registerSetting("JarModNagSeen", false);
+
+
+ // Init page provider
+ {
+ m_globalSettingsProvider = std::make_shared<GenericPageProvider>(tr("Settings"));
+ m_globalSettingsProvider->addPage<MultiMCPage>();
+ m_globalSettingsProvider->addPage<MinecraftPage>();
+ m_globalSettingsProvider->addPage<JavaPage>();
+ m_globalSettingsProvider->addPage<ProxyPage>();
+ m_globalSettingsProvider->addPage<ExternalToolsPage>();
+ m_globalSettingsProvider->addPage<AccountListPage>();
+ }
}
std::shared_ptr<LWJGLVersionList> MultiMC::lwjgllist()
diff --git a/application/MultiMC.h b/application/MultiMC.h
index 7389dc8b..c1df1bb7 100644
--- a/application/MultiMC.h
+++ b/application/MultiMC.h
@@ -8,6 +8,7 @@
#include <QDateTime>
#include <updater/GoUpdate.h>
+class GenericPageProvider;
class QFile;
class MinecraftVersionList;
class LWJGLVersionList;
@@ -54,6 +55,11 @@ public:
return m_settings;
}
+ std::shared_ptr<GenericPageProvider> globalSettingsPages()
+ {
+ return m_globalSettingsProvider;
+ }
+
qint64 timeSinceStart() const
{
return startTime.msecsTo(QDateTime::currentDateTime());
@@ -163,6 +169,7 @@ private:
std::shared_ptr<MinecraftVersionList> m_minecraftlist;
std::shared_ptr<JavaVersionList> m_javalist;
std::shared_ptr<TranslationDownloader> m_translationChecker;
+ std::shared_ptr<GenericPageProvider> m_globalSettingsProvider;
QMap<QString, std::shared_ptr<BaseProfilerFactory>> m_profilers;
QMap<QString, std::shared_ptr<BaseDetachedToolFactory>> m_tools;
diff --git a/application/SettingsUI.cpp b/application/SettingsUI.cpp
new file mode 100644
index 00000000..2a2010de
--- /dev/null
+++ b/application/SettingsUI.cpp
@@ -0,0 +1,9 @@
+#include "SettingsUI.h"
+namespace SettingsUI
+{
+void ShowInstancePageDialog(InstancePtr instance, QWidget * parent, QString open_page)
+{
+ auto provider = std::make_shared<InstancePageProvider>(instance);
+ ShowPageDialog(provider, parent, open_page);
+}
+}
diff --git a/application/SettingsUI.h b/application/SettingsUI.h
new file mode 100644
index 00000000..1e6dc8d0
--- /dev/null
+++ b/application/SettingsUI.h
@@ -0,0 +1,28 @@
+#pragma once
+#include "pages/BasePageProvider.h"
+#include "MultiMC.h"
+#include "pagedialog/PageDialog.h"
+#include "InstancePageProvider.h"
+#include <settings/SettingsObject.h>
+#include <BaseInstance.h>
+
+/*
+ * FIXME: this is a fragment. find a better place for it.
+ */
+namespace SettingsUI
+{
+template <typename T>
+void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QString())
+{
+ auto provider = std::dynamic_pointer_cast<BasePageProvider>(raw_provider);
+ if(!provider)
+ return;
+ {
+ SettingsObject::Lock lock(MMC->settings());
+ PageDialog dlg(provider, open_page, parent);
+ dlg.exec();
+ }
+}
+
+void ShowInstancePageDialog(InstancePtr instance, QWidget * parent, QString open_page = QString());
+}