| 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 KTOGGLETOOLBARACTION_H |
| 17 | #define KTOGGLETOOLBARACTION_H |
| 18 | |
| 19 | #include <KToggleAction> |
| 20 | #include <kxmlgui_export.h> |
| 21 | #include <memory> |
| 22 | |
| 23 | class KToolBar; |
| 24 | |
| 25 | /*! |
| 26 | * \class KToggleToolBarAction |
| 27 | * \inmodule KXmlGui |
| 28 | * |
| 29 | * An action that takes care of everything associated with |
| 30 | * showing or hiding a toolbar by a menu action. It will |
| 31 | * show or hide the toolbar with the given name when |
| 32 | * activated, and check or uncheck itself if the toolbar |
| 33 | * is manually shown or hidden. |
| 34 | * |
| 35 | * If you need to perform some additional action when the |
| 36 | * toolbar is shown or hidden, connect to the toggled(bool) |
| 37 | * signal. It will be emitted after the toolbar's |
| 38 | * visibility has changed, whenever it changes. |
| 39 | */ |
| 40 | class KXMLGUI_EXPORT KToggleToolBarAction : public KToggleAction |
| 41 | { |
| 42 | Q_OBJECT |
| 43 | |
| 44 | public: |
| 45 | /*! |
| 46 | * \brief Creates a KToggleToolBarAction that manages the \a toolBar |
| 47 | * with \a text in its label, as a child of \a parent. |
| 48 | */ |
| 49 | KToggleToolBarAction(KToolBar *toolBar, const QString &text, QObject *parent); |
| 50 | |
| 51 | /*! |
| 52 | * \brief Destroys the toggle toolbar action. |
| 53 | */ |
| 54 | ~KToggleToolBarAction() override; |
| 55 | |
| 56 | /*! |
| 57 | * \brief Returns a pointer to the tool bar it manages. |
| 58 | */ |
| 59 | KToolBar *toolBar(); |
| 60 | |
| 61 | /*! |
| 62 | * \brief Filters then returns the specified \a event |
| 63 | * for a given \a watched object. |
| 64 | * |
| 65 | * Reimplemented from QObject. |
| 66 | */ |
| 67 | bool eventFilter(QObject *watched, QEvent *event) override; |
| 68 | |
| 69 | private Q_SLOTS: |
| 70 | void slotToggled(bool checked) override; |
| 71 | |
| 72 | private: |
| 73 | std::unique_ptr<class KToggleToolBarActionPrivate> const d; |
| 74 | }; |
| 75 | |
| 76 | #endif |
| 77 | |