From 67d9e254c0cf77ab550e29bf0e5470350bf97ba2 Mon Sep 17 00:00:00 2001 From: FrogTheFrog Date: Fri, 17 Jan 2025 17:38:12 +0200 Subject: [PATCH] feat(tray): add button to reset display device settings on Windows --- src/system_tray.cpp | 12 ++++++++++++ src/system_tray.h | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/src/system_tray.cpp b/src/system_tray.cpp index 95edb67da4b..1709d8c9e1c 100644 --- a/src/system_tray.cpp +++ b/src/system_tray.cpp @@ -37,6 +37,7 @@ // local includes #include "confighttp.h" + #include "display_device.h" #include "logging.h" #include "platform/common.h" #include "process.h" @@ -70,6 +71,13 @@ namespace system_tray { platf::open_url("https://www.paypal.com/paypalme/ReenigneArcher"); } + void + tray_reset_display_device_config_cb(struct tray_menu *item) { + BOOST_LOG(info) << "Resetting display device config from system tray"sv; + + std::ignore = display_device::reset_persistence(); + } + void tray_restart_cb(struct tray_menu *item) { BOOST_LOG(info) << "Restarting from system tray"sv; @@ -110,6 +118,10 @@ namespace system_tray { { .text = "PayPal", .cb = tray_donate_paypal_cb }, { .text = nullptr } } }, { .text = "-" }, + // Currently display device settings are only supported on Windows + #ifdef _WIN32 + { .text = "Reset Display Device Config", .cb = tray_reset_display_device_config_cb }, + #endif { .text = "Restart", .cb = tray_restart_cb }, { .text = "Quit", .cb = tray_quit_cb }, { .text = nullptr } }, diff --git a/src/system_tray.h b/src/system_tray.h index d027fb45922..8d716c65289 100644 --- a/src/system_tray.h +++ b/src/system_tray.h @@ -36,6 +36,13 @@ namespace system_tray { void tray_donate_paypal_cb(struct tray_menu *item); + /** + * @brief Callback for resetting display device configuration. + * @param item The tray menu item. + */ + void + tray_reset_display_device_config_cb(struct tray_menu *item); + /** * @brief Callback for restarting Sunshine from the system tray. * @param item The tray menu item.