Skip to content

Commit ec263a7

Browse files
committedFeb 3, 2025
Fixup pre/post run scripts in shortcut settings
·
v1.1.3v0.95
1 parent 16f4982 commit ec263a7

File tree

3 files changed

+97
-33
lines changed

3 files changed

+97
-33
lines changed
 

‎src/neroprefixsettings.cpp

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ void NeroPrefixSettingsWindow::LoadSettings()
216216
for(const QString &dll : dllsToAdd) {
217217
const QString dllName = dllsToAdd.at(dllsToAdd.indexOf(dll)).left(dllsToAdd.at(dllsToAdd.indexOf(dll)).indexOf('='));
218218
const QString dllType = dllsToAdd.at(dllsToAdd.indexOf(dll)).mid(dllsToAdd.at(dllsToAdd.indexOf(dll)).indexOf('=')+1);
219-
if(dllType == "n,b") AddDLL(dllName, NeroConstant::DLLNativeThenBuiltin);
220-
else if(dllType == "builtin") AddDLL(dllName, NeroConstant::DLLBuiltinOnly);
221-
else if(dllType == "b,n") AddDLL(dllName, NeroConstant::DLLBuiltinThenNative);
222-
else if(dllType == "native") AddDLL(dllName, NeroConstant::DLLNativeOnly);
219+
if(dllType == "n,b") AddDLL(dllName, NeroConstant::DLLNativeThenBuiltin);
220+
else if(dllType == "builtin") AddDLL(dllName, NeroConstant::DLLBuiltinOnly);
221+
else if(dllType == "b,n") AddDLL(dllName, NeroConstant::DLLBuiltinThenNative);
222+
else if(dllType == "native") AddDLL(dllName, NeroConstant::DLLNativeOnly);
223223
else if(dllType == "disabled") AddDLL(dllName, NeroConstant::DLLDisabled);
224224
}
225225
}
@@ -254,6 +254,8 @@ void NeroPrefixSettingsWindow::LoadSettings()
254254
ui->shortcutArgs->setText(settings["Args"].toStringList().join(' '));
255255
ui->preRunScriptPath->setText(settings.value("PreRunScript").toString());
256256
ui->postRunScriptPath->setText(settings.value("PostRunScript").toString());
257+
if(ui->preRunScriptPath->text().isEmpty()) ui->preRunClearBtn->setVisible(false);
258+
if(ui->postRunScriptPath->text().isEmpty()) ui->postRunClearBtn->setVisible(false);
257259

258260
if(QFileInfo::exists(settings["Path"].toString().replace("C:/",
259261
NeroFS::GetPrefixesPath().canonicalPath()+'/'+NeroFS::GetCurrentPrefix()+"/drive_c/")))
@@ -529,7 +531,13 @@ void NeroPrefixSettingsWindow::on_preRunButton_clicked()
529531
"Select a Pre-run Script",
530532
qEnvironmentVariable("HOME"),
531533
"Unix Bash Script (.sh)");
532-
if(!scriptPath.isEmpty()) ui->preRunScriptPath->setText(scriptPath);
534+
if(!scriptPath.isEmpty()) {
535+
ui->preRunScriptPath->setText(scriptPath);
536+
ui->preRunClearBtn->setVisible(true);
537+
if(scriptPath != settings.value("PreRunScript").toString())
538+
ui->preRunScriptPath->setFont(boldFont);
539+
else ui->preRunScriptPath->setFont(QFont());
540+
}
533541
}
534542

535543

@@ -539,7 +547,33 @@ void NeroPrefixSettingsWindow::on_postRunButton_clicked()
539547
"Select a Post-run Script",
540548
qEnvironmentVariable("HOME"),
541549
"Unix Bash Script (.sh)");
542-
if(!scriptPath.isEmpty()) ui->postRunScriptPath->setText(scriptPath);
550+
if(!scriptPath.isEmpty()) {
551+
ui->postRunScriptPath->setText(scriptPath);
552+
ui->postRunClearBtn->setVisible(true);
553+
if(scriptPath != settings.value("PostRunScript").toString())
554+
ui->postRunScriptPath->setFont(boldFont);
555+
else ui->postRunScriptPath->setFont(QFont());
556+
}
557+
}
558+
559+
560+
void NeroPrefixSettingsWindow::on_preRunClearBtn_clicked()
561+
{
562+
ui->preRunScriptPath->clear();
563+
if(ui->preRunScriptPath->text() != settings.value("PreRunScript").toString())
564+
ui->preRunScriptPath->setFont(boldFont);
565+
else ui->preRunScriptPath->setFont(QFont());
566+
ui->preRunClearBtn->setVisible(false);
567+
}
568+
569+
570+
void NeroPrefixSettingsWindow::on_postRunClearBtn_clicked()
571+
{
572+
ui->postRunScriptPath->clear();
573+
if(ui->postRunScriptPath->text() != settings.value("PostRunScript").toString())
574+
ui->postRunScriptPath->setFont(boldFont);
575+
else ui->postRunScriptPath->setFont(QFont());
576+
ui->postRunClearBtn->setVisible(false);
543577
}
544578

545579

‎src/neroprefixsettings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ private slots:
7373

7474
void on_postRunButton_clicked();
7575

76+
void on_preRunClearBtn_clicked();
77+
78+
void on_postRunClearBtn_clicked();
79+
7680
void on_prefixInstallDiscordRPC_clicked();
7781

7882
void OptionSet();

‎src/neroprefixsettings.ui

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@
953953
<x>0</x>
954954
<y>0</y>
955955
<width>600</width>
956-
<height>454</height>
956+
<height>436</height>
957957
</rect>
958958
</property>
959959
<layout class="QVBoxLayout" name="verticalLayout_4">
@@ -1204,7 +1204,32 @@
12041204
<property name="alignment">
12051205
<set>Qt::AlignmentFlag::AlignCenter</set>
12061206
</property>
1207-
<layout class="QGridLayout" name="gridLayout_8">
1207+
<layout class="QGridLayout" name="gridLayout_8" columnstretch="1,0,0">
1208+
<item row="0" column="2">
1209+
<widget class="QPushButton" name="preRunButton">
1210+
<property name="whatsThis">
1211+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a Pre-run Script to run for this Shortcut.&lt;/p&gt;&lt;p&gt;When set, this script will be run whenever this shortcut is started &lt;span style=&quot; font-style:italic;&quot;&gt;before&lt;/span&gt; the Proton runner process. This can be used for setting up other services before the application starts.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1212+
</property>
1213+
<property name="accessibleName">
1214+
<string>Pre-Run Script</string>
1215+
</property>
1216+
<property name="text">
1217+
<string/>
1218+
</property>
1219+
<property name="icon">
1220+
<iconset theme="document-open"/>
1221+
</property>
1222+
<property name="iconSize">
1223+
<size>
1224+
<width>16</width>
1225+
<height>16</height>
1226+
</size>
1227+
</property>
1228+
<property name="flat">
1229+
<bool>false</bool>
1230+
</property>
1231+
</widget>
1232+
</item>
12081233
<item row="0" column="0">
12091234
<widget class="QLineEdit" name="preRunScriptPath">
12101235
<property name="whatsThis">
@@ -1216,12 +1241,12 @@
12161241
<property name="styleSheet">
12171242
<string notr="true">color: gray</string>
12181243
</property>
1244+
<property name="readOnly">
1245+
<bool>true</bool>
1246+
</property>
12191247
<property name="placeholderText">
12201248
<string>Path to a Pre-run Script</string>
12211249
</property>
1222-
<property name="clearButtonEnabled">
1223-
<bool>true</bool>
1224-
</property>
12251250
<property name="isFor" stdset="0">
12261251
<string>PreRunScript</string>
12271252
</property>
@@ -1238,24 +1263,24 @@
12381263
<property name="styleSheet">
12391264
<string notr="true">color: gray</string>
12401265
</property>
1266+
<property name="readOnly">
1267+
<bool>true</bool>
1268+
</property>
12411269
<property name="placeholderText">
12421270
<string>Path to a Post-run Script</string>
12431271
</property>
1244-
<property name="clearButtonEnabled">
1245-
<bool>true</bool>
1246-
</property>
12471272
<property name="isFor" stdset="0">
12481273
<string>PostRunScript</string>
12491274
</property>
12501275
</widget>
12511276
</item>
1252-
<item row="0" column="1">
1253-
<widget class="QPushButton" name="preRunButton">
1277+
<item row="1" column="2">
1278+
<widget class="QPushButton" name="postRunButton">
12541279
<property name="whatsThis">
1255-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a Pre-run Script to run for this Shortcut.&lt;/p&gt;&lt;p&gt;When set, this script will be run whenever this shortcut is started &lt;span style=&quot; font-style:italic;&quot;&gt;before&lt;/span&gt; the Proton runner process. This can be used for setting up other services before the application starts.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1280+
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a Post-run Script to run for this Shortcut.&lt;/p&gt;&lt;p&gt;When set, this script will be run whenever this shortcut is started &lt;span style=&quot; font-style:italic;&quot;&gt;after&lt;/span&gt; the Proton runner process. This can be used for cleaning up or closing other process that may have been started for the application, but don't need to be run in perpetuity.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
12561281
</property>
12571282
<property name="accessibleName">
1258-
<string>Pre-Run Script</string>
1283+
<string>Post-Run Script</string>
12591284
</property>
12601285
<property name="text">
12611286
<string/>
@@ -1269,30 +1294,31 @@
12691294
<height>16</height>
12701295
</size>
12711296
</property>
1297+
</widget>
1298+
</item>
1299+
<item row="0" column="1">
1300+
<widget class="QPushButton" name="preRunClearBtn">
1301+
<property name="text">
1302+
<string/>
1303+
</property>
1304+
<property name="icon">
1305+
<iconset theme="edit-clear"/>
1306+
</property>
12721307
<property name="flat">
1273-
<bool>false</bool>
1308+
<bool>true</bool>
12741309
</property>
12751310
</widget>
12761311
</item>
12771312
<item row="1" column="1">
1278-
<widget class="QPushButton" name="postRunButton">
1279-
<property name="whatsThis">
1280-
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Select a Post-run Script to run for this Shortcut.&lt;/p&gt;&lt;p&gt;When set, this script will be run whenever this shortcut is started &lt;span style=&quot; font-style:italic;&quot;&gt;after&lt;/span&gt; the Proton runner process. This can be used for cleaning up or closing other process that may have been started for the application, but don't need to be run in perpetuity.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1281-
</property>
1282-
<property name="accessibleName">
1283-
<string>Post-Run Script</string>
1284-
</property>
1313+
<widget class="QPushButton" name="postRunClearBtn">
12851314
<property name="text">
12861315
<string/>
12871316
</property>
12881317
<property name="icon">
1289-
<iconset theme="document-open"/>
1318+
<iconset theme="edit-clear"/>
12901319
</property>
1291-
<property name="iconSize">
1292-
<size>
1293-
<width>16</width>
1294-
<height>16</height>
1295-
</size>
1320+
<property name="flat">
1321+
<bool>true</bool>
12961322
</property>
12971323
</widget>
12981324
</item>
@@ -1733,7 +1759,7 @@
17331759
<x>0</x>
17341760
<y>0</y>
17351761
<width>624</width>
1736-
<height>68</height>
1762+
<height>101</height>
17371763
</rect>
17381764
</property>
17391765
<layout class="QVBoxLayout" name="verticalLayout_6">

0 commit comments

Comments
 (0)
Please sign in to comment.