1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org>
4 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
5 SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org>
6 SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org>
7 SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org>
8 SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
9 SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org>
10 SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org>
11 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
12
13 SPDX-License-Identifier: LGPL-2.0-only
14*/
15
16#ifndef KACTIONMENU_H
17#define KACTIONMENU_H
18
19#include <QToolButton>
20#include <QWidgetAction>
21#include <memory>
22
23#include <kwidgetsaddons_export.h>
24
25class QMenu;
26
27/*!
28 * \class KActionMenu
29 * \inmodule KWidgetsAddons
30 *
31 * \brief A KActionMenu is an action that provides a sub-menu of other actions.
32 *
33 * Plugged in a popupmenu, it will create a submenu.
34 *
35 * Plugged in a toolbar, it will create a button with a popup menu.
36 *
37 * This is the action used by the XMLGUI since it holds other actions.
38 *
39 * If you want a submenu for selecting one tool among many (without icons), see KSelectAction.
40 */
41class KWIDGETSADDONS_EXPORT KActionMenu : public QWidgetAction
42{
43 Q_OBJECT
44
45 /*!
46 * \property KActionMenu::popupMode
47 */
48 Q_PROPERTY(QToolButton::ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode)
49
50public:
51 /*!
52 *
53 */
54 explicit KActionMenu(QObject *parent);
55
56 /*!
57 *
58 */
59 KActionMenu(const QString &text, QObject *parent);
60
61 /*!
62 *
63 */
64 KActionMenu(const QIcon &icon, const QString &text, QObject *parent);
65
66 ~KActionMenu() override;
67
68 /*!
69 * Adds \a action to this KActionMenu.
70 * The KActionMenu does not take ownership of \a action.
71 */
72 void addAction(QAction *action);
73
74 /*!
75 *
76 */
77 QAction *addSeparator();
78
79 /*!
80 *
81 */
82 void insertAction(QAction *before, QAction *action);
83
84 /*!
85 *
86 */
87 QAction *insertSeparator(QAction *before);
88
89 /*!
90 *
91 */
92 void removeAction(QAction *action);
93
94 /*!
95 * The currently used popup mode when plugged in a KToolBar.
96 *
97 * \sa setPopupMode()
98 *
99 * \since 5.77
100 */
101 QToolButton::ToolButtonPopupMode popupMode() const;
102
103 /*!
104 * Determines the popup mode when plugged in a KToolBar.
105 *
106 * Options are:
107 * \list
108 * \li QToolButton::InstantPopup
109 * Clicking anywhere on the toolbar button opens the popup menu.
110 * \li QToolButton::DelayedPopup (Default)
111 * Clicking anywhere on the toolbar button triggers the default action.
112 * Clicking and holding the toolbar button opens the popup menu instead.
113 * \li QToolButton::MenuButtonPopup
114 * The toolbar button is split in a main button (triggers default action)
115 * and an arrow button (opens the popup menu).
116 * \endlist
117 *
118 * \sa QToolButton
119 *
120 * \since 5.77
121 */
122 void setPopupMode(QToolButton::ToolButtonPopupMode popupMode);
123
124 QWidget *createWidget(QWidget *parent) override;
125
126private:
127 std::unique_ptr<class KActionMenuPrivate> const d;
128};
129
130#endif
131

source code of kwidgetsaddons/src/kactionmenu.h