KDEUI
kgesturemap.h
Go to the documentation of this file.00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2006,2007 Andreas Hartmetz (ahartmetz@gmail.com) 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KGESTUREMAP_H 00021 #define KGESTUREMAP_H 00022 00023 #include <QtCore/QObject> 00024 #include <QtCore/QHash> 00025 #include <QTimer> 00026 #include <QPolygon> 00027 00028 #include "kgesture.h" 00029 00030 class KApplication; 00031 class KAction; 00032 class QEvent; 00033 00034 class KGestureMap : public QObject 00035 { 00036 Q_OBJECT 00037 public: 00038 static KGestureMap *self(); 00039 00040 virtual bool eventFilter(QObject *obj, QEvent *e); 00041 void addGesture(const KShapeGesture &gesture, KAction *kact); 00042 void addGesture(const KRockerGesture &gesture, KAction *kact); 00043 void removeGesture(const KShapeGesture &gesture, KAction *kact); 00044 void removeGesture(const KRockerGesture &gesture, KAction *kact); 00045 KAction *findAction(const KShapeGesture &gesture) const; 00046 KAction *findAction(const KRockerGesture &gesture) const; 00047 00048 private Q_SLOTS: 00049 void stopAcquisition(); 00050 00051 private: 00052 friend class KGestureMapContainer; 00053 KGestureMap(); 00054 virtual ~KGestureMap(); 00055 00056 friend class KApplicationPrivate; 00057 //intended to be used at application initialization 00058 void installEventFilterOnMe(KApplication *app); 00059 00060 inline int bitCount(int n); 00061 void handleAction(KAction *kact); 00062 void matchShapeGesture(); 00063 00064 //this is an internal class so don't bother with a d-pointer 00065 QHash<KShapeGesture, KAction *> m_shapeGestures; 00066 QHash<KRockerGesture, KAction *> m_rockerGestures; 00067 QPolygon m_points; 00068 QTimer m_gestureTimeout; 00069 bool m_acquiring; 00070 00071 KShapeGesture m_shapeGesture; 00072 KRockerGesture m_rockerGesture; 00073 }; 00074 00075 #endif //KGESTUREMAP_H