summaryrefslogtreecommitdiffstats
path: root/application/pages/global
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/global
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/global')
-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
4 files changed, 125 insertions, 74 deletions
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/>