libqutim 0.2.80.1
|
00001 /**************************************************************************** 00002 ** 00003 ** qutIM - instant messenger 00004 ** 00005 ** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru> 00006 ** 00007 ***************************************************************************** 00008 ** 00009 ** $QUTIM_BEGIN_LICENSE$ 00010 ** This program is free software: you can redistribute it and/or modify 00011 ** it under the terms of the GNU General Public License as published by 00012 ** the Free Software Foundation, either version 3 of the License, or 00013 ** (at your option) any later version. 00014 ** 00015 ** This program is distributed in the hope that it will be useful, 00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00018 ** See the GNU General Public License for more details. 00019 ** 00020 ** You should have received a copy of the GNU General Public License 00021 ** along with this program. If not, see http://www.gnu.org/licenses/. 00022 ** $QUTIM_END_LICENSE$ 00023 ** 00024 ****************************************************************************/ 00025 00026 #ifndef TOOLTIPMANAGER_H 00027 #define TOOLTIPMANAGER_H 00028 00029 #include "libqutim_global.h" 00030 #include "localizedstring.h" 00031 #include "extensionicon.h" 00032 #include <QPoint> 00033 #include <QEvent> 00034 #include <QVariant> 00035 00036 namespace qutim_sdk_0_3 00037 { 00038 class Buddy; 00039 class ToolTipEventPrivate; 00040 00041 class LIBQUTIM_EXPORT ToolTipEvent : public QEvent 00042 { 00043 public: 00044 enum IconPosition { 00045 IconBeforeTitle = 0, 00046 IconBeforeDescription 00047 }; 00048 00049 ToolTipEvent(bool generateLayout = true); 00050 ~ToolTipEvent(); 00051 void addHtml(const QString &html, quint8 priority = 60); 00052 void addField(const LocalizedString &title, 00053 const LocalizedString &description = LocalizedString(), 00054 quint8 priority = 60); 00055 void addField(const LocalizedString &title, 00056 const LocalizedString &description, 00057 const QString &icon, 00058 quint8 priority = 60); 00059 void addField(const LocalizedString &title, 00060 const LocalizedString &description, 00061 const ExtensionIcon &icon, 00062 quint8 priority = 60); 00063 void addField(const LocalizedString &title, 00064 const LocalizedString &description, 00065 const QString &icon, 00066 IconPosition iconPosition, 00067 quint8 priority = 60); 00068 void addField(const LocalizedString &title, 00069 const LocalizedString &description, 00070 const ExtensionIcon &icon, 00071 IconPosition iconPosition, 00072 quint8 priority = 60); 00073 bool generateLayout() const; 00074 QString html() const; 00075 static QEvent::Type eventType(); 00076 protected: 00077 friend class ToolTip; 00078 QScopedPointer<ToolTipEventPrivate> d; 00079 }; 00080 00081 class LIBQUTIM_EXPORT ToolTip : public QObject 00082 { 00083 Q_OBJECT 00084 public: 00085 static ToolTip *instance(); 00086 virtual void showText(const QPoint &pos, QObject *obj, QWidget *w = 0); 00087 inline void hideText() { showText(QPoint(), 0); } 00088 protected: 00089 ToolTip(QObject *parent = 0); 00090 bool eventFilter(QObject *, QEvent *); 00091 }; 00092 } 00093 00094 Q_DECLARE_METATYPE(qutim_sdk_0_3::ToolTipEvent::IconPosition) 00095 00096 #endif // TOOLTIPMANAGER_H 00097