Skip to content
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

Adjusted behavior of system tray icon #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gcbritt
Copy link

@gcbritt gcbritt commented Aug 16, 2024

Hello! I found your project recently, and I love it! I hope I can help contribute to its greatness with this change!

Most applications that I use which have a system tray behave as such: If the user exits the application, they either 1) inform the user that the application will continue in the background, and hide themselves or 2) hide themselves with no message.

I've adjusted the tray icon behavior to fit this 'standard'. I also fixed a couple places where if statements were unguarded, which led to a segfault sometimes if you saved the settings menu without changing anything.

I added a new button to the system tray to hide the window, as well as a popup that informs about the application hiding itself. This popup could be removed, or maybe adjusted to ask the user if they meant to close the application, maybe a checkbox to remember the setting so the window doesn't open each time the application is closed.

I hope you like it! Thanks for making this awesome application!

Related to #97

… is closed. Fixed unguarded ifs which avoids tray icon being created multiple times
@gcbritt
Copy link
Author

gcbritt commented Aug 16, 2024

I think we can take this further by adjusting the quitting behavior of the application.

If system tray is enabled:
When you exit the application with 'X', it will keep running as I've adjusted
If you click "quit" from the system tray, it will quit tuxclocker-qt and tuxclockerd.

If system tray is disabled:
In this case, regardless of how you choose to close the program, the frontend and daemon should both be killed.

Right now, I'm not seeing a user-accessible way to surrender control back from tuxclockerd, because there is not a way to close it as designed currently.

@pallaswept
Copy link

Great to see contributions here, cheers for that!
I hope this feedback is helpful...

This popup could be removed,
maybe a checkbox to remember the setting so the window doesn't open each time the application is closed.

This is very much needed. It's super annoying to have an app nag you every time you close it.
I understand that some other apps do it, but there isn't any need to notify the user. The DE should take care of that by showing the icon in the notification area. That's how it got that name ;) I would suggest you don't waste time on the checkbox, just don't bother to (redundantly) notify at all....but either works fine :)

I think we can take this further by adjusting the quitting behavior of the application.
If you click "quit" from the system tray, it will quit tuxclocker-qt and tuxclockerd.
regardless of how you choose to close the program, the frontend and daemon should both be killed.

Quitting the UI should not quit the daemon. Users should be able to run the UI, modify the daemon as required, leave the daemon running and functioning, and exit the UI to preserve resources - or, if the tray is enabled - minimise the UI to the tray to improve UX.

Closing the UI means "I am done configuring the daemon"
Closing the daemon means "I don't want tuxclocker working right now"
So we need to facilitate "I want to configure the daemon, and when I'm done, keep my OC working afterwards"
I'd guess that the number of times someone wants to reconfigure their overclock and then immediately disable it is quite low.

Copy link
Owner

@Lurkki14 Lurkki14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic changes look good, otherwise want some clarifications

Comment on lines +150 to +162
// if the tray icon is active, hide the application instead of closing it

if (m_trayIcon && m_trayIcon->isVisible()) {
QMessageBox::information(this, tr("TuxClocker"),
tr("TuxClocker will continue to run "
"in the background. To completely "
"exit the application, choose <b><u>Q</u>uit</b> "
"from the system tray icon"));
hide();
event->ignore();
return;
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we need this, since using the tray isn't the default, and we inform the user about this behavior with a tooltip in the settings too

Comment on lines -124 to +127
auto show = new QAction{_("&Maximize TuxClocker"), this};
auto show = new QAction{_("&Show TuxClocker"), this};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs changing, I think Maximize/Hide is clear enough, and translations would need to be changed

Comment on lines +158 to +159
hide();
event->ignore();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The window is already hidden in this condition, unless I'm missing something

@@ -104,27 +104,34 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {

void MainWindow::setTrayIconEnabled(bool enable) {
if (enable) {
if (!m_trayIcon)
// This seems to make the main window not close during closeEvent
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the comment?

}
// Remove tray icon
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=||=

@Lurkki14
Copy link
Owner

If system tray is disabled:
In this case, regardless of how you choose to close the program, the frontend and daemon should both be killed.

We don't want to do this unconditionally, since there may be other users of tuxclockerd eg. scripts.

If we want a way to terminate tuxclockerd at the same time as the GUI, we need to implement a method into the daemon, that makes tuxclockerd exit itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants