1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2001 Holger Freyther (freyher@yahoo.com) |
3 | based on ideas from Martijn and Simon |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License version 2 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | |
19 | Many thanks to Simon tronical Hausmann |
20 | */ |
21 | |
22 | #ifndef kguiitem_h |
23 | #define kguiitem_h |
24 | |
25 | #include <QtCore/QString> |
26 | |
27 | #include <kicontheme.h> |
28 | #include <kicon.h> |
29 | |
30 | /** |
31 | * @short An abstract class for GUI data such as ToolTip and Icon. |
32 | * |
33 | * @author Holger Freyther <freyher@yahoo.com> |
34 | * @see KStandardGuiItem |
35 | */ |
36 | class KDEUI_EXPORT KGuiItem |
37 | { |
38 | public: |
39 | KGuiItem(); |
40 | |
41 | // This is explicit because it's easy to get subtle bugs otherwise. The |
42 | // icon name, tooltip and whatsthis text get changed behind your back if |
43 | // you do 'setButtonFoo( "Bar" );' It gives the wrong impression that you |
44 | // just change the text. |
45 | explicit KGuiItem( const QString &text, |
46 | const QString &iconName = QString(), |
47 | const QString &toolTip = QString(), |
48 | const QString &whatsThis = QString() ); |
49 | |
50 | KGuiItem( const QString &text, const KIcon &icon, |
51 | const QString &toolTip = QString(), |
52 | const QString &whatsThis = QString() ); |
53 | |
54 | KGuiItem( const KGuiItem &rhs ); |
55 | KGuiItem &operator=( const KGuiItem &rhs ); |
56 | |
57 | ~KGuiItem(); |
58 | |
59 | QString text() const; |
60 | QString plainText() const; |
61 | |
62 | /// @deprecated use icon() instead |
63 | #ifndef KDE_NO_DEPRECATED |
64 | KDE_DEPRECATED QIcon iconSet( KIconLoader::Group=KIconLoader::Small, int size = 0) const; |
65 | #endif |
66 | |
67 | KIcon icon( ) const; |
68 | |
69 | QString iconName() const; |
70 | QString toolTip() const; |
71 | QString whatsThis() const; |
72 | bool isEnabled() const; |
73 | bool hasIcon() const; |
74 | #if !defined(KDE_NO_COMPAT) && !defined(KDE_NO_DEPRECATED) |
75 | KDE_DEPRECATED bool hasIconSet() const { return hasIcon(); } |
76 | #endif |
77 | |
78 | void setText( const QString &text ); |
79 | void setIcon( const KIcon &iconset ); |
80 | void setIconName( const QString &iconName ); |
81 | void setToolTip( const QString &tooltip ); |
82 | void setWhatsThis( const QString &whatsThis ); |
83 | void setEnabled( bool enable ); |
84 | |
85 | private: |
86 | class KGuiItemPrivate; |
87 | KGuiItemPrivate *d; //krazy:exclude=dpointer (implicitly shared) |
88 | }; |
89 | |
90 | /* vim: et sw=4 |
91 | */ |
92 | |
93 | #endif |
94 | |
95 | |