Prevent a user from losing access to the main window by minimizing it to the tray on the systems which have not “system tray” or “notification area” available (e.g. GNOME 3.26+).
Tested on Fedora 28 + GNOME 3.28.
Prevent a user from losing access to the main window by minimizing it to the tray on the systems which have not “system tray” or “notification area” available (e.g. GNOME 3.26+).
Tested on Fedora 28 + GNOME 3.28.
Original PR title: "Qt: Don't use systray icon on inappropriate systems"
When reading the PR title I first thought you were referring to Windows platforms :-)
53 | @@ -53,12 +54,16 @@ void OptionsModel::Init(bool resetSettings) 54 | // These are Qt-only settings: 55 | 56 | // Window 57 | - if (!settings.contains("fHideTrayIcon")) 58 | + if (!QSystemTrayIcon::isSystemTrayAvailable()) { 59 | + settings.setValue("fHideTrayIcon", true);
Kinda of nasty to change the saved setting just because you run it once on a platform that doesn't support it. I suggest leaving it be in settings, greying the setting, and ignoring it.
54 | @@ -54,7 +55,7 @@ void OptionsModel::Init(bool resetSettings) 55 | 56 | // Window 57 | if (!settings.contains("fHideTrayIcon")) 58 | - settings.setValue("fHideTrayIcon", false); 59 | + settings.setValue("fHideTrayIcon", !QSystemTrayIcon::isSystemTrayAvailable());
I'd leave this alone. Or at the very least, don't set any value if there's no systray.
If it'll be leaved alone the first call of the OptionsModel constructor sets fHideTrayIcon to the false anyway.
Why cannot it be initialized to the true on the GNOME environment?
I'd say that's another PR, like "gui: Enable system tray icon by default if available"
584 | @@ -585,6 +585,9 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled) 585 | 586 | void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle) 587 | { 588 | + if (!QSystemTrayIcon::isSystemTrayAvailable()) {
I would prevent calls to createTrayIcon and maybe assert(QSystemTrayIcon::isSystemTrayAvailable()) here?
How about createTrayIconMenu?
Thank you for your review.
How about
createTrayIconMenu?
Is it not enough?
This PR title has been changed as @promag proposed.
btw, gui prefix is not mentioned in the CONTRIBUTING.md. Is it valid? (answered by @laanwj on IRC)
utACK after squash
lightly tested on OSes where the tray is available. ACK 244774d9626f37e15d8e021de4e735302ae2d292.
Waiting on @promag's ack or further comments
@jonasschnelli thanks for the reminder, will check tonight.
Could guard these mappings https://github.com/bitcoin/bitcoin/blob/244774d9626f37e15d8e021de4e735302ae2d292/src/qt/optionsdialog.cpp#L222-L223
but since these widgets are disabled and the options dialog is the only place that changes these options, the guard is not necessary.
nit, could fix the comment
https://github.com/bitcoin/bitcoin/blob/244774d9626f37e15d8e021de4e735302ae2d292/src/qt/optionsdialog.cpp#L220
utACK 244774d — tomorrow I can setup a system without tray to test.
Should be "Non macOS"?
BTW, I'm currently installing fedora..
but since these widgets are disabled and the options dialog is the only place that changes these options, the guard is not necessary.
In fact, the guard around mapper is necessary: addMapping effectively overwrites ui settings in the OptionsDialog constructor.
Thank you for this catch. I'm going to fix it.
Prevent a user from losing access to the main window by minimizing it to
the tray on some systems (e.g. GNOME 3.26+).
<!--32850dd3fdea838b4049e64f46995ea2-->
| Coverage | Change (pull 14228) | Reference (master) |
|---|---|---|
| Lines | +0.0287 % | 87.0361 % |
| Functions | +0.1235 % | 84.1130 % |
| Branches | +0.0085 % | 51.5451 % |
utACK ec1201a36847f7aa942eab1b3a3d082f6daf0031