KDEUI
kmenu.h
Go to the documentation of this file.
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> 00003 Copyright (C) 2006 Olivier Goffart <ogoffart@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 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 #ifndef KMENU_H 00021 #define KMENU_H 00022 00023 #include <kdeui_export.h> 00024 00025 #include <QtGui/QMenu> 00026 00042 class KDEUI_EXPORT KMenu : public QMenu { 00043 Q_OBJECT 00044 public: 00048 explicit KMenu(QWidget *parent = 0L); 00049 00056 explicit KMenu(const QString& title, QWidget *parent = 0L); 00057 00061 ~KMenu(); 00062 00066 QAction* addTitle(const QString &text, QAction* before = 0L); 00067 00071 QAction* addTitle(const QIcon &icon, const QString &text, QAction* before = 0L); 00072 00088 void setKeyboardShortcutsEnabled(bool enable); 00089 00094 void setKeyboardShortcutsExecute(bool enable); 00095 00101 QMenu* contextMenu(); 00102 00106 const QMenu* contextMenu() const; 00107 00111 void hideContextMenu(); 00112 00116 static KMenu* contextMenuFocus(); 00117 00121 static QAction* contextMenuFocusAction(); 00122 00126 Qt::MouseButtons mouseButtons() const; 00127 00131 Qt::KeyboardModifiers keyboardModifiers() const; 00132 00133 Q_SIGNALS: 00140 void aboutToShowContextMenu(KMenu* menu, QAction* menuAction, QMenu* ctxMenu); 00141 00142 protected: 00143 virtual void closeEvent(QCloseEvent *); 00144 virtual void keyPressEvent(QKeyEvent* e); 00145 virtual void mouseReleaseEvent(QMouseEvent* e); 00146 virtual void mousePressEvent(QMouseEvent* e); 00147 virtual bool focusNextPrevChild( bool next ); 00148 virtual void contextMenuEvent(QContextMenuEvent *e); 00149 virtual void hideEvent(QHideEvent*); 00150 00151 private: 00152 QString underlineText(const QString& text, uint length); 00153 class KMenuPrivate; 00154 KMenuPrivate * const d; 00155 00156 Q_PRIVATE_SLOT(d, void resetKeyboardVars(bool b = false)) 00157 Q_PRIVATE_SLOT(d, void actionHovered(QAction*)) 00158 Q_PRIVATE_SLOT(d, void showCtxMenu(const QPoint &)) 00159 00160 }; 00161 00162 00163 00164 #endif
KDE 4.6 API Reference