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 
00166 public slots:
00173   void setUnderline (bool on = true);
00174 
00180   void setURL (const QString& url);
00181 
00185   virtual void setFont (const QFont&);
00186 
00194   void setUseTips (bool on = true);
00195 
00203   void setTipText (const QString& tip);
00204 
00211   void setHighlightedColor(const QColor& highcolor);
00212 
00218   void setHighlightedColor(const QString& highcolor);
00219 
00227   void setSelectedColor(const QColor& selcolor);
00228 
00234   void setSelectedColor(const QString& selcolor);
00235 
00239   virtual void setCursor ( const QCursor& cursor );
00240 
00244   virtual void unsetCursor ();
00245 
00256   void setUseCursor (bool on, QCursor* cursor = 0L);
00257 
00265   void setGlow (bool glow = true);
00266 
00278   void setFloat (bool do_float = true);
00279 
00289   void setAltPixmap (const QPixmap& altPix);
00290 
00291 signals:
00292 
00298   void enteredURL (const QString& url);
00299 
00303   void enteredURL ();
00304 
00310   void leftURL (const QString& url);
00311 
00315   void leftURL ();
00316 
00322   void leftClickedURL(const QString& url);
00323 
00327   void leftClickedURL();
00328 
00334   void rightClickedURL(const QString& url);
00335 
00339   void rightClickedURL();
00340 
00346   void middleClickedURL(const QString& url);
00347 
00351   void middleClickedURL();
00352 
00353 protected:
00354 
00358   virtual void mouseReleaseEvent ( QMouseEvent * e );
00359 
00363   virtual void enterEvent (QEvent*);
00364 
00368   virtual void leaveEvent (QEvent*);
00369 
00373   virtual bool event (QEvent *e);
00374 
00378   QRect activeRect() const;
00379 
00380 
00381 private slots:
00386   void updateColor ();
00387 
00388 private:
00393   void setLinkColor (const QColor& col);
00394 
00395 protected:
00396   virtual void virtual_hook( int id, void* data );
00397 private:
00398   class Private;
00399   Private* d;
00400 };
00401 
00402 #endif // KURLLABEL_H
KDE Home | KDE Accessibility Home | Description of Access Keys