From b1214a9ae8b6da5ddbd71ce3507399a76a199886 Mon Sep 17 00:00:00 2001 From: Max Sandholm Date: Sun, 24 Sep 2017 13:58:36 +0300 Subject: [PATCH] Ctrl-Q from the main window quits the application (#69) Ctrl-Q from the main window now quits the application. fixes #61 --- src/MainWindow.cc | 5 +++++ src/TrayIcon.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/MainWindow.cc b/src/MainWindow.cc index 21f4c732..364e6d66 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -22,6 +22,8 @@ #include #include #include +#include +#include MainWindow *MainWindow::instance_ = nullptr; @@ -84,6 +86,9 @@ MainWindow::MainWindow(QWidget *parent) this, SLOT(showChatPage(QString, QString, QString))); + QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit, this); + connect(quitShortcut, &QShortcut::activated, this, QApplication::quit); + QSettings settings; if (hasActiveUser()) { diff --git a/src/TrayIcon.cc b/src/TrayIcon.cc index c2caa6e6..a9e897d8 100644 --- a/src/TrayIcon.cc +++ b/src/TrayIcon.cc @@ -87,7 +87,7 @@ TrayIcon::TrayIcon(const QString &filename, QWidget *parent) quitAction_ = new QAction(tr("Quit"), parent); connect(viewAction_, SIGNAL(triggered()), parent, SLOT(show())); - connect(quitAction_, &QAction::triggered, this, [=]() { QApplication::quit(); }); + connect(quitAction_, &QAction::triggered, this, QApplication::quit); menu->addAction(viewAction_); menu->addAction(quitAction_);