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
00039 class KKey
00040 {
00041
public:
00046
enum { MOD_FLAG_COUNT = 4 };
00047
enum { QtWIN = (Qt::META) };
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& key);
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 uint sym() const;
00181 uint modFlags() const;
00182
00183
00194
int compare( const
KKey& key ) const;
00195
00200 bool operator == ( const
KKey& key )
const
00201
{
return compare( key ) == 0; }
00206 bool operator != (
const KKey& key )
const
00207
{
return compare( key ) != 0; }
00212 bool operator < (
const KKey& key )
const
00213
{
return compare( key ) < 0; }
00214
00215
00221
int keyCodeQt() const;
00222
00228
QString toString() const;
00229
00233
QString toStringInternal() const;
00234
00235
00239
void simplify();
00240
00247 static
KKey& null();
00248
00254 static
QString modFlagLabel( ModFlag f );
00255
00256 private:
00257
00258
00259
00260
00267 uint m_sym;
00271 uint m_mod;
00272
00273 private:
00274 friend class
KKeyNative;
00275 };
00276
00284 class
KKeySequence
00285 {
00286
public:
00288
enum { MAX_KEYS = 4 };
00289
00296 KKeySequence();
00297
00302 KKeySequence(
const QKeySequence& keySeq );
00303
00308 KKeySequence(
const KKey& key );
00309
00314 KKeySequence(
const KKeyNative& key );
00315
00320 KKeySequence(
const KKeySequence& keySeq );
00321
00330 KKeySequence(
const QString& keySeq );
00331
00332 ~KKeySequence();
00333
00339
void clear();
00340
00346
bool init(
const QKeySequence& keySeq );
00347
00353
bool init(
const KKey& key );
00354
00360
bool init(
const KKeyNative& key );
00361
00367
bool init(
const KKeySequence& keySeq );
00368
00378
bool init(
const QString& key );
00379
00383 KKeySequence& operator =(
const KKeySequence& seq )
00384 { init( seq );
return *
this; }
00385
00391 uint count() const;
00392
00401 const
KKey& key( uint i ) const;
00402
00406
bool isTriggerOnRelease() const;
00407
00416
bool setKey( uint i, const
KKey& key );
00417
00425
bool isNull() const;
00426
00432
bool startsWith( const KKeySequence& keySeq ) const;
00433
00446
int compare( const KKeySequence& keySeq ) const;
00447
00452 bool operator == ( const KKeySequence& seq )
const
00453
{
return compare( seq ) == 0; }
00454
00459 bool operator != (
const KKeySequence& seq )
const
00460
{
return compare( seq ) != 0; }
00461
00466 bool operator < (
const KKeySequence& seq )
const
00467
{
return compare( seq ) < 0; }
00468
00469
00474
QKeySequence qt() const;
00475
00482
int keyCodeQt() const;
00483
00490
QString toString() const;
00491
00495
QString toStringInternal() const;
00496
00503 static KKeySequence& null();
00504
00505 protected:
00506 uchar m_nKeys;
00507 uchar m_bTriggerOnRelease;
00508
00509
KKey m_rgvar[MAX_KEYS];
00510
00511 private:
00512 class KKeySequencePrivate* d;
00513 friend class KKeyNative;
00514 };
00515
00524 class
KShortcut
00525 {
00526
public:
00531
enum { MAX_SEQUENCES = 2 };
00532
00539 KShortcut();
00540
00547 KShortcut(
int keyQt );
00548
00554 KShortcut(
const QKeySequence& keySeq );
00555
00561 KShortcut(
const KKey& key );
00562
00568 KShortcut(
const KKeySequence& keySeq );
00569
00574 KShortcut(
const KShortcut& shortcut );
00575
00583 KShortcut(
const char* shortcut );
00584
00592 KShortcut(
const QString& shortcut );
00593 ~KShortcut();
00594
00600
void clear();
00601
00608
bool init(
int keyQt );
00609
00614
bool init(
const QKeySequence& keySeq );
00615
00620
bool init(
const KKey& key );
00621
00626
bool init(
const KKeySequence& keySeq );
00627
00632
bool init(
const KShortcut& shortcut );
00633
00641
bool init(
const QString& shortcut );
00642
00646 KShortcut& operator =(
const KShortcut& cut )
00647 { init( cut );
return *
this; }
00648
00655 uint count() const;
00656
00664 const KKeySequence& seq( uint i ) const;
00665
00673
int keyCodeQt() const;
00674
00682
bool isNull() const;
00683
00697
int compare( const KShortcut& shortcut ) const;
00698
00703 bool operator == ( const KShortcut& cut )
const
00704
{
return compare( cut ) == 0; }
00705
00710 bool operator != (
const KShortcut& cut )
const
00711
{
return compare( cut ) != 0; }
00712
00717 bool operator < (
const KShortcut& cut )
const
00718
{
return compare( cut ) < 0; }
00719
00726
bool contains(
const KKey& key )
const;
00727
00734
bool contains(
const KKeyNative& key )
const;
00735
00741
bool contains(
const KKeySequence& keySeq )
const;
00742
00752
bool setSeq( uint i,
const KKeySequence& keySeq );
00753
00761
bool append(
const KKeySequence& keySeq );
00762
00771
bool append(
const KKey& spec );
00772
00780
bool append(
const KShortcut& cut );
00781
00786 operator QKeySequence () const;
00787
00795
QString toString() const;
00796
00800
QString toStringInternal( const KShortcut* pcutDefault = 0 ) const;
00801
00808 static KShortcut& null();
00809
00810 protected:
00811 uint m_nSeqs;
00812 KKeySequence m_rgseq[MAX_SEQUENCES];
00813
00814 private:
00815 class KShortcutPrivate* d;
00816 friend class KKeyNative;
00817
00818 #ifndef KDE_NO_COMPAT
00819 public:
00820 operator
int ()
const {
return keyCodeQt(); }
00821
#endif
00822
};
00823
00824
#endif // __KSHORTCUT_H