ui: Display show/hide in the systray menu on all platforms

This commit is contained in:
Oleg Shparber 2017-10-22 02:24:51 +03:00
parent d0b2d4c2dd
commit 4769b7a228

View File

@ -718,19 +718,14 @@ void MainWindow::createTrayIcon()
QMenu *trayIconMenu = new QMenu(this);
#ifdef Q_OS_LINUX
if (QString::fromLocal8Bit(qgetenv("XDG_CURRENT_DESKTOP")) == QLatin1String("Unity")) {
QAction *showAction = trayIconMenu->addAction(tr("Show"));
connect(showAction, &QAction::triggered, this, &MainWindow::toggleWindow);
connect(trayIconMenu, &QMenu::aboutToShow, this, [this, showAction]() {
showAction->setText(isVisible() ? tr("Hide") : tr("Show"));
});
trayIconMenu->addSeparator();
}
#endif
// TODO: [Qt 5.6] Use addAction(text, receiver, method...).
QAction *toggleAction = trayIconMenu->addAction(tr("Show Zeal"));
connect(toggleAction, &QAction::triggered, this, &MainWindow::toggleWindow);
connect(trayIconMenu, &QMenu::aboutToShow, this, [this, toggleAction]() {
toggleAction->setText(isVisible() ? tr("Minimize to Tray") : tr("Show Zeal"));
});
trayIconMenu->addSeparator();
trayIconMenu->addAction(ui->actionQuit);
m_trayIcon->setContextMenu(trayIconMenu);