-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hide to system tray instead of quitting #151
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
Just some minor things, and making sure it works when using the system title bar (Settings > Interface > Title bar > Application title bar).
lib/include/lib/settings/general.hpp
Outdated
/** | ||
* Hide to system tray instead of quitting when the close button is pressed | ||
*/ | ||
bool hide_to_tray = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "close to tray" is a better name? Feels like it's more obvious what it does, as it could be mixed up as a "minimize to tray". Also applies to all other references.
bool hide_to_tray = false; | |
bool close_to_tray = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, now this is close_to_tray
, and other variables are consistent with this convention.
@@ -360,3 +360,14 @@ void MainToolBar::onMinimize(bool /*checked*/) | |||
auto *mainWindow = MainWindow::find(parentWidget()); | |||
mainWindow->minimize(); | |||
} | |||
|
|||
void MainToolBar::onClose(bool /*checked*/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This only works with the application title bar right? Maybe some handling in the main window itself would be required to make it work with the system title bar?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is true.
In order to make it work the same way when it's closed by the system title bar, I've added some logic to MainWindow::closeEvent
.
This function also catches every other method of closing like right-click->close
or alt+f4
, or any other thing available, and they're not distinguishable.
I thought this could be a problem; however, I've checked that other apps that use system tray work the same way, so I expect that It shouldn't be a problem. At least it's not uncommon.
Now, when you select the option to close to system tray, all these methods will result in spotify-qt
staying active in tray. In order to quit, one shall right-click the tray icon and select Quit, or use Ctrl+Q inside the app, or use menu->Quit.
2b75266
to
d66dbf9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, and again, thank you 👍
Related issues:
#124
#71
This adds an option to hide the app to system tray with the close button.
The default behaviour remains unchanged.
I've tested it on Linux.