diff options
| author | Petr Mrázek <peterix@gmail.com> | 2014-07-20 23:47:46 +0200 |
|---|---|---|
| committer | Petr Mrázek <peterix@gmail.com> | 2014-07-20 23:47:46 +0200 |
| commit | bc05ad30aa7c3da5d76947e82012f50466bb5d39 (patch) | |
| tree | b74fb5c1cc7d73d930e555ad9427c3d4885379cb /gui/pages | |
| parent | e178284172396ee51acb77c2daa8135b4855c12b (diff) | |
| download | PrismLauncher-bc05ad30aa7c3da5d76947e82012f50466bb5d39.tar.gz PrismLauncher-bc05ad30aa7c3da5d76947e82012f50466bb5d39.tar.bz2 PrismLauncher-bc05ad30aa7c3da5d76947e82012f50466bb5d39.zip | |
Rework the settings dialog. Rework all of it. Thoroughly.
Also introduces the ColumnResizer from:
https://github.com/agateau/columnresizer/
Diffstat (limited to 'gui/pages')
21 files changed, 2012 insertions, 1505 deletions
diff --git a/gui/pages/global/AccountListPage.cpp b/gui/pages/global/AccountListPage.cpp index cad7d5bc..00487d57 100644 --- a/gui/pages/global/AccountListPage.cpp +++ b/gui/pages/global/AccountListPage.cpp @@ -34,9 +34,10 @@ #include <MultiMC.h> AccountListPage::AccountListPage(QWidget *parent) - : QDialog(parent), ui(new Ui::AccountListPage) + : QWidget(parent), ui(new Ui::AccountListPage) { ui->setupUi(this); + ui->tabWidget->tabBar()->hide(); m_accounts = MMC->accounts(); diff --git a/gui/pages/global/AccountListPage.h b/gui/pages/global/AccountListPage.h index fd4724d1..fd2c96e3 100644 --- a/gui/pages/global/AccountListPage.h +++ b/gui/pages/global/AccountListPage.h @@ -29,7 +29,7 @@ class AccountListPage; class AuthenticateTask; -class AccountListPage : public QDialog, public BasePage +class AccountListPage : public QWidget, public BasePage { Q_OBJECT public: diff --git a/gui/pages/global/AccountListPage.ui b/gui/pages/global/AccountListPage.ui index 1e5b07eb..8ad78cf4 100644 --- a/gui/pages/global/AccountListPage.ui +++ b/gui/pages/global/AccountListPage.ui @@ -6,81 +6,107 @@ <rect> <x>0</x> <y>0</y> - <width>400</width> - <height>300</height> + <width>694</width> + <height>609</height> </rect> </property> <property name="windowTitle"> <string>Manage Accounts</string> </property> <layout class="QVBoxLayout" name="verticalLayout_2"> + <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="QLabel" name="welcomeLabel"> - <property name="text"> - <string><html><head/><body><p>Welcome! If you're new here, you can click the &quot;Add&quot; button to add your Mojang or Minecraft account.</p></body></html></string> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> </property> - <property name="wordWrap"> - <bool>true</bool> - </property> - </widget> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QTreeView" name="listView"/> - </item> - <item> - <layout class="QVBoxLayout" name="manageAcctsBtnBox"> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Tab 1</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout"> <item> - <widget class="QPushButton" name="addAccountBtn"> + <widget class="QLabel" name="welcomeLabel"> <property name="text"> - <string>&Add</string> + <string><html><head/><body><p>Welcome! If you're new here, you can click the &quot;Add&quot; button to add your Mojang or Minecraft account.</p></body></html></string> </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="rmAccountBtn"> - <property name="text"> - <string>&Remove</string> + <property name="wordWrap"> + <bool>true</bool> </property> </widget> </item> <item> - <spacer name="buttonSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="setDefaultBtn"> - <property name="toolTip"> - <string><html><head/><body><p>Set the currently selected account as the active account. The active account is the account that is used to log in (unless it is overridden in an instance-specific setting).</p></body></html></string> - </property> - <property name="text"> - <string>&Set Default</string> - </property> - </widget> - </item> - <item> - <widget class="QPushButton" name="noDefaultBtn"> - <property name="toolTip"> - <string>Set no default account. This will cause MultiMC to prompt you to select an account every time you launch an instance that doesn't have its own default set.</string> - </property> - <property name="text"> - <string>&No Default</string> - </property> - </widget> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QTreeView" name="listView"/> + </item> + <item> + <layout class="QVBoxLayout" name="manageAcctsBtnBox"> + <item> + <widget class="QPushButton" name="addAccountBtn"> + <property name="text"> + <string>&Add</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="rmAccountBtn"> + <property name="text"> + <string>&Remove</string> + </property> + </widget> + </item> + <item> + <spacer name="buttonSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="setDefaultBtn"> + <property name="toolTip"> + <string><html><head/><body><p>Set the currently selected account as the active account. The active account is the account that is used to log in (unless it is overridden in an instance-specific setting).</p></body></html></string> + </property> + <property name="text"> + <string>&Set Default</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="noDefaultBtn"> + <property name="toolTip"> + <string>Set no default account. This will cause MultiMC to prompt you to select an account every time you launch an instance that doesn't have its own default set.</string> + </property> + <property name="text"> + <string>&No Default</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> </item> </layout> - </item> - </layout> + </widget> + </widget> </item> </layout> </widget> diff --git a/gui/pages/global/BaseSettingsPage.cpp b/gui/pages/global/BaseSettingsPage.cpp deleted file mode 100644 index 167b23c0..00000000 --- a/gui/pages/global/BaseSettingsPage.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright 2014 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "BaseSettingsPage.h" - -#include "MultiMC.h" - -void BaseSettingsPage::opened() -{ - loadSettings(MMC->settings().get()); -} -bool BaseSettingsPage::apply() -{ - applySettings(MMC->settings().get()); - return true; -} diff --git a/gui/pages/global/BaseSettingsPage.h b/gui/pages/global/BaseSettingsPage.h deleted file mode 100644 index 55e5f2a4..00000000 --- a/gui/pages/global/BaseSettingsPage.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright 2014 MultiMC Contributors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "gui/pages/BasePage.h" - -class SettingsObject; - -class BaseSettingsPage : public BasePage -{ -public: - virtual ~BaseSettingsPage() - { - } - - void opened() override; - bool apply() override; - -protected: - virtual void loadSettings(SettingsObject *object) = 0; - virtual void applySettings(SettingsObject *object) = 0; -}; diff --git a/gui/pages/global/ExternalToolsPage.cpp b/gui/pages/global/ExternalToolsPage.cpp index e0312ee5..417a13e3 100644 --- a/gui/pages/global/ExternalToolsPage.cpp +++ b/gui/pages/global/ExternalToolsPage.cpp @@ -18,6 +18,7 @@ #include <QMessageBox> #include <QFileDialog> +#include <QStandardPaths> #include <pathutils.h> @@ -30,10 +31,16 @@ ExternalToolsPage::ExternalToolsPage(QWidget *parent) : ui(new Ui::ExternalToolsPage) { ui->setupUi(this); + ui->tabWidget->tabBar()->hide(); + + #if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) + ui->jsonEditorTextBox->setClearButtonEnabled(true); + #endif ui->mceditLink->setOpenExternalLinks(true); ui->jvisualvmLink->setOpenExternalLinks(true); ui->jprofilerLink->setOpenExternalLinks(true); + loadSettings(); } ExternalToolsPage::~ExternalToolsPage() @@ -41,17 +48,35 @@ ExternalToolsPage::~ExternalToolsPage() delete ui; } -void ExternalToolsPage::loadSettings(SettingsObject *object) +void ExternalToolsPage::loadSettings() { - ui->jprofilerPathEdit->setText(object->get("JProfilerPath").toString()); - ui->jvisualvmPathEdit->setText(object->get("JVisualVMPath").toString()); - ui->mceditPathEdit->setText(object->get("MCEditPath").toString()); + auto s = MMC->settings(); + ui->jprofilerPathEdit->setText(s->get("JProfilerPath").toString()); + ui->jvisualvmPathEdit->setText(s->get("JVisualVMPath").toString()); + ui->mceditPathEdit->setText(s->get("MCEditPath").toString()); + + // Editors + ui->jsonEditorTextBox->setText(s->get("JsonEditor").toString()); } -void ExternalToolsPage::applySettings(SettingsObject *object) +void ExternalToolsPage::applySettings() { - object->set("JProfilerPath", ui->jprofilerPathEdit->text()); - object->set("JVisualVMPath", ui->jvisualvmPathEdit->text()); - object->set("MCEditPath", ui->mceditPathEdit->text()); + auto s = MMC->settings(); + s->set("JProfilerPath", ui->jprofilerPathEdit->text()); + s->set("JVisualVMPath", ui->jvisualvmPathEdit->text()); + s->set("MCEditPath", ui->mceditPathEdit->text()); + + // Editors + QString jsonEditor = ui->jsonEditorTextBox->text(); + if (!jsonEditor.isEmpty() && + (!QFileInfo(jsonEditor).exists() || !QFileInfo(jsonEditor).isExecutable())) + { + QString found = QStandardPaths::findExecutable(jsonEditor); + if (!found.isEmpty()) + { + jsonEditor = found; + } + } + s->set("JsonEditor", jsonEditor); } void ExternalToolsPage::on_jprofilerPathBtn_clicked() @@ -175,3 +200,39 @@ void ExternalToolsPage::on_mceditCheckBtn_clicked() QMessageBox::information(this, tr("OK"), tr("MCEdit setup seems to be OK")); } } + +void ExternalToolsPage::on_jsonEditorBrowseBtn_clicked() +{ + QString raw_file = QFileDialog::getOpenFileName( + this, tr("JSON Editor"), + ui->jsonEditorTextBox->text().isEmpty() +#if defined(Q_OS_LINUX) + ? QString("/usr/bin") +#else + ? QStandardPaths::standardLocations(QStandardPaths::ApplicationsLocation).first() +#endif + : ui->jsonEditorTextBox->text()); + QString cooked_file = NormalizePath(raw_file); + + if (cooked_file.isEmpty()) + { + return; + } + + // it has to exist and be an executable + if (QFileInfo(cooked_file).exists() && QFileInfo(cooked_file).isExecutable()) + { + ui->jsonEditorTextBox->setText(cooked_file); + } + else + { + QMessageBox::warning(this, tr("Invalid"), + tr("The file chosen does not seem to be an executable")); + } +} + +bool ExternalToolsPage::apply() +{ + applySettings(); + return true; +} diff --git a/gui/pages/global/ExternalToolsPage.h b/gui/pages/global/ExternalToolsPage.h index 1b35a92b..027e164e 100644 --- a/gui/pages/global/ExternalToolsPage.h +++ b/gui/pages/global/ExternalToolsPage.h @@ -17,13 +17,13 @@ #include <QWidget> -#include "BaseSettingsPage.h" +#include "gui/pages/BasePage.h" namespace Ui { class ExternalToolsPage; } -class ExternalToolsPage : public QWidget, public BaseSettingsPage +class ExternalToolsPage : public QWidget, public BasePage { Q_OBJECT @@ -47,10 +47,11 @@ public: { return "External-tools"; } + virtual bool apply(); -protected: - void loadSettings(SettingsObject *object) override; - void applySettings(SettingsObject *object) override; +private: + void loadSettings(); + void applySettings(); private: Ui::ExternalToolsPage *ui; @@ -63,4 +64,5 @@ slots: void on_jvisualvmCheckBtn_clicked(); void on_mceditPathBtn_clicked(); void on_mceditCheckBtn_clicked(); + void on_jsonEditorBrowseBtn_clicked(); }; diff --git a/gui/pages/global/ExternalToolsPage.ui b/gui/pages/global/ExternalToolsPage.ui index 96650f0f..ba1b6f01 100644 --- a/gui/pages/global/ExternalToolsPage.ui +++ b/gui/pages/global/ExternalToolsPage.ui @@ -6,138 +6,190 @@ <rect> <x>0</x> <y>0</y> - <width>494</width> - <height>562</height> + <width>673</width> + <height>751</height> </rect> </property> <property name="windowTitle"> <string>Form</string> </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="QGroupBox" name="groupBox_2"> - <property name="title"> - <string>JProfiler</string> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> </property> - <layout class="QVBoxLayout" name="verticalLayout_10"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLineEdit" name="jprofilerPathEdit"/> - </item> - <item> - <widget class="QPushButton" name="jprofilerPathBtn"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QPushButton" name="jprofilerCheckBtn"> - <property name="text"> - <string>Check</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="jprofilerLink"> - <property name="text"> - <string><html><head/><body><p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html"><span style=" text-decoration: underline; color:#0000ff;">http://www.ej-technologies.com/products/jprofiler/overview.html</span></a></p></body></html></string> - </property> - </widget> - </item> - </layout> + <widget class="QWidget" name="tab"> + <attribute name="title"> + <string>Tab 1</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>JProfiler</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_10"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QLineEdit" name="jprofilerPathEdit"/> + </item> + <item> + <widget class="QPushButton" name="jprofilerPathBtn"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="jprofilerCheckBtn"> + <property name="text"> + <string>Check</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="jprofilerLink"> + <property name="text"> + <string><html><head/><body><p><a href="http://www.ej-technologies.com/products/jprofiler/overview.html"><span style=" text-decoration: underline; color:#0000ff;">http://www.ej-technologies.com/products/jprofiler/overview.html</span></a></p></body></html></string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_3"> + <property name="title"> + <string>JVisualVM</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_11"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QLineEdit" name="jvisualvmPathEdit"/> + </item> + <item> + <widget class="QPushButton" name="jvisualvmPathBtn"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="jvisualvmCheckBtn"> + <property name="text"> + <string>Check</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="jvisualvmLink"> + <property name="text"> + <string><html><head/><body><p><a href="http://visualvm.java.net/"><span style=" text-decoration: underline; color:#0000ff;">http://visualvm.java.net/</span></a></p></body></html></string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string>MCEdit</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_12"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <item> + <widget class="QLineEdit" name="mceditPathEdit"/> + </item> + <item> + <widget class="QPushButton" name="mceditPathBtn"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QPushButton" name="mceditCheckBtn"> + <property name="text"> + <string>Check</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="mceditLink"> + <property name="text"> + <string><html><head/><body><p><a href="http://www.mcedit.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.mcedit.net/</span></a></p></body></html></string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="editorsBox"> + <property name="title"> + <string>External Editors (leave empty for system default)</string> + </property> + <layout class="QGridLayout" name="foldersBoxLayout_2"> + <item row="0" column="1"> + <widget class="QLineEdit" name="jsonEditorTextBox"/> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="labelJsonEditor"> + <property name="text"> + <string>Text Editor:</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QToolButton" name="jsonEditorBrowseBtn"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>216</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> </widget> </item> - <item> - <widget class="QGroupBox" name="groupBox_3"> - <property name="title"> - <string>JVisualVM</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_11"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QLineEdit" name="jvisualvmPathEdit"/> - </item> - <item> - <widget class="QPushButton" name="jvisualvmPathBtn"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QPushButton" name="jvisualvmCheckBtn"> - <property name="text"> - <string>Check</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="jvisualvmLink"> - <property name="text"> - <string><html><head/><body><p><a href="http://visualvm.java.net/"><span style=" text-decoration: underline; color:#0000ff;">http://visualvm.java.net/</span></a></p></body></html></string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="groupBox_4"> - <property name="title"> - <string>MCEdit</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout_12"> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QLineEdit" name="mceditPathEdit"/> - </item> - <item> - <widget class="QPushButton" name="mceditPathBtn"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QPushButton" name="mceditCheckBtn"> - <property name="text"> - <string>Check</string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="mceditLink"> - <property name="text"> - <string><html><head/><body><p><a href="http://www.mcedit.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.mcedit.net/</span></a></p></body></html></string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>160</height> - </size> - </property> - </spacer> - </item> </layout> </widget> <resources/> diff --git a/gui/pages/global/JavaPage.cpp b/gui/pages/global/JavaPage.cpp new file mode 100644 index 00000000..86451411 --- /dev/null +++ b/gui/pages/global/JavaPage.cpp @@ -0,0 +1,146 @@ +/* Copyright 2013 MultiMC Contributors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "JavaPage.h" +#include "ui_JavaPage.h" + +#include <QFileDialog> +#include <QMessageBox> +#include <QDir> + +#include <pathutils.h> + +#include "logic/NagUtils.h" + +#include "gui/Platform.h" +#include "gui/dialogs/VersionSelectDialog.h" +#include <gui/ColumnResizer.h> + +#include "logic/java/JavaUtils.h" +#include "logic/java/JavaVersionList.h" +#include "logic/java/JavaChecker.h" + +#include "logic/settings/SettingsObject.h" +#include "MultiMC.h" + +JavaPage::JavaPage(QWidget *parent) |
