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

KDEUI

kacceleratormanager_private.h

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2002 Matthias H�zer-Klpfel <mhk@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or
00005     modify it under the terms of the GNU Library General Public
00006     License as published by the Free Software Foundation; either
00007     version 2 of the License, or (at your option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     Library General Public License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to
00016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017     Boston, MA 02110-1301, USA.
00018 */
00019 
00020 
00021 #ifndef KACCELERATORMANAGER_PRIVATE_H
00022 #define KACCELERATORMANAGER_PRIVATE_H
00023 
00024 
00025 #include <QtCore/QString>
00026 
00027 #include <QtCore/QObject>
00028 
00029 class QStackedWidget;
00030 
00041 class KAccelString
00042 {
00043 public:
00044 
00045   KAccelString() : m_pureText(), m_accel(-1) {}
00046   explicit KAccelString(const QString &input, int initalWeight=-1);
00047 
00048   void calculateWeights(int initialWeight);
00049 
00050   const QString &pure() const { return m_pureText; }
00051   QString accelerated() const;
00052 
00053   int accel() const { return m_accel; }
00054   void setAccel(int accel) { m_accel = accel; }
00055 
00056   int originalAccel() const { return m_orig_accel; }
00057   QString originalText() const { return m_origText; }
00058 
00059   QChar accelerator() const;
00060 
00061   int maxWeight(int &index, const QString &used) const;
00062 
00063   bool operator == (const KAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && m_orig_accel == c.m_orig_accel; }
00064 
00065 
00066 private:
00067 
00068   int stripAccelerator(QString &input);
00069 
00070   void dump();
00071 
00072   QString        m_pureText,  m_origText;
00073   int            m_accel, m_orig_accel;
00074   QVector<int> m_weight;
00075 
00076 };
00077 
00078 
00079 typedef QList<KAccelString> KAccelStringList;
00080 
00081 
00089 class KAccelManagerAlgorithm
00090 {
00091 public:
00092 
00093   enum {
00094     // Default control weight
00095     DEFAULT_WEIGHT = 50,
00096     // Additional weight for first character in string
00097     FIRST_CHARACTER_EXTRA_WEIGHT = 50,
00098     // Additional weight for the beginning of a word
00099     WORD_BEGINNING_EXTRA_WEIGHT = 50,
00100     // Additional weight for the dialog buttons (large, we basically never want these reassigned)
00101     DIALOG_BUTTON_EXTRA_WEIGHT = 300,
00102     // Additional weight for a 'wanted' accelerator
00103     WANTED_ACCEL_EXTRA_WEIGHT = 150,
00104     // Default weight for an 'action' widget (ie, pushbuttons)
00105     ACTION_ELEMENT_WEIGHT = 50,
00106     // Default weight for group boxes (low priority)
00107     GROUP_BOX_WEIGHT = -2000,
00108     // Default weight for menu titles
00109     MENU_TITLE_WEIGHT = 250,
00110     // Additional weight for KDE standard accelerators
00111     STANDARD_ACCEL = 300
00112   };
00113 
00114   static void findAccelerators(KAccelStringList &result, QString &used);
00115 
00116 };
00117 
00118 
00128 class KPopupAccelManager : public QObject
00129 {
00130   Q_OBJECT
00131 
00132 public:
00133 
00134   static void manage(QMenu *popup);
00135 
00136 
00137 protected:
00138 
00139   KPopupAccelManager(QMenu *popup);
00140 
00141 
00142 private Q_SLOTS:
00143 
00144   void aboutToShow();
00145 
00146 
00147 private:
00148 
00149   void calculateAccelerators();
00150 
00151   void findMenuEntries(KAccelStringList &list);
00152   void setMenuEntries(const KAccelStringList &list);
00153 
00154   QMenu       *m_popup;
00155   KAccelStringList m_entries;
00156   int              m_count;
00157 
00158 };
00159 
00160 
00161 class QWidgetStackAccelManager : public QObject
00162 {
00163   Q_OBJECT
00164 
00165 public:
00166 
00167   static void manage(QStackedWidget *popup);
00168 
00169 
00170 protected:
00171 
00172   QWidgetStackAccelManager(QStackedWidget *popup);
00173 
00174 
00175 private Q_SLOTS:
00176 
00177     void currentChanged(int child);
00178     bool eventFilter ( QObject * watched, QEvent * e );
00179 
00180 private:
00181 
00182   void calculateAccelerators();
00183 
00184   QStackedWidget     *m_stack;
00185   KAccelStringList m_entries;
00186 
00187 };
00188 
00189 
00190 #endif // KACCELERATORMANAGER_PRIVATE_H

KDEUI

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal