feat: use spacebar to quit app
This commit is contained in:
parent
fb9207cb71
commit
568c50deff
|
@ -14,6 +14,7 @@
|
|||
#include <QStyle>
|
||||
#include <QScreen>
|
||||
#include <QMenu>
|
||||
#include <QShortcut>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
@ -101,6 +102,10 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
m_gv->setOpacity(0, false);
|
||||
m_closeButton->setOpacity(0, false);
|
||||
|
||||
QShortcut * quitAppShorucut = new QShortcut(QKeySequence(Qt::Key_Space), this);
|
||||
connect(quitAppShorucut, &QShortcut::activated,
|
||||
std::bind(&MainWindow::quitAppAction, this, false));
|
||||
|
||||
centerWindow();
|
||||
}
|
||||
|
||||
|
@ -202,9 +207,7 @@ void MainWindow::mouseReleaseEvent(QMouseEvent *event)
|
|||
|
||||
void MainWindow::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!m_protectedMode) {
|
||||
closeWindow();
|
||||
}
|
||||
quitAppAction();
|
||||
|
||||
return QMainWindow::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
@ -395,3 +398,10 @@ bool MainWindow::stayOnTop()
|
|||
{
|
||||
return windowFlags().testFlag(Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
|
||||
void MainWindow::quitAppAction(bool force)
|
||||
{
|
||||
if (!m_protectedMode || force) {
|
||||
closeWindow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ protected slots:
|
|||
void toggleProtectedMode();
|
||||
void toggleStayOnTop();
|
||||
bool stayOnTop();
|
||||
void quitAppAction(bool force = false);
|
||||
|
||||
private:
|
||||
QPoint m_oldMousePos;
|
||||
|
|
Loading…
Reference in New Issue
Block a user