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

KDECore

kaccelmanager_private.h

Go to the documentation of this file.
00001 /*  This file is part of the KDE project
00002     Copyright (C) 2002 Matthias Hoelzer-Kluepfel <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 __KACCELMANAGER_PRIVATE_H__
00022 #define __KACCELMANAGER_PRIVATE_H__
00023 
00024 
00025 #include <qstring.h>
00026 #include <qmemarray.h>
00027 #include <qvaluelist.h>
00028 #include <qobject.h>
00029 
00030 class QWidgetStack;
00031 
00042 class KAccelString
00043 {
00044 public:
00045 
00046   KAccelString() : m_pureText(), m_accel(-1) {}
00047   KAccelString(const QString &input, int initalWeight=-1);
00048 
00049   void calculateWeights(int initialWeight);
00050 
00051   const QString &pure() const { return m_pureText; }
00052   QString accelerated() const;
00053 
00054   int accel() const { return m_accel; }
00055   void setAccel(int accel) { m_accel = accel; }
00056 
00057   int originalAccel() const { return m_orig_accel; }
00058   QString originalText() const { return m_origText; }
00059 
00060   QChar accelerator() const;
00061 
00062   int maxWeight(int &index, const QString &used);
00063 
00064   bool operator == (const KAccelString &c) const { return m_pureText == c.m_pureText && m_accel == c.m_accel && m_orig_accel == c.m_orig_accel; }
00065 
00066 
00067 private:
00068 
00069   int stripAccelerator(QString &input);
00070 
00071   void dump();
00072 
00073   QString        m_pureText,  m_origText;
00074   int            m_accel, m_orig_accel;
00075   QMemArray<int> m_weight;
00076 
00077 };
00078 
00079 
00080 typedef QValueList<KAccelString> KAccelStringList;
00081 
00082 
00090 class KAccelManagerAlgorithm
00091 {
00092 public:
00093 
00095   enum {
00097     DEFAULT_WEIGHT = 50,
00099     FIRST_CHARACTER_EXTRA_WEIGHT = 50,
00101     WORD_BEGINNING_EXTRA_WEIGHT = 50,
00103     DIALOG_BUTTON_EXTRA_WEIGHT = 300,
00105     WANTED_ACCEL_EXTRA_WEIGHT = 150,
00107     ACTION_ELEMENT_WEIGHT = 50,
00109     GROUP_BOX_WEIGHT = -2000,
00111     MENU_TITLE_WEIGHT = 250,
00113     STANDARD_ACCEL = 300
00114   };
00115 
00117   static void findAccelerators(KAccelStringList &result, QString &used);
00118 
00119 };
00120 
00121 
00122 class QPopupMenu;
00123 
00124 
00134 class KPopupAccelManager : public QObject
00135 {
00136   Q_OBJECT
00137 
00138 public:
00139 
00140   static void manage(QPopupMenu *popup);
00141 
00142 
00143 protected:
00144 
00145   KPopupAccelManager(QPopupMenu *popup);
00146 
00147 
00148 private slots:
00149 
00150   void aboutToShow();
00151 
00152 
00153 private:
00154 
00155   void calculateAccelerators();
00156 
00157   void findMenuEntries(KAccelStringList &list);
00158   void setMenuEntries(const KAccelStringList &list);
00159 
00160   QPopupMenu       *m_popup;
00161   KAccelStringList m_entries;
00162   int              m_count;
00163 
00164 };
00165 
00166 
00167 class QWidgetStackAccelManager : public QObject
00168 {
00169   Q_OBJECT
00170 
00171 public:
00172 
00173   static void manage(QWidgetStack *popup);
00174 
00175 
00176 protected:
00177 
00178   QWidgetStackAccelManager(QWidgetStack *popup);
00179 
00180 
00181 private slots:
00182 
00183   void aboutToShow(QWidget *);
00184     bool eventFilter ( QObject * watched, QEvent * e );
00185 
00186 private:
00187 
00188   void calculateAccelerators();
00189 
00190   QWidgetStack     *m_stack;
00191   KAccelStringList m_entries;
00192 
00193 };
00194 
00195 
00196 #endif

KDECore

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
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