Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
13 changed files
with
689 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.