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 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License version 2 as published by the Free Software Foundation. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00017 Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef KURLLABEL_H 00021 #define KURLLABEL_H 00022 00023 #include <qlabel.h> 00024 00025 class QColor; 00026 class QCursor; 00027 class QPixmap; 00028 00063 class KURLLabel : public QLabel 00064 { 00065 Q_OBJECT 00066 Q_PROPERTY (QString url READ url WRITE setURL) 00067 Q_PROPERTY (QPixmap altPixmap READ altPixmap WRITE setAltPixmap) 00068 00069 public: 00076 KURLLabel (QWidget* parent = 0L, const char* name = 0L); 00077 00087 KURLLabel (const QString& url, const QString& text = QString::null, 00088 QWidget* parent = 0L, const char* name = 0L); 00089 00093 virtual ~KURLLabel (); 00094 00098 const QString& url () const; 00099 00103 const QString& tipText () const; 00104 00110 bool useTips () const; 00111 00117 bool useCursor () const; 00118 00123 bool isGlowEnabled () const; 00124 00133 bool isFloatEnabled () const; 00134 00138 const QPixmap* altPixmap () const; 00139 00140 public slots: 00147 void setUnderline (bool on = true); 00148 00154 void setURL (const QString& url); 00155 00159 virtual void setFont (const QFont&); 00160 00168 void setUseTips (bool on = true); 00169 00177 void setTipText (const QString& tip); 00178 00185 void setHighlightedColor(const QColor& highcolor); 00186 00192 void setHighlightedColor(const QString& highcolor); 00193 00201 void setSelectedColor(const QColor& selcolor); 00202 00208 void setSelectedColor(const QString& selcolor); 00209 00220 void setUseCursor (bool on, QCursor* cursor = 0L); 00221 00229 void setGlow (bool glow = true); 00230 00242 void setFloat (bool do_float = true); 00243 00253 void setAltPixmap (const QPixmap& altPix); 00254 00255 signals: 00256 00262 void enteredURL (const QString& url); 00263 00267 void enteredURL (); 00268 00274 void leftURL (const QString& url); 00275 00279 void leftURL (); 00280 00286 void leftClickedURL(const QString& url); 00287 00291 void leftClickedURL(); 00292 00298 void rightClickedURL(const QString& url); 00299 00303 void rightClickedURL(); 00304 00310 void middleClickedURL(const QString& url); 00311 00315 void middleClickedURL(); 00316 00317 protected: 00318 00322 virtual void mouseReleaseEvent (QMouseEvent*); 00323 00327 virtual void enterEvent (QEvent*); 00328 00332 virtual void leaveEvent (QEvent*); 00333 00334 private slots: 00339 void updateColor (); 00340 00341 private: 00346 void setLinkColor (const QColor& col); 00347 00348 protected: 00349 virtual void virtual_hook( int id, void* data ); 00350 private: 00351 class Private; 00352 Private* d; 00353 }; 00354 00355 #endif // KURLLABEL_H