KDELibs4Support

kmenu.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 2000 Daniel M. Duley <[email protected]>
3  Copyright (C) 2006 Olivier Goffart <[email protected]>
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License version 2 as published by the Free Software Foundation.
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 #ifndef KMENU_H
21 #define KMENU_H
22 
23 #include <kdelibs4support_export.h>
24 
25 #include <QMenu>
26 
42 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KMenu : public QMenu
43 {
44  Q_OBJECT
45 public:
49  KDELIBS4SUPPORT_DEPRECATED explicit KMenu(QWidget *parent = nullptr);
50 
57  KDELIBS4SUPPORT_DEPRECATED explicit KMenu(const QString &title, QWidget *parent = nullptr);
58 
62  ~KMenu();
63 
67  QAction *addTitle(const QString &text, QAction *before = nullptr);
68 
72  QAction *addTitle(const QIcon &icon, const QString &text, QAction *before = nullptr);
73 
89  void setKeyboardShortcutsEnabled(bool enable);
90 
95  void setKeyboardShortcutsExecute(bool enable);
96 
102  QMenu *contextMenu();
103 
107  const QMenu *contextMenu() const;
108 
112  void hideContextMenu();
113 
117  static KMenu *contextMenuFocus();
118 
122  static QAction *contextMenuFocusAction();
123 
127  Qt::MouseButtons mouseButtons() const;
128 
132  Qt::KeyboardModifiers keyboardModifiers() const;
133 
134 Q_SIGNALS:
141  void aboutToShowContextMenu(KMenu *menu, QAction *menuAction, QMenu *ctxMenu);
142 
143 protected:
144  void closeEvent(QCloseEvent *) override;
145  void keyPressEvent(QKeyEvent *e) override;
146  void mouseReleaseEvent(QMouseEvent *e) override;
147  void mousePressEvent(QMouseEvent *e) override;
148  bool focusNextPrevChild(bool next) override;
149  void contextMenuEvent(QContextMenuEvent *e) override;
150  void hideEvent(QHideEvent *) override;
151 
152 private:
153  QString underlineText(const QString &text, uint length);
154  class KMenuPrivate;
155  KMenuPrivate *const d;
156 
157  Q_PRIVATE_SLOT(d, void resetKeyboardVars(bool b = false))
158  Q_PRIVATE_SLOT(d, void actionHovered(QAction *))
159  Q_PRIVATE_SLOT(d, void showCtxMenu(const QPoint &))
160 
161 };
162 
163 #endif
typedef KeyboardModifiers
virtual bool focusNextPrevChild(bool next) override
A menu with keyboard searching.
Definition: kmenu.h:42
typedef MouseButtons
virtual void contextMenuEvent(QContextMenuEvent *event)
virtual void mousePressEvent(QMouseEvent *e) override
virtual void hideEvent(QHideEvent *) override
virtual void closeEvent(QCloseEvent *event)
virtual void mouseReleaseEvent(QMouseEvent *e) override
virtual void keyPressEvent(QKeyEvent *e) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat Jul 4 2020 22:58:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.