summaryrefslogtreecommitdiffstats
path: root/application/pages
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2018-02-17 00:00:06 +0100
committerPetr Mrázek <peterix@gmail.com>2018-02-17 00:57:54 +0100
commit65bca654895c94e83ef25008dc1c44cc822cfbab (patch)
tree1ec8ced7e8f9af0f7c39c2407b72f51a05bb366f /application/pages
parenta7957f24bac2a6c7fea6f5f2fbfcd77b4db16fa8 (diff)
downloadMultiMC-65bca654895c94e83ef25008dc1c44cc822cfbab.tar
MultiMC-65bca654895c94e83ef25008dc1c44cc822cfbab.tar.gz
MultiMC-65bca654895c94e83ef25008dc1c44cc822cfbab.tar.lz
MultiMC-65bca654895c94e83ef25008dc1c44cc822cfbab.tar.xz
MultiMC-65bca654895c94e83ef25008dc1c44cc822cfbab.zip
GH-2150 Split out custom commands into a custom widget
Now it is used from a global page and from a sub-page in the instance settings.
Diffstat (limited to 'application/pages')
-rw-r--r--application/pages/InstanceSettingsPage.cpp22
-rw-r--r--application/pages/InstanceSettingsPage.ui96
-rw-r--r--application/pages/global/CustomCommandsPage.cpp50
-rw-r--r--application/pages/global/CustomCommandsPage.h55
-rw-r--r--application/pages/global/JavaPage.cpp15
-rw-r--r--application/pages/global/JavaPage.ui79
6 files changed, 151 insertions, 166 deletions
diff --git a/application/pages/InstanceSettingsPage.cpp b/application/pages/InstanceSettingsPage.cpp
index b146ffd8..71e90a32 100644
--- a/application/pages/InstanceSettingsPage.cpp
+++ b/application/pages/InstanceSettingsPage.cpp
@@ -12,6 +12,7 @@
#include <java/JavaInstallList.h>
#include <FileSystem.h>
#include <sys.h>
+#include <widgets/CustomCommands.h>
InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
@@ -130,13 +131,13 @@ void InstanceSettingsPage::applySettings()
m_settings->reset("OverrideJava");
// Custom Commands
- bool custcmd = ui->customCommandsGroupBox->isChecked();
+ bool custcmd = ui->customCommands->checked();
m_settings->set("OverrideCommands", custcmd);
if (custcmd)
{
- m_settings->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
- m_settings->set("WrapperCommand", ui->wrapperCmdTextBox->text());
- m_settings->set("PostExitCommand", ui->postExitCmdTextBox->text());
+ m_settings->set("PreLaunchCommand", ui->customCommands->prelaunchCommand());
+ m_settings->set("WrapperCommand", ui->customCommands->wrapperCommand());
+ m_settings->set("PostExitCommand", ui->customCommands->postexitCommand());
}
else
{
@@ -187,11 +188,14 @@ void InstanceSettingsPage::loadSettings()
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->wrapperCmdTextBox->setText(m_settings->get("WrapperCommand").toString());
- ui->postExitCmdTextBox->setText(m_settings->get("PostExitCommand").toString());
+ // Custom commands
+ ui->customCommands->initialize(
+ true,
+ m_settings->get("OverrideCommands").toBool(),
+ m_settings->get("PreLaunchCommand").toString(),
+ m_settings->get("WrapperCommand").toString(),
+ m_settings->get("PostExitCommand").toString()
+ );
}
void InstanceSettingsPage::on_javaDetectBtn_clicked()
diff --git a/application/pages/InstanceSettingsPage.ui b/application/pages/InstanceSettingsPage.ui
index 6163297f..60262b9a 100644
--- a/application/pages/InstanceSettingsPage.ui
+++ b/application/pages/InstanceSettingsPage.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>458</width>
- <height>508</height>
+ <width>553</width>
+ <height>583</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -42,7 +42,7 @@
<bool>true</bool>
</property>
<property name="title">
- <string>Java ins&amp;tallation</string>
+ <string>Java insta&amp;llation</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -196,7 +196,7 @@
<bool>true</bool>
</property>
<property name="title">
- <string>Java arguments</string>
+ <string>Java argumen&amp;ts</string>
</property>
<property name="checkable">
<bool>true</bool>
@@ -363,81 +363,7 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
- <widget class="QGroupBox" name="customCommandsGroupBox">
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="title">
- <string>Cus&amp;tom Commands</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- <property name="checked">
- <bool>false</bool>
- </property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="2" column="0">
- <widget class="QLabel" name="labelPostExitCmd">
- <property name="text">
- <string>Post-exit command:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="preLaunchCmdTextBox"/>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="labelPreLaunchCmd">
- <property name="text">
- <string>Pre-launch command:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLineEdit" name="postExitCmdTextBox"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="labelWrapperCmd">
- <property name="text">
- <string>Wrapper command:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="wrapperCmdTextBox"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelCustomCmdsDescription">
- <property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pre-launch command runs before the instance launches and post-exit command runs after it exits.&lt;/p&gt;&lt;p&gt;Both will be run in MultiMC's working folder with extra environment variables:&lt;/p&gt;&lt;ul style=&quot;margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;INST_NAME - Name of the instance&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;INST_ID - ID of the instance&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;INST_DIR - absolute path of the instance&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;INST_MC_DIR - absolute path of minecraft&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;INST_JAVA - java binary used for launch&lt;/li&gt;&lt;li style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;INST_JAVA_ARGS - command-line parameters used for launch&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- <property name="textInteractionFlags">
- <set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="verticalSpacerMinecraft_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>88</width>
- <height>186</height>
- </size>
- </property>
- </spacer>
+ <widget class="CustomCommands" name="customCommands" native="true"/>
</item>
</layout>
</widget>
@@ -445,6 +371,14 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>CustomCommands</class>
+ <extends>QWidget</extends>
+ <header>widgets/CustomCommands.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
<tabstops>
<tabstop>settingsTabs</tabstop>
<tabstop>javaSettingsGroupBox</tabstop>
@@ -466,10 +400,6 @@
<tabstop>showConsoleCheck</tabstop>
<tabstop>autoCloseConsoleCheck</tabstop>
<tabstop>showConsoleErrorCheck</tabstop>
- <tabstop>customCommandsGroupBox</tabstop>
- <tabstop>preLaunchCmdTextBox</tabstop>
- <tabstop>wrapperCmdTextBox</tabstop>
- <tabstop>postExitCmdTextBox</tabstop>
</tabstops>
<resources/>
<connections/>
diff --git a/application/pages/global/CustomCommandsPage.cpp b/application/pages/global/CustomCommandsPage.cpp
new file mode 100644
index 00000000..1352b6be
--- /dev/null
+++ b/application/pages/global/CustomCommandsPage.cpp
@@ -0,0 +1,50 @@
+#include "CustomCommandsPage.h"
+#include <QVBoxLayout>
+#include <QTabWidget>
+#include <QTabBar>
+
+CustomCommandsPage::CustomCommandsPage(QWidget* parent): QWidget(parent)
+{
+
+ auto verticalLayout = new QVBoxLayout(this);
+ verticalLayout->setObjectName(QStringLiteral("verticalLayout"));
+ verticalLayout->setContentsMargins(0, 0, 0, 0);
+
+ auto tabWidget = new QTabWidget(this);
+ tabWidget->setObjectName(QStringLiteral("tabWidget"));
+ commands = new CustomCommands(this);
+ tabWidget->addTab(commands, "Foo");
+ tabWidget->tabBar()->hide();
+ verticalLayout->addWidget(tabWidget);
+ loadSettings();
+}
+
+CustomCommandsPage::~CustomCommandsPage()
+{
+}
+
+bool CustomCommandsPage::apply()
+{
+ applySettings();
+ return true;
+}
+
+void CustomCommandsPage::applySettings()
+{
+ auto s = MMC->settings();
+ s->set("PreLaunchCommand", commands->prelaunchCommand());
+ s->set("WrapperCommand", commands->wrapperCommand());
+ s->set("PostExitCommand", commands->postexitCommand());
+}
+
+void CustomCommandsPage::loadSettings()
+{
+ auto s = MMC->settings();
+ commands->initialize(
+ false,
+ true,
+ s->get("PreLaunchCommand").toString(),
+ s->get("WrapperCommand").toString(),
+ s->get("PostExitCommand").toString()
+ );
+}
diff --git a/application/pages/global/CustomCommandsPage.h b/application/pages/global/CustomCommandsPage.h
new file mode 100644
index 00000000..52256ed3
--- /dev/null
+++ b/application/pages/global/CustomCommandsPage.h
@@ -0,0 +1,55 @@
+/* Copyright 2018-2018 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 <memory>
+#include <QDialog>
+
+#include "pages/BasePage.h"
+#include <MultiMC.h>
+#include "widgets/CustomCommands.h"
+
+class CustomCommandsPage : public QWidget, public BasePage
+{
+ Q_OBJECT
+
+public:
+ explicit CustomCommandsPage(QWidget *parent = 0);
+ ~CustomCommandsPage();
+
+ QString displayName() const override
+ {
+ return tr("Custom Commands");
+ }
+ QIcon icon() const override
+ {
+ return MMC->getThemedIcon("custom-commands");
+ }
+ QString id() const override
+ {
+ return "custom-commands";
+ }
+ QString helpPage() const override
+ {
+ return "Custom-commands";
+ }
+ bool apply() override;
+
+private:
+ void applySettings();
+ void loadSettings();
+ CustomCommands * commands;
+};
diff --git a/application/pages/global/JavaPage.cpp b/application/pages/global/JavaPage.cpp
index 4aa0f184..57250c79 100644
--- a/application/pages/global/JavaPage.cpp
+++ b/application/pages/global/JavaPage.cpp
@@ -22,7 +22,6 @@
#include <QDir>
#include "dialogs/VersionSelectDialog.h"
-#include <ColumnResizer.h>
#include "java/JavaUtils.h"
#include "java/JavaInstallList.h"
@@ -37,10 +36,6 @@ JavaPage::JavaPage(QWidget *parent) : QWidget(parent), ui(new Ui::JavaPage)
ui->setupUi(this);
ui->tabWidget->tabBar()->hide();
- auto resizer = new ColumnResizer(this);
- resizer->addWidgetsFromLayout(ui->javaSettingsGroupBox->layout(), 0);
- resizer->addWidgetsFromLayout(ui->customCommandsGroupBox->layout(), 0);
-
auto sysMB = Sys::getSystemRam() / Sys::megabyte;
ui->maxMemSpinBox->setMaximum(sysMB);
loadSettings();
@@ -80,11 +75,6 @@ void JavaPage::applySettings()
s->set("JavaPath", ui->javaPathTextBox->text());
s->set("JvmArgs", ui->jvmArgsTextBox->text());
JavaCommon::checkJVMArgs(s->get("JvmArgs").toString(), this->parentWidget());
-
- // Custom Commands
- s->set("PreLaunchCommand", ui->preLaunchCmdTextBox->text());
- s->set("WrapperCommand", ui->wrapperCmdTextBox->text());
- s->set("PostExitCommand", ui->postExitCmdTextBox->text());
}
void JavaPage::loadSettings()
{
@@ -107,11 +97,6 @@ void JavaPage::loadSettings()
// Java Settings
ui->javaPathTextBox->setText(s->get("JavaPath").toString());
ui->jvmArgsTextBox->setText(s->get("JvmArgs").toString());
-
- // Custom Commands
- ui->preLaunchCmdTextBox->setText(s->get("PreLaunchCommand").toString());
- ui->wrapperCmdTextBox->setText(s->get("WrapperCommand").toString());
- ui->postExitCmdTextBox->setText(s->get("PostExitCommand").toString());
}
void JavaPage::on_javaDetectBtn_clicked()
diff --git a/application/pages/global/JavaPage.ui b/application/pages/global/JavaPage.ui
index 9023b932..201b310c 100644
--- a/application/pages/global/JavaPage.ui
+++ b/application/pages/global/JavaPage.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>545</width>
- <height>760</height>
+ <height>580</height>
</rect>
</property>
<property name="sizePolicy">
@@ -17,7 +17,16 @@
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
- <property name="margin">
+ <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>
@@ -217,62 +226,17 @@
</widget>
</item>
<item>
- <widget class="QGroupBox" name="customCommandsGroupBox">
- <property name="title">
- <string>Custom Commands</string>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
- <layout class="QGridLayout" name="gridLayout_4">
- <item row="3" column="0">
- <widget class="QLabel" name="labelPostExitCmd">
- <property name="text">
- <string>Post-exit command:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="0">
- <widget class="QLabel" name="labelPreLaunchCmd">
- <property name="text">
- <string>Pre-launch command:</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QLineEdit" name="preLaunchCmdTextBox"/>
- </item>
- <item row="3" column="1">
- <widget class="QLineEdit" name="postExitCmdTextBox"/>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="labelWrapperCmd">
- <property name="text">
- <string>Wrapper command:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QLineEdit" name="wrapperCmdTextBox"/>
- </item>
- </layout>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelCustomCmdsDescription">
- <property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
</property>
- <property name="text">
- <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Pre-launch command runs before the instance launches and post-exit command runs after it exits. Both will be run in MultiMC's working folder with INST_ID, INST_DIR, and INST_NAME as environment variables.&lt;/p&gt;&lt;p&gt;Wrapper command allows running java using an extra wrapper program (like 'optirun' on Linux)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
+ </spacer>
</item>
</layout>
</widget>
@@ -289,9 +253,6 @@
<tabstop>jvmArgsTextBox</tabstop>
<tabstop>javaDetectBtn</tabstop>
<tabstop>javaTestBtn</tabstop>
- <tabstop>preLaunchCmdTextBox</tabstop>
- <tabstop>wrapperCmdTextBox</tabstop>
- <tabstop>postExitCmdTextBox</tabstop>
<tabstop>tabWidget</tabstop>
</tabstops>
<resources/>