~ubuntu-branches/ubuntu/gutsy/kde4libs/gutsy

« back to all changes in this revision

Viewing changes to kdeui/actions/ktoolbarlabelaction.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-02-21 11:00:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070221110012-6kw8khr9knv6lmg1
Tags: 3.80.3-0ubuntu1
New upstream unstable release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE libraries
 
2
    Copyright (C) 2004 Felix Berger <felixberger@beldesign.de>
 
3
 
 
4
    This library is free software; you can redistribute it and/or
 
5
    modify it under the terms of the GNU Library General Public
 
6
    License version 2 as published by the Free Software Foundation.
 
7
 
 
8
    This library is distributed in the hope that it will be useful,
 
9
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
    Library General Public License for more details.
 
12
 
 
13
    You should have received a copy of the GNU Library General Public License
 
14
    along with this library; see the file COPYING.LIB.  If not, write to
 
15
    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
16
    Boston, MA 02110-1301, USA.
 
17
*/
 
18
 
 
19
#ifndef KTOOLBARLABELACTION_H
 
20
#define KTOOLBARLABELACTION_H
 
21
 
 
22
#include <kaction.h>
 
23
 
 
24
/**
 
25
 * @short Class to display a label in a toolbar.
 
26
 *
 
27
 * KToolBarLabelAction is a convenience class for displaying a label in a
 
28
 * toolbar.
 
29
 *
 
30
 * It provides easy access to the label's #setBuddy(QAction*) and #buddy()
 
31
 * methods and can be used as follows:
 
32
 *
 
33
 * \code
 
34
 *
 
35
 * KHistoryCombo* findCombo = new KHistoryCombo( true, this );
 
36
 *
 
37
 * KWidgetAction* action = new KWidgetAction( findCombo, i18n("Find Combo"),
 
38
 *                                            Qt::Key_F6, this, SLOT( slotFocus() ),
 
39
 *                                            actionCollection(), "find_combo");
 
40
 *
 
41
 * KAction *action = new KToolBarLabelAction( action, i18n( "Find "), "find_label" );
 
42
 * action->setShortcut( Qt::Key_F6 );
 
43
 * connect( action, SIGNAL( triggered() ), this, SLOT( slotFocus() ) );
 
44
 *
 
45
 * \endcode
 
46
 *
 
47
 * @author Felix Berger <felixberger@beldesign.de>
 
48
 */
 
49
class KDEUI_EXPORT KToolBarLabelAction : public KAction
 
50
{
 
51
  Q_OBJECT
 
52
 
 
53
  public:
 
54
    /**
 
55
     * Creates a toolbar label.
 
56
     *
 
57
     * @param text The label's and the action's text.
 
58
     * @param parent This action's parent.
 
59
     */
 
60
    KToolBarLabelAction(const QString &text, QObject *parent);
 
61
 
 
62
    /**
 
63
     * Creates a toolbar label setting a buddy for the label.
 
64
     *
 
65
     * @param buddy The action whose widget which is focused when the label's accelerator is
 
66
     * typed.
 
67
     * @param text The label's and the action's text.
 
68
     * @param parent This action's parent.
 
69
     */
 
70
    KToolBarLabelAction(QAction *buddy, const QString &text, QObject *parent);
 
71
 
 
72
    /**
 
73
     * Destroys the toolbar label.
 
74
     */
 
75
    virtual ~KToolBarLabelAction();
 
76
 
 
77
    /**
 
78
     * Sets the label's buddy to buddy.
 
79
     *
 
80
     * See QLabel#setBuddy() for details.
 
81
     */
 
82
    void setBuddy( QAction *buddy );
 
83
 
 
84
    /**
 
85
     * Returns the label's buddy or 0 if no buddy is currently set.
 
86
     *
 
87
     * See QLabel#buddy() and QLabel#setBuddy() for more information.
 
88
     */
 
89
    QAction* buddy() const;
 
90
 
 
91
    /**
 
92
     * Reimplemented from @see QActionWidgetFactory.
 
93
     */
 
94
    virtual QWidget* createWidget( QWidget* parent );
 
95
 
 
96
  Q_SIGNALS:
 
97
    /**
 
98
     * This signal is emmitted whenever the text of this action
 
99
     * is changed.
 
100
     */
 
101
    void textChanged( const QString &newText );
 
102
 
 
103
  protected:
 
104
    virtual bool event( QEvent* );
 
105
 
 
106
  private:
 
107
    class Private;
 
108
    Private* const d;
 
109
};
 
110
 
 
111
#endif