File indexing completed on 2024-04-14 03:57:12

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 KTOGGLETOOLBARACTION_H
0017 #define KTOGGLETOOLBARACTION_H
0018 
0019 #include <KToggleAction>
0020 #include <kxmlgui_export.h>
0021 #include <memory>
0022 
0023 class KToolBar;
0024 
0025 /**
0026  * @class KToggleToolBarAction ktoggletoolbaraction.h KToggleToolBarAction
0027  *
0028  * An action that takes care of everything associated with
0029  * showing or hiding a toolbar by a menu action. It will
0030  * show or hide the toolbar with the given name when
0031  * activated, and check or uncheck itself if the toolbar
0032  * is manually shown or hidden.
0033  *
0034  * If you need to perform some additional action when the
0035  * toolbar is shown or hidden, connect to the toggled(bool)
0036  * signal. It will be emitted after the toolbar's
0037  * visibility has changed, whenever it changes.
0038  */
0039 class KXMLGUI_EXPORT KToggleToolBarAction : public KToggleAction
0040 {
0041     Q_OBJECT
0042 
0043 public:
0044     /**
0045      * Create a KToggleToolBarAction that manages the @p toolBar.
0046      *
0047      * @param toolBar the toolbar to be managed
0048      * @param parent the action's parent object.
0049      */
0050     KToggleToolBarAction(KToolBar *toolBar, const QString &text, QObject *parent);
0051 
0052     /**
0053      * Destroys toggle toolbar action.
0054      */
0055     ~KToggleToolBarAction() override;
0056 
0057     /**
0058      * Returns a pointer to the tool bar it manages.
0059      */
0060     KToolBar *toolBar();
0061 
0062     /**
0063      * Reimplemented from QObject.
0064      */
0065     bool eventFilter(QObject *watched, QEvent *event) override;
0066 
0067 private Q_SLOTS:
0068     void slotToggled(bool checked) override;
0069 
0070 private:
0071     std::unique_ptr<class KToggleToolBarActionPrivate> const d;
0072 };
0073 
0074 #endif