summaryrefslogtreecommitdiffstats
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp33
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;
}