From 65bca654895c94e83ef25008dc1c44cc822cfbab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sat, 17 Feb 2018 00:00:06 +0100 Subject: 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. --- application/widgets/CustomCommands.cpp | 48 +++++++++++++++++ application/widgets/CustomCommands.h | 43 +++++++++++++++ application/widgets/CustomCommands.ui | 98 ++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 application/widgets/CustomCommands.cpp create mode 100644 application/widgets/CustomCommands.h create mode 100644 application/widgets/CustomCommands.ui (limited to 'application/widgets') diff --git a/application/widgets/CustomCommands.cpp b/application/widgets/CustomCommands.cpp new file mode 100644 index 00000000..9f11e344 --- /dev/null +++ b/application/widgets/CustomCommands.cpp @@ -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(); +} diff --git a/application/widgets/CustomCommands.h b/application/widgets/CustomCommands.h new file mode 100644 index 00000000..2bc7cb1a --- /dev/null +++ b/application/widgets/CustomCommands.h @@ -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 + +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; +}; + + diff --git a/application/widgets/CustomCommands.ui b/application/widgets/CustomCommands.ui new file mode 100644 index 00000000..44104460 --- /dev/null +++ b/application/widgets/CustomCommands.ui @@ -0,0 +1,98 @@ + + + CustomCommands + + + + 0 + 0 + 518 + 646 + + + + Form + + + + + + true + + + Cus&tom Commands + + + true + + + false + + + + + + Post-exit command: + + + + + + + + + + Pre-launch command: + + + + + + + + + + Wrapper command: + + + + + + + + + + + + + <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> + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + -- cgit v1.2.3