Skip to content

Commit ac8a09a

Browse files
committed
add options to set wine binary
1 parent 4cd9bae commit ac8a09a

8 files changed

Lines changed: 73 additions & 12 deletions

File tree

src/Model.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ void Model::run(RunnerOptions options) {
157157
m_runner.addEnvironmentVariable(env);
158158
}
159159

160+
// Wine binary path
161+
if (!options.winePath.isEmpty()|| (options.command == WINE )) {
162+
m_runner.setWinePath(options.winePath);
163+
}
164+
160165
// Executable to run
161166
const quint64 type = getType(options.id);
162167
m_runner.addArguments(QStringList() << ExecutableNames().data[type]);

src/Runner.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const quint64 Runner::getStatus() {
3333
void Runner::clear() {
3434
m_arguments.clear();
3535
m_env.clear();
36+
m_winePath.clear();
3637
m_env.insert(QProcessEnvironment::systemEnvironment());
3738
m_cwd.clear();
3839
m_command = 0;
@@ -73,6 +74,10 @@ QString Runner::getCommandString(const quint64 cmd) {
7374
return result;
7475
}
7576

77+
void Runner::setWinePath(const QString& path) {
78+
m_winePath = path;
79+
}
80+
7681
void Runner::run() {
7782
if (m_isRunning) {
7883
qWarning() << "[Runner] Already running!";
@@ -85,7 +90,11 @@ void Runner::run() {
8590

8691
process.setWorkingDirectory(m_cwd);
8792
process.setProcessEnvironment(m_env);
88-
process.setProgram(getCommandString(m_command));
93+
if (m_winePath.isEmpty() == true) {
94+
process.setProgram(getCommandString(m_command));
95+
} else {
96+
process.setProgram(m_winePath);
97+
}
8998
process.setArguments(m_arguments);
9099
process.setProcessChannelMode(QProcess::MergedChannels);
91100

src/Runner.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class Runner : public QObject {
2525
void run();
2626
const quint64 getStatus();
2727
void clear();
28+
void setWinePath(const QString& path);
2829
void setProgram(const quint64 command);
2930
void setCurrentWorkingDirectory(const QString& dir);
3031
void addEnvironmentVariable(const QPair<QString, QString> env);
@@ -35,6 +36,7 @@ class Runner : public QObject {
3536
QProcessEnvironment m_env;
3637
QStringList m_arguments;
3738
QString m_cwd;
39+
QString m_winePath;
3840
quint64 m_command;
3941
quint64 m_status;
4042
bool m_isRunning;

src/globalTypes.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ struct RunnerOptions {
3636
quint64 id = 0;
3737
quint64 steamID = 0;
3838
quint64 command = 0;
39+
QString winePath;
3940
QList<QPair<QString, QString>> envList;
4041
QStringList arguments;
4142
bool setup = false;

src/pictures/Lara.png

-5.4 KB
Loading

src/view/Levels.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,13 @@ void UiLevels::runClicked() {
589589
QString("level%1/RunnerType").arg(id)).toInt();
590590
QString input = g_settings.value(
591591
QString("level%1/EnvironmentVariables").arg(id)).toString();
592+
593+
QString winePath;
594+
if (type == 1) {
595+
winePath = g_settings.value(
596+
QString("level%1/RunnerWinePath").arg(id)).toString();
597+
}
598+
592599
qDebug() << "Type was: " << type;
593600
RunnerOptions options;
594601

@@ -603,6 +610,7 @@ void UiLevels::runClicked() {
603610
} else if (type == 1) {
604611
options.id = id;
605612
options.command = WINE;
613+
options.winePath = winePath;
606614
options.setup =
607615
this->select->stackedWidgetBar->
608616
navigateWidgetBar->checkBoxSetup->isChecked();

src/view/Setup.cpp

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,17 @@ void UiSetup::globalResetClicked() {
158158
}
159159

160160
void UiSetup::levelSaveClicked(qint64 id) {
161-
g_settings.setValue(QString("level%1/EnvironmentVariables")
162-
.arg(id), this->settings->
163-
frameLevelSetup->frameLevelSetupSettings->widgetEnvironmentVariables->
164-
lineEditEnvironmentVariables->text());
165-
166-
g_settings.setValue(QString("level%1/RunnerType")
167-
.arg(id), this->settings->frameLevelSetup->
168-
frameLevelSetupSettings->widgetRunnerType->
169-
comboBoxRunnerType->currentIndex());
161+
g_settings.setValue(QString("level%1/EnvironmentVariables").arg(id),
162+
this->settings->frameLevelSetup->frameLevelSetupSettings->
163+
widgetEnvironmentVariables->lineEditEnvironmentVariables->text());
164+
165+
g_settings.setValue(QString("level%1/RunnerType").arg(id),
166+
this->settings->frameLevelSetup->frameLevelSetupSettings->
167+
widgetRunnerType->comboBoxRunnerType->currentIndex());
168+
169+
g_settings.setValue(QString("level%1/RunnerWinePath").arg(id),
170+
this->settings->frameLevelSetup->frameLevelSetupSettings->
171+
widgetRunnerType->lineEditWinePath->text());
170172
}
171173

172174
void UiSetup::levelResetClicked(qint64 id) {
@@ -181,6 +183,12 @@ void UiSetup::levelResetClicked(qint64 id) {
181183
g_settings.value(
182184
QString("level%1/RunnerType")
183185
.arg(id)).toInt());
186+
187+
this->settings->frameLevelSetup->frameLevelSetupSettings->
188+
widgetRunnerType->lineEditWinePath->setText(
189+
g_settings.value(
190+
QString("level%1/RunnerWinePath")
191+
.arg(id)).toString());
184192
}
185193

186194
void UiSetup::setState(qint64 id) {
@@ -195,6 +203,9 @@ void UiSetup::setState(qint64 id) {
195203
levelSettings->widgetRunnerType->comboBoxRunnerType->setCurrentIndex(
196204
g_settings.value(QString("level%1/RunnerType")
197205
.arg(id)).toInt());
206+
levelSettings->widgetRunnerType->lineEditWinePath->setText(
207+
g_settings.value(QString("level%1/RunnerWinePath")
208+
.arg(id)).toString());
198209
LevelControl* levelControl = this->settings->frameLevelSetup->levelControl;
199210
levelControl->commandLinkButtonLSSave->setEnabled(true);
200211
levelControl->commandLinkButtonLSReset->setEnabled(true);
@@ -599,6 +610,8 @@ WidgetRunnerType::WidgetRunnerType(QWidget* parent)
599610
labelRunnerType(new QLabel(
600611
tr("Runner Type"), this)),
601612
comboBoxRunnerType(new QComboBox(this)),
613+
labelWinePath(new QLabel(tr("Wine Path"), this)),
614+
lineEditWinePath(new QLineEdit(this)),
602615
layout(new QHBoxLayout(this))
603616
{
604617
layout->setContentsMargins(6, 6, 6, 6);
@@ -621,6 +634,25 @@ WidgetRunnerType::WidgetRunnerType(QWidget* parent)
621634
);
622635

623636
layout->addWidget(comboBoxRunnerType);
637+
labelWinePath->hide();
638+
layout->addWidget(labelWinePath);
639+
lineEditWinePath->hide();
640+
layout->addWidget(lineEditWinePath);
641+
642+
connect(comboBoxRunnerType,
643+
&QComboBox::currentTextChanged,
644+
this,
645+
[this](const QString &runner) {
646+
if (runner == "Wine") {
647+
labelWinePath->show();
648+
lineEditWinePath->show();
649+
} else {
650+
labelWinePath->hide();
651+
lineEditWinePath->hide();
652+
}
653+
});
654+
655+
624656
}
625657

626658
WidgetLevelID::WidgetLevelID(QWidget* parent)

src/view/Setup.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,16 @@ class WidgetRunnerType : public QWidget
192192
* (ui->tabs->setup->stackedWidget->settings->
193193
* frameLevelSetup->frameLevelSetupSettings)
194194
* LevelControl
195+
* ├── labelRunnerType
195196
* ├── comboBoxRunnerType
196-
* └── labelRunnerType
197+
* ├── labelWinePath
198+
* └── lineEditWinePath
197199
*/
198200
explicit WidgetRunnerType(QWidget* parent);
199-
QComboBox *comboBoxRunnerType{nullptr};
200201
QLabel *labelRunnerType{nullptr};
202+
QComboBox *comboBoxRunnerType{nullptr};
203+
QLabel *labelWinePath{nullptr};
204+
QLineEdit *lineEditWinePath{nullptr};
201205
private:
202206
QHBoxLayout *layout{nullptr};
203207
};

0 commit comments

Comments
 (0)