File indexing completed on 2024-06-16 04:15:40

0001 /* This file is part of the KDE libraries
0002     SPDX-FileCopyrightText: 1999 Reginald Stadlbauer <reggie@kde.org>
0003     SPDX-FileCopyrightText: 1999 Simon Hausmann <hausmann@kde.org>
0004     SPDX-FileCopyrightText: 2000 Nicolas Hadacek <haadcek@kde.org>
0005     SPDX-FileCopyrightText: 2000 Kurt Granroth <granroth@kde.org>
0006     SPDX-FileCopyrightText: 2000 Michael Koch <koch@kde.org>
0007     SPDX-FileCopyrightText: 2001 Holger Freyther <freyther@kde.org>
0008     SPDX-FileCopyrightText: 2002 Ellis Whitehead <ellis@kde.org>
0009     SPDX-FileCopyrightText: 2003 Andras Mantia <amantia@kde.org>
0010     SPDX-FileCopyrightText: 2005-2006 Hamish Rodda <rodda@kde.org>
0011 
0012     SPDX-License-Identifier: LGPL-2.0-only
0013 */
0014 
0015 #ifndef KTOGGLETOOLBARACTION_H
0016 #define KTOGGLETOOLBARACTION_H
0017 
0018 #include <ktoggleaction.h>
0019 #include <kritawidgetutils_export.h>
0020 
0021 class KisToolBar;
0022 
0023 /**
0024  * An action that takes care of everything associated with
0025  * showing or hiding a toolbar by a menu action. It will
0026  * show or hide the toolbar with the given name when
0027  * activated, and check or uncheck itself if the toolbar
0028  * is manually shown or hidden.
0029  *
0030  * If you need to perform some additional action when the
0031  * toolbar is shown or hidden, connect to the toggled(bool)
0032  * signal. It will be emitted after the toolbar's
0033  * visibility has changed, whenever it changes.
0034  */
0035 class KRITAWIDGETUTILS_EXPORT KToggleToolBarAction : public KToggleAction
0036 {
0037     Q_OBJECT
0038 
0039 public:
0040     /**
0041      * Create a KisKToggleToolbarAction that manages the toolbar
0042      * named @p toolBarName. This can be either the name of a
0043      * toolbar in an xml ui file, or a toolbar programmatically
0044      * created with that name.
0045      *
0046      * @param toolBarName The toolbar name.
0047      * @param text The toolbar hint text.
0048      * @param parent The action's parent object.
0049      */
0050     KToggleToolBarAction(const char *toolBarName, const QString &text, QObject *parent);
0051 
0052     /**
0053      * Create a KisKToggleToolbarAction that manages the @p toolBar.
0054      * This can be either the name of a toolbar in an xml ui file,
0055      * or a toolbar programmatically created with that name.
0056      *
0057      * @param toolBar the toolbar to be managed
0058      * @param text The action's text
0059      * @param parent The action's parent object.
0060      */
0061     KToggleToolBarAction(KisToolBar *toolBar, const QString &text, QObject *parent);
0062 
0063     /**
0064      * Destroys toggle toolbar action.
0065      */
0066     ~KToggleToolBarAction() override;
0067 
0068     /**
0069      * Returns a pointer to the tool bar it manages.
0070      */
0071     KisToolBar *toolBar();
0072 
0073     /**
0074      * Reimplemented from @see QObject.
0075      */
0076     bool eventFilter(QObject *watched, QEvent *event) override;
0077 
0078 private Q_SLOTS:
0079     void slotToggled(bool checked) override;
0080 
0081 private:
0082     class Private;
0083     Private *const d;
0084 };
0085 
0086 #endif