Skip to content

Commit 71edbd3

Browse files
committed
Qt: Add steam shortcuts
1 parent e6cf05c commit 71edbd3

15 files changed

Lines changed: 1003 additions & 55 deletions

rpcs3/rpcs3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ std::set<std::string> get_one_drive_paths()
131131
do
132132
{
133133
path_buffer.resize(path_buffer.size() + MAX_PATH);
134-
DWORD buffer_size = static_cast<DWORD>(path_buffer.size() - 1);
134+
DWORD buffer_size = static_cast<DWORD>((path_buffer.size() - 1) * sizeof(wchar_t));
135135
status = RegQueryValueExW(hkey, L"UserFolder", NULL, &type, reinterpret_cast<LPBYTE>(path_buffer.data()), &buffer_size);
136136
}
137137
while (status == ERROR_MORE_DATA);

rpcs3/rpcs3.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@
891891
<ClCompile Include="rpcs3qt\shortcut_settings.cpp" />
892892
<ClCompile Include="rpcs3qt\shortcut_utils.cpp" />
893893
<ClCompile Include="rpcs3qt\skylander_dialog.cpp" />
894+
<ClCompile Include="rpcs3qt\steam_utils.cpp" />
894895
<ClCompile Include="rpcs3qt\system_cmd_dialog.cpp" />
895896
<ClCompile Include="rpcs3qt\table_item_delegate.cpp" />
896897
<ClCompile Include="rpcs3qt\tooltips.cpp" />
@@ -1719,6 +1720,7 @@
17191720
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\QTGeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -D_WINDOWS -DUNICODE -DWIN32 -DWIN64 -DWIN32_LEAN_AND_MEAN -DHAVE_VULKAN -DMINIUPNP_STATICLIB -DHAVE_SDL3 -DWITH_DISCORD_RPC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DNDEBUG -DQT_CONCURRENT_LIB -DQT_MULTIMEDIA_LIB -DQT_MULTIMEDIAWIDGETS_LIB -DQT_SVG_LIB -D%(PreprocessorDefinitions) "-I.\..\3rdparty\SoundTouch\soundtouch\include" "-I.\..\3rdparty\cubeb\extra" "-I.\..\3rdparty\cubeb\cubeb\include" "-I.\..\3rdparty\protobuf\protobuf\src" "-I.\..\3rdparty\wolfssl\wolfssl" "-I.\..\3rdparty\curl\curl\include" "-I.\..\3rdparty\libusb\libusb\libusb" "-I$(VULKAN_SDK)\Include" "-I.\..\3rdparty\libsdl-org\SDL\include" "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtWidgets" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtCore" "-I.\release" "-I.\QTGeneratedFiles\$(ConfigurationName)" "-I.\QTGeneratedFiles" "-I$(QTDIR)\include\QtConcurrent" "-I$(QTDIR)\include\QtMultimedia" "-I$(QTDIR)\include\QtMultimediaWidgets" "-I$(QTDIR)\include\QtSvg"</Command>
17201721
</CustomBuild>
17211722
<ClInclude Include="rpcs3qt\shortcut_utils.h" />
1723+
<ClInclude Include="rpcs3qt\steam_utils.h" />
17221724
<ClInclude Include="rpcs3qt\stylesheets.h" />
17231725
<CustomBuild Include="rpcs3qt\skylander_dialog.h">
17241726
<AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(QTDIR)\bin\moc.exe;%(FullPath)</AdditionalInputs>

rpcs3/rpcs3.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,9 @@
12781278
<ClCompile Include="rpcs3qt\log_level_dialog.cpp">
12791279
<Filter>Gui\settings</Filter>
12801280
</ClCompile>
1281+
<ClCompile Include="rpcs3qt\steam_utils.cpp">
1282+
<Filter>Gui\utils</Filter>
1283+
</ClCompile>
12811284
</ItemGroup>
12821285
<ItemGroup>
12831286
<ClInclude Include="Input\ds4_pad_handler.h">
@@ -1523,6 +1526,9 @@
15231526
<ClInclude Include="rpcs3qt\log_level_dialog.h">
15241527
<Filter>Gui\settings</Filter>
15251528
</ClInclude>
1529+
<ClInclude Include="rpcs3qt\steam_utils.h">
1530+
<Filter>Gui\utils</Filter>
1531+
</ClInclude>
15261532
</ItemGroup>
15271533
<ItemGroup>
15281534
<ClInclude Include="resource.h">

rpcs3/rpcs3qt/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ add_library(rpcs3_ui STATIC
104104
shortcut_settings.cpp
105105
skylander_dialog.cpp
106106
sound_effect_manager_dialog.cpp
107+
steam_utils.cpp
107108
syntax_highlighter.cpp
108109
system_cmd_dialog.cpp
109110
table_item_delegate.cpp

rpcs3/rpcs3qt/debugger_frame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ void debugger_frame::UpdateUnitList()
10931093
idm::select<named_thread<ppu_thread>>(on_select, idm::unlocked);
10941094
}
10951095

1096-
m_hw_ppu_idx = cpu_list.size() + 1; // Account for NoThreadString thread
1096+
m_hw_ppu_idx = ::size32(cpu_list) + 1; // Account for NoThreadString thread
10971097

10981098
for (u32 i = 0; i < g_cfg.core.ppu_threads + 0u; i++)
10991099
{

rpcs3/rpcs3qt/game_list_actions.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1507,7 +1507,7 @@ void game_list_actions::CreateShortcuts(const std::vector<game_info>& games, con
15071507
continue;
15081508
}
15091509

1510-
for (const gui::utils::shortcut_location& location : locations)
1510+
for (gui::utils::shortcut_location location : locations)
15111511
{
15121512
std::string destination;
15131513

@@ -1519,6 +1519,9 @@ void game_list_actions::CreateShortcuts(const std::vector<game_info>& games, con
15191519
case gui::utils::shortcut_location::applications:
15201520
destination = "application menu";
15211521
break;
1522+
case gui::utils::shortcut_location::steam:
1523+
destination = "Steam";
1524+
break;
15221525
#ifdef _WIN32
15231526
case gui::utils::shortcut_location::rpcs3_shortcuts:
15241527
destination = "/games/shortcuts/";

rpcs3/rpcs3qt/game_list_context_menu.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "input_dialog.h"
77
#include "qt_utils.h"
88
#include "shortcut_utils.h"
9+
#include "steam_utils.h"
910
#include "settings_dialog.h"
1011
#include "pad_settings_dialog.h"
1112
#include "patch_manager_dialog.h"
@@ -273,6 +274,7 @@ void game_list_context_menu::show_single_selection_context_menu(const game_info&
273274
{
274275
m_game_list_actions->CreateShortcuts({gameinfo}, {gui::utils::shortcut_location::desktop});
275276
});
277+
276278
#ifdef _WIN32
277279
QAction* create_start_menu_shortcut = manage_game_menu->addAction(tr("&Create Start Menu Shortcut"));
278280
#elif defined(__APPLE__)
@@ -285,6 +287,16 @@ void game_list_context_menu::show_single_selection_context_menu(const game_info&
285287
m_game_list_actions->CreateShortcuts({gameinfo}, {gui::utils::shortcut_location::applications});
286288
});
287289

290+
if constexpr (gui::utils::steam_supported())
291+
{
292+
QAction* create_steam_shortcut = manage_game_menu->addAction(tr("&Create Steam Shortcut"));
293+
connect(create_steam_shortcut, &QAction::triggered, this, [this, gameinfo]()
294+
{
295+
m_game_list_actions->CreateShortcuts({gameinfo}, {gui::utils::shortcut_location::steam});
296+
});
297+
create_steam_shortcut->setEnabled(gui::utils::steam_shortcut::steam_installed());
298+
}
299+
288300
manage_game_menu->addSeparator();
289301

290302
// Hide/rename game in game list
@@ -843,6 +855,16 @@ void game_list_context_menu::show_multi_selection_context_menu(const std::vector
843855
m_game_list_actions->CreateShortcuts(games, {gui::utils::shortcut_location::applications});
844856
});
845857

858+
if constexpr (gui::utils::steam_supported())
859+
{
860+
QAction* create_steam_shortcut = manage_game_menu->addAction(tr("&Create Steam Shortcut"));
861+
connect(create_steam_shortcut, &QAction::triggered, this, [this, games]()
862+
{
863+
m_game_list_actions->CreateShortcuts(games, {gui::utils::shortcut_location::steam});
864+
});
865+
create_steam_shortcut->setEnabled(gui::utils::steam_shortcut::steam_installed());
866+
}
867+
846868
manage_game_menu->addSeparator();
847869

848870
// Hide game in game list

rpcs3/rpcs3qt/main_window.cpp

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
#include "camera_settings_dialog.h"
3636
#include "ps_move_tracker_dialog.h"
3737
#include "ipc_settings_dialog.h"
38-
#include "shortcut_utils.h"
3938
#include "config_checker.h"
4039
#include "shortcut_dialog.h"
40+
#include "steam_utils.h"
4141
#include "system_cmd_dialog.h"
4242
#include "emulated_pad_settings_dialog.h"
4343
#include "emulated_logitech_g27_settings_dialog.h"
@@ -935,9 +935,8 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
935935
}
936936

937937
std::vector<compat::package_info> packages;
938+
std::set<gui::utils::shortcut_location> shortcut_locations;
938939
bool precompile_caches = false;
939-
bool create_desktop_shortcuts = false;
940-
bool create_app_shortcut = false;
941940
bool canceled = false;
942941

943942
game_compatibility* compat = m_game_list_frame ? m_game_list_frame->GetGameCompatibility() : nullptr;
@@ -954,8 +953,15 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
954953

955954
packages = dlg.get_paths_to_install();
956955
precompile_caches = dlg.precompile_caches();
957-
create_desktop_shortcuts = dlg.create_desktop_shortcuts();
958-
create_app_shortcut = dlg.create_app_shortcut();
956+
957+
if (dlg.create_desktop_shortcuts())
958+
shortcut_locations.insert(gui::utils::shortcut_location::desktop);
959+
960+
if (dlg.create_app_shortcut())
961+
shortcut_locations.insert(gui::utils::shortcut_location::applications);
962+
963+
if (dlg.create_steam_shortcut())
964+
shortcut_locations.insert(gui::utils::shortcut_location::steam);
959965
});
960966
dlg.exec();
961967

@@ -1136,7 +1142,7 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
11361142

11371143
if (!bootable_paths_installed.empty())
11381144
{
1139-
m_game_list_frame->AddRefreshedSlot([this, create_desktop_shortcuts, precompile_caches, create_app_shortcut, paths = std::move(bootable_paths_installed)](std::set<std::string>& claimed_paths) mutable
1145+
m_game_list_frame->AddRefreshedSlot([this, shortcut_locations, precompile_caches, paths = std::move(bootable_paths_installed)](std::set<std::string>& claimed_paths) mutable
11401146
{
11411147
// Try to claim operations on ID
11421148
for (auto it = paths.begin(); it != paths.end();)
@@ -1154,7 +1160,7 @@ bool main_window::HandlePackageInstallation(QStringList file_paths, bool from_bo
11541160
}
11551161
}
11561162

1157-
CreateShortCuts(paths, create_desktop_shortcuts, create_app_shortcut);
1163+
CreateShortCuts(paths, shortcut_locations);
11581164

11591165
if (precompile_caches)
11601166
{
@@ -2370,6 +2376,7 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
23702376
#else
23712377
QCheckBox* quick_check = new QCheckBox(tr("Add launcher shortcut(s)"));
23722378
#endif
2379+
QCheckBox* steam_check = nullptr;
23732380
QLabel* label = new QLabel(tr("%1\nWould you like to precompile caches and install shortcuts to the installed software? (%2 new software detected)\n\n").arg(message).arg(bootable_paths.size()), dlg);
23742381

23752382
vlayout->addWidget(label);
@@ -2381,6 +2388,13 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
23812388
vlayout->addWidget(quick_check);
23822389
vlayout->addStretch(3);
23832390

2391+
if constexpr (gui::utils::steam_supported())
2392+
{
2393+
steam_check = new QCheckBox(tr("Add Steam shortcut(s)"));
2394+
vlayout->addWidget(steam_check);
2395+
vlayout->addStretch(3);
2396+
}
2397+
23842398
QDialogButtonBox* btn_box = new QDialogButtonBox(QDialogButtonBox::Ok);
23852399

23862400
vlayout->addWidget(btn_box);
@@ -2389,13 +2403,22 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
23892403
connect(btn_box, &QDialogButtonBox::accepted, this, [=, this, paths = std::move(bootable_paths)]()
23902404
{
23912405
const bool precompile_caches = precompile_check->isChecked();
2392-
const bool create_desktop_shortcuts = desk_check->isChecked();
2393-
const bool create_app_shortcut = quick_check->isChecked();
2406+
2407+
std::set<gui::utils::shortcut_location> shortcut_locations;
2408+
2409+
if (desk_check->isChecked())
2410+
shortcut_locations.insert(gui::utils::shortcut_location::desktop);
2411+
2412+
if (quick_check->isChecked())
2413+
shortcut_locations.insert(gui::utils::shortcut_location::applications);
2414+
2415+
if (steam_check && steam_check->isChecked())
2416+
shortcut_locations.insert(gui::utils::shortcut_location::steam);
23942417

23952418
dlg->hide();
23962419
dlg->accept();
23972420

2398-
CreateShortCuts(paths, create_desktop_shortcuts, create_app_shortcut);
2421+
CreateShortCuts(paths, shortcut_locations);
23992422

24002423
if (precompile_caches)
24012424
{
@@ -2407,52 +2430,40 @@ void main_window::ShowOptionalGamePreparations(const QString& title, const QStri
24072430
dlg->open();
24082431
}
24092432

2410-
void main_window::CreateShortCuts(const std::map<std::string, QString>& paths, bool create_desktop_shortcuts, bool create_app_shortcut)
2433+
void main_window::CreateShortCuts(const std::map<std::string, QString>& paths, std::set<gui::utils::shortcut_location> locations)
24112434
{
24122435
if (paths.empty()) return;
24132436

2414-
std::set<gui::utils::shortcut_location> locations;
2415-
24162437
#ifdef _WIN32
24172438
locations.insert(gui::utils::shortcut_location::rpcs3_shortcuts);
2418-
#endif
2419-
if (create_desktop_shortcuts)
2439+
#else
2440+
if (locations.empty())
24202441
{
2421-
locations.insert(gui::utils::shortcut_location::desktop);
2442+
return;
24222443
}
2444+
#endif
24232445

2424-
if (create_app_shortcut)
2425-
{
2426-
locations.insert(gui::utils::shortcut_location::applications);
2427-
}
2446+
std::vector<game_info> game_data_shortcuts;
24282447

2429-
if (!locations.empty())
2448+
for (const auto& [boot_path, title_id] : paths)
24302449
{
2431-
std::vector<game_info> game_data_shortcuts;
2432-
2433-
for (const auto& [boot_path, title_id] : paths)
2450+
for (const game_info& gameinfo : m_game_list_frame->GetGameInfo())
24342451
{
2435-
for (const game_info& gameinfo : m_game_list_frame->GetGameInfo())
2452+
if (gameinfo && gameinfo->info.serial == title_id.toStdString())
24362453
{
2437-
if (gameinfo && gameinfo->info.serial == title_id.toStdString())
2454+
if (Emu.IsPathInsideDir(boot_path, gameinfo->info.path))
24382455
{
2439-
if (Emu.IsPathInsideDir(boot_path, gameinfo->info.path))
2440-
{
2441-
if (!locations.empty())
2442-
{
2443-
game_data_shortcuts.push_back(gameinfo);
2444-
}
2445-
}
2446-
2447-
break;
2456+
game_data_shortcuts.push_back(gameinfo);
24482457
}
2458+
2459+
break;
24492460
}
24502461
}
2462+
}
24512463

2452-
if (!game_data_shortcuts.empty() && !locations.empty())
2453-
{
2454-
m_game_list_frame->actions()->CreateShortcuts(game_data_shortcuts, locations);
2455-
}
2464+
if (!game_data_shortcuts.empty())
2465+
{
2466+
m_game_list_frame->actions()->CreateShortcuts(game_data_shortcuts, locations);
24562467
}
24572468
}
24582469

rpcs3/rpcs3qt/main_window.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "update_manager.h"
1111
#include "settings.h"
1212
#include "shortcut_handler.h"
13+
#include "shortcut_utils.h"
1314
#include "Emu/config_mode.h"
1415
#include "Emu/System.h"
1516

@@ -145,7 +146,7 @@ private Q_SLOTS:
145146
static bool InstallFileInExData(const std::string& extension, const QString& path, const std::string& filename);
146147

147148
bool HandlePackageInstallation(QStringList file_paths, bool from_boot);
148-
void CreateShortCuts(const std::map<std::string, QString>& paths, bool create_desktop_shortcuts, bool create_app_shortcut);
149+
void CreateShortCuts(const std::map<std::string, QString>& paths, std::set<gui::utils::shortcut_location> locations);
149150

150151
void HandlePupInstallation(const QString& file_path, const QString& dir_path = "");
151152
void ExtractPup();

rpcs3/rpcs3qt/pkg_install_dialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "numbered_widget_item.h"
44
#include "richtext_item_delegate.h"
55
#include "qt_utils.h"
6+
#include "steam_utils.h"
67

78
#include "Emu/system_utils.hpp"
89
#include "Utilities/File.h"
@@ -186,6 +187,13 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
186187
#endif
187188
connect(quick_check, &QCheckBox::checkStateChanged, this, [this](Qt::CheckState state){ m_create_app_shortcut = state != Qt::CheckState::Unchecked; });
188189

190+
QCheckBox* steam_check = nullptr;
191+
if constexpr (gui::utils::steam_supported())
192+
{
193+
steam_check = new QCheckBox(tr("Add Steam shortcut(s)"));
194+
connect(steam_check, &QCheckBox::checkStateChanged, this, [this](Qt::CheckState state){ m_create_steam_shortcut = state != Qt::CheckState::Unchecked; });
195+
}
196+
189197
QVBoxLayout* vbox = new QVBoxLayout;
190198
vbox->addWidget(description);
191199
if (hbox) vbox->addLayout(hbox);
@@ -194,6 +202,10 @@ pkg_install_dialog::pkg_install_dialog(const QStringList& paths, game_compatibil
194202
vbox->addWidget(precompile_check);
195203
vbox->addWidget(desk_check);
196204
vbox->addWidget(quick_check);
205+
if (steam_check)
206+
{
207+
vbox->addWidget(steam_check);
208+
}
197209
vbox->addWidget(installation_info);
198210
vbox->addWidget(buttons);
199211

0 commit comments

Comments
 (0)