KDEUI
kdedglobalaccel.h
Go to the documentation of this file.00001 /* 00002 This file is part of the KDE libraries 00003 00004 Copyright (c) 2007 Andreas Hartmetz <ahartmetz@gmail.com> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License as published by the Free Software Foundation; either 00009 version 2 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Library General Public License for more details. 00015 00016 You should have received a copy of the GNU Library General Public License 00017 along with this library; see the file COPYING.LIB. If not, write to 00018 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00019 Boston, MA 02110-1301, USA. 00020 */ 00021 00022 /* 00023 data per main component: 00024 -unique name 00025 -i18n name 00026 -(KActions) 00027 00028 data per KAction: 00029 -unique name 00030 -i18n name 00031 -shortcut 00032 -default shortcut (special purpose API for KCMs) 00033 00034 */ 00035 00036 #ifndef KDEDGLOBALACCEL_H 00037 #define KDEDGLOBALACCEL_H 00038 00039 #include <kdedmodule.h> 00040 #include "kaction.h" 00041 #include <QtCore/QStringList> 00042 00043 struct actionData; 00044 class KdedGlobalAccelPrivate; 00045 00046 class KdedGlobalAccel : public KDEDModule 00047 { 00048 Q_OBJECT 00049 public: 00050 enum SetShortcutFlags 00051 { 00052 SetPresent = 2, 00053 NoAutoloading = 4, 00054 IsDefault = 8 00055 }; 00056 00057 KdedGlobalAccel(QObject*, const QList<QVariant>&); 00058 ~KdedGlobalAccel(); 00059 00060 //All of the following public methods and signals are part of the DBus interface 00061 QList<QStringList> allComponents(); 00062 QList<QStringList> allActionsForComponent(const QStringList &actionId); 00063 00064 QList<int> allKeys(); 00065 QStringList allKeysAsString(); 00066 00067 QStringList actionId(int key); 00068 //to be called by main components not owning the action 00069 QList<int> shortcut(const QStringList &actionId); 00070 //to be called by main components not owning the action 00071 QList<int> defaultShortcut(const QStringList &actionId); 00072 //to be called by main components owning the action 00073 QList<int> setShortcut(const QStringList &actionId, 00074 const QList<int> &keys, uint flags); 00075 //this is used if application A wants to change shortcuts of application B 00076 void setForeignShortcut(const QStringList &actionId, const QList<int> &keys); 00077 //to be called when a KAction is destroyed. The shortcut stays in the data structures for 00078 //conflict resolution but won't trigger. 00079 void setInactive(const QStringList &actionId); 00080 00081 void doRegister(const QStringList &actionId); 00082 00083 void unRegister(const QStringList &actionId); 00084 00085 //called by the implementation to inform us about key presses 00086 //returns true if the key was handled 00087 bool keyPressed(int keyQt); 00088 00089 Q_SIGNALS: 00090 // this is qlonglong because manually written adaptor is used and just long doesn't work 00091 void invokeAction(const QStringList &actionId, qlonglong timestamp); 00092 void yourShortcutGotChanged(const QStringList &actionId, const QList<int> &newKeys); 00093 00094 private Q_SLOTS: 00095 void writeSettings(); 00096 00097 private: 00098 void loadSettings(); 00099 void scheduleWriteSettings(); 00100 QList<int> keysFromString(const QString &str); 00101 QString stringFromKeys(const QList<int> &keys); 00102 00103 KdedGlobalAccelPrivate *const d; 00104 }; 00105 00106 #endif //KDEDGLOBALACCEL_H