Skip to content

Commit f815d99

Browse files
committed
Modify the Quit button on the Main Window to be a Hide button if the
Tray is active.
1 parent 896ccd7 commit f815d99

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/core/ui/mainwindow.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent),
4949
actHelp = new QAction(QIcon::fromTheme(QStringLiteral("system-help")), tr("Help"), this);
5050
actAbout = new QAction(QIcon::fromTheme(QStringLiteral("system-about")), tr("About"), this);
5151
actQuit = new QAction(QIcon::fromTheme(QStringLiteral("application-exit")), tr("Quit"), this);
52+
actHideQuit = new QAction(QIcon::fromTheme(QStringLiteral("application-exit")), tr("QuitHide"), this);
5253

5354
// connect actions to slots
5455
Core *c = Core::instance();
@@ -79,9 +80,9 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent),
7980

8081
QWidget* spacer = new QWidget();
8182
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
82-
_ui->toolBar->addWidget(spacer);
83+
_ui->toolBar->addWidget(spacer);
8384

84-
_ui->toolBar->addAction(actQuit);
85+
_ui->toolBar->addAction(actHideQuit);
8586

8687
void (QSpinBox::*delayChange)(int) = &QSpinBox::valueChanged;
8788
connect(_ui->delayBox, delayChange, this, &MainWindow::delayBoxChange);
@@ -217,14 +218,14 @@ void MainWindow::show()
217218
{
218219
if (!isVisible() && !_trayed)
219220
showNormal();
220-
if (_trayIcon){
221+
if (_trayIcon) {
221222
if (_conf->getShowTrayIcon())
222223
{
223224
_trayIcon->blockSignals(false);
224225
_trayIcon->setContextMenu(_trayMenu);
225226
}
226227

227-
_trayIcon->setVisible(true);
228+
_trayIcon->setVisible(true);
228229
}
229230
QMainWindow::show();
230231
}
@@ -451,6 +452,17 @@ void MainWindow::updateUI()
451452
_ui->checkIncludeCursor->setChecked(_conf->getIncludeCursor());
452453

453454
updateShortcuts();
455+
Core* c = Core::instance();
456+
457+
if (_conf->getShowTrayIcon()) {
458+
disconnect(actHideQuit, &QAction::triggered, c, &Core::coreQuit);
459+
connect(actHideQuit, &QAction::triggered, this, &MainWindow::windowHideShow);
460+
actHideQuit->setText(tr("Hide"));
461+
} else {
462+
disconnect(actHideQuit, &QAction::triggered, this, &MainWindow::windowHideShow);
463+
connect(actHideQuit, &QAction::triggered, c, &Core::coreQuit);
464+
actHideQuit->setText(tr("Quit"));
465+
}
454466

455467
// create tray object
456468
if (_conf->getShowTrayIcon() && !_trayIcon)

src/core/ui/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public Q_SLOTS:
7474
QAction *actAbout;
7575
QAction *actHelp;
7676
QAction *actQuit;
77+
QAction *actHideQuit;
7778
Config *_conf;
7879
QMenu *_trayMenu;
7980
QShortcut *_hideWnd;

0 commit comments

Comments
 (0)