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

KDEUI

  • sources
  • kde-4.12
  • kdelibs
  • kdeui
  • shortcuts
kacceleratormanager_private.h
Go to the documentation of this file.
1 /* This file is part of the KDE project
2  Copyright (C) 2002 Matthias H�zer-Klpfel <mhk@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 
21 #ifndef KACCELERATORMANAGER_PRIVATE_H
22 #define KACCELERATORMANAGER_PRIVATE_H
23 
24 
25 #include <QtCore/QString>
26 
27 #include <QtCore/QObject>
28 
29 class QStackedWidget;
30 
41 class KAccelString
42 {
43 public:
44 
45  KAccelString() : m_pureText(), m_accel(-1) {}
46  explicit KAccelString(const QString &input, int initalWeight=-1);
47 
48  void calculateWeights(int initialWeight);
49 
50  const QString &pure() const { return m_pureText; }
51  QString accelerated() const;
52 
53  int accel() const { return m_accel; }
54  void setAccel(int accel) { m_accel = accel; }
55 
56  int originalAccel() const { return m_orig_accel; }
57  QString originalText() const { return m_origText; }
58 
59  QChar accelerator() const;
60 
61  int maxWeight(int &index, const QString &used) const;
62 
63  bool operator == (const KAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && m_orig_accel == c.m_orig_accel; }
64 
65 
66 private:
67 
68  int stripAccelerator(QString &input);
69 
70  void dump();
71 
72  QString m_pureText, m_origText;
73  int m_accel, m_orig_accel;
74  QVector<int> m_weight;
75 
76 };
77 
78 
79 typedef QList<KAccelString> KAccelStringList;
80 
81 
89 class KAccelManagerAlgorithm
90 {
91 public:
92 
93  enum {
94  // Default control weight
95  DEFAULT_WEIGHT = 50,
96  // Additional weight for first character in string
97  FIRST_CHARACTER_EXTRA_WEIGHT = 50,
98  // Additional weight for the beginning of a word
99  WORD_BEGINNING_EXTRA_WEIGHT = 50,
100  // Additional weight for the dialog buttons (large, we basically never want these reassigned)
101  DIALOG_BUTTON_EXTRA_WEIGHT = 300,
102  // Additional weight for a 'wanted' accelerator
103  WANTED_ACCEL_EXTRA_WEIGHT = 150,
104  // Default weight for an 'action' widget (ie, pushbuttons)
105  ACTION_ELEMENT_WEIGHT = 50,
106  // Default weight for group boxes (lowest priority)
107  GROUP_BOX_WEIGHT = -2000,
108  // Default weight for checkable group boxes (low priority)
109  CHECKABLE_GROUP_BOX_WEIGHT = 20,
110  // Default weight for menu titles
111  MENU_TITLE_WEIGHT = 250,
112  // Additional weight for KDE standard accelerators
113  STANDARD_ACCEL = 300
114  };
115 
116  static void findAccelerators(KAccelStringList &result, QString &used);
117 
118 };
119 
120 
130 class KPopupAccelManager : public QObject
131 {
132  Q_OBJECT
133 
134 public:
135 
136  static void manage(QMenu *popup);
137 
138 
139 protected:
140 
141  KPopupAccelManager(QMenu *popup);
142 
143 
144 private Q_SLOTS:
145 
146  void aboutToShow();
147 
148 
149 private:
150 
151  void calculateAccelerators();
152 
153  void findMenuEntries(KAccelStringList &list);
154  void setMenuEntries(const KAccelStringList &list);
155 
156  QMenu *m_popup;
157  KAccelStringList m_entries;
158  int m_count;
159 
160 };
161 
162 
163 class QWidgetStackAccelManager : public QObject
164 {
165  Q_OBJECT
166 
167 public:
168 
169  static void manage(QStackedWidget *popup);
170 
171 
172 protected:
173 
174  QWidgetStackAccelManager(QStackedWidget *popup);
175 
176 
177 private Q_SLOTS:
178 
179  void currentChanged(int child);
180  bool eventFilter ( QObject * watched, QEvent * e );
181 
182 private:
183 
184  void calculateAccelerators();
185 
186  QStackedWidget *m_stack;
187  KAccelStringList m_entries;
188 
189 };
190 
191 
192 #endif // KACCELERATORMANAGER_PRIVATE_H
KAccelString::pure
const QString & pure() const
Definition: kacceleratormanager_private.h:50
KAccelManagerAlgorithm::DEFAULT_WEIGHT
Definition: kacceleratormanager_private.h:95
QWidgetStackAccelManager::QWidgetStackAccelManager
QWidgetStackAccelManager(QStackedWidget *popup)
Definition: kacceleratormanager.cpp:888
KAccelString
A string class handling accelerators.
Definition: kacceleratormanager_private.h:41
KAccelManagerAlgorithm::WANTED_ACCEL_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:103
KAccelString::accelerated
QString accelerated() const
Definition: kacceleratormanager.cpp:559
QString
QObject
KAccelString::KAccelString
KAccelString()
Definition: kacceleratormanager_private.h:45
KAccelManagerAlgorithm::FIRST_CHARACTER_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:97
QWidgetStackAccelManager::manage
static void manage(QStackedWidget *popup)
Definition: kacceleratormanager.cpp:882
KPopupAccelManager
This class manages a popup menu.
Definition: kacceleratormanager_private.h:130
KAccelManagerAlgorithm::WORD_BEGINNING_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:99
KPopupAccelManager::KPopupAccelManager
KPopupAccelManager(QMenu *popup)
Definition: kacceleratormanager.cpp:787
KAccelManagerAlgorithm::ACTION_ELEMENT_WEIGHT
Definition: kacceleratormanager_private.h:105
KAccelString::originalText
QString originalText() const
Definition: kacceleratormanager_private.h:57
KAccelManagerAlgorithm
This class encapsulates the algorithm finding the 'best' distribution of accelerators in a hierarchy ...
Definition: kacceleratormanager_private.h:89
KAccelManagerAlgorithm::findAccelerators
static void findAccelerators(KAccelStringList &result, QString &used)
Definition: kacceleratormanager.cpp:737
KAccelString::maxWeight
int maxWeight(int &index, const QString &used) const
Definition: kacceleratormanager.cpp:678
KAccelManagerAlgorithm::GROUP_BOX_WEIGHT
Definition: kacceleratormanager_private.h:107
QMenu
QWidgetStackAccelManager
Definition: kacceleratormanager_private.h:163
KPopupAccelManager::manage
static void manage(QMenu *popup)
Definition: kacceleratormanager.cpp:875
KAccelString::setAccel
void setAccel(int accel)
Definition: kacceleratormanager_private.h:54
KAccelString::calculateWeights
void calculateWeights(int initialWeight)
Definition: kacceleratormanager.cpp:598
KAccelString::operator==
bool operator==(const KAccelString &c) const
Definition: kacceleratormanager_private.h:63
KAccelManagerAlgorithm::STANDARD_ACCEL
Definition: kacceleratormanager_private.h:113
KAccelStringList
QList< KAccelString > KAccelStringList
Definition: kacceleratormanager_private.h:79
KAccelString::accelerator
QChar accelerator() const
Definition: kacceleratormanager.cpp:589
QList< KAccelString >
KAccelManagerAlgorithm::DIALOG_BUTTON_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:101
KAccelManagerAlgorithm::MENU_TITLE_WEIGHT
Definition: kacceleratormanager_private.h:111
KAccelString::originalAccel
int originalAccel() const
Definition: kacceleratormanager_private.h:56
KAccelString::accel
int accel() const
Definition: kacceleratormanager_private.h:53
KAccelManagerAlgorithm::CHECKABLE_GROUP_BOX_WEIGHT
Definition: kacceleratormanager_private.h:109
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:13 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • 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