File indexing completed on 2024-06-16 04:56:14
0001 /* 0002 view/htmllabel.h 0003 0004 This file is part of Kleopatra, the KDE keymanager 0005 SPDX-FileCopyrightText: 2021, 2022 g10 Code GmbH 0006 SPDX-FileContributor: Ingo Klöcker <dev@ingo-kloecker.de> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 #include <interfaces/anchorprovider.h> 0014 0015 #include <QLabel> 0016 0017 #include <memory> 0018 0019 namespace Kleo 0020 { 0021 0022 class HtmlLabel : public QLabel, public AnchorProvider 0023 { 0024 Q_OBJECT 0025 public: 0026 explicit HtmlLabel(QWidget *parent = nullptr); 0027 explicit HtmlLabel(const QString &html, QWidget *parent = nullptr); 0028 ~HtmlLabel() override; 0029 0030 void setHtml(const QString &html); 0031 0032 void setLinkColor(const QColor &color); 0033 0034 // AnchorProvider 0035 int numberOfAnchors() const override; 0036 QString anchorText(int index) const override; 0037 QString anchorHref(int index) const override; 0038 void activateAnchor(int index) override; 0039 int selectedAnchor() const override; 0040 0041 protected: 0042 bool focusNextPrevChild(bool next) override; 0043 0044 private: 0045 using QLabel::setText; 0046 0047 private: 0048 class Private; 0049 std::unique_ptr<Private> d; 0050 }; 0051 0052 }