KWidgetsAddons

kurllabel.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 1998 Kurt Granroth <[email protected]>
3  Copyright (C) 2000 Peter Putzer <[email protected]>
4  Copyright (C) 2005 JarosÅ‚aw Staniek <[email protected]>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License version 2 as published by the Free Software Foundation.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public License
16  along with this library; see the file COPYING.LIB. If not, write to
17  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  Boston, MA 02110-1301, USA.
19 */
20 
21 #ifndef KURLLABEL_H
22 #define KURLLABEL_H
23 
24 #include <kwidgetsaddons_export.h>
25 
26 #include <QColor>
27 #include <QLabel>
28 #include <QPixmap>
29 
30 class QCursor;
31 
71 class KWIDGETSADDONS_EXPORT KUrlLabel : public QLabel
72 {
73  Q_OBJECT
74  Q_PROPERTY(QString url READ url WRITE setUrl)
75  Q_PROPERTY(QString tipText READ tipText WRITE setTipText)
76  Q_PROPERTY(QPixmap alternatePixmap READ alternatePixmap WRITE setAlternatePixmap)
77  Q_PROPERTY(bool glowEnabled READ isGlowEnabled WRITE setGlowEnabled)
78  Q_PROPERTY(bool floatEnabled READ isFloatEnabled WRITE setFloatEnabled)
79  Q_PROPERTY(bool useTips READ useTips WRITE setUseTips)
80  Q_PROPERTY(bool useCursor READ useCursor WRITE setUseCursor)
81 
82 public:
89  explicit KUrlLabel(QWidget *parent = nullptr);
90 
102  explicit KUrlLabel(const QString &url, const QString &text = QString(),
103  QWidget *parent = nullptr);
104 
108  ~KUrlLabel() override;
109 
113  QString url() const;
114 
118  QString tipText() const;
119 
125  bool useTips() const;
126 
132  bool useCursor() const;
133 
138  bool isGlowEnabled() const;
139 
148  bool isFloatEnabled() const;
149 
153  const QPixmap *alternatePixmap() const;
154 
155 public Q_SLOTS:
162  void setUnderline(bool on = true);
163 
169  void setUrl(const QString &url);
170 
174  virtual void setFont(const QFont &font);
175 
183  void setUseTips(bool on = true);
184 
192  void setTipText(const QString &tip);
193 
200  void setHighlightedColor(const QColor &highcolor);
201 
207  void setHighlightedColor(const QString &highcolor);
208 
216  void setSelectedColor(const QColor &color);
217 
223  void setSelectedColor(const QString &color);
224 
235  void setUseCursor(bool on, QCursor *cursor = nullptr);
236 
244  void setGlowEnabled(bool glow = true);
245 
257  void setFloatEnabled(bool do_float = true);
258 
268  void setAlternatePixmap(const QPixmap &pixmap);
269 
270 Q_SIGNALS:
271 
272 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 65)
273 
279  KWIDGETSADDONS_DEPRECATED_VERSION(5, 65, "Use KUrlLabel::enteredUrl()")
280  void enteredUrl(const QString &url);
281 #endif
282 
285  void enteredUrl();
286 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 65)
287 
293  KWIDGETSADDONS_DEPRECATED_VERSION(5, 65, "Use KUrlLabel::leftUrl()")
294  void leftUrl(const QString &url);
295 #endif
296 
300  void leftUrl();
301 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 65)
302 
308  KWIDGETSADDONS_DEPRECATED_VERSION(5, 65, "Use KUrlLabel::leftClickedUrl()")
309  void leftClickedUrl(const QString &url);
310 #endif
311 
314  void leftClickedUrl();
315 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 65)
316 
322  KWIDGETSADDONS_DEPRECATED_VERSION(5, 65, "Use KUrlLabel::rightClickedUrl()")
323  void rightClickedUrl(const QString &url);
324 #endif
325 
328  void rightClickedUrl();
329 #if KWIDGETSADDONS_ENABLE_DEPRECATED_SINCE(5, 65)
330 
336  KWIDGETSADDONS_DEPRECATED_VERSION(5, 65, "Use KUrlLabel::middleClickedUrl()")
337  void middleClickedUrl(const QString &url);
338 #endif
339 
342  void middleClickedUrl();
343 
344 protected:
348  void mouseReleaseEvent(QMouseEvent *) override;
349 
353  void enterEvent(QEvent *) override;
354 
358  void leaveEvent(QEvent *) override;
359 
363  bool event(QEvent *) override;
364 
365 private:
366  class Private;
367  Private *const d;
368 
369  Q_PRIVATE_SLOT(d, void updateColor())
370 };
371 
372 #endif
virtual bool event(QEvent *e) override
virtual void enterEvent(QEvent *event)
Q_PROPERTY(...)
void setFont(const QFont &)
virtual void mouseReleaseEvent(QMouseEvent *ev) override
virtual void leaveEvent(QEvent *event)
A drop-in replacement for QLabel that displays hyperlinks.
Definition: kurllabel.h:71
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 31 2020 22:51:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.