Skip to content

Commit

Permalink
Add warning for non-existant file paths in shortcut settings
Browse files Browse the repository at this point in the history
With an appropriate coloring and message to indicate as such.

That's kinda it.
Happy New Year btw lol
  • Loading branch information
SeongGino committed Jan 2, 2025
1 parent 6dbc869 commit 6c97449
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 59 deletions.
17 changes: 17 additions & 0 deletions src/neroprefixsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@ void NeroPrefixSettingsWindow::LoadSettings()
ui->shortcutPath->setText(settings["Path"].toString());
ui->shortcutArgs->setText(settings["Args"].toStringList().join(' '));

if(QFileInfo::exists(settings["Path"].toString().replace("C:/",
NeroFS::GetPrefixesPath().canonicalPath()+'/'+NeroFS::GetCurrentPrefix()+"/drive_c/")))
ui->pathNoExistWarning->setVisible(false);
else {
// adjust font recoloring for light mode (unused, but just in case?)
/* if(this->palette().window().color().value() > this->palette().text().color().value())
ui->shortcutPath->setStyleSheet("color: darkred");
else */
ui->shortcutPath->setStyleSheet("color: red");
}

QDir ico(QString("%1/%2/.icoCache").arg(NeroFS::GetPrefixesPath().path(),
NeroFS::GetCurrentPrefix() ));
if(ico.exists(QString("%1-%2.png").arg(settings["Name"].toString(), currentShortcutHash))) {
Expand Down Expand Up @@ -379,6 +390,12 @@ void NeroPrefixSettingsWindow::on_shortcutPathBtn_clicked()
if(newApp != settings.value("Path").toString())
ui->shortcutPath->setFont(boldFont);
else ui->shortcutPath->setFont(QFont());

// probably assumed that in this decision path, the file is gonna be valid
if(ui->pathNoExistWarning->isVisible()) {
ui->pathNoExistWarning->setVisible(false);
ui->shortcutPath->setStyleSheet("color: gray");
}
}
}

Expand Down
137 changes: 78 additions & 59 deletions src/neroprefixsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -139,76 +139,92 @@
</item>
<item>
<layout class="QGridLayout" name="shortcutFields">
<item row="2" column="0">
<widget class="QLineEdit" name="shortcutPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The current path for this shortcut.&lt;/p&gt;&lt;p&gt;If the path is within the prefix's &lt;span style=&quot; font-style:italic;&quot;&gt;drive_c&lt;/span&gt; folder (or in other words, within the virtual Windows' &lt;span style=&quot; font-style:italic;&quot;&gt;C:/&lt;/span&gt; drive), this shortcut will always be run relative to the path of this current prefix - so if the current prefix changes name or location, but not the application itself, then this shortcut will still work until the application path itself changes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Executable Path</string>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="nameMatchWarning">
<property name="font">
<font>
<pointsize>9</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: gray</string>
</property>
<property name="readOnly">
<bool>true</bool>
<string notr="true">color: red</string>
</property>
<property name="placeholderText">
<string>Path</string>
<property name="text">
<string>Another shortcut with this name already exists!</string>
</property>
<property name="isFor" stdset="0">
<string>Path</string>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="shortcutPathBtn">
<item row="2" column="2">
<widget class="QPushButton" name="openToShortcutPath">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Click to select a new executable for this shortcut.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Click to open the folder linked to this shortcut in the system's file explorer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Select an Executable</string>
<string>Open folder in file explorer</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="document-open"/>
<iconset theme="folder-visiting"/>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="openToShortcutPath">
<item row="4" column="0" colspan="3">
<widget class="QLineEdit" name="shortcutArgs">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Click to open the folder linked to this shortcut in the system's file explorer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter any arguments that gets passed to the executable for this shortcut. These usually allow for enabling hidden or undocumented features of an app, such as borderless windowed modes or fullscreen on launch. Refer to your app's documentation for information on what arguments can be used with it.&lt;/p&gt;&lt;p&gt;If unsure, leave this field blank.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Open folder in file explorer</string>
<string>Shortcut Arguments</string>
</property>
<property name="text">
<string/>
<property name="placeholderText">
<string>Shortcut Arguments (-fullscreen, --borderless, etc.)</string>
</property>
<property name="icon">
<iconset theme="folder-visiting"/>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
<property name="isFor" stdset="0">
<string>Args</string>
</property>
<property name="flat">
</widget>
</item>
<item row="2" column="0">
<widget class="QLineEdit" name="shortcutPath">
<property name="enabled">
<bool>true</bool>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The current path for this shortcut.&lt;/p&gt;&lt;p&gt;If the path is within the prefix's &lt;span style=&quot; font-style:italic;&quot;&gt;drive_c&lt;/span&gt; folder (or in other words, within the virtual Windows' &lt;span style=&quot; font-style:italic;&quot;&gt;C:/&lt;/span&gt; drive), this shortcut will always be run relative to the path of this current prefix - so if the current prefix changes name or location, but not the application itself, then this shortcut will still work until the application path itself changes.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Executable Path</string>
</property>
<property name="styleSheet">
<string notr="true">color: gray</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>Path</string>
</property>
<property name="isFor" stdset="0">
<string>Path</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
Expand All @@ -227,8 +243,30 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QLabel" name="nameMatchWarning">
<item row="2" column="1">
<widget class="QPushButton" name="shortcutPathBtn">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Click to select a new executable for this shortcut.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Select an Executable</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset theme="document-open"/>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QLabel" name="pathNoExistWarning">
<property name="font">
<font>
<pointsize>9</pointsize>
Expand All @@ -239,32 +277,13 @@
<string notr="true">color: red</string>
</property>
<property name="text">
<string>Another shortcut with this name already exists!</string>
<string>File does not exist! Please update the path.</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
<item row="3" column="0" colspan="3">
<widget class="QLineEdit" name="shortcutArgs">
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Enter any arguments that gets passed to the executable for this shortcut. These usually allow for enabling hidden or undocumented features of an app, such as borderless windowed modes or fullscreen on launch. Refer to your app's documentation for information on what arguments can be used with it.&lt;/p&gt;&lt;p&gt;If unsure, leave this field blank.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="accessibleName">
<string>Shortcut Arguments</string>
</property>
<property name="placeholderText">
<string>Shortcut Arguments (-fullscreen, --borderless, etc.)</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
<property name="isFor" stdset="0">
<string>Args</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down

0 comments on commit 6c97449

Please sign in to comment.