From 619eaa1552d6c9d2c08c63b995a2b5cb593154f0 Mon Sep 17 00:00:00 2001 From: sniperbeamer Date: Sat, 16 Feb 2008 22:08:30 +0000 Subject: [PATCH] Global auto-type now works when using the kde plugin git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@156 b624d157-de02-0410-bad0-e51aec6abb33 --- src/Application_X11.cpp | 9 +++++++- src/Application_X11.h | 1 + src/plugins/gnome/keepassx-gnome.h | 4 ++-- src/plugins/kde/KpKApplication.cpp | 31 +++++++++++++++++++++++++++ src/plugins/kde/KpKApplication.h | 34 ++++++++++++++++++++++++++++++ src/plugins/kde/keepassx-kde.cpp | 4 ++++ src/plugins/kde/keepassx-kde.h | 6 +++--- src/plugins/kde/keepassx-kde.pro | 4 ++++ 8 files changed, 87 insertions(+), 6 deletions(-) create mode 100644 src/plugins/kde/KpKApplication.cpp create mode 100644 src/plugins/kde/KpKApplication.h diff --git a/src/Application_X11.cpp b/src/Application_X11.cpp index 4e19a1b..ceb4966 100644 --- a/src/Application_X11.cpp +++ b/src/Application_X11.cpp @@ -25,11 +25,18 @@ KeepassApplication::KeepassApplication(int& argc, char** argv) : QApplication(ar } bool KeepassApplication::x11EventFilter(XEvent* event){ + if (x11KeyEvent(event)) + return true; + else + return QApplication::x11EventFilter(event); +} + +bool KeepassApplication::x11KeyEvent(XEvent* event){ static const unsigned int remove_invalid = ControlMask|ShiftMask|Mod1Mask|Mod5Mask|Mod4Mask; if (event->type==KeyPress && AutoType::shortcut.key!=0u && event->xkey.keycode==XKeysymToKeycode(event->xkey.display,HelperX11::getKeysym(AutoType::shortcut.key)) && (event->xkey.state&remove_invalid)==HelperX11::getShortcutModifierMask(AutoType::shortcut) && QApplication::focusWidget()==NULL ){ AutoType::performGlobal(); return true; } else - return QApplication::x11EventFilter(event); + return false; } diff --git a/src/Application_X11.h b/src/Application_X11.h index dc5772f..f6dd374 100644 --- a/src/Application_X11.h +++ b/src/Application_X11.h @@ -29,6 +29,7 @@ class KeepassApplication : public QApplication public: KeepassApplication(int& argc, char** argv); bool x11EventFilter(XEvent* event); + static bool x11KeyEvent(XEvent* event); }; #endif // APPLICATION_X11_H diff --git a/src/plugins/gnome/keepassx-gnome.h b/src/plugins/gnome/keepassx-gnome.h index 98aa78f..24a44d5 100644 --- a/src/plugins/gnome/keepassx-gnome.h +++ b/src/plugins/gnome/keepassx-gnome.h @@ -27,8 +27,8 @@ class GnomePlugin:public QObject,public IFileDialog,public IGnomeInit{ Q_OBJECT - Q_INTERFACES(IFileDialog) - Q_INTERFACES(IGnomeInit) + Q_INTERFACES(IFileDialog); + Q_INTERFACES(IGnomeInit); public: virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir, QStringList Filters); diff --git a/src/plugins/kde/KpKApplication.cpp b/src/plugins/kde/KpKApplication.cpp new file mode 100644 index 0000000..ea472ce --- /dev/null +++ b/src/plugins/kde/KpKApplication.cpp @@ -0,0 +1,31 @@ +/*************************************************************************** + * Copyright (C) 2005-2008 by Felix Geyer * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 of the License. * + + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include "KpKApplication.h" +#include "Application_X11.h" + +KpKApplication::KpKApplication() : KApplication(){ +} + +bool KeepassApplication::x11EventFilter(XEvent* event){ + if (KeepassApplication::x11KeyEvent(event)) + return true; + else + return KApplication::x11EventFilter(event); +} diff --git a/src/plugins/kde/KpKApplication.h b/src/plugins/kde/KpKApplication.h new file mode 100644 index 0000000..a3f4705 --- /dev/null +++ b/src/plugins/kde/KpKApplication.h @@ -0,0 +1,34 @@ +/*************************************************************************** + * Copyright (C) 2005-2008 by Felix Geyer * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; version 2 of the License. * + + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#ifndef KP_KAPPLICATION_H +#define KP_KAPPLICATION_H + +#include + +class KpKApplication : public KApplication +{ + Q_OBJECT + + public: + KpKApplication(); + bool x11EventFilter(XEvent* event); +}; + +#endif // KP_KAPPLICATION_H diff --git a/src/plugins/kde/keepassx-kde.cpp b/src/plugins/kde/keepassx-kde.cpp index b7dc010..0559056 100644 --- a/src/plugins/kde/keepassx-kde.cpp +++ b/src/plugins/kde/keepassx-kde.cpp @@ -153,7 +153,11 @@ QApplication* KdePlugin::getMainAppObject(int argc, char** argv){ QByteArray("0.2.3"), ki18n("Cross Platform Password Manager")); createIconMap(); +#ifdef GLOBAL_AUTOTYPE + return dynamic_cast( new KpKApplication() ); +#else return dynamic_cast( new KApplication() ); +#emdif } diff --git a/src/plugins/kde/keepassx-kde.h b/src/plugins/kde/keepassx-kde.h index de08712..cc83dbd 100644 --- a/src/plugins/kde/keepassx-kde.h +++ b/src/plugins/kde/keepassx-kde.h @@ -28,9 +28,9 @@ class KdePlugin:public QObject,public IFileDialog,public IKdeInit,public IIconTheme{ Q_OBJECT - Q_INTERFACES(IFileDialog) - Q_INTERFACES(IKdeInit) - Q_INTERFACES(IIconTheme) + Q_INTERFACES(IFileDialog); + Q_INTERFACES(IKdeInit); + Q_INTERFACES(IIconTheme); public: virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir, QStringList Filters, int SelectedFilter); diff --git a/src/plugins/kde/keepassx-kde.pro b/src/plugins/kde/keepassx-kde.pro index 5d152fc..02ce3cb 100644 --- a/src/plugins/kde/keepassx-kde.pro +++ b/src/plugins/kde/keepassx-kde.pro @@ -6,6 +6,10 @@ TEMPLATE = lib CONFIG += plugin release HEADERS += keepassx-kde.h SOURCES += keepassx-kde.cpp +contains(DEFINES,GLOBAL_AUTOTYPE) { +HEADERS += KpKApplication.h +SOURCES += KpKApplication.cpp +} MOC_DIR = ../../../build/moc OBJECTS_DIR = ../../../build TARGET = ../../../lib/keepassx-kde