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:
48
application/widgets/CustomCommands.cpp
Normal file
48
application/widgets/CustomCommands.cpp
Normal 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();
|
||||
}
|
43
application/widgets/CustomCommands.h
Normal file
43
application/widgets/CustomCommands.h
Normal 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;
|
||||
};
|
||||
|
||||
|
98
application/widgets/CustomCommands.ui
Normal file
98
application/widgets/CustomCommands.ui
Normal 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&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><html><head/><body><p>Pre-launch command runs before the instance launches and post-exit command runs after it exits.</p><p>Both will be run in MultiMC's working folder with extra environment variables:</p><ul><li>INST_NAME - Name of the instance</li><li>INST_ID - ID of the instance</li><li>INST_DIR - absolute path of the instance</li><li>INST_MC_DIR - absolute path of minecraft</li><li>INST_JAVA - java binary used for launch</li><li>INST_JAVA_ARGS - command-line parameters used for launch</li></ul><p>Wrapper command allows launching using an extra wrapper program (like 'optirun' on Linux)</p></body></html></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>
|
Reference in New Issue
Block a user