NOISSUE add option to open global settings from instance settings

This should hopefully giude people towards using the right thing.
This commit is contained in:
Petr Mrázek 2019-06-01 12:28:53 +02:00
parent 59e1ed3d87
commit 932160818e
10 changed files with 55 additions and 53 deletions

View File

@ -64,9 +64,6 @@ SET(MULTIMC_SOURCES
themes/SystemTheme.cpp themes/SystemTheme.cpp
themes/SystemTheme.h themes/SystemTheme.h
# GUI - settings-specific wrappers for paged dialog
SettingsUI.h
# Processes # Processes
LaunchController.h LaunchController.h
LaunchController.cpp LaunchController.cpp

View File

@ -9,7 +9,6 @@
#include "InstanceWindow.h" #include "InstanceWindow.h"
#include "BuildConfig.h" #include "BuildConfig.h"
#include "JavaCommon.h" #include "JavaCommon.h"
#include "SettingsUI.h"
#include <QLineEdit> #include <QLineEdit>
#include <QInputDialog> #include <QInputDialog>
#include <tasks/Task.h> #include <tasks/Task.h>
@ -53,7 +52,7 @@ void LaunchController::login()
if (reply == QMessageBox::Yes) if (reply == QMessageBox::Yes)
{ {
// Open the account manager. // Open the account manager.
SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), m_parentWidget, "accounts"); MMC->ShowGlobalSettings(m_parentWidget, "accounts");
} }
} }
else if (account.get() == nullptr) else if (account.get() == nullptr)

View File

@ -70,7 +70,6 @@
#include "InstanceProxyModel.h" #include "InstanceProxyModel.h"
#include "JavaCommon.h" #include "JavaCommon.h"
#include "LaunchController.h" #include "LaunchController.h"
#include "SettingsUI.h"
#include "groupview/GroupView.h" #include "groupview/GroupView.h"
#include "groupview/InstanceDelegate.h" #include "groupview/InstanceDelegate.h"
#include "widgets/LabeledToolButton.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. // model reset -> selection is invalid. All the instance pointers are wrong.
connect(MMC->instances().get(), &InstanceList::dataIsInvalid, this, &MainWindow::selectionBad); 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_statusLeft = new QLabel(tr("No instance selected"), this);
m_statusRight = new ServerStatus(this); m_statusRight = new ServerStatus(this);
statusBar()->addPermanentWidget(m_statusLeft, 1); statusBar()->addPermanentWidget(m_statusLeft, 1);
@ -1572,7 +1574,11 @@ void MainWindow::checkForUpdates()
void MainWindow::on_actionSettings_triggered() 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. // FIXME: quick HACK to make this work. improve, optimize.
MMC->instances()->loadList(); MMC->instances()->loadList();
proxymodel->invalidate(); proxymodel->invalidate();
@ -1608,7 +1614,7 @@ void MainWindow::on_actionScreenshots_triggered()
void MainWindow::on_actionManageAccounts_triggered() void MainWindow::on_actionManageAccounts_triggered()
{ {
SettingsUI::ShowPageDialog(MMC->globalSettingsPages(), this, "accounts"); MMC->ShowGlobalSettings(this, "accounts");
} }
void MainWindow::on_actionReportBug_triggered() void MainWindow::on_actionReportBug_triggered()

View File

@ -181,6 +181,8 @@ private slots:
void konamiTriggered(); void konamiTriggered();
void globalSettingsClosed();
private: private:
void addInstance(QString url = QString()); void addInstance(QString url = QString());
void activateInstance(InstancePtr instance); void activateInstance(InstancePtr instance);

View File

@ -66,6 +66,8 @@
#include <ganalytics.h> #include <ganalytics.h>
#include <sys.h> #include <sys.h>
#include "pagedialog/PageDialog.h"
#if defined Q_OS_WIN32 #if defined Q_OS_WIN32
#ifndef WIN32_LEAN_AND_MEAN #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) MainWindow* MultiMC::showMainWindow(bool minimized)
{ {
if(m_mainWindow) if(m_mainWindow)

View File

@ -65,11 +65,6 @@ public:
return m_settings; return m_settings;
} }
std::shared_ptr<GenericPageProvider> globalSettingsPages() const
{
return m_globalSettingsProvider;
}
qint64 timeSinceStart() const qint64 timeSinceStart() const
{ {
return startTime.msecsTo(QDateTime::currentDateTime()); return startTime.msecsTo(QDateTime::currentDateTime());
@ -146,8 +141,12 @@ public:
void updateIsRunning(bool running); void updateIsRunning(bool running);
bool updatesAreAllowed(); bool updatesAreAllowed();
void ShowGlobalSettings(class QWidget * parent, QString open_page = QString());
signals: signals:
void updateAllowedChanged(bool status); void updateAllowedChanged(bool status);
void globalSettingsAboutToOpen();
void globalSettingsClosed();
public slots: public slots:
bool launch(InstancePtr instance, bool online = true, BaseProfilerFactory *profiler = nullptr); bool launch(InstancePtr instance, bool online = true, BaseProfilerFactory *profiler = nullptr);

View File

@ -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();
}
}
}

View File

@ -21,6 +21,9 @@ InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
auto sysMB = Sys::getSystemRam() / Sys::megabyte; auto sysMB = Sys::getSystemRam() / Sys::megabyte;
ui->maxMemSpinBox->setMaximum(sysMB); 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(); loadSettings();
} }
@ -34,6 +37,11 @@ InstanceSettingsPage::~InstanceSettingsPage()
delete ui; delete ui;
} }
void InstanceSettingsPage::globalSettingsButtonClicked(bool)
{
MMC->ShowGlobalSettings(this, "global-settings");
}
bool InstanceSettingsPage::apply() bool InstanceSettingsPage::apply()
{ {
applySettings(); applySettings();

View File

@ -66,6 +66,8 @@ private slots:
void checkerFinished(); void checkerFinished();
void globalSettingsButtonClicked(bool checked);
private: private:
Ui::InstanceSettingsPage *ui; Ui::InstanceSettingsPage *ui;
BaseInstance *m_instance; BaseInstance *m_instance;

View File

@ -6,23 +6,21 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>553</width> <width>738</width>
<height>522</height> <height>804</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin"> <item>
<number>0</number> <widget class="QCommandLinkButton" name="openGlobalJavaSettingsButton">
<property name="text">
<string>Open Global Settings</string>
</property> </property>
<property name="topMargin"> <property name="description">
<number>0</number> <string>The settings here are overrides for global settings.</string>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property> </property>
</widget>
</item>
<item> <item>
<widget class="QTabWidget" name="settingsTabs"> <widget class="QTabWidget" name="settingsTabs">
<property name="tabShape"> <property name="tabShape">
@ -367,6 +365,7 @@
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>openGlobalJavaSettingsButton</tabstop>
<tabstop>settingsTabs</tabstop> <tabstop>settingsTabs</tabstop>
<tabstop>javaSettingsGroupBox</tabstop> <tabstop>javaSettingsGroupBox</tabstop>
<tabstop>javaPathTextBox</tabstop> <tabstop>javaPathTextBox</tabstop>