Skip to content

Commit

Permalink
qt_gui: Fix shortcut's name got cut off in some cases
Browse files Browse the repository at this point in the history
Example: P.T. -> P
  • Loading branch information
ngoquang2708 committed Jan 10, 2025
1 parent 562ed2a commit bb82a1d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/qt_gui/gui_context_menus.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class GuiContextMenus : public QObject {
#ifdef Q_OS_WIN
if (createShortcutWin(linkPath, ebootPath, icoPath, exePath)) {
#else
if (createShortcutLinux(linkPath, ebootPath, iconPath)) {
if (createShortcutLinux(linkPath, m_games[itemID].name, ebootPath, iconPath)) {
#endif
QMessageBox::information(
nullptr, tr("Shortcut creation"),
Expand All @@ -301,7 +301,7 @@ class GuiContextMenus : public QObject {
#ifdef Q_OS_WIN
if (createShortcutWin(linkPath, ebootPath, iconPath, exePath)) {
#else
if (createShortcutLinux(linkPath, ebootPath, iconPath)) {
if (createShortcutLinux(linkPath, m_games[itemID].name, ebootPath, iconPath)) {
#endif
QMessageBox::information(
nullptr, tr("Shortcut creation"),
Expand Down Expand Up @@ -510,8 +510,8 @@ class GuiContextMenus : public QObject {
return SUCCEEDED(hres);
}
#else
bool createShortcutLinux(const QString& linkPath, const QString& targetPath,
const QString& iconPath) {
bool createShortcutLinux(const QString& linkPath, const std::string& name,
const QString& targetPath, const QString& iconPath) {
QFile shortcutFile(linkPath);
if (!shortcutFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(nullptr, "Error",
Expand All @@ -522,7 +522,7 @@ class GuiContextMenus : public QObject {
QTextStream out(&shortcutFile);
out << "[Desktop Entry]\n";
out << "Version=1.0\n";
out << "Name=" << QFileInfo(linkPath).baseName() << "\n";
out << "Name=" << QString::fromStdString(name) << "\n";
out << "Exec=" << QCoreApplication::applicationFilePath() << " \"" << targetPath << "\"\n";
out << "Icon=" << iconPath << "\n";
out << "Terminal=false\n";
Expand Down

0 comments on commit bb82a1d

Please sign in to comment.