1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 (C) 2003 Andras Mantia <amantia@kde.org>
10 (C) 2005-2006 Hamish Rodda <rodda@kde.org>
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License version 2 as published by the Free Software Foundation.
15
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
20
21 You should have received a copy of the GNU Library General Public License
22 along with this library; see the file COPYING.LIB. If not, write to
23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 Boston, MA 02110-1301, USA.
25*/
26
27#ifndef KTOGGLETOOLBARACTION_H
28#define KTOGGLETOOLBARACTION_H
29
30#include <ktoggleaction.h>
31
32class KToolBar;
33
34/**
35 * An action that takes care of everything associated with
36 * showing or hiding a toolbar by a menu action. It will
37 * show or hide the toolbar with the given name when
38 * activated, and check or uncheck itself if the toolbar
39 * is manually shown or hidden.
40 *
41 * If you need to perfom some additional action when the
42 * toolbar is shown or hidden, connect to the toggled(bool)
43 * signal. It will be emitted after the toolbar's
44 * visibility has changed, whenever it changes.
45 */
46class KDEUI_EXPORT KToggleToolBarAction : public KToggleAction
47{
48 Q_OBJECT
49
50 public:
51 /**
52 * Create a KToggleToolbarAction that manages the toolbar
53 * named toolBarName. This can be either the name of a
54 * toolbar in an xml ui file, or a toolbar programmatically
55 * created with that name.
56 *
57 * @param The action's parent object.
58 */
59 KToggleToolBarAction(const char* toolBarName, const QString& text, QObject *parent);
60
61 /**
62 * Create a KToggleToolbarAction that manages the @param toolBar.
63 * This can be either the name of a toolbar in an xml ui file,
64 * or a toolbar programmatically created with that name.
65 *
66 * @param toolBar the toolbar to be managed
67 * @param parent The action's parent object.
68 */
69 KToggleToolBarAction(KToolBar *toolBar, const QString &text, QObject *parent);
70
71 /**
72 * Destroys toggle toolbar action.
73 */
74 virtual ~KToggleToolBarAction();
75
76 /**
77 * Returns a pointer to the tool bar it manages.
78 */
79 KToolBar *toolBar();
80
81 /**
82 * Reimplemented from @see QObject.
83 */
84 virtual bool eventFilter( QObject* watched, QEvent* event );
85
86 private Q_SLOTS:
87 virtual void slotToggled( bool checked );
88
89 private:
90 class Private;
91 Private* const d;
92};
93
94#endif
95