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

KDEUI

  • 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
29class QStackedWidget;
30
41class KAccelString
42{
43public:
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
66private:
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
79typedef QList<KAccelString> KAccelStringList;
80
81
89class KAccelManagerAlgorithm
90{
91public:
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
130class KPopupAccelManager : public QObject
131{
132 Q_OBJECT
133
134public:
135
136 static void manage(QMenu *popup);
137
138
139protected:
140
141 KPopupAccelManager(QMenu *popup);
142
143
144private Q_SLOTS:
145
146 void aboutToShow();
147
148
149private:
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
163class QWidgetStackAccelManager : public QObject
164{
165 Q_OBJECT
166
167public:
168
169 static void manage(QStackedWidget *popup);
170
171
172protected:
173
174 QWidgetStackAccelManager(QStackedWidget *popup);
175
176
177private Q_SLOTS:
178
179 void currentChanged(int child);
180 bool eventFilter ( QObject * watched, QEvent * e );
181
182private:
183
184 void calculateAccelerators();
185
186 QStackedWidget *m_stack;
187 KAccelStringList m_entries;
188
189};
190
191
192#endif // KACCELERATORMANAGER_PRIVATE_H
KAccelManagerAlgorithm
This class encapsulates the algorithm finding the 'best' distribution of accelerators in a hierarchy ...
Definition: kacceleratormanager_private.h:90
KAccelManagerAlgorithm::findAccelerators
static void findAccelerators(KAccelStringList &result, QString &used)
Definition: kacceleratormanager.cpp:737
KAccelManagerAlgorithm::DEFAULT_WEIGHT
@ DEFAULT_WEIGHT
Definition: kacceleratormanager_private.h:95
KAccelManagerAlgorithm::WANTED_ACCEL_EXTRA_WEIGHT
@ WANTED_ACCEL_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:103
KAccelManagerAlgorithm::CHECKABLE_GROUP_BOX_WEIGHT
@ CHECKABLE_GROUP_BOX_WEIGHT
Definition: kacceleratormanager_private.h:109
KAccelManagerAlgorithm::ACTION_ELEMENT_WEIGHT
@ ACTION_ELEMENT_WEIGHT
Definition: kacceleratormanager_private.h:105
KAccelManagerAlgorithm::MENU_TITLE_WEIGHT
@ MENU_TITLE_WEIGHT
Definition: kacceleratormanager_private.h:111
KAccelManagerAlgorithm::FIRST_CHARACTER_EXTRA_WEIGHT
@ FIRST_CHARACTER_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:97
KAccelManagerAlgorithm::STANDARD_ACCEL
@ STANDARD_ACCEL
Definition: kacceleratormanager_private.h:113
KAccelManagerAlgorithm::WORD_BEGINNING_EXTRA_WEIGHT
@ WORD_BEGINNING_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:99
KAccelManagerAlgorithm::GROUP_BOX_WEIGHT
@ GROUP_BOX_WEIGHT
Definition: kacceleratormanager_private.h:107
KAccelManagerAlgorithm::DIALOG_BUTTON_EXTRA_WEIGHT
@ DIALOG_BUTTON_EXTRA_WEIGHT
Definition: kacceleratormanager_private.h:101
KAccelString
A string class handling accelerators.
Definition: kacceleratormanager_private.h:42
KAccelString::KAccelString
KAccelString()
Definition: kacceleratormanager_private.h:45
KAccelString::calculateWeights
void calculateWeights(int initialWeight)
Definition: kacceleratormanager.cpp:598
KAccelString::pure
const QString & pure() const
Definition: kacceleratormanager_private.h:50
KAccelString::originalText
QString originalText() const
Definition: kacceleratormanager_private.h:57
KAccelString::maxWeight
int maxWeight(int &index, const QString &used) const
Definition: kacceleratormanager.cpp:678
KAccelString::setAccel
void setAccel(int accel)
Definition: kacceleratormanager_private.h:54
KAccelString::accel
int accel() const
Definition: kacceleratormanager_private.h:53
KAccelString::accelerator
QChar accelerator() const
Definition: kacceleratormanager.cpp:589
KAccelString::operator==
bool operator==(const KAccelString &c) const
Definition: kacceleratormanager_private.h:63
KAccelString::accelerated
QString accelerated() const
Definition: kacceleratormanager.cpp:559
KAccelString::originalAccel
int originalAccel() const
Definition: kacceleratormanager_private.h:56
KPopupAccelManager
This class manages a popup menu.
Definition: kacceleratormanager_private.h:131
KPopupAccelManager::manage
static void manage(QMenu *popup)
Definition: kacceleratormanager.cpp:875
QList
QMenu
QObject
QWidgetStackAccelManager
Definition: kacceleratormanager_private.h:164
QWidgetStackAccelManager::manage
static void manage(QStackedWidget *popup)
Definition: kacceleratormanager.cpp:882
KAccelStringList
QList< KAccelString > KAccelStringList
Definition: kacceleratormanager_private.h:79
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 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-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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