Qt: Misc Shortcut Cleanups

This commit is contained in:
KamFretoZ 2025-12-07 11:21:11 +07:00 committed by Ty
parent eb50aaea35
commit 4d2c1a82c9
5 changed files with 47 additions and 29 deletions

View File

@ -28,7 +28,7 @@
#endif #endif
#if defined(_WIN32) #if defined(_WIN32)
#include "RedtapeWindows.h" #include "common/RedtapeWindows.h"
#include <io.h> #include <io.h>
#include <malloc.h> #include <malloc.h>
#include <pathcch.h> #include <pathcch.h>

View File

@ -1734,8 +1734,8 @@ void MainWindow::onCreateGameShortcutTriggered()
const QString title = QString::fromStdString(entry->GetTitle()); const QString title = QString::fromStdString(entry->GetTitle());
const QString path = QString::fromStdString(entry->path); const QString path = QString::fromStdString(entry->path);
VMLock lock(pauseAndLockVM());
ShortcutCreationDialog dlg(lock.getDialogParent(), title, path); ShortcutCreationDialog dlg(this, title, path);
dlg.exec(); dlg.exec();
} }
#endif #endif

View File

@ -13,7 +13,7 @@
#include "VMManager.h" #include "VMManager.h"
#if defined(_WIN32) #if defined(_WIN32)
#include <Windows.h> #include "common/RedtapeWindows.h"
#include <shlobj.h> #include <shlobj.h>
#include <winnls.h> #include <winnls.h>
#include <shobjidl.h> #include <shobjidl.h>
@ -61,16 +61,6 @@ ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& t
connect(m_ui.bootOptionToggle, &QCheckBox::toggled, m_ui.bootOptionDropdown, &QPushButton::setEnabled); connect(m_ui.bootOptionToggle, &QCheckBox::toggled, m_ui.bootOptionDropdown, &QPushButton::setEnabled);
connect(m_ui.fullscreenMode, &QCheckBox::toggled, m_ui.fullscreenModeDropdown, &QPushButton::setEnabled); connect(m_ui.fullscreenMode, &QCheckBox::toggled, m_ui.fullscreenModeDropdown, &QPushButton::setEnabled);
m_ui.shortcutDesktop->setChecked(true);
m_ui.overrideBootELFPath->setEnabled(false);
m_ui.overrideBootELFButton->setEnabled(false);
m_ui.gameArgs->setEnabled(false);
m_ui.bootOptionDropdown->setEnabled(false);
m_ui.fullscreenModeDropdown->setEnabled(false);
m_ui.loadStateIndex->setEnabled(false);
m_ui.loadStateFileBrowse->setEnabled(false);
m_ui.loadStateFilePath->setEnabled(false);
m_ui.loadStateIndex->setMaximum(VMManager::NUM_SAVE_STATE_SLOTS); m_ui.loadStateIndex->setMaximum(VMManager::NUM_SAVE_STATE_SLOTS);
if (std::getenv("container")) if (std::getenv("container"))
@ -80,6 +70,7 @@ ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& t
m_ui.shortcutStartMenu->setEnabled(false); m_ui.shortcutStartMenu->setEnabled(false);
} }
connect(m_ui.dialogButtons, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(m_ui.dialogButtons, &QDialogButtonBox::accepted, this, [&]() { connect(m_ui.dialogButtons, &QDialogButtonBox::accepted, this, [&]() {
std::vector<std::string> args; std::vector<std::string> args;
@ -111,7 +102,6 @@ ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& t
} }
} }
if (m_ui.loadStateFileToggle->isChecked())
if (m_ui.loadStateFileToggle->isChecked() && !m_ui.loadStateFilePath->text().isEmpty()) if (m_ui.loadStateFileToggle->isChecked() && !m_ui.loadStateFilePath->text().isEmpty())
{ {
args.push_back("-statefile"); args.push_back("-statefile");
@ -124,15 +114,12 @@ ShortcutCreationDialog::ShortcutCreationDialog(QWidget* parent, const QString& t
if (m_ui.bigPictureModeToggle->isChecked()) if (m_ui.bigPictureModeToggle->isChecked())
args.push_back("-bigpicture"); args.push_back("-bigpicture");
m_desktop = m_ui.shortcutDesktop->isChecked();
std::string custom_args = m_ui.customArgsInput->text().toStdString(); std::string custom_args = m_ui.customArgsInput->text().toStdString();
ShortcutCreationDialog::CreateShortcut(title.toStdString(), path.toStdString(), args, custom_args, m_desktop); ShortcutCreationDialog::CreateShortcut(title.toStdString(), path.toStdString(), args, custom_args, m_ui.shortcutDesktop->isChecked());
accept(); accept();
}); });
connect(m_ui.dialogButtons, &QDialogButtonBox::rejected, this, &QDialog::reject);
} }
void ShortcutCreationDialog::CreateShortcut(const std::string name, const std::string game_path, std::vector<std::string> passed_cli_args, std::string custom_args, bool is_desktop) void ShortcutCreationDialog::CreateShortcut(const std::string name, const std::string game_path, std::vector<std::string> passed_cli_args, std::string custom_args, bool is_desktop)
@ -190,7 +177,10 @@ void ShortcutCreationDialog::CreateShortcut(const std::string name, const std::s
lossless &= ShortcutCreationDialog::EscapeShortcutCommandLine(&arg); lossless &= ShortcutCreationDialog::EscapeShortcutCommandLine(&arg);
if (!lossless) if (!lossless)
QMessageBox::warning(this, tr("Failed to create shortcut"), tr("File path contains invalid character(s). The resulting shortcut may not work."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); {
QMessageBox::warning(this, tr("Failed to create shortcut"), tr("File path contains invalid character(s)."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok);
return;
}
ShortcutCreationDialog::EscapeShortcutCommandLine(&clean_path); ShortcutCreationDialog::EscapeShortcutCommandLine(&clean_path);
std::string combined_args = StringUtil::JoinString(passed_cli_args.begin(), passed_cli_args.end(), " "); std::string combined_args = StringUtil::JoinString(passed_cli_args.begin(), passed_cli_args.end(), " ");
@ -344,7 +334,7 @@ void ShortcutCreationDialog::CreateShortcut(const std::string name, const std::s
} }
else else
{ {
QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Home path is empty."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok); QMessageBox::critical(this, tr("Failed to create shortcut"), tr("Path to the Home directory is empty."), QMessageBox::StandardButton::Ok, QMessageBox::StandardButton::Ok);
return; return;
} }

View File

@ -22,8 +22,9 @@ public:
bool EscapeShortcutCommandLine(std::string* cmdline); bool EscapeShortcutCommandLine(std::string* cmdline);
protected: protected:
QString m_title; const QString m_title;
QString m_path; const QString m_path;
bool m_desktop;
private:
Ui::ShortcutCreationDialog m_ui; Ui::ShortcutCreationDialog m_ui;
}; };

View File

@ -10,7 +10,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>500</width> <width>500</width>
<height>685</height> <height>700</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="shortcutLayout"> <layout class="QGridLayout" name="shortcutLayout">
@ -59,6 +59,9 @@
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QComboBox" name="fullscreenModeDropdown"> <widget class="QComboBox" name="fullscreenModeDropdown">
<property name="enabled">
<bool>false</bool>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Force Enable</string> <string>Force Enable</string>
@ -82,10 +85,17 @@
</widget> </widget>
</item> </item>
<item row="3" column="2" colspan="2"> <item row="3" column="2" colspan="2">
<widget class="QLineEdit" name="gameArgs"/> <widget class="QLineEdit" name="gameArgs">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item> </item>
<item row="4" column="2" colspan="2"> <item row="4" column="2" colspan="2">
<widget class="QComboBox" name="bootOptionDropdown"> <widget class="QComboBox" name="bootOptionDropdown">
<property name="enabled">
<bool>false</bool>
</property>
<item> <item>
<property name="text"> <property name="text">
<string>Fast Boot</string> <string>Fast Boot</string>
@ -107,13 +117,20 @@
</item> </item>
<item row="2" column="3"> <item row="2" column="3">
<widget class="QPushButton" name="overrideBootELFButton"> <widget class="QPushButton" name="overrideBootELFButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Browse...</string> <string>Browse...</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QLineEdit" name="overrideBootELFPath"/> <widget class="QLineEdit" name="overrideBootELFPath">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item> </item>
<item row="10" column="0" colspan="4"> <item row="10" column="0" colspan="4">
<widget class="QGroupBox" name="saveStateGroup"> <widget class="QGroupBox" name="saveStateGroup">
@ -123,6 +140,9 @@
<layout class="QGridLayout" name="savestateGridLayout"> <layout class="QGridLayout" name="savestateGridLayout">
<item row="1" column="1"> <item row="1" column="1">
<widget class="QSpinBox" name="loadStateIndex"> <widget class="QSpinBox" name="loadStateIndex">
<property name="enabled">
<bool>false</bool>
</property>
<property name="showGroupSeparator" stdset="0"> <property name="showGroupSeparator" stdset="0">
<bool>false</bool> <bool>false</bool>
</property> </property>
@ -132,7 +152,11 @@
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="loadStateFilePath"/> <widget class="QLineEdit" name="loadStateFilePath">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QRadioButton" name="loadStateNone"> <widget class="QRadioButton" name="loadStateNone">
@ -160,6 +184,9 @@
</item> </item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QPushButton" name="loadStateFileBrowse"> <widget class="QPushButton" name="loadStateFileBrowse">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text"> <property name="text">
<string>Browse...</string> <string>Browse...</string>
</property> </property>
@ -194,7 +221,7 @@
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="customArgsInstruction"> <widget class="QLabel" name="customArgsInstruction">
<property name="text"> <property name="text">
<string>You may add additional (space-separated) &lt;a href=&quot;https://pcsx2.net/docs/post/cli/&quot;&gt;custom arguments&lt;/a&gt; that are not listed above here:</string> <string>You may add additional (space-separated) &lt;a href=&quot;https://pcsx2.net/docs/advanced/cli/&quot;&gt;custom arguments&lt;/a&gt; that are not listed above here:</string>
</property> </property>
<property name="textFormat"> <property name="textFormat">
<enum>Qt::TextFormat::RichText</enum> <enum>Qt::TextFormat::RichText</enum>