From a5412cc274b00a02f0c03cd4e4325801ddb0aeef Mon Sep 17 00:00:00 2001 From: David Sansome Date: Wed, 31 Mar 2010 03:07:11 +0000 Subject: [PATCH] Make sure to hide the mainwindow on startup if it was hidden last time. Also fix the logic to ensure either the tray icon or the window is visible. --- src/mainwindow.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 6a527f1bc..fadeadd91 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -342,20 +342,17 @@ MainWindow::MainWindow(QNetworkAccessManager* network, QWidget *parent) library_->SetGroupBy(g); UpdateGroupBySelection(g); - if (!settings_.value("hidden", false).toBool()) { - show(); - } + bool hidden = settings_.value("hidden", false).toBool(); + bool show_tray = settings_.value("showtray", true).toBool(); + setVisible(!hidden); - if (settings_.value("showtray", true).toBool()) { + if (show_tray) tray_icon_->show(); - } - else { + else ui_.action_hide_tray_icon->setText(tr("&Show tray icon")); - } // Force the window to show in case somehow the config has tray and window set to hide - // Why doesn't .toBool() work? This might be the case for any combinations with .toBool(); use .toInt() - if (!settings_.value("hidden", true).toInt() && !settings_.value("showtray", false).toInt()) { + if (hidden && !show_tray) { settings_.setValue("hidden", false); show(); }