From 73bc060908ab1f1604649f656a0a59e20737a47e Mon Sep 17 00:00:00 2001 From: Yukino Song Date: Tue, 30 Jul 2024 01:29:43 +0800 Subject: [PATCH] Add force close option on tray menu --- src/system_tray.cpp | 27 +++++++++++++++++---------- src/system_tray.h | 3 +++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/system_tray.cpp b/src/system_tray.cpp index e949ff57..fe24b687 100644 --- a/src/system_tray.cpp +++ b/src/system_tray.cpp @@ -75,6 +75,12 @@ namespace system_tray { platf::open_url("https://www.paypal.com/paypalme/ReenigneArcher"); } + void + tray_force_stop_cb(struct tray_menu *item) { + BOOST_LOG(info) << "Force stop from system tray"sv; + proc::proc.terminate(); + } + void tray_restart_cb(struct tray_menu *item) { BOOST_LOG(info) << "Restarting from system tray"sv; @@ -106,16 +112,17 @@ namespace system_tray { (struct tray_menu[]) { // todo - use boost/locale to translate menu strings { .text = "Open Sunshine", .cb = tray_open_ui_cb }, - { .text = "-" }, - { .text = "Donate", - .submenu = - (struct tray_menu[]) { - { .text = "GitHub Sponsors", .cb = tray_donate_github_cb }, - { .text = "MEE6", .cb = tray_donate_mee6_cb }, - { .text = "Patreon", .cb = tray_donate_patreon_cb }, - { .text = "PayPal", .cb = tray_donate_paypal_cb }, - { .text = nullptr } } }, - { .text = "-" }, + // { .text = "-" }, + // { .text = "Donate", + // .submenu = + // (struct tray_menu[]) { + // { .text = "GitHub Sponsors", .cb = tray_donate_github_cb }, + // { .text = "MEE6", .cb = tray_donate_mee6_cb }, + // { .text = "Patreon", .cb = tray_donate_patreon_cb }, + // { .text = "PayPal", .cb = tray_donate_paypal_cb }, + // { .text = nullptr } } }, + // { .text = "-" }, + { .text = "Force Close", .cb = tray_force_stop_cb }, { .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 c87c3040..6f74cb3f 100644 --- a/src/system_tray.h +++ b/src/system_tray.h @@ -43,6 +43,9 @@ namespace system_tray { void tray_donate_paypal_cb(struct tray_menu *item); + void + tray_force_stop_cb(struct tray_menu *item); + /** * @brief Callback for restarting Sunshine from the system tray. * @param item The tray menu item.