Fixes and improvements

This commit is contained in:
boludoz 2023-10-15 03:16:29 -03:00
parent 3062a35eb1
commit 0a75519ab5
3 changed files with 32 additions and 13 deletions

View file

@ -363,13 +363,28 @@ fs::path GetDesktopPath() {
LOG_ERROR(Common_Filesystem, LOG_ERROR(Common_Filesystem,
"[GetDesktopPath] Failed to get the path to the desktop directory"); "[GetDesktopPath] Failed to get the path to the desktop directory");
} }
#else
fs::path shortcut_path = GetHomeDirectory() / "Desktop";
if (fs::exists(shortcut_path)) {
return shortcut_path;
}
#endif
return fs::path{}; return fs::path{};
#else
fs::path shortcut_path{};
// Array of possible desktop
std::vector<std::string> desktop_paths = {
"Desktop", "Escritorio", "Bureau", "Skrivebord", "Plocha",
"Skrivbord", "Desktop", "Рабочий стол", "Pulpit", "Área de Trabalho",
"Робочий стіл", "Bureaublad", "デスクトップ", "桌面", "Pöytä",
"바탕 화면", "바탕 화면", "سطح المكتب", "دسکتاپ", "שולחן עבודה"};
for (auto& path : desktop_paths) {
if (fs::exists(GetHomeDirectory() / path)) {
return path;
}
}
LOG_ERROR(Common_Filesystem,
"[GetDesktopPath] Failed to get the path to the desktop directory");
return shortcut_path;
#endif
} }
fs::path GetAppsShortcutsPath() { fs::path GetAppsShortcutsPath() {
@ -387,16 +402,20 @@ fs::path GetAppsShortcutsPath() {
LOG_ERROR(Common_Filesystem, LOG_ERROR(Common_Filesystem,
"[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts directory"); "[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts directory");
} }
return fs::path{};
#else #else
fs::path shortcut_path = GetHomeDirectory() / ".local/share/applications"; fs::path shortcut_path = GetHomeDirectory() / ".local/share/applications";
if (!fs::exists(shortcut_path)) { if (!fs::exists(shortcut_path)) {
shortcut_path = std::filesystem::path("/usr/share/applications"); shortcut_path = std::filesystem::path("/usr/share/applications");
return shortcut_path; if (!fs::exists(shortcut_path)) {
} else { LOG_ERROR(Common_Filesystem,
return shortcut_path; "[GetAppsShortcutsPath] Failed to get the path to the App Shortcuts "
"directory");
}
} }
#endif
return fs::path{}; return fs::path{};
#endif
} }
// vvvvvvvvvv Deprecated vvvvvvvvvv // // vvvvvvvvvv Deprecated vvvvvvvvvv //

View file

@ -152,7 +152,7 @@ class GMainWindow : public QMainWindow {
UI_EMU_STOPPING, UI_EMU_STOPPING,
}; };
const enum { enum {
CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES, CREATE_SHORTCUT_MSGBOX_FULLSCREEN_YES,
CREATE_SHORTCUT_MSGBOX_SUCCESS, CREATE_SHORTCUT_MSGBOX_SUCCESS,
CREATE_SHORTCUT_MSGBOX_ERROR, CREATE_SHORTCUT_MSGBOX_ERROR,

View file

@ -144,7 +144,7 @@ bool SaveIconToFile(const QImage& image, const std::filesystem::path& icon_path)
} }
return true; return true;
#endif #else
return false; return false;
#endif
} }