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.
This commit is contained in:
Petr Mrázek 2018-02-17 00:00:06 +01:00
parent a7957f24ba
commit 65bca65489
13 changed files with 689 additions and 166 deletions

View File

@ -101,6 +101,8 @@ SET(MULTIMC_SOURCES
# GUI - global settings pages
pages/global/AccountListPage.cpp
pages/global/AccountListPage.h
pages/global/CustomCommandsPage.cpp
pages/global/CustomCommandsPage.h
pages/global/ExternalToolsPage.cpp
pages/global/ExternalToolsPage.h
pages/global/JavaPage.cpp
@ -155,6 +157,8 @@ SET(MULTIMC_SOURCES
# GUI - widgets
widgets/Common.cpp
widgets/Common.h
widgets/CustomCommands.cpp
widgets/CustomCommands.h
widgets/FocusLineEdit.cpp
widgets/FocusLineEdit.h
widgets/IconLabel.cpp
@ -232,6 +236,7 @@ SET(MULTIMC_UIS
dialogs/SkinUploadDialog.ui
# Widgets/other
widgets/CustomCommands.ui
widgets/MCModInfoFrame.ui
)

View File

@ -11,6 +11,7 @@
#include "pages/global/AccountListPage.h"
#include "pages/global/PasteEEPage.h"
#include "pages/global/PackagesPage.h"
#include "pages/global/CustomCommandsPage.h"
#include "themes/ITheme.h"
#include "themes/SystemTheme.h"
@ -65,6 +66,7 @@
#include <ganalytics.h>
#include <sys.h>
#if defined Q_OS_WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
@ -514,6 +516,7 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv)
m_globalSettingsProvider->addPage<MultiMCPage>();
m_globalSettingsProvider->addPage<MinecraftPage>();
m_globalSettingsProvider->addPage<JavaPage>();
m_globalSettingsProvider->addPage<CustomCommandsPage>();
m_globalSettingsProvider->addPage<ProxyPage>();
// m_globalSettingsProvider->addPage<PackagesPage>();
m_globalSettingsProvider->addPage<ExternalToolsPage>();

View File

@ -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()

View File

@ -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/>

View File

@ -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()
);
}

View File

@ -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;
};

View File

@ -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()

View File

@ -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 name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</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>
<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/>

View File

@ -62,6 +62,9 @@
<file>64x64/screenshots.png</file>
<file>scalable/screenshots.svg</file>
<!-- Custom commands. -->
<file>scalable/custom-commands.svg</file>
<!-- Patron logo. (C) 2014 Patreon, Inc., http://www.patreon.com/toolbox?ftyp=media -->
<file>16x16/patreon.png</file>
<file>22x22/patreon.png</file>

View File

@ -0,0 +1,338 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg2"
height="64"
width="64"
version="1.1"
sodipodi:docname="custom-commands.svg"
inkscape:version="0.92.2 5c3e80d, 2017-08-06">
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="3840"
inkscape:window-height="2123"
id="namedview52"
showgrid="false"
inkscape:zoom="20.85965"
inkscape:cx="28.409224"
inkscape:cy="33.675543"
inkscape:window-x="1200"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:current-layer="svg2"
inkscape:snap-bbox="true"
inkscape:bbox-paths="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:snap-bbox-midpoints="true"
inkscape:bbox-nodes="true">
<inkscape:grid
type="xygrid"
id="grid858" />
</sodipodi:namedview>
<defs
id="defs4">
<linearGradient
id="linearGradient3931">
<stop
offset="0"
style="stop-color:#ffffff;stop-opacity:0"
id="stop3933" />
<stop
offset="0.69999987"
style="stop-color:#ffffff;stop-opacity:0.10396039"
id="stop3939" />
<stop
offset="1"
style="stop-color:#ffffff;stop-opacity:0.14356436"
id="stop3935" />
</linearGradient>
<linearGradient
id="linearGradient3900">
<stop
offset="0"
style="stop-color:#f6f6f6;stop-opacity:1"
id="stop3902" />
<stop
offset="0.75714284"
style="stop-color:#494949;stop-opacity:1"
id="stop3904" />
<stop
offset="1"
style="stop-color:#2c2c2c;stop-opacity:1"
id="stop3906" />
</linearGradient>
<linearGradient
id="linearGradient3808">
<stop
offset="0"
style="stop-color:#333333;stop-opacity:1"
id="stop3810" />
<stop
offset="1"
style="stop-color:#c8c8c8;stop-opacity:1"
id="stop3812" />
</linearGradient>
<linearGradient
id="linearGradient3030">
<stop
offset="0"
style="stop-color:#000000;stop-opacity:1"
id="stop3032" />
<stop
offset="0.75714284"
style="stop-color:#333333;stop-opacity:1"
id="stop3038" />
<stop
offset="1"
style="stop-color:#4d4d4d;stop-opacity:1"
id="stop3034" />
</linearGradient>
<radialGradient
gradientTransform="matrix(1.3519242,1.8838281,-1.5359217,1.1022493,15.935733,948.08165)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3030"
id="radialGradient3036"
fy="14.242621"
fx="29.381905"
r="16.375"
cy="14.242621"
cx="29.381905" />
<linearGradient
gradientTransform="matrix(1.5,0,0,1,-16,4)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3808"
id="linearGradient3824"
y2="1033.8622"
x2="34"
y1="1033.8622"
x1="30" />
<linearGradient
gradientTransform="matrix(0.82142857,0,0,1.500001,6.7142857,-522.68214)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3808"
id="linearGradient3834"
y2="1039.3622"
x2="32"
y1="1043.3622"
x1="32" />
<radialGradient
gradientTransform="matrix(6.479993,1.9525666,-10.415476,2.1794781,10657.845,-1282.8793)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3900"
id="radialGradient3844"
fy="1039.813"
fx="30.724609"
r="3"
cy="1039.813"
cx="30.724609" />
<radialGradient
gradientTransform="matrix(2.5191507,2.9862959,-4.0491019,3.333339,4186.8847,-2518.44)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3900"
id="radialGradient3852"
fy="1039.813"
fx="30.724609"
r="3"
cy="1039.813"
cx="30.724609" />
<radialGradient
gradientTransform="matrix(-2.5191507,2.9863064,4.0491022,3.3333507,-4122.8849,-2518.4524)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3900"
id="radialGradient3857"
fy="1039.813"
fx="30.724609"
r="3"
cy="1039.813"
cx="30.724609" />
<radialGradient
gradientTransform="matrix(-0.69414478,2.3073251,-1.6952184,-0.67174747,96.941544,960.82172)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient3900"
id="radialGradient3937"
fy="21.976955"
fx="31.946348"
r="19.25"
cy="21.976955"
cx="31.946348" />
</defs>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
transform="translate(0,-988.36218)">
<rect
style="color:#000000;display:inline;overflow:visible;visibility:visible;fill:url(#radialGradient3036);fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:1.25954175;stroke-opacity:1;marker:none;enable-background:accumulate"
id="rect2997"
y="992.99194"
x="5.6297708"
ry="0.70710492"
rx="0.70710504"
height="53.740437"
width="53.740459" />
</g>
<g
id="g1021"
transform="translate(1.7703716e-7,-0.42472956)">
<g
style="fill:#008000"
transform="matrix(0.08572572,0,0,0.08572572,9.999999,10.424713)"
id="g899">
<g
style="fill:#008000"
id="g867">
<g
style="fill:#008000"
id="g865">
<path
style="fill:#008000"
d="m 226.434,249.503 c 0,-6.995 -2.705,-13.403 -7.846,-18.556 L 61.8,74.165 c -5.128,-5.141 -11.554,-7.852 -18.568,-7.852 -7.026,0 -13.452,2.717 -18.556,7.846 l -16.83,16.83 c -5.129,5.135 -7.84,11.549 -7.84,18.538 0,7.026 2.717,13.452 7.846,18.556 L 129.267,249.503 7.84,370.936 C 2.711,376.071 0,382.491 0,389.486 c 0,7.02 2.717,13.439 7.846,18.544 l 16.775,16.774 c 5.116,5.165 11.555,7.895 18.611,7.895 7.044,0 13.47,-2.723 18.556,-7.846 l 156.813,-156.8 c 5.128,-5.14 7.833,-11.549 7.833,-18.55 z"
id="path860"
inkscape:connector-curvature="0" />
<path
style="fill:#008000"
d="m 498.866,384.951 h -323.02 c -7.203,0 -13.611,2.583 -18.581,7.528 -4.896,4.92 -7.484,11.327 -7.484,18.531 v 21.536 c 0,7.252 2.607,13.672 7.491,18.543 4.915,4.927 11.34,7.528 18.574,7.528 h 323.02 c 7.239,0 13.659,-2.607 18.531,-7.497 4.927,-4.908 7.533,-11.334 7.533,-18.58 v -21.537 c 0,-7.209 -2.589,-13.616 -7.54,-18.592 -4.913,-4.877 -11.321,-7.46 -18.524,-7.46 z"
id="path862"
inkscape:connector-curvature="0" />
</g>
</g>
<g
style="fill:#008000"
id="g869" />
<g
style="fill:#008000"
id="g871" />
<g
style="fill:#008000"
id="g873" />
<g
style="fill:#008000"
id="g875" />
<g
style="fill:#008000"
id="g877" />
<g
style="fill:#008000"
id="g879" />
<g
style="fill:#008000"
id="g881" />
<g
style="fill:#008000"
id="g883" />
<g
style="fill:#008000"
id="g885" />
<g
style="fill:#008000"
id="g887" />
<g
style="fill:#008000"
id="g889" />
<g
style="fill:#008000"
id="g891" />
<g
style="fill:#008000"
id="g893" />
<g
style="fill:#008000"
id="g895" />
<g
style="fill:#008000"
id="g897" />
</g>
<g
id="g914"
transform="matrix(0.08572572,0,0,0.08572572,9.9999994,8.4247072)"
style="fill:#00ff00">
<g
id="g856"
style="fill:#00ff00">
<g
id="g854"
style="fill:#00ff00">
<path
inkscape:connector-curvature="0"
id="path850"
d="m 226.434,249.503 c 0,-6.995 -2.705,-13.403 -7.846,-18.556 L 61.8,74.165 c -5.128,-5.141 -11.554,-7.852 -18.568,-7.852 -7.026,0 -13.452,2.717 -18.556,7.846 l -16.83,16.83 c -5.129,5.135 -7.84,11.549 -7.84,18.538 0,7.026 2.717,13.452 7.846,18.556 L 129.267,249.503 7.84,370.936 C 2.711,376.071 0,382.491 0,389.486 c 0,7.02 2.717,13.439 7.846,18.544 l 16.775,16.774 c 5.116,5.165 11.555,7.895 18.611,7.895 7.044,0 13.47,-2.723 18.556,-7.846 l 156.813,-156.8 c 5.128,-5.14 7.833,-11.549 7.833,-18.55 z"
style="fill:#00ff00" />
<path
inkscape:connector-curvature="0"
id="path852"
d="m 498.866,384.951 h -323.02 c -7.203,0 -13.611,2.583 -18.581,7.528 -4.896,4.92 -7.484,11.327 -7.484,18.531 v 21.536 c 0,7.252 2.607,13.672 7.491,18.543 4.915,4.927 11.34,7.528 18.574,7.528 h 323.02 c 7.239,0 13.659,-2.607 18.531,-7.497 4.927,-4.908 7.533,-11.334 7.533,-18.58 v -21.537 c 0,-7.209 -2.589,-13.616 -7.54,-18.592 -4.913,-4.877 -11.321,-7.46 -18.524,-7.46 z"
style="fill:#00ff00" />
</g>
</g>
<g
id="g858"
style="fill:#00ff00" />
<g
id="g860"
style="fill:#00ff00" />
<g
id="g862"
style="fill:#00ff00" />
<g
id="g864"
style="fill:#00ff00" />
<g
id="g866"
style="fill:#00ff00" />
<g
id="g868"
style="fill:#00ff00" />
<g
id="g870"
style="fill:#00ff00" />
<g
id="g872"
style="fill:#00ff00" />
<g
id="g874"
style="fill:#00ff00" />
<g
id="g876"
style="fill:#00ff00" />
<g
id="g878"
style="fill:#00ff00" />
<g
id="g880"
style="fill:#00ff00" />
<g
id="g882"
style="fill:#00ff00" />
<g
id="g884"
style="fill:#00ff00" />
<g
id="g886"
style="fill:#00ff00" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,48 @@
#include "CustomCommands.h"
#include "ui_CustomCommands.h"
CustomCommands::~CustomCommands()
{
}
CustomCommands::CustomCommands(QWidget* parent):
QWidget(parent),
ui(new Ui::CustomCommands)
{
ui->setupUi(this);
}
void CustomCommands::initialize(bool checkable, bool checked, const QString& prelaunch, const QString& wrapper, const QString& postexit)
{
ui->customCommandsGroupBox->setCheckable(checkable);
if(checkable)
{
ui->customCommandsGroupBox->setChecked(checked);
}
ui->preLaunchCmdTextBox->setText(prelaunch);
ui->wrapperCmdTextBox->setText(wrapper);
ui->postExitCmdTextBox->setText(postexit);
}
bool CustomCommands::checked() const
{
if(!ui->customCommandsGroupBox->isCheckable())
return true;
return ui->customCommandsGroupBox->isChecked();
}
QString CustomCommands::prelaunchCommand() const
{
return ui->preLaunchCmdTextBox->text();
}
QString CustomCommands::wrapperCommand() const
{
return ui->wrapperCmdTextBox->text();
}
QString CustomCommands::postexitCommand() const
{
return ui->postExitCmdTextBox->text();
}

View File

@ -0,0 +1,43 @@
/* 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 <QWidget>
namespace Ui
{
class CustomCommands;
}
class CustomCommands : public QWidget
{
Q_OBJECT
public:
explicit CustomCommands(QWidget *parent = 0);
~CustomCommands();
void initialize(bool checkable, bool checked, const QString & prelaunch, const QString & wrapper, const QString & postexit);
bool checked() const;
QString prelaunchCommand() const;
QString wrapperCommand() const;
QString postexitCommand() const;
private:
Ui::CustomCommands *ui;
};

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CustomCommands</class>
<widget class="QWidget" name="CustomCommands">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>518</width>
<height>646</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<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&gt;&lt;li&gt;INST_NAME - Name of the instance&lt;/li&gt;&lt;li&gt;INST_ID - ID of the instance&lt;/li&gt;&lt;li&gt;INST_DIR - absolute path of the instance&lt;/li&gt;&lt;li&gt;INST_MC_DIR - absolute path of minecraft&lt;/li&gt;&lt;li&gt;INST_JAVA - java binary used for launch&lt;/li&gt;&lt;li&gt;INST_JAVA_ARGS - command-line parameters used for launch&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Wrapper command allows launching 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>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>