File indexing completed on 2024-09-08 12:23:24
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 toolbar 0046 * named @p toolBarName. This can be either the name of a 0047 * toolbar in an xml ui file, or a toolbar programmatically 0048 * created with that name. 0049 * 0050 * @param parent the action's parent object. 0051 */ 0052 KToggleToolBarAction(const char *toolBarName, const QString &text, QObject *parent); 0053 0054 /** 0055 * Create a KToggleToolBarAction that manages the @p toolBar. 0056 * 0057 * @param toolBar the toolbar to be managed 0058 * @param parent the action's parent object. 0059 */ 0060 KToggleToolBarAction(KToolBar *toolBar, const QString &text, QObject *parent); 0061 0062 /** 0063 * Destroys toggle toolbar action. 0064 */ 0065 ~KToggleToolBarAction() override; 0066 0067 /** 0068 * Returns a pointer to the tool bar it manages. 0069 */ 0070 KToolBar *toolBar(); 0071 0072 /** 0073 * Reimplemented from QObject. 0074 */ 0075 bool eventFilter(QObject *watched, QEvent *event) override; 0076 0077 private Q_SLOTS: 0078 void slotToggled(bool checked) override; 0079 0080 private: 0081 std::unique_ptr<class KToggleToolBarActionPrivate> const d; 0082 }; 0083 0084 #endif