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
00230
QString toString() const;
00231
00236
QString toStringInternal() const;
00237
00238
00242
void simplify();
00243
00250 static
KKey& null();
00251
00257 static
QString modFlagLabel( ModFlag f );
00258
00259 private:
00260
00261
00262
00263
00270 uint m_sym;
00274 uint m_mod;
00275
00276 private:
00277 friend class
KKeyNative;
00278 };
00279
00287 class
KKeySequence
00288 {
00289
public:
00291
enum { MAX_KEYS = 4 };
00292
00299 KKeySequence();
00300
00305 KKeySequence(
const QKeySequence& keySeq );
00306
00311 KKeySequence(
const KKey& key );
00312
00317 KKeySequence(
const KKeyNative& key );
00318
00323 KKeySequence(
const KKeySequence& keySeq );
00324
00333 KKeySequence(
const QString& keySeq );
00334
00335 ~KKeySequence();
00336
00342
void clear();
00343
00349
bool init(
const QKeySequence& keySeq );
00350
00356
bool init(
const KKey& key );
00357
00363
bool init(
const KKeyNative& key );
00364
00370
bool init(
const KKeySequence& keySeq );
00371
00381
bool init(
const QString& key );
00382
00386 KKeySequence&
operator =(
const KKeySequence& seq )
00387 {
init( seq );
return *
this; }
00388
00394 uint count() const;
00395
00404 const
KKey& key( uint i ) const;
00405
00409
bool isTriggerOnRelease() const;
00410
00419
bool setKey( uint i, const
KKey& key );
00420
00428
bool isNull() const;
00429
00435
bool startsWith( const KKeySequence& keySeq ) const;
00436
00449
int compare( const KKeySequence& keySeq ) const;
00450
00455 bool operator == ( const KKeySequence& seq )
const
00456
{
return compare( seq ) == 0; }
00457
00462 bool operator != (
const KKeySequence& seq )
const
00463
{
return compare( seq ) != 0; }
00464
00469 bool operator < (
const KKeySequence& seq )
const
00470
{
return compare( seq ) < 0; }
00471
00472
00477
QKeySequence qt() const;
00478
00485
int keyCodeQt() const;
00486
00493
QString toString() const;
00494
00498
QString toStringInternal() const;
00499
00506 static KKeySequence& null();
00507
00508 protected:
00509 uchar m_nKeys;
00510 uchar m_bTriggerOnRelease;
00511
00512
KKey m_rgvar[MAX_KEYS];
00513
00514 private:
00515 class KKeySequencePrivate* d;
00516 friend class KKeyNative;
00517 };
00518
00527 class
KShortcut
00528 {
00529
public:
00534
enum { MAX_SEQUENCES = 2 };
00535
00542 KShortcut();
00543
00550 KShortcut(
int keyQt );
00551
00557 KShortcut(
const QKeySequence& keySeq );
00558
00564 KShortcut(
const KKey& key );
00565
00571 KShortcut(
const KKeySequence& keySeq );
00572
00577 KShortcut(
const KShortcut& shortcut );
00578
00586 KShortcut(
const char* shortcut );
00587
00595 KShortcut(
const QString& shortcut );
00596 ~KShortcut();
00597
00603
void clear();
00604
00611
bool init(
int keyQt );
00612
00617
bool init(
const QKeySequence& keySeq );
00618
00623
bool init(
const KKey& key );
00624
00629
bool init(
const KKeySequence& keySeq );
00630
00635
bool init(
const KShortcut& shortcut );
00636
00644
bool init(
const QString& shortcut );
00645
00649 KShortcut&
operator =(
const KShortcut& cut )
00650 {
init( cut );
return *
this; }
00651
00658 uint count() const;
00659
00667 const KKeySequence& seq( uint i ) const;
00668
00676
int keyCodeQt() const;
00677
00685
bool isNull() const;
00686
00700
int compare( const KShortcut& shortcut ) const;
00701
00706 bool operator == ( const KShortcut& cut )
const
00707
{
return compare( cut ) == 0; }
00708
00713 bool operator != (
const KShortcut& cut )
const
00714
{
return compare( cut ) != 0; }
00715
00720 bool operator < (
const KShortcut& cut )
const
00721
{
return compare( cut ) < 0; }
00722
00729
bool contains(
const KKey& key )
const;
00730
00737
bool contains(
const KKeyNative& key )
const;
00738
00744
bool contains(
const KKeySequence& keySeq )
const;
00745
00755
bool setSeq( uint i,
const KKeySequence& keySeq );
00756
00764
bool append(
const KKeySequence& keySeq );
00765
00771
void remove(
const KKeySequence& keySeq );
00772
00781
bool append(
const KKey& spec );
00782
00790
bool append(
const KShortcut& cut );
00791
00796 operator QKeySequence () const;
00797
00805
QString toString() const;
00806
00810
QString toStringInternal( const KShortcut* pcutDefault = 0 ) const;
00811
00818 static KShortcut& null();
00819
00820 protected:
00821 uint m_nSeqs;
00822 KKeySequence m_rgseq[MAX_SEQUENCES];
00823
00824 private:
00825 class KShortcutPrivate* d;
00826 friend class KKeyNative;
00827
00828 #ifndef KDE_NO_COMPAT
00829 public:
00830 operator
int ()
const {
return keyCodeQt(); }
00831
#endif
00832
};
00833
00834
#endif // __KSHORTCUT_H