kshortcut.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __KSHORTCUT_H
00021 #define __KSHORTCUT_H
00022
00023 #include <qkeysequence.h>
00024 #include <qstring.h>
00025 #include "kdelibs_export.h"
00026
00027 class QKeyEvent;
00028 class KKeyNative;
00029
00040 class KDECORE_EXPORT KKey
00041 {
00042 public:
00047 enum { MOD_FLAG_COUNT = 4 };
00048 enum { QtWIN = (Qt::META) };
00053 enum ModFlag {
00054 SHIFT = 0x01,
00055 CTRL = 0x02,
00056 ALT = 0x04,
00057 WIN = 0x08
00058 };
00059
00066 KKey();
00067
00073 KKey( int keyQt );
00074
00079 KKey( const QKeySequence& keySeq );
00080
00085 KKey( const QKeyEvent* keyEvent );
00086
00090 KKey( const KKey& key );
00091
00100 KKey( const QString& key );
00104 KKey( uint key, uint mod );
00105 ~KKey();
00106
00107
00112 void clear();
00113
00120 bool init( int keyQt );
00121
00127 bool init( const QKeySequence& keySeq );
00128
00134 bool init( const QKeyEvent* keyEvent );
00135
00141 bool init( const KKey& key );
00142
00152 bool init( const QString& key);
00153
00157 bool init( uint key, uint mod );
00158
00162 KKey& operator =( const KKey& key )
00163 { init( key ); return *this; }
00164
00165
00173 bool isNull() const;
00174
00178 uint sym() const;
00182 uint modFlags() const;
00183
00184
00195 int compare( const KKey& key ) const;
00196
00201 bool operator == ( const KKey& key ) const
00202 { return compare( key ) == 0; }
00207 bool operator != ( const KKey& key ) const
00208 { return compare( key ) != 0; }
00213 bool operator < ( const KKey& key ) const
00214 { return compare( key ) < 0; }
00215
00216
00222 int keyCodeQt() const;
00223
00231 QString toString() const;
00232
00237 QString toStringInternal() const;
00238
00239
00243 void simplify();
00244
00251 static KKey& null();
00252
00258 static QString modFlagLabel( ModFlag f );
00259
00260 private:
00261
00262
00263
00264
00271 uint m_sym;
00275 uint m_mod;
00276
00277 private:
00278 friend class KKeyNative;
00279 };
00280
00288 class KDECORE_EXPORT KKeySequence
00289 {
00290 public:
00292 enum { MAX_KEYS = 4 };
00293
00300 KKeySequence();
00301
00306 KKeySequence( const QKeySequence& keySeq );
00307
00312 KKeySequence( const KKey& key );
00313
00318 KKeySequence( const KKeyNative& key );
00319
00324 KKeySequence( const KKeySequence& keySeq );
00325
00334 KKeySequence( const QString& keySeq );
00335
00336 ~KKeySequence();
00337
00343 void clear();
00344
00350 bool init( const QKeySequence& keySeq );
00351
00357 bool init( const KKey& key );
00358
00364 bool init( const KKeyNative& key );
00365
00371 bool init( const KKeySequence& keySeq );
00372
00382 bool init( const QString& key );
00383
00387 KKeySequence& operator =( const KKeySequence& seq )
00388 { init( seq ); return *this; }
00389
00395 uint count() const;
00396
00405 const KKey& key( uint i ) const;
00406
00410 bool isTriggerOnRelease() const;
00411
00420 bool setKey( uint i, const KKey& key );
00421
00429 bool isNull() const;
00430
00436 bool startsWith( const KKeySequence& keySeq ) const;
00437
00450 int compare( const KKeySequence& keySeq ) const;
00451
00456 bool operator == ( const KKeySequence& seq ) const
00457 { return compare( seq ) == 0; }
00458
00463 bool operator != ( const KKeySequence& seq ) const
00464 { return compare( seq ) != 0; }
00465
00470 bool operator < ( const KKeySequence& seq ) const
00471 { return compare( seq ) < 0; }
00472
00473
00478 QKeySequence qt() const;
00479
00486 int keyCodeQt() const;
00487
00494 QString toString() const;
00495
00499 QString toStringInternal() const;
00500
00507 static KKeySequence& null();
00508
00509 protected:
00510 uchar m_nKeys;
00511 uchar m_bTriggerOnRelease;
00512
00513 KKey m_rgvar[MAX_KEYS];
00514
00515 private:
00516 class KKeySequencePrivate* d;
00517 friend class KKeyNative;
00518 };
00519
00543 class KDECORE_EXPORT KShortcut
00544 {
00545 public:
00550 enum { MAX_SEQUENCES = 2 };
00551
00558 KShortcut();
00559
00566 KShortcut( int keyQt );
00567
00573 KShortcut( const QKeySequence& keySeq );
00574
00580 KShortcut( const KKey& key );
00581
00587 KShortcut( const KKeySequence& keySeq );
00588
00593 KShortcut( const KShortcut& shortcut );
00594
00602 KShortcut( const char* shortcut );
00603
00611 KShortcut( const QString& shortcut );
00612 ~KShortcut();
00613
00619 void clear();
00620
00627 bool init( int keyQt );
00628
00633 bool init( const QKeySequence& keySeq );
00634
00639 bool init( const KKey& key );
00640
00645 bool init( const KKeySequence& keySeq );
00646
00651 bool init( const KShortcut& shortcut );
00652
00660 bool init( const QString& shortcut );
00661
00665 KShortcut& operator =( const KShortcut& cut )
00666 { init( cut ); return *this; }
00667
00674 uint count() const;
00675
00683 const KKeySequence& seq( uint i ) const;
00684
00692 int keyCodeQt() const;
00693
00701 bool isNull() const;
00702
00716 int compare( const KShortcut& shortcut ) const;
00717
00722 bool operator == ( const KShortcut& cut ) const
00723 { return compare( cut ) == 0; }
00724
00729 bool operator != ( const KShortcut& cut ) const
00730 { return compare( cut ) != 0; }
00731
00736 bool operator < ( const KShortcut& cut ) const
00737 { return compare( cut ) < 0; }
00738
00745 bool contains( const KKey& key ) const;
00746
00753 bool contains( const KKeyNative& key ) const;
00754
00760 bool contains( const KKeySequence& keySeq ) const;
00761
00770 bool setSeq( uint i, const KKeySequence& keySeq );
00771
00781 bool append( const KKeySequence& keySeq );
00782
00788 void remove( const KKeySequence& keySeq );
00789
00798 bool append( const KKey& spec );
00799
00807 bool append( const KShortcut& cut );
00808
00813 operator QKeySequence () const;
00814
00822 QString toString() const;
00823
00827 QString toStringInternal( const KShortcut* pcutDefault = 0 ) const;
00828
00835 static KShortcut& null();
00836
00837 protected:
00838 uint m_nSeqs;
00839 KKeySequence m_rgseq[MAX_SEQUENCES];
00840
00841 private:
00842 class KShortcutPrivate* d;
00843 friend class KKeyNative;
00844
00845 #ifndef KDE_NO_COMPAT
00846 public:
00847 operator int () const { return keyCodeQt(); }
00848 #endif
00849 };
00850
00851 #endif // __KSHORTCUT_H
|