• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

  • sources
  • kde-4.14
  • kdelibs
  • kdeui
  • shortcuts
kshortcut.h
Go to the documentation of this file.
1 /* This file is part of the KDE libraries
2  Copyright (C) 2001,2002 Ellis Whitehead <ellis@kde.org>
3  Copyright (C) 2006 Hamish Rodda <rodda@kde.org>
4  Copyright (C) 2006 Andreas Hartmetz <ahartmetz@gmail.com>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
27 #ifndef KSHORTCUT_H
28 #define KSHORTCUT_H
29 
30 #include <kdeui_export.h>
31 
32 #include <QtCore/QList>
33 #include <QtCore/QMetaType>
34 #include <QtGui/QKeySequence>
35 
36 class KShortcutPrivate;
37 
57 class KDEUI_EXPORT KShortcut
58 {
59 public:
63  enum EmptyHandling {
65  KeepEmpty = 0,
67  RemoveEmpty
68  };
69 
75  KShortcut();
76 
82  explicit KShortcut(const QKeySequence &primary);
83 
91  KShortcut(const QKeySequence &primary, const QKeySequence &alternate);
92 
101  explicit KShortcut(int keyQtPri, int keyQtAlt = 0);
102 
106  KShortcut(const KShortcut &other);
107 
117  explicit KShortcut(const QString &description);
118 
125  explicit KShortcut(const QList<QKeySequence> &seqs);
126 
130  ~KShortcut();
131 
139  QKeySequence primary() const;
140 
145  QKeySequence alternate() const;
146 
151  bool isEmpty() const;
152 
157  bool contains(const QKeySequence &needle) const;
158 
163  bool conflictsWith(const QKeySequence &needle) const;
164 
172  QString toString() const;
173 
182  QString toString(QKeySequence::SequenceFormat format) const;
183 
184  bool operator==(const KShortcut &other) const;
185 
186  bool operator!=(const KShortcut &other) const;
187 
196  operator QList<QKeySequence>() const;
197 
205  QList<QKeySequence> toList(enum EmptyHandling handleEmpty = RemoveEmpty) const;
206 
210  operator QVariant() const;
211 
220  void setPrimary(const QKeySequence &keySeq);
221 
226  void setAlternate(const QKeySequence &keySeq);
227 
234  void remove(const QKeySequence &keySeq, enum EmptyHandling handleEmpty = RemoveEmpty);
235 
239  KShortcut &operator=(const KShortcut &other);
240 
241 private:
242  class KShortcutPrivate *const d;
243 };
244 
245 uint qHash(int);
246 inline uint qHash(const KShortcut &key)
247 {
248  return qHash(key.primary()[0]) + qHash(key.primary()[1]);
249 }
250 
251 inline uint qHash(const QKeySequence &key)
252 {
253  uint hash = 0;
254  for(uint i = 0; i < key.count(); i++)
255  hash += qHash(key[i]);
256  return hash;
257 }
258 
259 Q_DECLARE_METATYPE(KShortcut)
260 
261 #endif // KSHORTCUT_H
QKeySequence::count
uint count() const
operator!=
bool operator!=(const KEntry &k1, const KEntry &k2)
KShortcut
Represents a keyboard shortcut.
Definition: kshortcut.h:57
operator==
bool operator==(const KEntry &k1, const KEntry &k2)
QString
QList
KShortcut::EmptyHandling
EmptyHandling
An enum about the behavior of operations that treat a KShortcut like a list of QKeySequences.
Definition: kshortcut.h:63
qHash
uint qHash(int)
QKeySequence
kdeui_export.h
KShortcut::primary
QKeySequence primary() const
Returns the primary key sequence of this shortcut.
Definition: kshortcut.cpp:134
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:24:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal