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:
Integral 2026-02-01 21:17:16 +08:00
parent 9650c5f4be
commit 3d9e14e001
No known key found for this signature in database
GPG key ID: 06313911057DD5A8
2 changed files with 12 additions and 4 deletions

View file

@ -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");

View file

@ -40,7 +40,7 @@ public slots:
void setUnreadCount(int count);
private:
QAction *viewAction_;
QAction *toggleAction_;
QAction *quitAction_;
int previousCount = 0;