diff options
author | 2021-04-05 09:52:28 +0530 | |
---|---|---|
committer | 2021-04-05 09:52:28 +0530 | |
commit | b36d68f0f3e066226c30ac51127e80e07bcc158a (patch) | |
tree | bb2d535e27b701dcad4e4d58fd7276df5d73ab4b | |
parent | 6805310b65751f52bff954e3d2e78036a6e5c5a9 (diff) | |
download | whatsie-b36d68f0f3e066226c30ac51127e80e07bcc158a.tar.gz whatsie-b36d68f0f3e066226c30ac51127e80e07bcc158a.zip |
fixed dark style bg color,
update system tray menu according to window state,
restore window geometry after minimizing to tray.
-rw-r--r-- | src/mainwindow.cpp | 23 | ||||
-rw-r--r-- | src/mainwindow.h | 1 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 38ecbe6..d27ae79 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -58,7 +58,9 @@ void MainWindow::updateWindowTheme() palette.setColor(QPalette::Window,QColor("#131C21")); //whatsapp dark color palette.setColor(QPalette::WindowText,Qt::white); palette.setColor(QPalette::Disabled,QPalette::WindowText,QColor(127,127,127)); - palette.setColor(QPalette::Base,QColor(42,42,42)); + //palette.setColor(QPalette::Base,QColor(42,42,42)); + palette.setColor(QPalette::Base,QColor(84,84,84)); + palette.setColor(QPalette::AlternateBase,QColor(66,66,66)); palette.setColor(QPalette::ToolTipBase,Qt::white); palette.setColor(QPalette::ToolTipText,QColor(53,53,53)); @@ -245,7 +247,7 @@ void MainWindow::createActions() addAction(minimizeAction); restoreAction = new QAction(tr("&Restore"), this); - connect(restoreAction, &QAction::triggered, this, &QWidget::showNormal); + connect(restoreAction, &QAction::triggered, this, &QWidget::show); addAction(restoreAction); reloadAction = new QAction(tr("Re&load"), this); @@ -277,6 +279,7 @@ void MainWindow::createStatusBar() void MainWindow::createTrayIcon() { trayIconMenu = new QMenu(this); + trayIconMenu->setObjectName("trayIconMenu"); trayIconMenu->addAction(minimizeAction); trayIconMenu->addAction(restoreAction); trayIconMenu->addSeparator(); @@ -288,6 +291,7 @@ void MainWindow::createTrayIcon() trayIcon = new QSystemTrayIcon(trayIconRead, this); trayIcon->setContextMenu(trayIconMenu); + connect(trayIconMenu,SIGNAL(aboutToShow()),this,SLOT(check_window_state())); trayIcon->show(); @@ -297,6 +301,21 @@ void MainWindow::createTrayIcon() this, &MainWindow::iconActivated); } +//check window state and set tray menus +void MainWindow::check_window_state() +{ + QObject *tray_icon_menu = this->findChild<QObject*>("trayIconMenu"); + if(tray_icon_menu != nullptr){ + if(this->isVisible()){ + ((QMenu*)(tray_icon_menu))->actions().at(0)->setDisabled(false); + ((QMenu*)(tray_icon_menu))->actions().at(1)->setDisabled(true); + }else{ + ((QMenu*)(tray_icon_menu))->actions().at(0)->setDisabled(true); + ((QMenu*)(tray_icon_menu))->actions().at(1)->setDisabled(false); + } + } +} + void MainWindow::init_globalWebProfile() { diff --git a/src/mainwindow.h b/src/mainwindow.h index 367d18a..fb68e11 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -102,6 +102,7 @@ private slots: void createWebPage(bool offTheRecord =false); void init_settingWidget(); void init_globalWebProfile(); + void check_window_state(); }; #endif // MAINWINDOW_H |