Kstars

kshelplabel.cpp
1 /*
2  SPDX-FileCopyrightText: 2010 Valery Kharitonov <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "kshelplabel.h"
8 #include "Options.h"
9 #include <KHelpClient>
10 #include <QMessageBox>
11 #include <QDesktopServices>
12 
13 KSHelpLabel::KSHelpLabel(const QString &text, const QString &anchor, QWidget *parent) : QLabel(parent), m_anchor(anchor)
14 {
15  setText(text);
16  updateText();
17  connect(this, SIGNAL(linkActivated(QString)), SLOT(slotShowDefinition(QString)));
18 }
19 
21 {
22  connect(this, SIGNAL(linkActivated(QString)), SLOT(slotShowDefinition(QString)));
23 }
24 
25 void KSHelpLabel::setAnchor(const QString &anchor)
26 {
27  m_anchor = anchor;
28  updateText();
29 }
30 
31 void KSHelpLabel::updateText()
32 {
33  //TODO This function probably needs to be removed since the theme setting stakes care already of link colors
34  /*
35  QString linkcolor =
36  (Options::darkAppColors() ?
37  "red" :
38  "blue"); // In night colors mode, use red links because blue links are black through a red filter.
39  QLabel::setText("<a href=\"ai-" + m_anchor + "\" style=\"color: " + linkcolor + "\" >" + text() + "</a>");
40  */
41  QLabel::setText("<a href=\"ai-" + m_anchor + "\">" + text() + "</a>");
42 }
43 
44 void KSHelpLabel::slotShowDefinition(const QString &term)
45 {
46 #ifdef Q_OS_OSX // This is because KHelpClient doesn't seem to be working right on MacOS
47  QDesktopServices::openUrl(QUrl("https://docs.kde.org/trunk5/en/kstars/kstars/index.html"));
48 #else
50 #endif
51 }
52 
53 void KSHelpLabel::setText(const QString &txt)
54 {
55  m_cleanText = txt;
56  updateText();
57 }
void setText(const QString &)
bool openUrl(const QUrl &url)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void linkActivated(const QString &link)
KSHelpLabel(QWidget *parent=nullptr)
Constructor.
Definition: kshelplabel.cpp:20
void invokeHelp(const QString &anchor=QString(), const QString &appname=QString())
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Tue Aug 9 2022 04:06:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.