diff options
Diffstat (limited to 'gui/pages')
43 files changed, 0 insertions, 6482 deletions
diff --git a/gui/pages/BasePage.h b/gui/pages/BasePage.h deleted file mode 100644 index ecf0692c..00000000 --- a/gui/pages/BasePage.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright 2013-2015 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 <QString> -#include <QIcon> -#include <memory> - -class BasePage -{ -public: - virtual ~BasePage() {} - virtual QString id() const = 0; - virtual QString displayName() const = 0; - virtual QIcon icon() const = 0; - virtual bool apply() { return true; } - virtual bool shouldDisplay() const { return true; } - virtual QString helpPage() const { return QString(); } - virtual void opened() {} - virtual void closed() {} - int stackIndex = -1; - int listIndex = -1; -}; - -typedef std::shared_ptr<BasePage> BasePagePtr; diff --git a/gui/pages/BasePageProvider.h b/gui/pages/BasePageProvider.h deleted file mode 100644 index c55683e0..00000000 --- a/gui/pages/BasePageProvider.h +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright 2013-2015 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 "BasePage.h" -#include <memory> -#include <functional> - -class BasePageProvider -{ -public: - virtual QList<BasePage *> getPages() = 0; - 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/pages/InstanceSettingsPage.cpp b/gui/pages/InstanceSettingsPage.cpp deleted file mode 100644 index e1a9c666..00000000 --- a/gui/pages/InstanceSettingsPage.cpp +++ /dev/null @@ -1,216 +0,0 @@ -#include "InstanceSettingsPage.h" -#include "ui_InstanceSettingsPage.h" - -#include <QFileDialog> -#include <QDialog> -#include <QMessageBox> - -#include "gui/dialogs/VersionSelectDialog.h" -#include "gui/NagUtils.h" -#include "logic/java/JavaVersionList.h" -#include "MultiMC.h" - -InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent) - : QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst) -{ - m_settings = &(inst->settings()); - ui->setupUi(this); - loadSettings(); -} - -bool InstanceSettingsPage::shouldDisplay() const -{ - return !m_instance->isRunning(); -} - -InstanceSettingsPage::~InstanceSettingsPage() -{ - delete ui; -} - -bool InstanceSettingsPage::apply() -{ - applySettings(); - return true; -} - -void InstanceSettingsPage::applySettings() -{ - // Console - bool console = ui->consoleSettingsBox->isChecked(); - m_settings->set("OverrideConsole", console); - if (console) - { - m_settings->set("ShowConsole", ui->showConsoleCheck->isChecked()); - m_settings->set("AutoCloseConsole", ui->autoCloseConsoleCheck->isChecked()); - } - else - { - m_settings->reset("ShowConsole"); - m_settings->reset("AutoCloseConsole"); - } - - // Window Size - bool window = ui->windowSizeGroupBox->isChecked(); - m_settings->set("OverrideWindow", window); - if (window) - { - m_settings->set("LaunchMaximized", ui->maximizedCheckBox->isChecked()); - m_settings->set("MinecraftWinWidth", ui->windowWidthSpinBox->value()); - m_settings->set("MinecraftWinHeight", ui->windowHeightSpinBox->value()); - } - else - { - m_settings->reset("LaunchMaximized"); - m_settings->reset("MinecraftWinWidth"); - m_settings->reset("MinecraftWinHeight"); - } - - // Memory - bool memory = ui->memoryGroupBox->isChecked(); - m_settings->set("OverrideMemory", memory); - if (memory) - { - m_settings->set("MinMemAlloc", ui->minMemSpinBox->value()); - m_settings->set("MaxMemAlloc", ui->maxMemSpinBox->value()); - m_settings->set("PermGen", ui->permGenSpinBox->value()); - } - else - { - m_settings->reset("MinMemAlloc"); - m_settings->reset("MaxMemAlloc"); - m_settings->reset("PermGen"); - } - - // Java Install Settings - bool javaInstall = ui->javaSettingsGroupBox->isChecked(); - m_settings->set("OverrideJavaLocation", javaInstall); - if (javaInstall) - { - m_settings->set("JavaPath", ui->javaPathTextBox->text()); - } - else - { - m_settings->reset("JavaPath"); - } - - // Java arguments - bool javaArgs = ui->javaArgumentsGroupBox->isChecked(); - m_settings->set("OverrideJavaArgs", javaArgs); - if(javaArgs) - { - m_settings->set("JvmArgs", ui->jvmArgsTextBox->toPlainText().replace("\n", " ")); - NagUtils::checkJVMArgs(m_settings->get("JvmArgs").toString(), this->parentWidget()); - } - else - { - m_settings->reset("JvmArgs"); - } - - // old generic 'override both' is removed. - m_settings->reset("OverrideJava"); - - // Custom Commands - bool custcmd = ui->customCommandsGroupBox->isChecked(); - m_settings->set("OverrideCommands", custcmd); - if (custcmd) - { - m_settings->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text()); - m_settings->set("PostExitCommand", ui->postExitCmdTextBox->text()); - } - else - { - m_settings->reset("PreLaunchCommand"); - m_settings->reset("PostExitCommand"); - } -} - -void InstanceSettingsPage::loadSettings() -{ - // Console - ui->consoleSettingsBox->setChecked(m_settings->get("OverrideConsole").toBool()); - ui->showConsoleCheck->setChecked(m_settings->get("ShowConsole").toBool()); - ui->autoCloseConsoleCheck->setChecked(m_settings->get("AutoCloseConsole").toBool()); - - // Window Size - ui->windowSizeGroupBox->setChecked(m_settings->get("OverrideWindow").toBool()); - ui->maximizedCheckBox->setChecked(m_settings->get("LaunchMaximized").toBool()); - ui->windowWidthSpinBox->setValue(m_settings->get("MinecraftWinWidth").toInt()); - ui->windowHeightSpinBox->setValue(m_settings->get("MinecraftWinHeight").toInt()); - - // Memory - ui->memoryGroupBox->setChecked(m_settings->get("OverrideMemory").toBool()); - ui->minMemSpinBox->setValue(m_settings->get("MinMemAlloc").toInt()); - ui->maxMemSpinBox->setValue(m_settings->get("MaxMemAlloc").toInt()); - ui->permGenSpinBox->setValue(m_settings->get("PermGen").toInt()); - - // Java Settings - bool overrideJava = m_settings->get("OverrideJava").toBool(); - bool overrideLocation = m_settings->get("OverrideJavaLocation").toBool() || overrideJava; - bool overrideArgs = m_settings->get("OverrideJavaArgs").toBool() || overrideJava; - - ui->javaSettingsGroupBox->setChecked(overrideLocation); - ui->javaPathTextBox->setText(m_settings->get("JavaPath").toString()); - - ui->javaArgumentsGroupBox->setChecked(overrideArgs); - ui->jvmArgsTextBox->setPlainText(m_settings->get("JvmArgs").toString()); - - // Custom Commands - ui->customCommandsGroupBox->setChecked(m_settings->get("OverrideCommands").toBool()); - ui->preLaunchCmdTextBox->setText(m_settings->get("PreLaunchCommand").toString()); - ui->postExitCmdTextBox->setText(m_settings->get("PostExitCommand").toString()); -} - -void InstanceSettingsPage::on_javaDetectBtn_clicked() -{ - JavaVersionPtr java; - - VersionSelectDialog vselect(MMC->javalist().get(), tr("Select a Java version"), this, true); - vselect.setResizeOn(2); - vselect.exec(); - - if (vselect.result() == QDialog::Accepted && vselect.selectedVersion()) - { - java = std::dynamic_pointer_cast<JavaVersion>(vselect.selectedVersion()); - ui->javaPathTextBox->setText(java->path); - } -} - -void InstanceSettingsPage::on_javaBrowseBtn_clicked() -{ - QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable")); - if (!dir.isNull()) - { - ui->javaPathTextBox->setText(dir); - } -} - -void InstanceSettingsPage::on_javaTestBtn_clicked() -{ - checker.reset(new JavaChecker()); - connect(checker.get(), SIGNAL(checkFinished(JavaCheckResult)), this, - SLOT(checkFinished(JavaCheckResult))); - checker->path = ui->javaPathTextBox->text(); - checker->performCheck(); -} - -void InstanceSettingsPage::checkFinished(JavaCheckResult result) -{ - if (result.valid) - { - QString text; - text += "Java test succeeded!\n"; - if (result.is_64bit) - text += "Using 64bit java.\n"; - text += "\n"; - text += "Platform reported: " + result.realPlatform; - QMessageBox::information(this, tr("Java test success"), text); - } - else - { - QMessageBox::warning( - this, tr("Java test failure"), - tr("The specified java binary didn't work. You should use the auto-detect feature, " - "or set the path to the java executable.")); - } -} diff --git a/gui/pages/InstanceSettingsPage.h b/gui/pages/InstanceSettingsPage.h deleted file mode 100644 index 8835d02e..00000000 --- a/gui/pages/InstanceSettingsPage.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright 2013-2015 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 "logic/net/NetJob.h" -#include "logic/java/JavaChecker.h" -#include "logic/BaseInstance.h" -#include "BasePage.h" -#include "MultiMC.h" - -class JavaChecker; -namespace Ui -{ -class InstanceSettingsPage; -} - -class InstanceSettingsPage : public QWidget, public BasePage -{ - Q_OBJECT - -public: - explicit InstanceSettingsPage(BaseInstance *inst, QWidget *parent = 0); - virtual ~InstanceSettingsPage(); - virtual QString displayName() const override - { - return tr("Settings"); - } - virtual QIcon icon() const override - { - return MMC->getThemedIcon("instance-settings"); - } - virtual QString id() const override - { - return "settings"; - } - virtual bool apply(); - virtual QString helpPage() const override - { - return "Instance-settings"; - } - virtual bool shouldDisplay() const; -private slots: - void on_javaDetectBtn_clicked(); - - void on_javaTestBtn_clicked(); - - void on_javaBrowseBtn_clicked(); - - void checkFinished(JavaCheckResult result); - - void applySettings(); - void loadSettings(); - -private: - Ui::InstanceSettingsPage *ui; - BaseInstance *m_instance; - SettingsObject *m_settings; - std::shared_ptr<JavaChecker> checker; -}; diff --git a/gui/pages/InstanceSettingsPage.ui b/gui/pages/InstanceSettingsPage.ui deleted file mode 100644 index 64109378..00000000 --- a/gui/pages/InstanceSettingsPage.ui +++ /dev/null @@ -1,453 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>InstanceSettingsPage</class> - <widget class="QWidget" name="InstanceSettingsPage"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>458</width> - <height>426</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="QTabWidget" name="settingsTabs"> - <property name="tabShape"> - <enum>QTabWidget::Rounded</enum> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="minecraftTab"> - <attribute name="title"> - <string>Java</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <widget class="QGroupBox" name="javaSettingsGroupBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="title"> - <string>Java installation</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="3"> - <widget class="QLineEdit" name="javaPathTextBox"/> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="javaDetectBtn"> - <property name="text"> - <string>Auto-detect...</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="javaBrowseBtn"> - <property name="text"> - <string>Browse...</string> - </property> - </widget> - </item> - <item row="1" column="2"> - <widget class="QPushButton" name="javaTestBtn"> - <property name="text"> - <string>Test</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="memoryGroupBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="title"> - <string>Memory</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="1"> - <widget class="QSpinBox" name="maxMemSpinBox"> - <property name="toolTip"> - <string>The maximum amount of memory Minecraft is allowed to use.</string> - </property> - <property name="suffix"> - <string> MB</string> - </property> - <property name="minimum"> - <number>512</number> - </property> - <property name="maximum"> - <number>65536</number> - </property> - <property name="singleStep"> - <number>128</number> - </property> - <property name="value"> - <number>1024</number> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="labelMinMem"> - <property name="text"> - <string>Minimum memory allocation:</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="labelMaxMem"> - <property name="text"> - <string>Maximum memory allocation:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="minMemSpinBox"> - <property name="toolTip"> - <string>The amount of memory Minecraft is started with.</string> - </property> - <property name="suffix"> - <string> MB</string> - </property> - <property name="minimum"> - <number>256</number> - </property> - <property name="maximum"> - <number>65536</number> - </property> - <property name="singleStep"> - <number>128</number> - </property> - <property name="value"> - <number>256</number> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QSpinBox" name="permGenSpinBox"> - <property name="toolTip"> - <string>The amount of memory available to store loaded Java classes.</string> - </property> - <property name="suffix"> - <string> MB</string> - </property> - <property name="minimum"> - <number>64</number> - </property> - <property name="maximum"> - <number>999999999</number> - </property> - <property name="singleStep"> - <number>8</number> - </property> - <property name="value"> - <number>64</number> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="labelPermGen"> - <property name="text"> - <string>PermGen:</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="javaArgumentsGroupBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="title"> - <string>Java arguments</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QGridLayout" name="gridLayout_5"> - <item row="1" column="1"> - <widget class="QPlainTextEdit" name="jvmArgsTextBox"/> - </item> - </layout> - </widget> - </item> - <item> - <spacer name="verticalSpacerMinecraft"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="javaTab"> - <attribute name="title"> - <string>Game windows</string> - </attribute> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> - <widget class="QGroupBox" name="windowSizeGroupBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="title"> - <string>Game Window</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_4"> - <item> - <widget class="QCheckBox" name="maximizedCheckBox"> - <property name="text"> - <string>Start Minecraft maximized?</string> - </property> - </widget> - </item> - <item> - <layout class="QGridLayout" name="gridLayoutWindowSize"> - <item row="1" column="0"> - <widget class="QLabel" name="labelWindowHeight"> - <property name="text"> - <string>Window height:</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="labelWindowWidth"> - <property name="text"> - <string>Window width:</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QSpinBox" name="windowWidthSpinBox"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>65536</number> - </property> - <property name="singleStep"> - <number>1</number> - </property> - <property name="value"> - <number>854</number> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QSpinBox" name="windowHeightSpinBox"> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>65536</number> - </property> - <property name="value"> - <number>480</number> - </property> - </widget> - </item> - </layout> - </item> - </layout> - </widget> - </item> - <item> - <widget class="QGroupBox" name="consoleSettingsBox"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="title"> - <string>Console Settings</string> - </property> - <property name="checkable"> - <bool>true</bool> - </property> - <property name="checked"> - <bool>false</bool> - </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> - <item> - <widget class="QCheckBox" |
