some more win32'fication to fix non-ascii filename handling
[kdelibs.git] / plasma / tooltipcontent.h
blobe54df9812033801536cce0fa42d75d9a69509817
1 /*
2 * Copyright 2008 by Aaron Seigo <aseigo@kde.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
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 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifndef PLASMA_TOOLTIPCONTENT_H
21 #define PLASMA_TOOLTIPCONTENT_H
23 #include <QtCore/QString>
24 #include <QtCore/QUrl>
25 #include <QtCore/QVariant>
26 #include <QtGui/QPixmap>
27 #include <QtGui/QIcon>
29 #include <plasma/plasma_export.h>
31 class QTextDocument;
33 /**
34 * This provides the content for a tooltip.
36 * Normally you will want to set at least the @p mainText and
37 * @p subText.
40 namespace Plasma
43 class ToolTipContentPrivate;
45 class PLASMA_EXPORT ToolTipContent
47 public:
48 enum ResourceType { ImageResource = 0, HtmlResource, CssResource };
50 /** Creates an empty Content */
51 ToolTipContent();
53 ~ToolTipContent();
55 /** Copy constructor */
56 ToolTipContent(const ToolTipContent &other);
58 /** Constructor that sets the common fields */
59 ToolTipContent(const QString &mainText,
60 const QString &subText,
61 const QPixmap &image = QPixmap());
63 /** Constructor that sets the common fields */
64 ToolTipContent(const QString &mainText,
65 const QString &subText,
66 const QIcon &icon);
68 ToolTipContent &operator=(const ToolTipContent &other);
70 /** @return true if all the fields are empty */
71 bool isEmpty() const;
73 /** Sets the main text which containts important information, e.g. the title */
74 void setMainText(const QString &text);
76 /** Important information, e.g. the title */
77 QString mainText() const;
79 /** Sets text which elaborates on the @p mainText */
80 void setSubText(const QString &text) ;
82 /** Elaborates on the @p mainText */
83 QString subText() const;
85 /** Sets the icon to show **/
86 void setImage(const QPixmap &image);
88 /** Sets the icon to show **/
89 void setImage(const QIcon &icon);
91 /** An icon to display */
92 QPixmap image() const;
94 /** Sets the ID of the window to show a preview for */
95 void setWindowToPreview(WId id);
97 /** Id of a window if you want to show a preview */
98 WId windowToPreview() const;
100 /** Sets whether or not to autohide the tooltip, defaults to true */
101 void setAutohide(bool autohide);
103 /** Whether or not to autohide the tooltip, defaults to true */
104 bool autohide() const;
106 /** Adds a resource that can then be referenced from the text elements
107 using rich text **/
108 void addResource(ResourceType type, const QUrl &path, const QVariant &resource);
110 /** Registers all resources with a given document */
111 void registerResources(QTextDocument *document) const;
113 private:
114 ToolTipContentPrivate * const d;
117 } // namespace Plasma
119 #endif