Skip to content

Commit

Permalink
(ckb Linux) Ctrl+Q shortcut to quit the app
Browse files Browse the repository at this point in the history
  • Loading branch information
ccMSC committed Mar 27, 2015
1 parent a805c2d commit 81c263f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ckb/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSharedMemory>
#include <QShortcut>
#include <QMessageBox>
#include <QMenuBar>

Expand Down Expand Up @@ -40,10 +41,13 @@ MainWindow::MainWindow(QWidget *parent) :
QMenuBar* menuBar = new QMenuBar(this);
setMenuBar(menuBar);
this->menuBar()->addMenu("ckb")->addAction(closeAction);
#else
// On linux, add a handler for Ctrl+Q
new QShortcut(QKeySequence("Ctrl+Q"), this, SLOT(quitApp()));
#endif

connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(closeAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(ui->actionExit, SIGNAL(triggered()), this, SLOT(quitApp()));
connect(closeAction, SIGNAL(triggered()), this, SLOT(quitApp()));
connect(restoreAction, SIGNAL(triggered()), this, SLOT(showWindow()));

connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(cleanup()));
Expand Down Expand Up @@ -214,6 +218,10 @@ void MainWindow::showWindow(){
trayIcon->show();
}

void MainWindow::quitApp(){
qApp->quit();
}

void MainWindow::cleanup(){
foreach(KbWidget* w, kbWidgets)
delete w;
Expand Down
1 change: 1 addition & 0 deletions src/ckb/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class MainWindow : public QMainWindow
private slots:
void timerTick();
void showWindow();
void quitApp();
void cleanup();
void showFwUpdateNotification(QWidget* widget, float version);

Expand Down

0 comments on commit 81c263f

Please sign in to comment.