diff options
| author | Jan Dalheimer <jan@dalheimer.de> | 2014-07-16 00:13:40 +0200 |
|---|---|---|
| committer | Petr Mrázek <peterix@gmail.com> | 2014-07-20 15:01:02 +0200 |
| commit | e178284172396ee51acb77c2daa8135b4855c12b (patch) | |
| tree | d37c3d95355073997b023c6bdf34072d3bb468b0 | |
| parent | c91adfb3d18b124b36cf19bcb89973a66c9ef1c9 (diff) | |
| download | PrismLauncher-e178284172396ee51acb77c2daa8135b4855c12b.tar.gz PrismLauncher-e178284172396ee51acb77c2daa8135b4855c12b.tar.bz2 PrismLauncher-e178284172396ee51acb77c2daa8135b4855c12b.zip | |
Merge global settings and accounts into a pagedialog
Also split external tools into it's own page
| -rw-r--r-- | CMakeLists.txt | 17 | ||||
| -rw-r--r-- | gui/MainWindow.cpp | 36 | ||||
| -rw-r--r-- | gui/MainWindow.h | 3 | ||||
| -rw-r--r-- | gui/pages/BasePageProvider.h | 41 | ||||
| -rw-r--r-- | gui/pages/global/AccountListPage.cpp (renamed from gui/dialogs/AccountListDialog.cpp) | 47 | ||||
| -rw-r--r-- | gui/pages/global/AccountListPage.h (renamed from gui/dialogs/AccountListDialog.h) | 33 | ||||
| -rw-r--r-- | gui/pages/global/AccountListPage.ui (renamed from gui/dialogs/AccountListDialog.ui) | 11 | ||||
| -rw-r--r-- | gui/pages/global/BaseSettingsPage.cpp | 28 | ||||
| -rw-r--r-- | gui/pages/global/BaseSettingsPage.h | 35 | ||||
| -rw-r--r-- | gui/pages/global/ExternalToolsPage.cpp | 177 | ||||
| -rw-r--r-- | gui/pages/global/ExternalToolsPage.h | 66 | ||||
| -rw-r--r-- | gui/pages/global/ExternalToolsPage.ui | 145 | ||||
| -rw-r--r-- | gui/pages/global/SettingsPage.cpp (renamed from gui/dialogs/SettingsDialog.cpp) | 227 | ||||
| -rw-r--r-- | gui/pages/global/SettingsPage.h (renamed from gui/dialogs/SettingsDialog.h) | 53 | ||||
| -rw-r--r-- | gui/pages/global/SettingsPage.ui (renamed from gui/dialogs/SettingsDialog.ui) | 196 |
15 files changed, 637 insertions, 478 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ac497f46..7cae21dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,12 +312,18 @@ SET(MULTIMC_SOURCES gui/pages/ScreenshotsPage.h gui/pages/OtherLogsPage.cpp gui/pages/OtherLogsPage.h + gui/pages/global/SettingsPage.cpp + gui/pages/global/SettingsPage.h + gui/pages/global/ExternalToolsPage.cpp + gui/pages/global/ExternalToolsPage.h + gui/pages/global/BaseSettingsPage.cpp + gui/pages/global/BaseSettingsPage.h + gui/pages/global/AccountListPage.cpp + gui/pages/global/AccountListPage.h # GUI - dialogs gui/dialogs/AboutDialog.cpp gui/dialogs/AboutDialog.h - gui/dialogs/AccountListDialog.cpp - gui/dialogs/AccountListDialog.h gui/dialogs/AccountSelectDialog.cpp gui/dialogs/AccountSelectDialog.h gui/dialogs/CopyInstanceDialog.cpp @@ -342,8 +348,6 @@ SET(MULTIMC_SOURCES gui/pagedialog/PageDialog.h gui/dialogs/ProgressDialog.cpp gui/dialogs/ProgressDialog.h - gui/dialogs/SettingsDialog.cpp - gui/dialogs/SettingsDialog.h gui/dialogs/UpdateDialog.cpp gui/dialogs/UpdateDialog.h gui/dialogs/VersionSelectDialog.cpp @@ -644,9 +648,11 @@ SET(MULTIMC_UIS gui/pages/NotesPage.ui gui/pages/ScreenshotsPage.ui gui/pages/OtherLogsPage.ui + gui/pages/global/SettingsPage.ui + gui/pages/global/ExternalToolsPage.ui + gui/pages/global/AccountListPage.ui # Dialogs - gui/dialogs/SettingsDialog.ui gui/dialogs/CopyInstanceDialog.ui gui/dialogs/NewInstanceDialog.ui gui/dialogs/AboutDialog.ui @@ -654,7 +660,6 @@ SET(MULTIMC_UIS gui/dialogs/LwjglSelectDialog.ui gui/dialogs/ProgressDialog.ui gui/dialogs/IconPickerDialog.ui - gui/dialogs/AccountListDialog.ui gui/dialogs/AccountSelectDialog.ui gui/dialogs/EditAccountDialog.ui gui/dialogs/LoginDialog.ui diff --git a/gui/MainWindow.cpp b/gui/MainWindow.cpp index 1a92139c..81ee466b 100644 --- a/gui/MainWindow.cpp +++ b/gui/MainWindow.cpp @@ -49,7 +49,6 @@ #include "gui/widgets/LabeledToolButton.h" #include "widgets/ServerStatus.h" -#include "gui/dialogs/SettingsDialog.h" #include "gui/dialogs/NewInstanceDialog.h" #include "gui/dialogs/ProgressDialog.h" #include "gui/dialogs/AboutDialog.h" @@ -58,12 +57,15 @@ #include "gui/dialogs/LwjglSelectDialog.h" #include "gui/dialogs/IconPickerDialog.h" #include "gui/dialogs/CopyInstanceDialog.h" -#include "gui/dialogs/AccountListDialog.h" #include "gui/dialogs/AccountSelectDialog.h" #include "gui/dialogs/UpdateDialog.h" #include "gui/dialogs/EditAccountDialog.h" #include "gui/dialogs/NotificationDialog.h" +#include "gui/pages/global/SettingsPage.h" +#include "gui/pages/global/ExternalToolsPage.h" +#include "gui/pages/global/AccountListPage.h" + #include "gui/ConsoleWindow.h" #include "pagedialog/PageDialog.h" @@ -245,6 +247,14 @@ 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<AccountListPage>(); + m_globalSettingsProvider->addPage<SettingsPage>(); + m_globalSettingsProvider->addPage<ExternalToolsPage>(); + } + // 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... @@ -937,16 +947,6 @@ void MainWindow::on_actionCheckUpdate_triggered() updater->checkForUpdate(true); } -void MainWindow::on_actionSettings_triggered() -{ - SettingsDialog dialog(this); - dialog.exec(); - // FIXME: quick HACK to make this work. improve, optimize. - proxymodel->invalidate(); - proxymodel->sort(0); - updateToolsMenu(); -} - template <typename T> void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QString()) { @@ -957,6 +957,15 @@ void ShowPageDialog(T raw_provider, QWidget * parent, QString open_page = QStrin dlg.exec(); } +void MainWindow::on_actionSettings_triggered() +{ + ShowPageDialog(m_globalSettingsProvider, this, "global-settings"); + // FIXME: quick HACK to make this work. improve, optimize. + proxymodel->invalidate(); + proxymodel->sort(0); + updateToolsMenu(); +} + void MainWindow::on_actionInstanceSettings_triggered() { ShowPageDialog(m_selectedInstance, this, "settings"); @@ -980,8 +989,7 @@ void MainWindow::on_actionScreenshots_triggered() void MainWindow::on_actionManageAccounts_triggered() { - AccountListDialog dialog(this); - dialog.exec(); + ShowPageDialog(m_globalSettingsProvider, this, "accounts"); } void MainWindow::on_actionReportBug_triggered() diff --git a/gui/MainWindow.h b/gui/MainWindow.h index 36ef883b..32ad4daf 100644 --- a/gui/MainWindow.h +++ b/gui/MainWindow.h @@ -30,6 +30,7 @@ class QLabel; class MinecraftProcess; class ConsoleWindow; class BaseProfilerFactory; +class GenericPageProvider; namespace Ui { @@ -189,6 +190,8 @@ private: QToolButton *changeIconButton; QToolButton *newsLabel; + std::shared_ptr<GenericPageProvider> m_globalSettingsProvider; + InstancePtr m_selectedInstance; QString m_currentInstIcon; diff --git a/gui/pages/BasePageProvider.h b/gui/pages/BasePageProvider.h index cff9c8e7..5e5a11fb 100644 --- a/gui/pages/BasePageProvider.h +++ b/gui/pages/BasePageProvider.h @@ -17,6 +17,7 @@ #include "BasePage.h" #include <memory> +#include <functional> class BasePageProvider { @@ -25,4 +26,44 @@ public: virtual QString dialogTitle() = 0; }; +class GenericPageProvider : public BasePageProvider +{ + typedef std::function<BasePage *()> PageCreator; +public: + explicit GenericPageProvider(const QString &dialogTitle) + : m_dialogTitle(dialogTitle) + { + } + + QList<BasePage *> getPages() override + { + QList<BasePage *> pages; + for (PageCreator creator : m_creators) + { + pages.append(creator()); + } + return pages; + } + QString dialogTitle() override { return m_dialogTitle; } + + void setDialogTitle(const QString &title) + { + m_dialogTitle = title; + } + void addPageCreator(PageCreator page) + { + m_creators.append(page); + } + + template<typename PageClass> + void addPage() + { + addPageCreator([](){return new PageClass();}); + } + +private: + QList<PageCreator> m_creators; + QString m_dialogTitle; +}; + typedef std::shared_ptr<BasePageProvider> BasePageProviderPtr; diff --git a/gui/dialogs/AccountListDialog.cpp b/gui/pages/global/AccountListPage.cpp index 688cffa8..cad7d5bc 100644 --- a/gui/dialogs/AccountListDialog.cpp +++ b/gui/pages/global/AccountListPage.cpp @@ -13,28 +13,28 @@ * limitations under the License. */ -#include "AccountListDialog.h" -#include "ui_AccountListDialog.h" +#include "AccountListPage.h" +#include "ui_AccountListPage.h" #include <QItemSelectionModel> #include <logger/QsLog.h> -#include <logic/net/NetJob.h> -#include <logic/net/URLConstants.h> +#include "logic/net/NetJob.h" +#include "logic/net/URLConstants.h" -#include <gui/dialogs/EditAccountDialog.h> -#include <gui/dialogs/ProgressDialog.h> -#include <gui/dialogs/AccountSelectDialog.h> -#include <gui/dialogs/LoginDialog.h> -#include "CustomMessageBox.h" -#include <logic/tasks/Task.h> -#include <logic/auth/YggdrasilTask.h> +#include "gui/dialogs/EditAccountDialog.h" +#include "gui/dialogs/ProgressDialog.h" +#include "gui/dialogs/AccountSelectDialog.h" +#include "gui/dialogs/LoginDialog.h" +#include "gui/dialogs/CustomMessageBox.h" +#include "logic/tasks/Task.h" +#include "logic/auth/YggdrasilTask.h" #include <MultiMC.h> -AccountListDialog::AccountListDialog(QWidget *parent) - : QDialog(parent), ui(new Ui::AccountListDialog) +AccountListPage::AccountListPage(QWidget *parent) + : QDialog(parent), ui(new Ui::AccountListPage) { ui->setupUi(this); @@ -58,23 +58,23 @@ AccountListDialog::AccountListDialog(QWidget *parent) updateButtonStates(); } -AccountListDialog::~AccountListDialog() +AccountListPage::~AccountListPage() { delete ui; } -void AccountListDialog::listChanged() +void AccountListPage::listChanged() { updateButtonStates(); } -void AccountListDialog::on_addAccountBtn_clicked() +void AccountListPage::on_addAccountBtn_clicked() { addAccount(tr("Please enter your Mojang or Minecraft account username and password to add " "your account.")); } -void AccountListDialog::on_rmAccountBtn_clicked() +void AccountListPage::on_rmAccountBtn_clicked() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) @@ -84,7 +84,7 @@ void AccountListDialog::on_rmAccountBtn_clicked() } } -void AccountListDialog::on_setDefaultBtn_clicked() +void AccountListPage::on_setDefaultBtn_clicked() { QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); if (selection.size() > 0) @@ -96,17 +96,12 @@ void AccountListDialog::on_setDefaultBtn_clicked() } } -void AccountListDialog::on_noDefaultBtn_clicked() +void AccountListPage::on_noDefaultBtn_clicked() { m_accounts->setActiveAccount(""); } -void AccountListDialog::on_closeBtnBox_rejected() -{ - close(); -} - -void AccountListDialog::updateButtonStates() +void AccountListPage::updateButtonStates() { // If there is no selection, disable buttons that require something selected. QModelIndexList selection = ui->listView->selectionModel()->selectedIndexes(); @@ -117,7 +112,7 @@ void AccountListDialog::updateButtonStates() ui->noDefaultBtn->setDown(m_accounts->activeAccount().get() == nullptr); } -void AccountListDialog::addAccount(const QString &errMsg) +void AccountListPage::addAccount(const QString &errMsg) { // TODO: The login dialog isn't quite done yet MojangAccountPtr account = LoginDialog::newAccount(this, errMsg); diff --git a/gui/dialogs/AccountListDialog.h b/gui/pages/global/AccountListPage.h index fe0c8773..fd4724d1 100644 --- a/gui/dialogs/AccountListDialog.h +++ b/gui/pages/global/AccountListPage.h @@ -16,24 +16,42 @@ #pragma once #include <QDialog> - #include <memory> +#include "gui/pages/BasePage.h" + #include "logic/auth/MojangAccountList.h" namespace Ui { -class AccountListDialog; +class AccountListPage; } class AuthenticateTask; -class AccountListDialog : public QDialog +class AccountListPage : public QDialog, public BasePage { Q_OBJECT public: - explicit AccountListDialog(QWidget *parent = 0); - ~AccountListDialog(); + explicit AccountListPage(QWidget *parent = 0); + ~AccountListPage(); + + QString displayName() const override + { + return tr("Accounts"); + } + QIcon icon() const override + { + return QIcon::fromTheme("noaccount"); + } + QString id() const override + { + return "accounts"; + } + QString helpPage() const override + { + return "Accounts"; + } public slots: @@ -45,9 +63,6 @@ slots: void on_noDefaultBtn_clicked(); - // This will be sent when the "close" button is clicked. - void on_closeBtnBox_rejected(); - void listChanged(); //! Updates the states of the dialog's buttons. @@ -61,5 +76,5 @@ slots: void addAccount(const QString& errMsg=""); private: - Ui::AccountListDialog *ui; + Ui::AccountListPage *ui; }; diff --git a/gui/dialogs/AccountListDialog.ui b/gui/pages/global/AccountListPage.ui index 72682163..1e5b07eb 100644 --- a/gui/dialogs/AccountListDialog.ui +++ b/gui/pages/global/AccountListPage.ui @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> - <class>AccountListDialog</class> - <widget class="QDialog" name="AccountListDialog"> + <class>AccountListPage</class> + <widget class="QWidget" name="AccountListPage"> <property name="geometry"> <rect> <x>0</x> @@ -82,13 +82,6 @@ </item> </layout> </item> - <item> - <widget class="QDialogButtonBox" name="closeBtnBox"> - <property name="standardButtons"> - <set>QDialogButtonBox::Close</set> - </property> - </widget> - </item> </layout> </widget> <resources/> diff --git a/gui/pages/global/BaseSettingsPage.cpp b/gui/pages/global/BaseSettingsPage.cpp new file mode 100644 index 00000000..167b23c0 --- /dev/null +++ b/gui/pages/global/BaseSettingsPage.cpp @@ -0,0 +1,28 @@ +/* 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 new file mode 100644 index 00000000..55e5f2a4 --- /dev/null +++ b/gui/pages/global/BaseSettingsPage.h @@ -0,0 +1,35 @@ +/* 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 new file mode 100644 index 00000000..e0312ee5 --- /dev/null +++ b/gui/pages/global/ExternalToolsPage.cpp @@ -0,0 +1,177 @@ +/* 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 "ExternalToolsPage.h" +#include "ui_ExternalToolsPage.h" + +#include <QMessageBox> +#include <QFileDialog> + +#include <pathutils.h> + +#include "logic/settings/SettingsObject.h" +#include "logic/tools/BaseProfiler.h" +#include "MultiMC.h" + +ExternalToolsPage::ExternalToolsPage(QWidget *parent) : + QWidget(parent), + ui(new Ui::ExternalToolsPage) +{ + ui->setupUi(this); + + ui->mceditLink->setOpenExternalLinks(true); + ui->jvisualvmLink->setOpenExternalLinks(true); + ui->jprofilerLink->setOpenExternalLinks(true); +} + +ExternalToolsPage::~ExternalToolsPage() +{ + delete ui; +} + +void ExternalToolsPage::loadSettings(SettingsObject *object) +{ + ui->jprofilerPathEdit->setText(object->get("JProfilerPath").toString()); + ui->jvisualvmPathEdit->setText(object->get("JVisualVMPath").toString()); + ui->mceditPathEdit->setText(object->get("MCEditPath").toString()); +} +void ExternalToolsPage::applySettings(SettingsObject *object) +{ + object->set("JProfilerPath", ui->jprofilerPathEdit->text()); + object->set("JVisualVMPath", ui->jvisualvmPathEdit->text()); + object->set("MCEditPath", ui->mceditPathEdit->text()); +} + +void ExternalToolsPage::on_jprofilerPathBtn_clicked() +{ + QString raw_dir = ui->jprofilerPathEdit->text(); + QString error; + do + { + raw_dir = QFileDialog::getExistingDirectory(this, tr("JProfiler Directory"), raw_dir); + if (raw_dir.isEmpty()) + { + break; + } + QString cooked_dir = NormalizePath(raw_dir); + if (!MMC->profilers()["jprofiler"]->check(cooked_dir, &error)) + { + QMessageBox::critical(this, tr("Error"), + tr("Error while checking JProfiler install:\n%1").arg(error)); + continue; + } + else + { + ui->jprofilerPathEdit->setText(cooked_dir); + break; + } + } while (1); +} +void ExternalToolsPage::on_jprofilerCheckBtn_clicked() +{ + QString error; + if (!MMC->profilers()["jprofiler"]->check(ui->jprofilerPathEdit->text(), &error)) + { + QMessageBox::critical(this, tr("Error"), + tr("Error while checking JProfiler install:\n%1").arg(error)); + } + else + { + QMessageBox::information(this, tr("OK"), tr("JProfiler setup seems to be OK")); + } +} + +void ExternalToolsPage::on_jvisualvmPathBtn_clicked() +{ + QString raw_dir = ui->jvisualvmPathEdit->text(); + QString error; + do + { + raw_dir = QFileDialog::getOpenFileName(this, tr("JVisualVM Executable"), raw_dir); + if (raw_dir.isEmpty()) + { + break; + } + QString cooked_dir = NormalizePath(raw_dir); + if (!MMC->profilers()["jvisualvm"]->check(cooked_dir, &error)) + { + QMessageBox::critical(this, tr("Error"), + tr("Error while checking JVisualVM install:\n%1").arg(error)); + continue; + } + else + { + ui->jvisualvmPathEdit->setText(cooked_dir); + break; + } + } while (1); +} +void ExternalToolsPage::on_jvisualvmCheckBtn_clicked() +{ + QString error; + if (!MMC->profilers()["jvisualvm"]->check(ui->jvisualvmPathEdit->text(), &error)) + { + QMessageBox::critical(this, tr("Error"), + tr("Error while checking JVisualVM install:\n%1").arg(error)); + } + else + { + QMessageBox::information(this, tr("OK"), tr("JVisualVM setup seems to be OK")); + } +} + +void ExternalToolsPage::on_mceditPathBtn_clicked() +{ + QString raw_dir = ui->mceditPathEdit->text(); + QString error; + do + { +#ifdef Q_OS_OSX +#warning stuff + raw_dir = QFileDialog::getOpenFileName(this, tr("MCEdit Application"), raw_dir); +#else + raw_dir = QFileDialog::getExistingDirectory(this, tr("MCEdit Directory"), raw_dir); +#endif + if (raw_dir.isEmpty()) + { + break; + } + QString cooked_dir = NormalizePath(raw_dir); + if (!MMC->tools()["mcedit"]->check(cooked_dir, &error)) + { + QMessageBox::critical(this, tr("Error"), + tr("Error while checking MCEdit install:\n%1").arg(error)); + continue; + } + else + { + ui->mceditPathEdit->setText(cooked_dir); + break; + } + } while (1); +} +void ExternalToolsPage::on_mceditCheckBtn_clicked() +{ + QString error; + if (!MMC->tools()["mcedit"]->check(ui->mceditPathEdit->text(), &error)) + { + QMessageBox::critical(this, tr("Error"), + tr("Error while checking MCEdit install:\n%1").arg(error)); + } + else + { + QMessageBox::information(this, tr("OK"), tr("MCEdit setup seems to be OK")); + } +} diff --git a/gui/pages/global/ExternalToolsPage.h b/gui/pages/global/ExternalToolsPage.h new file mode 100644 index 00000000..1b35a92b --- /dev/null +++ b/gui/pages/global/ExternalToolsPage.h @@ -0,0 +1,66 @@ +/* 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 <QWidget> + +#include "BaseSettingsPage.h" + +namespace Ui { +class ExternalToolsPage; +} + +class ExternalToolsPage : public QWidget, public BaseSettingsPage +{ + Q_OBJECT + +public: + explicit ExternalToolsPage(QWidget *parent = 0); + ~ExternalToolsPage(); + + QString displayName() const override + { + return tr("External Tools"); + } + QIcon icon() const override + { + return QIcon::fromTheme("plugin-blue"); + } + QString id() const override + { + return "external-tools"; + } + QString helpPage() const override + { + return "External-tools"; + } + +protected: + void loadSettings(SettingsObject *object) override; + void applySettings(SettingsObject *object) override; + +private: + Ui::ExternalToolsPage *ui; + +private +slots: + void on_jprofilerPathBtn_clicked(); + void on_jprofilerCheckBtn_clicked(); + void on_jvisualvmPathBtn_clicked(); + void on_jvisualvmCheckBtn_clicked(); + void on_mceditPathBtn_clicked(); + void on_mceditCheckBtn_clicked(); +}; diff --git a/gui/pages/global/ExternalToolsPage.ui b/gui/pages/global/ExternalToolsPage.ui new file mode 100644 index 00000000..96650f0f --- /dev/null +++ b/gui/pages/global/ExternalToolsPage.ui @@ -0,0 +1,145 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>ExternalToolsPage</class> + <widget class="QWidget" name="ExternalToolsPage"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>494</width> + <height>562</height> + </rect> + </property> + <property name="windowTitle"> + <string>Form</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <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> + <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/> + <connections/> +</ui> diff --git a/gui/dialogs/SettingsDialog.cpp b/gui/pages/global/SettingsPage.cpp index 347cd67e..37b0539c 100644 --- a/gui/dialogs/SettingsDialog.cpp +++ b/gui/pages/global/SettingsPage.cpp @@ -13,10 +13,14 @@ * limitations under the License. */ -#include "MultiMC.h" +#include "SettingsPage.h" +#include "ui_SettingsPage.h" + +#include <QFileDialog> +#include <QMessageBox> +#include <QDir> -#include "gui/dialogs/SettingsDialog.h" -#include "ui_SettingsDialog.h" +#include <pathutils.h> #include "gui/Platform.h" #include "gui/dialogs/VersionSelectDialog.h" @@ -33,10 +37,7 @@ #include "logic/tools/BaseProfiler.h" #include "logic/settings/SettingsObject.h" -#include <pathutils.h> -#include <QFileDialog> -#include <QMessageBox> -#include <QDir> +#include "MultiMC.h" // FIXME: possibly move elsewhere enum InstSortMode @@ -47,7 +48,7 @@ enum InstSortMode Sort_LastLaunch }; -SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::SettingsDialog) +SettingsPage::SettingsPage(QWidget *parent) : QWidget(parent), ui(new Ui::SettingsPage) { MultiMCPlatform::fixWM_CLASS(this); ui->setupUi(this); @@ -61,11 +62,8 @@ SettingsDialog::SettingsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::Se restoreGeometry( QByteArray::fromBase64(MMC->settings()->get("SettingsGeometry").toByteArray())); - loadSettings(MMC->settings().get()); - updateCheckboxStuff(); - QObject::connect(MMC->updateChecker().get(), &UpdateChecker::channelListLoaded, this, - &SettingsDialog::refreshUpdateChannelList); + &SettingsPage::refreshUpdateChannelList); if (MMC->updateChecker()->ha |
