diff options
author | Claudio Maradonna <penguyman@stronzi.org> | 2018-05-01 17:44:34 +0200 |
---|---|---|
committer | Claudio Maradonna <penguyman@stronzi.org> | 2018-05-01 17:44:34 +0200 |
commit | 20f78f150f257f481fc0d49ec59b54ab822f5466 (patch) | |
tree | 36372626c5bfa90283336cae76f810a1e0f7f171 /src/mainwindow.cpp | |
parent | 18cdb184367a73a439be37ba168a1ca9061fbe9d (diff) |
Some TrayIcon refactor. Should the mainwindow know if is SystemTrayIsAvailable
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9b9413ed..23e81b4e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -285,9 +285,9 @@ bool MainWindow::checkConfig() { // since we are still in constructor, can't directly hide QTimer::singleShot(10, this, SLOT(hide())); } - } else if (!QtPassSettings::isUseTrayIcon() && tray != NULL) { + } /*else if (!QtPassSettings::isUseTrayIcon() && tray != NULL) { destroyTrayIcon(); - } + }*/ // dbg()<< version; @@ -387,11 +387,10 @@ void MainWindow::config() { if (QtPassSettings::isAlwaysOnTop()) { Qt::WindowFlags flags = windowFlags(); this->setWindowFlags(flags | Qt::WindowStaysOnTopHint); - this->show(); } else { this->setWindowFlags(Qt::Window); - this->show(); } + this->show(); updateProfileBox(); ui->treeView->setRootIndex(proxyModel.mapFromSource( @@ -408,8 +407,9 @@ void MainWindow::config() { updateGitButtonVisibility(); if (QtPassSettings::isUseTrayIcon() && tray == NULL) initTrayIcon(); - else if (!QtPassSettings::isUseTrayIcon() && tray != NULL) + else if (!QtPassSettings::isUseTrayIcon() && tray != NULL) { destroyTrayIcon(); + } } freshStart = false; } @@ -1089,17 +1089,14 @@ void MainWindow::on_profileBox_currentIndexChanged(QString name) { * it */ void MainWindow::initTrayIcon() { - if (tray != NULL) { - dbg() << "Creating tray icon again?"; - return; - } - if (QSystemTrayIcon::isSystemTrayAvailable() == true) { - // Setup tray icon - this->tray = new TrayIcon(this); - if (tray == NULL) - dbg() << "Allocating tray icon failed."; - } else { - dbg() << "No tray icon for this OS possibly also not show options?"; + this->tray = new TrayIcon(this); + // Setup tray icon + + if (tray == NULL) + dbg() << "Allocating tray icon failed."; + + if (!tray->getIsAllocated()) { + destroyTrayIcon(); } } @@ -1107,10 +1104,6 @@ void MainWindow::initTrayIcon() { * @brief MainWindow::destroyTrayIcon remove that pesky tray icon */ void MainWindow::destroyTrayIcon() { - if (tray == NULL) { - dbg() << "Destroy non existing tray icon?"; - return; - } delete this->tray; tray = NULL; } |