• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
tdeshortcut.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef __TDESHORTCUT_H
21 #define __TDESHORTCUT_H
22 
23 #include <tqkeysequence.h>
24 #include <tqstring.h>
25 #include "tdelibs_export.h"
26 
27 class TQKeyEvent;
28 class KKeyNative;
29 
40 class TDECORE_EXPORT KKey
41 {
42  public:
47  enum { MOD_FLAG_COUNT = 4 };
48  enum { QtWIN = (Qt::META) };
53  enum ModFlag {
54  SHIFT = 0x01,
55  CTRL = 0x02,
56  ALT = 0x04,
57  WIN = 0x08
58  };
59 
66  KKey();
67 
73  KKey( int keyQt );
74 
79  KKey( const TQKeySequence& keySeq );
80 
85  KKey( const TQKeyEvent* keyEvent );
86 
90  KKey( const KKey& key );
91 
100  KKey( const TQString& key );
104  KKey( uint key, uint mod );
105  ~KKey();
106 
107  // Initialization methods
112  void clear();
113 
120  bool init( int keyQt );
121 
127  bool init( const TQKeySequence& keySeq );
128 
134  bool init( const TQKeyEvent* keyEvent );
135 
141  bool init( const KKey& key );
142 
152  bool init( const TQString& key);
153 
157  bool init( uint key, uint mod );
158 
162  KKey& operator =( const KKey& key )
163  { init( key ); return *this; }
164 
165  // Query methods.
173  bool isNull() const;
174 
178  uint sym() const;
182  uint modFlags() const;
183 
184  // Comparison Methods
195  int compare( const KKey& key ) const;
196 
201  bool operator == ( const KKey& key ) const
202  { return compare( key ) == 0; }
207  bool operator != ( const KKey& key ) const
208  { return compare( key ) != 0; }
213  bool operator < ( const KKey& key ) const
214  { return compare( key ) < 0; }
215 
216  // Conversion methods.
222  int keyCodeQt() const;
223 
231  TQString toString() const;
232 
237  TQString toStringInternal() const;
238 
239  // Operation methods
243  void simplify();
244 
251  static KKey& null();
252 
258  static TQString modFlagLabel( ModFlag f );
259 
260  private:
261  /*
262  * Under X11, m_key will hold an X11 key symbol.
263  * For Qt/Embedded, it will hold the Qt key code.
264  */
271  uint m_sym;
275  uint m_mod;
276 
277  private:
278  friend class KKeyNative;
279 };
280 
288 class TDECORE_EXPORT KKeySequence
289 {
290  public:
292  enum { MAX_KEYS = 4 };
293 
300  KKeySequence();
301 
306  KKeySequence( const TQKeySequence& keySeq );
307 
312  KKeySequence( const KKey& key );
313 
318  KKeySequence( const KKeyNative& key );
319 
324  KKeySequence( const KKeySequence& keySeq );
325 
334  KKeySequence( const TQString& keySeq );
335 
336  ~KKeySequence();
337 
343  void clear();
344 
350  bool init( const TQKeySequence& keySeq );
351 
357  bool init( const KKey& key );
358 
364  bool init( const KKeyNative& key );
365 
371  bool init( const KKeySequence& keySeq );
372 
382  bool init( const TQString& key );
383 
387  KKeySequence& operator =( const KKeySequence& seq )
388  { init( seq ); return *this; }
389 
395  uint count() const;
396 
405  const KKey& key( uint i ) const;
406 
410  bool isTriggerOnRelease() const;
411 
420  bool setKey( uint i, const KKey& key );
421 
429  bool isNull() const;
430 
436  bool startsWith( const KKeySequence& keySeq ) const;
437 
450  int compare( const KKeySequence& keySeq ) const;
451 
456  bool operator == ( const KKeySequence& seq ) const
457  { return compare( seq ) == 0; }
458 
463  bool operator != ( const KKeySequence& seq ) const
464  { return compare( seq ) != 0; }
465 
470  bool operator < ( const KKeySequence& seq ) const
471  { return compare( seq ) < 0; }
472  // TODO: consider adding Qt::SequenceMatch matches(...) methods for TQKeySequence equivalence
473 
478  TQKeySequence qt() const;
479 
486  int keyCodeQt() const;
487 
494  TQString toString() const;
495 
499  TQString toStringInternal() const;
500 
507  static KKeySequence& null();
508 
509  protected:
510  uchar m_nKeys;
511  uchar m_bTriggerOnRelease;
512  // BCI: m_rgvar should be renamed to m_rgkey for KDE 4.0
513  KKey m_rgvar[MAX_KEYS];
514 
515  private:
516  class KKeySequencePrivate* d;
517  friend class KKeyNative;
518 };
519 
543 class TDECORE_EXPORT TDEShortcut
544 {
545  public:
550  enum { MAX_SEQUENCES = 2 };
551 
558  TDEShortcut();
559 
566  TDEShortcut( int keyQt );
567 
573  TDEShortcut( const TQKeySequence& keySeq );
574 
580  TDEShortcut( const KKey& key );
581 
587  TDEShortcut( const KKeySequence& keySeq );
588 
593  TDEShortcut( const TDEShortcut& shortcut );
594 
602  TDEShortcut( const char* shortcut );
603 
611  TDEShortcut( const TQString& shortcut );
612  ~TDEShortcut();
613 
619  void clear();
620 
627  bool init( int keyQt );
628 
633  bool init( const TQKeySequence& keySeq );
634 
639  bool init( const KKey& key );
640 
645  bool init( const KKeySequence& keySeq );
646 
651  bool init( const TDEShortcut& shortcut );
652 
660  bool init( const TQString& shortcut );
661 
665  TDEShortcut& operator =( const TDEShortcut& cut )
666  { init( cut ); return *this; }
667 
674  uint count() const;
675 
683  const KKeySequence& seq( uint i ) const;
684 
692  int keyCodeQt() const;
693 
701  bool isNull() const;
702 
716  int compare( const TDEShortcut& shortcut ) const;
717 
722  bool operator == ( const TDEShortcut& cut ) const
723  { return compare( cut ) == 0; }
724 
729  bool operator != ( const TDEShortcut& cut ) const
730  { return compare( cut ) != 0; }
731 
736  bool operator < ( const TDEShortcut& cut ) const
737  { return compare( cut ) < 0; }
738 
745  bool contains( const KKey& key ) const;
746 
753  bool contains( const KKeyNative& key ) const;
754 
760  bool contains( const KKeySequence& keySeq ) const;
761 
770  bool setSeq( uint i, const KKeySequence& keySeq );
771 
781  bool append( const KKeySequence& keySeq );
782 
788  void remove( const KKeySequence& keySeq );
789 
798  bool append( const KKey& spec );
799 
807  bool append( const TDEShortcut& cut );
808 
813  operator TQKeySequence () const;
814 
822  TQString toString() const;
823 
827  TQString toStringInternal( const TDEShortcut* pcutDefault = 0 ) const;
828 
835  static TDEShortcut& null();
836 
837  protected:
838  uint m_nSeqs;
839  KKeySequence m_rgseq[MAX_SEQUENCES];
840 
841  private:
842  class TDEShortcutPrivate* d;
843  friend class KKeyNative;
844 
845 #ifndef KDE_NO_COMPAT
846  public:
847  operator int () const { return keyCodeQt(); }
848 #endif
849 };
850 
851 #endif // __TDESHORTCUT_H
KKey::ModFlag
ModFlag
Flags to represent the modifiers.
Definition: tdeshortcut.h:53
KKeySequence
A KKeySequence object holds a sequence of up to 4 keys.
Definition: tdeshortcut.h:288
KKeyNative::keyCodeQt
int keyCodeQt() const
Returns the qt key code.
KKeyNative
Representation of a key in the format native of the windowing system (eg.
Definition: kkeynative.h:37
KKey
A KKey object represents a single key with possible modifiers (Shift, Ctrl, Alt, Win).
Definition: tdeshortcut.h:40
TDEShortcut
The TDEShortcut class is used to represent a keyboard shortcut to an action.
Definition: tdeshortcut.h:543

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.