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 kactionmenu.h KActionMenu
29 *
30 * A KActionMenu is an action that provides a sub-menu of other actions.
31 *
32 * Plugged in a popupmenu, it will create a submenu.
33 * Plugged in a toolbar, it will create a button with a popup menu.
34 *
35 * This is the action used by the XMLGUI since it holds other actions.
36 * If you want a submenu for selecting one tool among many (without icons), see KSelectAction.
37 */
38class KWIDGETSADDONS_EXPORT KActionMenu : public QWidgetAction
39{
40 Q_OBJECT
41 Q_PROPERTY(QToolButton::ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode)
42
43public:
44 explicit KActionMenu(QObject *parent);
45 KActionMenu(const QString &text, QObject *parent);
46 KActionMenu(const QIcon &icon, const QString &text, QObject *parent);
47 ~KActionMenu() override;
48
49 /**
50 * Adds @p action to this KActionMenu.
51 * The KActionMenu does not take ownership of @p action.
52 */
53 void addAction(QAction *action);
54 QAction *addSeparator();
55 void insertAction(QAction *before, QAction *action);
56 QAction *insertSeparator(QAction *before);
57 void removeAction(QAction *action);
58
59 /**
60 * The currently used popup mode when plugged in a KToolBar.
61 *
62 * @see setPopupMode()
63 *
64 * @since 5.77
65 */
66 QToolButton::ToolButtonPopupMode popupMode() const;
67
68 /**
69 * Determines the popup mode when plugged in a KToolBar.
70 *
71 * Options are:
72 * - QToolButton::InstantPopup
73 * Clicking anywhere on the toolbar button opens the popup menu.
74 * - QToolButton::DelayedPopup (Default)
75 * Clicking anywhere on the toolbar button triggers the default action.
76 * Clicking and holding the toolbar button opens the popup menu instead.
77 * - QToolButton::MenuButtonPopup
78 * The toolbar button is split in a main button (triggers default action)
79 * and an arrow button (opens the popup menu).
80 *
81 * @see QToolButton
82 *
83 * @since 5.77
84 */
85 void setPopupMode(QToolButton::ToolButtonPopupMode popupMode);
86
87 QWidget *createWidget(QWidget *parent) override;
88
89private:
90 std::unique_ptr<class KActionMenuPrivate> const d;
91};
92
93#endif
94

source code of kwidgetsaddons/src/kactionmenu.h