kurllabel.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1998 Kurt Granroth <granroth@kde.org> 00003 Copyright (C) 2000 Peter Putzer <putzer@kde.org> 00004 Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Library General Public 00008 License version 2 as published by the Free Software Foundation. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef KURLLABEL_H 00022 #define KURLLABEL_H 00023 00024 #include <qlabel.h> 00025 00026 #include <kdelibs_export.h> 00027 00028 class QColor; 00029 class QCursor; 00030 class QPixmap; 00031 00071 class KDEUI_EXPORT KURLLabel : public QLabel 00072 { 00073 Q_OBJECT 00074 Q_PROPERTY (QString url READ url WRITE setURL) 00075 Q_PROPERTY (QString tipText READ tipText WRITE setTipText ) 00076 Q_PROPERTY (QPixmap altPixmap READ altPixmap WRITE setAltPixmap) 00077 Q_PROPERTY (bool glowEnabled READ isGlowEnabled WRITE setGlow ) 00078 Q_PROPERTY (bool floatEnabled READ isFloatEnabled WRITE setFloat ) 00079 Q_PROPERTY (bool useTips READ useTips WRITE setUseTips ) 00080 Q_PROPERTY (bool useCursor READ useCursor WRITE setUseCursor ) 00081 00082 public: 00089 KURLLabel (QWidget* parent = 0L, const char* name = 0L); 00090 00103 KURLLabel (const QString& url, const QString& text = QString::null, 00104 QWidget* parent = 0L, const char* name = 0L); 00105 00109 virtual ~KURLLabel (); 00110 00114 const QString& url () const; 00115 00119 const QString& tipText () const; 00120 00126 bool useTips () const; 00127 00133 bool useCursor () const; 00134 00139 bool isGlowEnabled () const; 00140 00149 bool isFloatEnabled () const; 00150 00154 const QPixmap* altPixmap () const; 00155 00159 virtual void setMargin ( int margin ); 00160 00164 virtual void setFocusPolicy ( FocusPolicy policy ); 00165 00169 virtual void setSizePolicy ( QSizePolicy ); 00170 00171 public slots: 00178 void setUnderline (bool on = true); 00179 00185 void setURL (const QString& url); 00186 00190 virtual void setFont (const QFont&); 00191 00199 void setUseTips (bool on = true); 00200 00208 void setTipText (const QString& tip); 00209 00216 void setHighlightedColor(const QColor& highcolor); 00217 00223 void setHighlightedColor(const QString& highcolor); 00224 00232 void setSelectedColor(const QColor& selcolor); 00233 00239 void setSelectedColor(const QString& selcolor); 00240 00244 virtual void setCursor ( const QCursor& cursor ); 00245 00249 virtual void unsetCursor (); 00250 00261 void setUseCursor (bool on, QCursor* cursor = 0L); 00262 00270 void setGlow (bool glow = true); 00271 00283 void setFloat (bool do_float = true); 00284 00294 void setAltPixmap (const QPixmap& altPix); 00295 00296 signals: 00297 00303 void enteredURL (const QString& url); 00304 00308 void enteredURL (); 00309 00315 void leftURL (const QString& url); 00316 00320 void leftURL (); 00321 00327 void leftClickedURL(const QString& url); 00328 00332 void leftClickedURL(); 00333 00339 void rightClickedURL(const QString& url); 00340 00344 void rightClickedURL(); 00345 00351 void middleClickedURL(const QString& url); 00352 00356 void middleClickedURL(); 00357 00358 protected: 00359 00363 virtual void mouseReleaseEvent ( QMouseEvent * e ); 00364 00368 virtual void enterEvent (QEvent*); 00369 00373 virtual void leaveEvent (QEvent*); 00374 00378 virtual bool event (QEvent *e); 00379 00383 QRect activeRect() const; 00384 00385 00386 private slots: 00391 void updateColor (); 00392 00393 private: 00398 void setLinkColor (const QColor& col); 00399 00400 protected: 00401 virtual void virtual_hook( int id, void* data ); 00402 private: 00403 class Private; 00404 Private* d; 00405 }; 00406 00407 #endif // KURLLABEL_H