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
00026 class QKeyEvent;
00027 class KKeyNative;
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class KKey
00040 {
00041 public:
00046 enum { MOD_FLAG_COUNT = 4 };
00047 enum { QtWIN = (Qt::ALT << 1) };
00052 enum ModFlag {
00053 SHIFT = 0x01,
00054 CTRL = 0x02,
00055 ALT = 0x04,
00056 WIN = 0x08
00057 };
00058
00065 KKey();
00066
00072 KKey( int keyQt );
00073
00078 KKey( const QKeySequence& keySeq );
00079
00084 KKey( const QKeyEvent* keyEvent );
00085
00089 KKey( const KKey& key );
00090
00099 KKey( const QString& key );
00103 KKey( uint key, uint mod );
00104 ~KKey();
00105
00106
00111 void clear();
00112
00119 bool init( int keyQt );
00120
00126 bool init( const QKeySequence& keySeq );
00127
00133 bool init( const QKeyEvent* keyEvent );
00134
00140 bool init( const KKey& key );
00141
00151 bool init( const QString& );
00152
00156 bool init( uint key, uint mod );
00157
00161 KKey& operator =( const KKey& key )
00162 { init( key ); return *this; }
00163
00164
00172 bool isNull() const;
00173
00177 bool isValidQt() const;
00178
00182 bool isValidNative() const;
00183
00187 uint sym() const;
00191 uint modFlags() const;
00192
00193
00204 int compare( const KKey& key ) const;
00205
00210 bool operator == ( const KKey& key ) const
00211 { return compare( key ) == 0; }
00216 bool operator != ( const KKey& key ) const
00217 { return compare( key ) != 0; }
00222 bool operator < ( const KKey& key ) const
00223 { return compare( key ) < 0; }
00224
00225
00231 int keyCodeQt() const;
00232
00238 QString toString() const;
00239
00243 QString toStringInternal() const;
00244
00245
00249 void simplify();
00250
00257 static KKey& null();
00258
00264 static QString modFlagLabel( ModFlag f );
00265
00266 private:
00267
00268
00269
00270
00277 uint m_sym;
00281 uint m_mod;
00282
00283 private:
00284 friend class KKeyNative;
00285 };
00286
00294 class KKeySequence
00295 {
00296 public:
00298 enum { MAX_KEYS = 4 };
00299
00306 KKeySequence();
00307
00312 KKeySequence( const QKeySequence& keySeq );
00313
00318 KKeySequence( const KKey& key );
00319
00324 KKeySequence( const KKeyNative& key );
00325
00330 KKeySequence( const KKeySequence& keySeq );
00331
00340 KKeySequence( const QString& keySeq );
00341
00342 ~KKeySequence();
00343
00349 void clear();
00350
00356 bool init( const QKeySequence& keySeq );
00357
00363 bool init( const KKey& key );
00364
00370 bool init( const KKeyNative& key );
00371
00377 bool init( const KKeySequence& keySeq );
00378
00388 bool init( const QString& key );
00389
00393 KKeySequence& operator =( const KKeySequence& seq )
00394 { init( seq ); return *this; }
00395
00401 uint count() const;
00402
00411 const KKey& key( uint i ) const;
00412
00416 bool isTriggerOnRelease() const;
00417
00426 bool setKey( uint i, const KKey& key );
00427
00431 void setTriggerOnRelease( bool );
00432
00440 bool isNull() const;
00441
00447 bool startsWith( const KKeySequence& keySeq ) const;
00448
00461 int compare( const KKeySequence& keySeq ) const;
00462
00467 bool operator == ( const KKeySequence& seq ) const
00468 { return compare( seq ) == 0; }
00469
00474 bool operator != ( const KKeySequence& seq ) const
00475 { return compare( seq ) != 0; }
00476
00481 bool operator < ( const KKeySequence& seq ) const
00482 { return compare( seq ) < 0; }
00483
00484
00489 QKeySequence qt() const;
00490
00497 int keyCodeQt() const;
00498
00505 QString toString() const;
00506
00510 QString toStringInternal() const;
00511
00518 static KKeySequence& null();
00519
00520 protected:
00521 uchar m_nKeys;
00522 uchar m_bTriggerOnRelease;
00523
00524 KKey m_rgvar[MAX_KEYS];
00525
00526 private:
00527 class KKeySequencePrivate* d;
00528 friend class KKeyNative;
00529 };
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539 class KShortcut
00540 {
00541 public:
00546 enum { MAX_SEQUENCES = 2 };
00547
00554 KShortcut();
00555
00562 KShortcut( int keyQt );
00563
00569 KShortcut( const QKeySequence& keySeq );
00570
00576 KShortcut( const KKey& key );
00577
00583 KShortcut( const KKeySequence& keySeq );
00584
00589 KShortcut( const KShortcut& shortcut );
00590
00598 KShortcut( const char* shortcut );
00599
00607 KShortcut( const QString& shortcut );
00608 ~KShortcut();
00609
00615 void clear();
00616
00623 bool init( int keyQt );
00624
00629 bool init( const QKeySequence& keySeq );
00630
00635 bool init( const KKey& key );
00636
00641 bool init( const KKeySequence& keySeq );
00642
00647 bool init( const KShortcut& shortcut );
00648
00656 bool init( const QString& shortcut );
00657
00661 KShortcut& operator =( const KShortcut& cut )
00662 { init( cut ); return *this; }
00663
00670 uint count() const;
00671
00679 const KKeySequence& seq( uint i ) const;
00680
00688 int keyCodeQt() const;
00689
00697 bool isNull() const;
00698
00712 int compare( const KShortcut& shortcut ) const;
00713
00718 bool operator == ( const KShortcut& cut ) const
00719 { return compare( cut ) == 0; }
00720
00725 bool operator != ( const KShortcut& cut ) const
00726 { return compare( cut ) != 0; }
00727
00732 bool operator < ( const KShortcut& cut ) const
00733 { return compare( cut ) < 0; }
00734
00741 bool contains( const KKey& key ) const;
00742
00749 bool contains( const KKeyNative& key ) const;
00750
00756 bool contains( const KKeySequence& keySeq ) const;
00757
00767 bool setSeq( uint i, const KKeySequence& keySeq );
00768
00776 bool append( const KKeySequence& keySeq );
00777
00782 operator QKeySequence () const;
00783
00791 QString toString() const;
00792
00796 QString toStringInternal( const KShortcut* pcutDefault = 0 ) const;
00797
00804 static KShortcut& null();
00805
00806 protected:
00807 uint m_nSeqs;
00808 KKeySequence m_rgseq[MAX_SEQUENCES];
00809
00810 private:
00811 class KShortcutPrivate* d;
00812 friend class KKeyNative;
00813
00814 #ifndef KDE_NO_COMPAT
00815 public:
00816 operator int () const { return keyCodeQt(); }
00817 #endif
00818 };
00819
00820 #endif // __KSHORTCUT_H
This file is part of the documentation for kdelibs Version 3.1.5.