diff options
author | Mateusz Łukasik <mati75@linuxmint.pl> | 2016-06-15 20:23:58 +0200 |
---|---|---|
committer | Mateusz Łukasik <mati75@linuxmint.pl> | 2016-06-15 20:23:58 +0200 |
commit | 42be0eb4f1d7a25dca97e8e2eb4ec4d03b7931fb (patch) | |
tree | fae3347b0c924378c57862feea2708766d159771 /src/myapplication.cpp | |
parent | 1a2f0c9c1087899a00298db8fa70518d3c1e69f8 (diff) |
Imported Upstream version 16.6.0~ds0
Diffstat (limited to 'src/myapplication.cpp')
-rw-r--r-- | src/myapplication.cpp | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/src/myapplication.cpp b/src/myapplication.cpp index 47c6ac7..b90c432 100644 --- a/src/myapplication.cpp +++ b/src/myapplication.cpp @@ -18,6 +18,40 @@ #include "myapplication.h" +#ifdef SINGLE_INSTANCE +MyApplication::MyApplication ( const QString & appId, int & argc, char ** argv ) + : QtSingleApplication(appId, argc, argv) +{ +#if defined(USE_WINEVENTFILTER) && QT_VERSION >= 0x050000 + installNativeEventFilter(this); +#endif +}; + +#else + +MyApplication::MyApplication ( const QString & appId, int & argc, char ** argv ) + : QApplication(argc, argv) +{ +#if defined(USE_WINEVENTFILTER) && QT_VERSION >= 0x050000 + installNativeEventFilter(this); +#endif +}; + +#endif + +#if defined(USE_WINEVENTFILTER) && QT_VERSION >= 0x050000 +bool MyApplication::nativeEventFilter(const QByteArray &eventType, void *message, long *result) { + //qDebug() << "MyApplication::nativeEventFilter:" <<eventType; + + if (eventType == "windows_generic_MSG" || eventType == "windows_dispatcher_MSG") { + MSG * m = static_cast<MSG *>(message); + return winEventFilter(m, result); + } + + return false; +} +#endif + #ifdef USE_WINEVENTFILTER #include <QKeyEvent> #include <QEvent> @@ -121,9 +155,9 @@ bool MyApplication::winEventFilter(MSG * msg, long * result) { if ((last_appcommand == APPCOMMAND_MEDIA_STOP) && (msg->wParam == VK_MEDIA_STOP)) eat_key = true; if (eat_key) { - qDebug("MyApplication::winEventFilter: ignoring key %X", msg->wParam); + qDebug() << "MyApplication::winEventFilter: ignoring key" << msg->wParam; last_appcommand = 0; - *result = true; + //*result = true; return true; } } @@ -164,7 +198,7 @@ bool MyApplication::winEventFilter(MSG * msg, long * result) { QKeyEvent event(QEvent::KeyPress, key, modifier, name); QWidget * w = QApplication::focusWidget(); if (w) QCoreApplication::sendEvent(w, &event); - *result = true; + //*result = true; return true; } //} |