Merge pull request #2003 from Integral-Tech/fix-toggle-action

Update `toggleAction_` text when parent window visibility changes
This commit is contained in:
DeepBlueV7.X 2026-02-17 01:20:06 +01:00 committed by GitHub
commit abb2325a99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -110,14 +110,11 @@ TrayIcon::TrayIcon(const QString &filename, QWindow *parent)
toggleAction_ = new QAction(tr("Show"), this);
quitAction_ = new QAction(tr("Quit"), this);
connect(toggleAction_, &QAction::triggered, parent, [=, this]() {
if (parent->isVisible()) {
parent->hide();
toggleAction_->setText(tr("Show"));
} else {
parent->show();
toggleAction_->setText(tr("Hide"));
}
connect(parent, &QWindow::visibleChanged, toggleAction_, [=, this] {
toggleAction_->setText(tr(parent->isVisible() ? "Hide" : "Show"));
});
connect(toggleAction_, &QAction::triggered, parent, [=] {
parent->isVisible() ? parent->hide() : parent->show();
});
connect(quitAction_, &QAction::triggered, this, QApplication::quit);