Ctrl-Q from the main window quits the application (#69)

Ctrl-Q from the main window now quits the application.

fixes #61
This commit is contained in:
Max Sandholm 2017-09-24 13:58:36 +03:00 committed by mujx
parent ed5a96341b
commit b1214a9ae8
2 changed files with 6 additions and 1 deletions

View file

@ -22,6 +22,8 @@
#include <QNetworkReply> #include <QNetworkReply>
#include <QSettings> #include <QSettings>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QShortcut>
#include <QApplication>
MainWindow *MainWindow::instance_ = nullptr; MainWindow *MainWindow::instance_ = nullptr;
@ -84,6 +86,9 @@ MainWindow::MainWindow(QWidget *parent)
this, this,
SLOT(showChatPage(QString, QString, QString))); SLOT(showChatPage(QString, QString, QString)));
QShortcut *quitShortcut = new QShortcut(QKeySequence::Quit, this);
connect(quitShortcut, &QShortcut::activated, this, QApplication::quit);
QSettings settings; QSettings settings;
if (hasActiveUser()) { if (hasActiveUser()) {

View file

@ -87,7 +87,7 @@ TrayIcon::TrayIcon(const QString &filename, QWidget *parent)
quitAction_ = new QAction(tr("Quit"), parent); quitAction_ = new QAction(tr("Quit"), parent);
connect(viewAction_, SIGNAL(triggered()), parent, SLOT(show())); 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(viewAction_);
menu->addAction(quitAction_); menu->addAction(quitAction_);