Change "Show" to "Hide" in tray icon menu when the window is visible
This change updates the tray icon menu action to reflect the current state of the window. Closes: #2000
This commit is contained in:
parent
9650c5f4be
commit
3d9e14e001
2 changed files with 12 additions and 4 deletions
|
|
@ -107,13 +107,21 @@ TrayIcon::TrayIcon(const QString &filename, QWindow *parent)
|
|||
QMenu *menu = new QMenu();
|
||||
setContextMenu(menu);
|
||||
|
||||
viewAction_ = new QAction(tr("Show"), this);
|
||||
toggleAction_ = new QAction(tr("Show"), this);
|
||||
quitAction_ = new QAction(tr("Quit"), this);
|
||||
|
||||
connect(viewAction_, &QAction::triggered, parent, &QWindow::show);
|
||||
connect(toggleAction_, &QAction::triggered, parent, [=, this](){
|
||||
if (parent->isVisible()) {
|
||||
parent->hide();
|
||||
toggleAction_->setText(tr("Show"));
|
||||
} else {
|
||||
parent->show();
|
||||
toggleAction_->setText(tr("Hide"));
|
||||
}
|
||||
});
|
||||
connect(quitAction_, &QAction::triggered, this, QApplication::quit);
|
||||
|
||||
menu->addAction(viewAction_);
|
||||
menu->addAction(toggleAction_);
|
||||
menu->addAction(quitAction_);
|
||||
|
||||
QString toolTip = QLatin1String("nheko");
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public slots:
|
|||
void setUnreadCount(int count);
|
||||
|
||||
private:
|
||||
QAction *viewAction_;
|
||||
QAction *toggleAction_;
|
||||
QAction *quitAction_;
|
||||
|
||||
int previousCount = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue