diff options
author | Petr Mrázek <peterix@gmail.com> | 2019-06-01 12:28:53 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2019-06-01 12:28:53 +0200 |
commit | 932160818e8e15dc124e1ce281749d28e10c5e66 (patch) | |
tree | 1924f82fffccf54ef14cbfcd8a7f25ccda53daaf | |
parent | 59e1ed3d8750b499b6d515a82bc08f6f72cc456a (diff) | |
download | MultiMC-932160818e8e15dc124e1ce281749d28e10c5e66.tar MultiMC-932160818e8e15dc124e1ce281749d28e10c5e66.tar.gz MultiMC-932160818e8e15dc124e1ce281749d28e10c5e66.tar.lz MultiMC-932160818e8e15dc124e1ce281749d28e10c5e66.tar.xz MultiMC-932160818e8e15dc124e1ce281749d28e10c5e66.zip |
NOISSUE add option to open global settings from instance settings
This should hopefully giude people towards using the right thing.
-rw-r--r-- | application/CMakeLists.txt | 3 | ||||
-rw-r--r-- | application/LaunchController.cpp | 3 | ||||
-rw-r--r-- | application/MainWindow.cpp | 12 | ||||
-rw-r--r-- | application/MainWindow.h | 2 | ||||
-rw-r--r-- | application/MultiMC.cpp | 16 | ||||
-rw-r--r-- | application/MultiMC.h | 9 | ||||
-rw-r--r-- | application/SettingsUI.h | 26 | ||||
-rw-r--r-- | application/pages/instance/InstanceSettingsPage.cpp | 8 | ||||
-rw-r--r-- | application/pages/instance/InstanceSettingsPage.h | 2 | ||||
-rw-r--r-- | application/pages/instance/InstanceSettingsPage.ui | 27 |
10 files changed, 55 insertions, 53 deletions
diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 26852df0..f8709cfd 100644 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -64,9 +64,6 @@ SET(MULTIMC_SOURCES themes/SystemTheme.cpp themes/SystemTheme.h - # GUI - settings-specific wrappers for paged dialog - SettingsUI.h - # Processes LaunchController.h LaunchController.cpp diff --git a/application/LaunchController.cpp b/application/LaunchController.cpp index 8f3e6596..e39048f1 100644 --- a/application/LaunchController.cpp +++ b/application/LaunchController.cpp @@ -9,7 +9,6 @@ #include "InstanceWindow.h" #include "BuildConfig.h" #include "JavaCommon.h" -#include "SettingsUI.h" #include <QLineEdit> #include <QInputDialog> #include <tasks/Task.h> @@ -53,7 +52,7 @@ void LaunchController::login() if (reply == QMessageBox::Yes) { // Open the account manager. - SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), m_parentWidget, "accounts"); + MMC->ShowGlobalSettings(m_parentWidget, "accounts"); } } else if (account.get() == nullptr) diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp index 34dfb369..bec57c0d 100644 --- a/application/MainWindow.cpp +++ b/application/MainWindow.cpp @@ -70,7 +70,6 @@ #include "InstanceProxyModel.h" #include "JavaCommon.h" #include "LaunchController.h" -#include "SettingsUI.h" #include "groupview/GroupView.h" #include "groupview/InstanceDelegate.h" #include "widgets/LabeledToolButton.h" @@ -703,6 +702,9 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new MainWindow // model reset -> selection is invalid. All the instance pointers are wrong. connect(MMC->instances().get(), &InstanceList::dataIsInvalid, this, &MainWindow::selectionBad); + // When the global settings page closes, we want to know about it and update our state + connect(MMC, &MultiMC::globalSettingsClosed, this, &MainWindow::globalSettingsClosed); + m_statusLeft = new QLabel(tr("No instance selected"), this); m_statusRight = new ServerStatus(this); statusBar()->addPermanentWidget(m_statusLeft, 1); @@ -1572,7 +1574,11 @@ void MainWindow::checkForUpdates() void MainWindow::on_actionSettings_triggered() { - SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), this, "global-settings"); + MMC->ShowGlobalSettings(this, "global-settings"); +} + +void MainWindow::globalSettingsClosed() +{ // FIXME: quick HACK to make this work. improve, optimize. MMC->instances()->loadList(); proxymodel->invalidate(); @@ -1608,7 +1614,7 @@ void MainWindow::on_actionScreenshots_triggered() void MainWindow::on_actionManageAccounts_triggered() { - SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), this, "accounts"); + MMC->ShowGlobalSettings(this, "accounts"); } void MainWindow::on_actionReportBug_triggered() diff --git a/application/MainWindow.h b/application/MainWindow.h index 8a555ae2..7691d50e 100644 --- a/application/MainWindow.h +++ b/application/MainWindow.h @@ -181,6 +181,8 @@ private slots: void konamiTriggered(); + void globalSettingsClosed(); + private: void addInstance(QString url = QString()); void activateInstance(InstancePtr instance); diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index f31c4ba5..179839fe 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -66,6 +66,8 @@ #include <ganalytics.h> #include <sys.h> +#include "pagedialog/PageDialog.h" + #if defined Q_OS_WIN32 #ifndef WIN32_LEAN_AND_MEAN @@ -1088,6 +1090,20 @@ void MultiMC::controllerFailed(const QString& error) } } +void MultiMC::ShowGlobalSettings(class QWidget* parent, QString open_page) +{ + if(!m_globalSettingsProvider) { + return; + } + emit globalSettingsAboutToOpen(); + { + SettingsObject::Lock lock(MMC->settings()); + PageDialog dlg(m_globalSettingsProvider.get(), open_page, parent); + dlg.exec(); + } + emit globalSettingsClosed(); +} + MainWindow* MultiMC::showMainWindow(bool minimized) { if(m_mainWindow) diff --git a/application/MultiMC.h b/application/MultiMC.h index 9fe98aa1..d7c727e0 100644 --- a/application/MultiMC.h +++ b/application/MultiMC.h @@ -65,11 +65,6 @@ public: return m_settings; } - std::shared_ptr<GenericPageProvider> globalSettingsPages() const - { - return m_globalSettingsProvider; - } - qint64 timeSinceStart() const { return startTime.msecsTo(QDateTime::currentDateTime()); @@ -146,8 +141,12 @@ public: void updateIsRunning(bool running); bool updatesAreAllowed(); + void ShowGlobalSettings(class QWidget * parent, QString open_page = QString()); + signals: void updateAllowedChanged(bool status); + void globalSettingsAboutToOpen(); + void globalSettingsClosed(); public slots: bool launch(InstancePtr instance, bool online = true, BaseProfilerFactory *profiler = nullptr); diff --git a/application/SettingsUI.h b/application/SettingsUI.h deleted file mode 100644 index 474bc1ab..00000000 --- a/application/SettingsUI.h +++ /dev/null @@ -1,26 +0,0 @@ -#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.get(), open_page, parent); - dlg.exec(); - } -} -} diff --git a/application/pages/instance/InstanceSettingsPage.cpp b/application/pages/instance/InstanceSettingsPage.cpp index 61911f67..210820fc 100644 --- a/application/pages/instance/InstanceSettingsPage.cpp +++ b/application/pages/instance/InstanceSettingsPage.cpp @@ -21,6 +21,9 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent) ui->setupUi(this); auto sysMB = Sys::getSystemRam() / Sys::megabyte; ui->maxMemSpinBox->setMaximum(sysMB); + connect(ui->openGlobalJavaSettingsButton, &QCommandLinkButton::clicked, this, &InstanceSettingsPage::globalSettingsButtonClicked); + connect(MMC, &MultiMC::globalSettingsAboutToOpen, this, &InstanceSettingsPage::applySettings); + connect(MMC, &MultiMC::globalSettingsClosed, this, &InstanceSettingsPage::loadSettings); loadSettings(); } @@ -34,6 +37,11 @@ InstanceSettingsPage::~InstanceSettingsPage() delete ui; } +void InstanceSettingsPage::globalSettingsButtonClicked(bool) +{ + MMC->ShowGlobalSettings(this, "global-settings"); +} + bool InstanceSettingsPage::apply() { applySettings(); diff --git a/application/pages/instance/InstanceSettingsPage.h b/application/pages/instance/InstanceSettingsPage.h index 18687ede..c3c78fd5 100644 --- a/application/pages/instance/InstanceSettingsPage.h +++ b/application/pages/instance/InstanceSettingsPage.h @@ -66,6 +66,8 @@ private slots: void checkerFinished(); + void globalSettingsButtonClicked(bool checked); + private: Ui::InstanceSettingsPage *ui; BaseInstance *m_instance; diff --git a/application/pages/instance/InstanceSettingsPage.ui b/application/pages/instance/InstanceSettingsPage.ui index 0c180df3..ad4dcfcf 100644 --- a/application/pages/instance/InstanceSettingsPage.ui +++ b/application/pages/instance/InstanceSettingsPage.ui @@ -6,23 +6,21 @@ <rect> <x>0</x> <y>0</y> - <width>553</width> - <height>522</height> + <width>738</width> + <height>804</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> + <item> + <widget class="QCommandLinkButton" name="openGlobalJavaSettingsButton"> + <property name="text"> + <string>Open Global Settings</string> + </property> + <property name="description"> + <string>The settings here are overrides for global settings.</string> + </property> + </widget> + </item> <item> <widget class="QTabWidget" name="settingsTabs"> <property name="tabShape"> @@ -367,6 +365,7 @@ </customwidget> </customwidgets> <tabstops> + <tabstop>openGlobalJavaSettingsButton</tabstop> <tabstop>settingsTabs</tabstop> <tabstop>javaSettingsGroupBox</tabstop> <tabstop>javaPathTextBox</tabstop> |