File indexing completed on 2025-04-20 06:34:37
0001 /* 0002 SPDX-FileCopyrightText: 2010 Valery Kharitonov <kharvd@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KSHELPLABEL_H 0008 #define KSHELPLABEL_H 0009 0010 #include <QLabel> 0011 0012 /** Label for displaying links to AstroInfo project 0013 * @author Valery Kharitonov 0014 */ 0015 class KSHelpLabel : public QLabel 0016 { 0017 Q_OBJECT 0018 Q_PROPERTY(QString anchor READ anchor WRITE setAnchor) 0019 Q_PROPERTY(QString text READ text WRITE setText) 0020 0021 public: 0022 /** 0023 * Constructor. Creates clear label 0024 */ 0025 explicit KSHelpLabel(QWidget *parent = nullptr); 0026 0027 /** 0028 * Constructor. Creates label with a text and help anchor. 0029 * @param text Text of the label 0030 * @param anchor Name of the section in the AstroInfo project (without 'ai-') 0031 * @param parent Parent widget 0032 */ 0033 KSHelpLabel(const QString &text, const QString &anchor, QWidget *parent = nullptr); 0034 0035 QString text() const { return m_cleanText; } 0036 void setText(const QString &text); 0037 0038 void setAnchor(const QString &anchor); 0039 QString anchor() const { return m_anchor; } 0040 0041 private slots: 0042 /** Open AstroInfo definition of the terms 0043 * @param term jargon term */ 0044 void slotShowDefinition(const QString &term); 0045 0046 private: 0047 /** 0048 * Updates text with the new anchor 0049 */ 0050 void updateText(); 0051 0052 /** 0053 * Anchor in AstroInfo project 0054 */ 0055 QString m_anchor; 0056 0057 /** 0058 * String without markup 0059 */ 0060 QString m_cleanText; 0061 }; 0062 0063 #endif // KSHELPLABEL_H