kshortcut.h
00001
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
00528 class KDECORE_EXPORT KShortcut
00529 {
00530 public:
00535 enum { MAX_SEQUENCES = 2 };
00536
00543 KShortcut();
00544
00551 KShortcut( int keyQt );
00552
00558 KShortcut( const QKeySequence& keySeq );
00559
00565 KShortcut( const KKey& key );
00566
00572 KShortcut( const KKeySequence& keySeq );
00573
00578 KShortcut( const KShortcut& shortcut );
00579
00587 KShortcut( const char* shortcut );
00588
00596 KShortcut( const QString& shortcut );
00597 ~KShortcut();
00598
00604 void clear();
00605
00612 bool init( int keyQt );
00613
00618 bool init( const QKeySequence& keySeq );
00619
00624 bool init( const KKey& key );
00625
00630 bool init( const KKeySequence& keySeq );
00631
00636 bool init( const KShortcut& shortcut );
00637
00645 bool init( const QString& shortcut );
00646
00650 KShortcut& operator =( const KShortcut& cut )
00651 { init( cut ); return *this; }
00652
00659 uint count() const;
00660
00668 const KKeySequence& seq( uint i ) const;
00669
00677 int keyCodeQt() const;
00678
00686 bool isNull() const;
00687
00701 int compare( const KShortcut& shortcut ) const;
00702
00707 bool operator == ( const KShortcut& cut ) const
00708 { return compare( cut ) == 0; }
00709
00714 bool operator != ( const KShortcut& cut ) const
00715 { return compare( cut ) != 0; }
00716
00721 bool operator < ( const KShortcut& cut ) const
00722 { return compare( cut ) < 0; }
00723
00730 bool contains( const KKey& key ) const;
00731
00738 bool contains( const KKeyNative& key ) const;
00739
00745 bool contains( const KKeySequence& keySeq ) const;
00746
00756 bool setSeq( uint i, const KKeySequence& keySeq );
00757
00765 bool append( const KKeySequence& keySeq );
00766
00772 void remove( const KKeySequence& keySeq );
00773
00782 bool append( const KKey& spec );
00783
00791 bool append( const KShortcut& cut );
00792
00797 operator QKeySequence () const;
00798
00806 QString toString() const;
00807
00811 QString toStringInternal( const KShortcut* pcutDefault = 0 ) const;
00812
00819 static KShortcut& null();
00820
00821 protected:
00822 uint m_nSeqs;
00823 KKeySequence m_rgseq[MAX_SEQUENCES];
00824
00825 private:
00826 class KShortcutPrivate* d;
00827 friend class KKeyNative;
00828
00829 #ifndef KDE_NO_COMPAT
00830 public:
00831 operator int () const { return keyCodeQt(); }
00832 #endif
00833 };
00834
00835 #endif // __KSHORTCUT_H
This file is part of the documentation for kdecore Library Version 3.3.90.