diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 07253114f2..255ac1ac84 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -245,6 +245,7 @@ if (ENABLE_QT) endif() if (ENABLE_QT_QML) + set(QML_IMPORT_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "") add_subdirectory(Eden) endif() diff --git a/src/Eden/Config/pages/general/UiGameListPage.qml b/src/Eden/Config/pages/general/UiGameListPage.qml index 1032fd0d82..1c3cbb98e4 100644 --- a/src/Eden/Config/pages/general/UiGameListPage.qml +++ b/src/Eden/Config/pages/general/UiGameListPage.qml @@ -1,6 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later - import QtQuick import QtQuick.Controls import QtQuick.Layouts @@ -15,7 +14,6 @@ PageScrollView { ui.apply() } - // TODO: language, theme ColumnLayout { width: scroll.width - scroll.effectiveScrollBarWidth diff --git a/src/Eden/Config/pages/global/GlobalGeneralPage.qml b/src/Eden/Config/pages/global/GlobalGeneralPage.qml index 54362407b1..6c7fc25694 100644 --- a/src/Eden/Config/pages/global/GlobalGeneralPage.qml +++ b/src/Eden/Config/pages/global/GlobalGeneralPage.qml @@ -1,13 +1,13 @@ + // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later - import QtQuick import Eden.Config GlobalTab { property alias swipe: swipe - tabs: ["General", "Hotkeys", "Game List"] + tabs: ["General", "Game List", "Hotkeys"] GlobalTabSwipeView { id: swipe @@ -15,7 +15,7 @@ GlobalTab { // TODO: platform-specific stuff UiGeneralPage {} - Item {} UiGameListPage {} + Item {} } } diff --git a/src/Eden/Interface/SettingsInterface.h b/src/Eden/Interface/SettingsInterface.h index 178f93fe11..9b1ed5ddd1 100644 --- a/src/Eden/Interface/SettingsInterface.h +++ b/src/Eden/Interface/SettingsInterface.h @@ -15,41 +15,41 @@ namespace SettingsCategories { Q_NAMESPACE enum class Category { - Android = static_cast(Settings::Category::Android), - Audio = static_cast(Settings::Category::Audio), - Core = static_cast(Settings::Category::Core), - Cpu = static_cast(Settings::Category::Cpu), - CpuDebug = static_cast(Settings::Category::CpuDebug), - CpuUnsafe = static_cast(Settings::Category::CpuUnsafe), - Overlay = static_cast(Settings::Category::Overlay), - Renderer = static_cast(Settings::Category::Renderer), - RendererAdvanced = static_cast(Settings::Category::RendererAdvanced), - RendererExtensions = static_cast(Settings::Category::RendererExtensions), - RendererDebug = static_cast(Settings::Category::RendererDebug), - System = static_cast(Settings::Category::System), - SystemAudio = static_cast(Settings::Category::SystemAudio), - DataStorage = static_cast(Settings::Category::DataStorage), - Debugging = static_cast(Settings::Category::Debugging), - DebuggingGraphics = static_cast(Settings::Category::DebuggingGraphics), - GpuDriver = static_cast(Settings::Category::GpuDriver), - Miscellaneous = static_cast(Settings::Category::Miscellaneous), - Network = static_cast(Settings::Category::Network), - WebService = static_cast(Settings::Category::WebService), - AddOns = static_cast(Settings::Category::AddOns), - Controls = static_cast(Settings::Category::Controls), - Ui = static_cast(Settings::Category::Ui), - UiAudio = static_cast(Settings::Category::UiAudio), - UiGeneral = static_cast(Settings::Category::UiGeneral), - UiLayout = static_cast(Settings::Category::UiLayout), - UiGameList = static_cast(Settings::Category::UiGameList), - Screenshots = static_cast(Settings::Category::Screenshots), - Shortcuts = static_cast(Settings::Category::Shortcuts), - Multiplayer = static_cast(Settings::Category::Multiplayer), - Services = static_cast(Settings::Category::Services), - Paths = static_cast(Settings::Category::Paths), - Linux = static_cast(Settings::Category::Linux), - LibraryApplet = static_cast(Settings::Category::LibraryApplet), - MaxEnum = static_cast(Settings::Category::MaxEnum), + Android = u32(Settings::Category::Android), + Audio = u32(Settings::Category::Audio), + Core = u32(Settings::Category::Core), + Cpu = u32(Settings::Category::Cpu), + CpuDebug = u32(Settings::Category::CpuDebug), + CpuUnsafe = u32(Settings::Category::CpuUnsafe), + Overlay = u32(Settings::Category::Overlay), + Renderer = u32(Settings::Category::Renderer), + RendererAdvanced = u32(Settings::Category::RendererAdvanced), + RendererExtensions = u32(Settings::Category::RendererExtensions), + RendererDebug = u32(Settings::Category::RendererDebug), + System = u32(Settings::Category::System), + SystemAudio = u32(Settings::Category::SystemAudio), + DataStorage = u32(Settings::Category::DataStorage), + Debugging = u32(Settings::Category::Debugging), + DebuggingGraphics = u32(Settings::Category::DebuggingGraphics), + GpuDriver = u32(Settings::Category::GpuDriver), + Miscellaneous = u32(Settings::Category::Miscellaneous), + Network = u32(Settings::Category::Network), + WebService = u32(Settings::Category::WebService), + AddOns = u32(Settings::Category::AddOns), + Controls = u32(Settings::Category::Controls), + Ui = u32(Settings::Category::Ui), + UiAudio = u32(Settings::Category::UiAudio), + UiGeneral = u32(Settings::Category::UiGeneral), + UiLayout = u32(Settings::Category::UiLayout), + UiGameList = u32(Settings::Category::UiGameList), + Screenshots = u32(Settings::Category::Screenshots), + Shortcuts = u32(Settings::Category::Shortcuts), + Multiplayer = u32(Settings::Category::Multiplayer), + Services = u32(Settings::Category::Services), + Paths = u32(Settings::Category::Paths), + Linux = u32(Settings::Category::Linux), + LibraryApplet = u32(Settings::Category::LibraryApplet), + MaxEnum = u32(Settings::Category::MaxEnum), }; Q_ENUM_NS(Category) } diff --git a/src/Eden/Native/CMakeLists.txt b/src/Eden/Native/CMakeLists.txt index f778a8d121..37e4066560 100644 --- a/src/Eden/Native/CMakeLists.txt +++ b/src/Eden/Native/CMakeLists.txt @@ -8,6 +8,7 @@ qt_add_executable(eden main.cpp icons.qrc EdenApplication.h EdenApplication.cpp + LibQtCommon.cpp ) set(MODULES diff --git a/src/Eden/Native/LibQtCommon.cpp b/src/Eden/Native/LibQtCommon.cpp new file mode 100644 index 0000000000..8b629bc941 --- /dev/null +++ b/src/Eden/Native/LibQtCommon.cpp @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "CarboxylQuickInterface.h" +#include "CarboxylApplication.h" +#include "qt_common/abstract/frontend.h" + +namespace QtCommon::Frontend { + +StandardButton ShowMessage(Icon icon, const QString& title, const QString& text, + StandardButtons buttons, QObject* parent) { + auto res = g_carboxylApp->interface()->showMessageBox( + CarboxylEnums::Icon(int(icon)), title, text, + QPlatformDialogHelper::StandardButton(int(buttons)), parent); + return StandardButton(res); +} + +const QString GetOpenFileName(const QString& title, const QString& dir, const QString& filter, + QString* selectedFilter, Options options) { + // TODO + // return QFileDialog::getOpenFileName((QWidget *) rootObject, title, dir, filter, + // selectedFilter, QFileDialog::Options(int(options))); + return QString(); +} + +const QString GetSaveFileName(const QString& title, const QString& dir, const QString& filter, + QString* selectedFilter, Options options) { + // return QFileDialog::getSaveFileName((QWidget *) rootObject, title, dir, filter, + // selectedFilter, QFileDialog::Options(int(options))); + return QString(); +} + + +const QString GetExistingDirectory(const QString& caption, const QString& dir, Options options) { + // return QFileDialog::getExistingDirectory((QWidget *) rootObject, caption, dir, + // QFileDialog::Options(int(options))); + return QString(); +} + +} // namespace QtCommon::Frontend diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp index 9bdbdee9c8..558335568c 100644 --- a/src/frontend_common/config.cpp +++ b/src/frontend_common/config.cpp @@ -4,7 +4,8 @@ // SPDX-FileCopyrightText: 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "config.h" +#include +#include #include "common/assert.h" #include "common/fs/fs.h" #include "common/fs/path_util.h" diff --git a/src/qt_common/CMakeLists.txt b/src/qt_common/CMakeLists.txt index 80b6c24723..74118657a9 100644 --- a/src/qt_common/CMakeLists.txt +++ b/src/qt_common/CMakeLists.txt @@ -23,7 +23,7 @@ add_library(qt_common STATIC util/applet.h util/applet.cpp util/compress.h util/compress.cpp - abstract/frontend.h abstract/frontend.cpp + abstract/frontend.h abstract/qt_progress_dialog.h abstract/qt_progress_dialog.cpp qt_string_lookup.h @@ -54,11 +54,6 @@ if (USE_DISCORD_PRESENCE) target_compile_definitions(qt_common PUBLIC USE_DISCORD_PRESENCE) endif() -# TODO(crueter) -if (ENABLE_QT_WIDGETS) - target_link_libraries(qt_common PRIVATE Qt6::Widgets) -endif() - target_compile_definitions(qt_common PUBLIC # Use QStringBuilder for string concatenation to reduce # the overall number of temporary strings created. @@ -87,6 +82,7 @@ find_package(frozen) target_link_libraries(qt_common PRIVATE core input_common) target_link_libraries(qt_common PRIVATE gamemode::headers) target_link_libraries(qt_common PRIVATE Qt6::Core Qt6::Concurrent SimpleIni::SimpleIni QuaZip::QuaZip) +target_link_libraries(qt_common PRIVATE Qt6::Widgets) target_link_libraries(qt_common PUBLIC frozen::frozen-headers Vulkan::UtilityHeaders) if (NOT APPLE AND ENABLE_OPENGL) diff --git a/src/qt_common/abstract/frontend.h b/src/qt_common/abstract/frontend.h index 0ef9ea97e4..d09433af84 100644 --- a/src/qt_common/abstract/frontend.h +++ b/src/qt_common/abstract/frontend.h @@ -7,12 +7,6 @@ #include #include "qt_common/qt_common.h" -#ifdef YUZU_QT_WIDGETS -#include -#include -#include -#endif - /** * manages common functionality e.g. message boxes and such for Qt/QML */ @@ -20,15 +14,6 @@ namespace QtCommon::Frontend { Q_NAMESPACE -#ifdef YUZU_QT_WIDGETS -using Options = QFileDialog::Options; -using Option = QFileDialog::Option; - -using StandardButton = QMessageBox::StandardButton; -using StandardButtons = QMessageBox::StandardButtons; - -using Icon = QMessageBox::Icon; -#else enum Option { ShowDirsOnly = 0x00000001, DontResolveSymlinks = 0x00000002, @@ -83,7 +68,7 @@ typedef StandardButton Button; Q_DECLARE_FLAGS(StandardButtons, StandardButton) Q_FLAG_NS(StandardButtons) -enum Icon { +enum class Icon { // keep this in sync with QMessageDialogOptions::StandardIcon NoIcon = 0, Information = 1, @@ -93,8 +78,6 @@ enum Icon { }; Q_ENUM_NS(Icon) -#endif - // TODO(crueter) widgets-less impl, choices et al. StandardButton ShowMessage(Icon icon, const QString &title, @@ -106,16 +89,28 @@ StandardButton ShowMessage(Icon icon, inline StandardButton level(QObject *parent, \ const QString &title, \ const QString &text, \ - StandardButtons buttons = StandardButton::Ok) \ + StandardButtons buttons) \ { \ return ShowMessage(Icon::level, title, text, buttons, parent); \ } \ + inline StandardButton level(QObject *parent, \ + const QString &title, \ + const QString &text, \ + int buttons = StandardButton::Ok) \ + { \ + return ShowMessage(Icon::level, title, text, StandardButtons(buttons), parent); \ + } \ inline StandardButton level(const QString title, \ const QString &text, \ - StandardButtons buttons \ - = StandardButton::Ok) \ + StandardButtons buttons) \ { \ return ShowMessage(Icon::level, title, text, buttons, rootObject); \ + } \ + inline StandardButton level(const QString &title, \ + const QString &text, \ + int buttons = StandardButton::Ok) \ + { \ + return ShowMessage(Icon::level, title, text, StandardButtons(buttons), rootObject); \ } UTIL_OVERRIDES(Information) diff --git a/src/qt_common/config/qt_config.cpp b/src/qt_common/config/qt_config.cpp index 88c93cefbc..bf55fd169d 100644 --- a/src/qt_common/config/qt_config.cpp +++ b/src/qt_common/config/qt_config.cpp @@ -5,6 +5,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" +#include "common/settings_common.h" #include "input_common/main.h" #include "qt_config.h" #include "uisettings.h" @@ -561,11 +562,12 @@ void QtConfig::SaveMultiplayerValues() { } std::vector& QtConfig::FindRelevantList(Settings::Category category) { - auto& map = Settings::values.linkage.by_category; - if (map.contains(category)) { - return Settings::values.linkage.by_category[category]; - } - return UISettings::values.linkage.by_category[category]; + // This solution sucks, but by_category is unreliable because the settings backend + // mangles category mapping for some reason. + static auto list = Settings::values.linkage.by_category[category]; + auto uilist = UISettings::values.linkage.by_category[category]; + list.insert(list.end(), uilist.begin(), uilist.end()); + return list; } void QtConfig::ReadQtControlPlayerValues(std::size_t player_index) { diff --git a/src/qt_common/externals/CMakeLists.txt b/src/qt_common/externals/CMakeLists.txt index 36287fbf0a..c804f00e9d 100644 --- a/src/qt_common/externals/CMakeLists.txt +++ b/src/qt_common/externals/CMakeLists.txt @@ -22,4 +22,7 @@ AddJsonPackage(frozen) # TODO if (ENABLE_QT_QML) AddJsonPackage(carboxyl) + if (NOT MSVC) + target_compile_options(CarboxylBase PUBLIC -Wno-shadow) + endif() endif() diff --git a/src/qt_common/externals/cpmfile.json b/src/qt_common/externals/cpmfile.json index 968638cc9b..f65e136030 100644 --- a/src/qt_common/externals/cpmfile.json +++ b/src/qt_common/externals/cpmfile.json @@ -19,8 +19,8 @@ "package": "Carboxyl", "repo": "crueter/Carboxyl", "git_host": "git.crueter.xyz", - "sha": "8fb8d80f90", - "hash": "3b1f259060f9685f90071ac03eb1fef68370a3b9ec7c311a94d22fefa0b703140883c846818a363ab1bee0807f44759ba7a91e05107b2adcd3f9048efe447a6a", + "sha": "ea2f2fa4bc", + "hash": "4b2102379c1e5de68263cd68b705c2524fd220c6707964cb586f4b6c3e221083348c022128f6c61682d7e12c8cfd67a3723ccb7023d28b7560ce3542d6b75545", "bundled": "true", "options": [ "CARBOXYL_DEMO OFF" diff --git a/src/qt_common/qt_common.cpp b/src/qt_common/qt_common.cpp index 384a72b916..2a52b6fd8a 100644 --- a/src/qt_common/qt_common.cpp +++ b/src/qt_common/qt_common.cpp @@ -52,11 +52,7 @@ using namespace Common::Literals; namespace QtCommon { -#ifdef YUZU_QT_WIDGETS -QWidget* rootObject = nullptr; -#else QObject* rootObject = nullptr; -#endif std::unique_ptr system = nullptr; std::shared_ptr vfs = nullptr; @@ -193,11 +189,7 @@ static void RemoveCachedContents() { } -#ifdef YUZU_QT_WIDGETS -void Init(QWidget * root) -#else void Init(QObject* root) -#endif { system = std::make_unique(); rootObject = root; diff --git a/src/qt_common/qt_common.h b/src/qt_common/qt_common.h index df5ae465d9..781c6095af 100644 --- a/src/qt_common/qt_common.h +++ b/src/qt_common/qt_common.h @@ -14,11 +14,7 @@ namespace QtCommon { -#ifdef YUZU_QT_WIDGETS -extern QWidget *rootObject; -#else extern QObject *rootObject; -#endif extern std::unique_ptr system; extern std::shared_ptr vfs; @@ -31,11 +27,7 @@ Core::Frontend::WindowSystemType GetWindowSystemType(); Core::Frontend::EmuWindow::WindowSystemInfo GetWindowSystemInfo(QWindow *window); -#ifdef YUZU_QT_WIDGETS -void Init(QWidget *root); -#else void Init(QObject *root); -#endif const QString tr(const char *str); const QString tr(const std::string &str); diff --git a/src/qt_common/util/content.cpp b/src/qt_common/util/content.cpp index c190e11410..081052b6ed 100644 --- a/src/qt_common/util/content.cpp +++ b/src/qt_common/util/content.cpp @@ -26,16 +26,14 @@ bool CheckGameFirmware(u64 program_id, QObject* parent) { if (FirmwareManager::GameRequiresFirmware(program_id) && !FirmwareManager::CheckFirmwarePresence(*system)) { - auto result = QtCommon::Frontend::ShowMessage( - QMessageBox::Warning, + auto result = QtCommon::Frontend::Warning( tr("Game Requires Firmware"), tr("The game you are trying to launch requires firmware to boot or to get past the " "opening menu. Please " "dump and install firmware, or press \"OK\" to launch anyways."), - QMessageBox::Ok | QMessageBox::Cancel, - parent); + QtCommon::Frontend::Ok | QtCommon::Frontend::Cancel); - return result == QMessageBox::Ok; + return result == QtCommon::Frontend::Ok; } return true; @@ -47,7 +45,7 @@ void InstallFirmware(const QString& location, bool recursive) tr("Cancel"), 0, 100, - rootObject); + (QWidget *)rootObject); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration(100); progress.setAutoClose(false); @@ -62,7 +60,7 @@ void InstallFirmware(const QString& location, bool recursive) QString failedTitle = tr("Firmware Install Failed"); QString successTitle = tr("Firmware Install Succeeded"); - QMessageBox::Icon icon; + QtCommon::Frontend::Icon icon; FirmwareInstallResult result; const auto ShowMessage = [&]() { @@ -104,7 +102,7 @@ void InstallFirmware(const QString& location, bool recursive) if (out.size() <= 0) { result = FirmwareInstallResult::NoNCAs; - icon = QMessageBox::Warning; + icon = QtCommon::Frontend::Icon::Warning; ShowMessage(); return; } @@ -114,7 +112,7 @@ void InstallFirmware(const QString& location, bool recursive) if (sysnand_content_vdir->IsWritable() && !sysnand_content_vdir->CleanSubdirectoryRecursive("registered")) { result = FirmwareInstallResult::FailedDelete; - icon = QMessageBox::Critical; + icon = QtCommon::Frontend::Icon::Critical; ShowMessage(); return; } @@ -145,7 +143,7 @@ void InstallFirmware(const QString& location, bool recursive) if (callback(100, 20 + static_cast(((i) / static_cast(out.size())) * 70.0))) { result = FirmwareInstallResult::FailedCorrupted; - icon = QMessageBox::Warning; + icon = QtCommon::Frontend::Icon::Warning; ShowMessage(); return; } @@ -153,7 +151,7 @@ void InstallFirmware(const QString& location, bool recursive) if (!success) { result = FirmwareInstallResult::FailedCopy; - icon = QMessageBox::Critical; + icon = QtCommon::Frontend::Icon::Critical; ShowMessage(); return; } @@ -225,7 +223,7 @@ void VerifyGameContents(const std::string& game_path) tr("Cancel"), 0, 100, - rootObject); + (QWidget *)rootObject); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration(100); progress.setAutoClose(false); @@ -294,7 +292,7 @@ void VerifyInstalledContents() tr("Cancel"), 0, 100, - rootObject); + (QWidget *)rootObject); progress.setWindowModality(Qt::WindowModal); progress.setMinimumDuration(100); progress.setAutoClose(false); @@ -377,18 +375,18 @@ void ClearDataDir(FrontendCommon::DataManager::DataDir dir, const std::string& u { auto result = QtCommon::Frontend::Warning(tr("Really clear data?"), tr("Important data may be lost!"), - QMessageBox::Yes | QMessageBox::No); + QtCommon::Frontend::Yes | QtCommon::Frontend::No); - if (result != QMessageBox::Yes) + if (result != QtCommon::Frontend::Yes) return; result = QtCommon::Frontend::Warning( tr("Are you REALLY sure?"), tr("Once deleted, your data will NOT come back!\n" "Only do this if you're 100% sure you want to delete this data."), - QMessageBox::Yes | QMessageBox::No); + QtCommon::Frontend::Yes | QtCommon::Frontend::No); - if (result != QMessageBox::Yes) + if (result != QtCommon::Frontend::Yes) return; QtCommon::Frontend::QtProgressDialog dialog(tr("Clearing..."), QString(), 0, 0); @@ -415,7 +413,7 @@ void ExportDataDir(FrontendCommon::DataManager::DataDir data_dir, return; QtProgressDialog* progress = new QtProgressDialog( - tr("Exporting data. This may take a while..."), tr("Cancel"), 0, 100, rootObject); + tr("Exporting data. This may take a while..."), tr("Cancel"), 0, 100, (QWidget*)rootObject); progress->setWindowTitle(tr("Exporting")); progress->setWindowModality(Qt::WindowModal); @@ -486,11 +484,11 @@ void ImportDataDir(FrontendCommon::DataManager::DataDir data_dir, "proceed?"), StandardButton::Yes | StandardButton::No); - if (button != QMessageBox::Yes) + if (button != QtCommon::Frontend::Yes) return; QtProgressDialog* progress = new QtProgressDialog( - tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100, rootObject); + tr("Importing data. This may take a while..."), tr("Cancel"), 0, 100, (QWidget *)rootObject); progress->setWindowTitle(tr("Importing")); progress->setWindowModality(Qt::WindowModal); diff --git a/src/qt_common/util/fs.cpp b/src/qt_common/util/fs.cpp index dd105849aa..f5d62bfec6 100644 --- a/src/qt_common/util/fs.cpp +++ b/src/qt_common/util/fs.cpp @@ -1,8 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include #include +#include #include "common/fs/ryujinx_compat.h" #include "common/fs/symlink.h" #include "fs.h" diff --git a/src/qt_common/util/game.cpp b/src/qt_common/util/game.cpp index 8949d21892..2239511c18 100644 --- a/src/qt_common/util/game.cpp +++ b/src/qt_common/util/game.cpp @@ -11,7 +11,6 @@ #include "qt_common/abstract/frontend.h" #include "qt_common/config/uisettings.h" #include "qt_common/qt_common.h" -#include "yuzu/util/util.h" #include #include @@ -406,29 +405,31 @@ void ResetMetadata(bool show_message) inline constexpr bool CreateShortcutMessagesGUI(ShortcutMessages imsg, const QString& game_title) { int result = 0; - QMessageBox::StandardButtons buttons; + using namespace QtCommon::Frontend; + int buttons; + switch (imsg) { case ShortcutMessages::Fullscreen: - buttons = QMessageBox::Yes | QMessageBox::No; + buttons = Yes | No; result = QtCommon::Frontend::Information(tr("Create Shortcut"), tr("Do you want to launch the game in fullscreen?"), buttons); - return result == QMessageBox::Yes; + return result == Yes; case ShortcutMessages::Success: QtCommon::Frontend::Information(tr("Shortcut Created"), tr("Successfully created a shortcut to %1").arg(game_title)); return false; case ShortcutMessages::Volatile: - buttons = QMessageBox::StandardButton::Ok | QMessageBox::StandardButton::Cancel; + buttons = Ok | Cancel; result = QtCommon::Frontend::Warning( tr("Shortcut may be Volatile!"), tr("This will create a shortcut to the current AppImage. This may " "not work well if you update. Continue?"), buttons); - return result == QMessageBox::Ok; + return result == Ok; default: - buttons = QMessageBox::Ok; + buttons = Ok; QtCommon::Frontend::Critical(tr("Failed to Create Shortcut"), tr("Failed to create a shortcut to %1").arg(game_title), buttons); diff --git a/src/qt_common/util/path.cpp b/src/qt_common/util/path.cpp index 73689058c6..99b5ea092b 100644 --- a/src/qt_common/util/path.cpp +++ b/src/qt_common/util/path.cpp @@ -17,11 +17,11 @@ bool OpenShaderCache(u64 program_id, QObject *parent) const auto shader_cache_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::ShaderDir); const auto shader_cache_folder_path{shader_cache_dir / fmt::format("{:016x}", program_id)}; if (!Common::FS::CreateDirs(shader_cache_folder_path)) { - QtCommon::Frontend::ShowMessage(QMessageBox::Warning, + QtCommon::Frontend::ShowMessage(QtCommon::Frontend::Icon::Warning, tr("Error Opening Shader Cache"), tr("Failed to create or open shader cache for this title, " "ensure your app data directory has write permissions."), - QMessageBox::Ok, + QtCommon::Frontend::Ok, parent); } diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index b0096178dc..b7c6520dac 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -233,6 +233,7 @@ add_executable(yuzu data_widget.ui ryujinx_dialog.h ryujinx_dialog.cpp ryujinx_dialog.ui main_window.h main_window.cpp + libqt_common.cpp ) set_target_properties(yuzu PROPERTIES OUTPUT_NAME "eden") diff --git a/src/qt_common/abstract/frontend.cpp b/src/yuzu/libqt_common.cpp similarity index 56% rename from src/qt_common/abstract/frontend.cpp rename to src/yuzu/libqt_common.cpp index a0ce943538..5eaad8ad92 100644 --- a/src/qt_common/abstract/frontend.cpp +++ b/src/yuzu/libqt_common.cpp @@ -1,24 +1,19 @@ // SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later -#include "frontend.h" -#include "qt_common/qt_common.h" - -#ifdef YUZU_QT_WIDGETS #include -#endif +#include + +#include "qt_common/abstract/frontend.h" +#include "qt_common/qt_common.h" namespace QtCommon::Frontend { StandardButton ShowMessage( Icon icon, const QString &title, const QString &text, StandardButtons buttons, QObject *parent) { -#ifdef YUZU_QT_WIDGETS - QMessageBox *box = new QMessageBox(icon, title, text, buttons, (QWidget *) parent); - return static_cast(box->exec()); -#endif - // TODO(crueter): If Qt Widgets is disabled... - // need a way to reference icon/buttons too + QMessageBox *box = new QMessageBox(QMessageBox::Icon(int(icon)), title, text, QMessageBox::StandardButtons(int(buttons)), (QWidget *) parent); + return StandardButton(box->exec()); } const QString GetOpenFileName(const QString &title, @@ -27,9 +22,7 @@ const QString GetOpenFileName(const QString &title, QString *selectedFilter, Options options) { -#ifdef YUZU_QT_WIDGETS - return QFileDialog::getOpenFileName(rootObject, title, dir, filter, selectedFilter, options); -#endif + return QFileDialog::getOpenFileName((QWidget *) rootObject, title, dir, filter, selectedFilter, QFileDialog::Options(int(options))); } const QString GetSaveFileName(const QString &title, @@ -38,16 +31,12 @@ const QString GetSaveFileName(const QString &title, QString *selectedFilter, Options options) { -#ifdef YUZU_QT_WIDGETS - return QFileDialog::getSaveFileName(rootObject, title, dir, filter, selectedFilter, options); -#endif + return QFileDialog::getSaveFileName((QWidget *) rootObject, title, dir, filter, selectedFilter, QFileDialog::Options(int(options))); } const QString GetExistingDirectory(const QString& caption, const QString& dir, - Options options) { -#ifdef YUZU_QT_WIDGETS - return QFileDialog::getExistingDirectory(rootObject, caption, dir, options); -#endif + Options options) { + return QFileDialog::getExistingDirectory((QWidget *) rootObject, caption, dir, QFileDialog::Options(int(options))); } } // namespace QtCommon::Frontend diff --git a/src/yuzu/util/util.cpp b/src/yuzu/util/util.cpp index 81e05aecb1..54c7383378 100644 --- a/src/yuzu/util/util.cpp +++ b/src/yuzu/util/util.cpp @@ -52,7 +52,7 @@ const std::optional GetProfileID() { .display_options = {}, .purpose = Service::AM::Frontend::UserSelectionPurpose::General, }; - QtProfileSelectionDialog dialog(*QtCommon::system, QtCommon::rootObject, parameters); + QtProfileSelectionDialog dialog(*QtCommon::system, (QWidget *)QtCommon::rootObject, parameters); dialog.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint); dialog.setWindowModality(Qt::WindowModal);