Warning, file /frameworks/kwidgetsaddons/src/ktoolbarpopupaction.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org> 0004 SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org> 0005 SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org> 0006 SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org> 0007 SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org> 0008 SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org> 0009 SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org> 0010 SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org> 0011 SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org> 0012 0013 SPDX-License-Identifier: LGPL-2.0-only 0014 */ 0015 0016 #ifndef KTOOLBARPOPUPACTION_H 0017 #define KTOOLBARPOPUPACTION_H 0018 0019 #include <QToolButton> 0020 #include <QWidgetAction> 0021 #include <memory> 0022 0023 #include <kwidgetsaddons_export.h> 0024 0025 class QMenu; 0026 0027 /** 0028 * @class KToolBarPopupAction ktoolbarpopupaction.h KToolBarPopupAction 0029 * 0030 * This action is a normal action everywhere, except in a toolbar 0031 * where it also has a popupmenu (optionally delayed). This action is designed 0032 * for history actions (back/forward, undo/redo) and for any other action 0033 * that has more detail in a toolbar than in a menu (e.g. tool chooser 0034 * with "Other" leading to a dialog...). 0035 * 0036 * In contrast to KActionMenu, this action is a \e simple menuitem when plugged 0037 * into a menu, and has a popup only in a toolbar. 0038 * 0039 * Use cases include Back/Forward, and Undo/Redo. Simple click is what's most commonly 0040 * used, and enough for menus, but in toolbars there is \e also an optional popup 0041 * to go back N steps or undo N steps. 0042 */ 0043 class KWIDGETSADDONS_EXPORT KToolBarPopupAction : public QWidgetAction 0044 { 0045 Q_OBJECT 0046 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 78) 0047 Q_PROPERTY(bool delayed READ delayed WRITE setDelayed) 0048 Q_PROPERTY(bool stickyMenu READ stickyMenu WRITE setStickyMenu) 0049 #endif 0050 Q_PROPERTY(QToolButton::ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode) 0051 0052 public: 0053 // Not all constructors - because we need an icon, since this action only makes 0054 // sense when being plugged at least in a toolbar. 0055 /** 0056 * Create a KToolBarPopupAction, with a text, an icon, a 0057 * parent and a name. 0058 * 0059 * @param icon The icon to display. 0060 * @param text The text that will be displayed. 0061 * @param parent This action's parent. 0062 */ 0063 KToolBarPopupAction(const QIcon &icon, const QString &text, QObject *parent); 0064 0065 /** 0066 * Destroys the toolbar popup action. 0067 */ 0068 ~KToolBarPopupAction() override; 0069 0070 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 0) 0071 /** 0072 * The popup menu that is shown when clicking (some time) on the toolbar 0073 * button. You may want to plug items into it on creation, or connect to 0074 * aboutToShow for a more dynamic menu. 0075 * 0076 * \deprecated Since 5.0, use menu() instead 0077 */ 0078 KWIDGETSADDONS_DEPRECATED_VERSION(5, 0, "Use KToolBarPopupAction::menu()") 0079 QMenu *popupMenu() const; 0080 #endif 0081 0082 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 78) 0083 /** 0084 * Returns true if this action creates a delayed popup menu 0085 * when plugged in a KToolBar. 0086 * 0087 * @deprecated Since 5.78, use popupMode() instead. 0088 */ 0089 bool delayed() const; 0090 #endif 0091 0092 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 78) 0093 /** 0094 * If set to true, this action will create a delayed popup menu 0095 * when plugged in a KToolBar. Otherwise it creates a normal popup. 0096 * Default: delayed. 0097 * 0098 * @deprecated Since 5.78, use setPopupMode() instead. 0099 */ 0100 void setDelayed(bool delayed); 0101 #endif 0102 0103 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 78) 0104 /** 0105 * Returns true if this action creates a sticky popup menu. 0106 * @see setStickyMenu(). 0107 * @deprecated Since 5.78, use popupMode() instead. 0108 */ 0109 bool stickyMenu() const; 0110 #endif 0111 0112 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 78) 0113 /** 0114 * If set to true, this action will create a sticky popup menu 0115 * when plugged in a KToolBar. 0116 * "Sticky", means it's visible until a selection is made or the mouse is 0117 * clicked elsewhere. This feature allows you to make a selection without 0118 * having to press and hold down the mouse while making a selection. 0119 * Only available if delayed() is true. 0120 * Default: sticky. 0121 * 0122 * @deprecated Since 5.78, use setPopupMode() instead. 0123 */ 0124 void setStickyMenu(bool sticky); 0125 #endif 0126 0127 /** 0128 * The popup mode of the toolbar button. 0129 * 0130 * @see setPopupMode() 0131 * 0132 * @since 5.78 0133 */ 0134 QToolButton::ToolButtonPopupMode popupMode() const; 0135 0136 /** 0137 * Determines the popup mode of the toolbar button. 0138 * 0139 * Options are: 0140 * - QToolButton::InstantPopup 0141 * Clicking anywhere on the toolbar button opens the popup menu. 0142 * - QToolButton::DelayedPopup 0143 * Clicking anywhere on the toolbar button triggers the default action. 0144 * Clicking and holding the toolbar button opens the popup menu instead. 0145 * - QToolButton::MenuButtonPopup (Default) 0146 * The toolbar button is split in a main button (triggers default action) 0147 * and an arrow button (opens the popup menu). 0148 * 0149 * @see QToolButton 0150 * 0151 * @since 5.78 0152 */ 0153 void setPopupMode(QToolButton::ToolButtonPopupMode popupMode); 0154 0155 /** 0156 * Reimplemented from QWidgetAction. 0157 */ 0158 QWidget *createWidget(QWidget *parent) override; 0159 0160 private: 0161 std::unique_ptr<class KToolBarPopupActionPrivate> const d; 0162 }; 0163 0164 #endif