Update toggleAction_ text when parent window visibility changes
Currently, the `toggleAction_` text is only updated when the parent window visibility changes via the tray icon menu. If the visibility changes through other means, the action text becomes out of sync. Connect parent window visibility changes to `toggleAction_` to keep the text in sync.
This commit is contained in:
parent
597aa36f28
commit
b5ce330c82
1 changed files with 5 additions and 8 deletions
|
|
@ -110,14 +110,11 @@ TrayIcon::TrayIcon(const QString &filename, QWindow *parent)
|
||||||
toggleAction_ = new QAction(tr("Show"), this);
|
toggleAction_ = new QAction(tr("Show"), this);
|
||||||
quitAction_ = new QAction(tr("Quit"), this);
|
quitAction_ = new QAction(tr("Quit"), this);
|
||||||
|
|
||||||
connect(toggleAction_, &QAction::triggered, parent, [=, this]() {
|
connect(parent, &QWindow::visibleChanged, toggleAction_, [=, this] {
|
||||||
if (parent->isVisible()) {
|
toggleAction_->setText(tr(parent->isVisible() ? "Hide" : "Show"));
|
||||||
parent->hide();
|
});
|
||||||
toggleAction_->setText(tr("Show"));
|
connect(toggleAction_, &QAction::triggered, parent, [=] {
|
||||||
} else {
|
parent->isVisible() ? parent->hide() : parent->show();
|
||||||
parent->show();
|
|
||||||
toggleAction_->setText(tr("Hide"));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
connect(quitAction_, &QAction::triggered, this, QApplication::quit);
|
connect(quitAction_, &QAction::triggered, this, QApplication::quit);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue