Skip to content
Snippets Groups Projects
Unverified Commit c08da2d6 authored by liamwhite's avatar liamwhite Committed by GitHub
Browse files

Merge pull request #11792 from boludoz/new-shortcut

Improved shortcut: add games in applist for Windows, question for sta…
parents 44589207 c9038af2
No related branches found
No related tags found
No related merge requests found
...@@ -567,9 +567,10 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri ...@@ -567,9 +567,10 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
QAction* verify_integrity = context_menu.addAction(tr("Verify Integrity")); QAction* verify_integrity = context_menu.addAction(tr("Verify Integrity"));
QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard")); QAction* copy_tid = context_menu.addAction(tr("Copy Title ID to Clipboard"));
QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry")); QAction* navigate_to_gamedb_entry = context_menu.addAction(tr("Navigate to GameDB entry"));
// TODO: Implement shortcut creation for macOS
#if !defined(__APPLE__)
QMenu* shortcut_menu = context_menu.addMenu(tr("Create Shortcut")); QMenu* shortcut_menu = context_menu.addMenu(tr("Create Shortcut"));
QAction* create_desktop_shortcut = shortcut_menu->addAction(tr("Add to Desktop")); QAction* create_desktop_shortcut = shortcut_menu->addAction(tr("Add to Desktop"));
#ifndef WIN32
QAction* create_applications_menu_shortcut = QAction* create_applications_menu_shortcut =
shortcut_menu->addAction(tr("Add to Applications Menu")); shortcut_menu->addAction(tr("Add to Applications Menu"));
#endif #endif
...@@ -647,10 +648,11 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri ...@@ -647,10 +648,11 @@ void GameList::AddGamePopup(QMenu& context_menu, u64 program_id, const std::stri
connect(navigate_to_gamedb_entry, &QAction::triggered, [this, program_id]() { connect(navigate_to_gamedb_entry, &QAction::triggered, [this, program_id]() {
emit NavigateToGamedbEntryRequested(program_id, compatibility_list); emit NavigateToGamedbEntryRequested(program_id, compatibility_list);
}); });
// TODO: Implement shortcut creation for macOS
#if !defined(__APPLE__)
connect(create_desktop_shortcut, &QAction::triggered, [this, program_id, path]() { connect(create_desktop_shortcut, &QAction::triggered, [this, program_id, path]() {
emit CreateShortcut(program_id, path, GameListShortcutTarget::Desktop); emit CreateShortcut(program_id, path, GameListShortcutTarget::Desktop);
}); });
#ifndef WIN32
connect(create_applications_menu_shortcut, &QAction::triggered, [this, program_id, path]() { connect(create_applications_menu_shortcut, &QAction::triggered, [this, program_id, path]() {
emit CreateShortcut(program_id, path, GameListShortcutTarget::Applications); emit CreateShortcut(program_id, path, GameListShortcutTarget::Applications);
}); });
......
This diff is collapsed.
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <filesystem>
#include <QMainWindow> #include <QMainWindow>
#include <QMessageBox> #include <QMessageBox>
#include <QPushButton> #include <QPushButton>
...@@ -174,6 +175,13 @@ class GMainWindow : public QMainWindow { ...@@ -174,6 +175,13 @@ class GMainWindow : public QMainWindow {
UI_EMU_STOPPING, UI_EMU_STOPPING,
}; };
enum {
CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES,
CREATE_SHORTCUT_MSGBOX_SUCCESS,
CREATE_SHORTCUT_MSGBOX_ERROR,
CREATE_SHORTCUT_MSGBOX_APPVOLATILE_WARNING,
};
public: public:
void filterBarSetChecked(bool state); void filterBarSetChecked(bool state);
void UpdateUITheme(); void UpdateUITheme();
...@@ -456,11 +464,14 @@ private: ...@@ -456,11 +464,14 @@ private:
bool ConfirmShutdownGame(); bool ConfirmShutdownGame();
QString GetTasStateDescription() const; QString GetTasStateDescription() const;
bool CreateShortcut(const std::string& shortcut_path, const std::string& title, bool CreateShortcutMessagesGUI(QWidget* parent, int imsg, const QString& game_title);
const std::string& comment, const std::string& icon_path, bool MakeShortcutIcoPath(const u64 program_id, const std::string_view game_file_name,
const std::string& command, const std::string& arguments, std::filesystem::path& out_icon_path);
const std::string& categories, const std::string& keywords); bool CreateShortcutLink(const std::filesystem::path& shortcut_path, const std::string& comment,
const std::filesystem::path& icon_path,
const std::filesystem::path& command, const std::string& arguments,
const std::string& categories, const std::string& keywords,
const std::string& name);
/** /**
* Mimic the behavior of QMessageBox::question but link controller navigation to the dialog * Mimic the behavior of QMessageBox::question but link controller navigation to the dialog
* The only difference is that it returns a boolean. * The only difference is that it returns a boolean.
......
...@@ -42,7 +42,7 @@ QPixmap CreateCirclePixmapFromColor(const QColor& color) { ...@@ -42,7 +42,7 @@ QPixmap CreateCirclePixmapFromColor(const QColor& color) {
return circle_pixmap; return circle_pixmap;
} }
bool SaveIconToFile(const std::string_view path, const QImage& image) { bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image) {
#if defined(WIN32) #if defined(WIN32)
#pragma pack(push, 2) #pragma pack(push, 2)
struct IconDir { struct IconDir {
...@@ -73,7 +73,7 @@ bool SaveIconToFile(const std::string_view path, const QImage& image) { ...@@ -73,7 +73,7 @@ bool SaveIconToFile(const std::string_view path, const QImage& image) {
.id_count = static_cast<WORD>(scale_sizes.size()), .id_count = static_cast<WORD>(scale_sizes.size()),
}; };
Common::FS::IOFile icon_file(path, Common::FS::FileAccessMode::Write, Common::FS::IOFile icon_file(icon_path.string(), Common::FS::FileAccessMode::Write,
Common::FS::FileType::BinaryFile); Common::FS::FileType::BinaryFile);
if (!icon_file.IsOpen()) { if (!icon_file.IsOpen()) {
return false; return false;
...@@ -134,6 +134,14 @@ bool SaveIconToFile(const std::string_view path, const QImage& image) { ...@@ -134,6 +134,14 @@ bool SaveIconToFile(const std::string_view path, const QImage& image) {
} }
icon_file.Close(); icon_file.Close();
return true;
#elif defined(__linux__) || defined(__FreeBSD__)
// Convert and write the icon as a PNG
if (!image.save(QString::fromStdString(icon_path.string()))) {
LOG_ERROR(Frontend, "Could not write icon as PNG to file");
} else {
LOG_INFO(Frontend, "Wrote an icon to {}", icon_path.string());
}
return true; return true;
#else #else
return false; return false;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#pragma once #pragma once
#include <filesystem>
#include <QFont> #include <QFont>
#include <QString> #include <QString>
...@@ -25,4 +26,4 @@ ...@@ -25,4 +26,4 @@
* @param image The image to save * @param image The image to save
* @return bool If the operation succeeded * @return bool If the operation succeeded
*/ */
[[nodiscard]] bool SaveIconToFile(const std::string_view path, const QImage& image); [[nodiscard]] bool SaveIconToFile(const std::filesystem::path& icon_path, const QImage& image);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment