libqutim 0.2.80.1
|
00001 /**************************************************************************** 00002 ** 00003 ** qutIM - instant messenger 00004 ** 00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> 00006 ** 00007 ***************************************************************************** 00008 ** 00009 ** $QUTIM_BEGIN_LICENSE$ 00010 ** This program is free software: you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation, either version 3 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 ** See the GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see http://www.gnu.org/licenses/. 00022 ** $QUTIM_END_LICENSE$ 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef SHORTCUT_H 00027 #define SHORTCUT_H 00028 00029 #include <QShortcut> 00030 #include "localizedstring.h" 00031 00032 namespace qutim_sdk_0_3 00033 { 00034 class ShortcutPrivate; 00035 class GlobalShortcutPrivate; 00036 00037 // REMOVE ME, it's ugly 00038 struct KeySequence 00039 { 00040 QString id; 00041 LocalizedString name; 00042 LocalizedString group; 00043 QKeySequence key; 00044 Qt::ShortcutContext context; 00045 }; 00046 00047 class LIBQUTIM_EXPORT Shortcut : public QShortcut 00048 { 00049 Q_OBJECT 00050 Q_DECLARE_PRIVATE(Shortcut) 00051 public: 00052 explicit Shortcut(const QString &id, QWidget *parent); 00053 virtual ~Shortcut(); 00054 00055 static bool registerSequence(const QString &id, const LocalizedString &name, 00056 const LocalizedString &group, const QKeySequence &key, 00057 Qt::ShortcutContext context = Qt::WindowShortcut); 00058 static QStringList ids(); 00059 static KeySequence getSequence(const QString &id); 00060 static void setSequence(const QString &id,const QKeySequence &key); 00061 protected: 00062 QScopedPointer<ShortcutPrivate> d_ptr; 00063 }; 00064 00065 class LIBQUTIM_EXPORT GlobalShortcut : public QObject 00066 { 00067 Q_OBJECT 00068 Q_DECLARE_PRIVATE(GlobalShortcut) 00069 public: 00070 explicit GlobalShortcut(const QString &id, QObject *parent = 0); 00071 virtual ~GlobalShortcut(); 00072 00073 static bool registerSequence(const QString &id, const LocalizedString &name, 00074 const LocalizedString &group, const QKeySequence &key); 00075 static QStringList ids(); 00076 static KeySequence getSequence(const QString &id); 00077 static void setSequence(const QString &id,const QKeySequence &key); 00078 signals: 00079 void activated(); 00080 private slots: 00081 void onHotKeyPressed(quint32); 00082 protected: 00083 QScopedPointer<GlobalShortcutPrivate> d_ptr; 00084 }; 00085 } 00086 00087 #endif // SHORTCUT_H 00088