Kstars

kshelplabel.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Valery Kharitonov <kharvd@gmail.com>
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
13KSHelpLabel::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
25void KSHelpLabel::setAnchor(const QString &anchor)
26{
27 m_anchor = anchor;
28 updateText();
29}
30
31void 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
44void 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
53void KSHelpLabel::setText(const QString &txt)
54{
55 m_cleanText = txt;
56 updateText();
57}
KSHelpLabel(QWidget *parent=nullptr)
Constructor.
void invokeHelp(const QString &anchor=QString(), const QString &appname=QString())
bool openUrl(const QUrl &url)
void linkActivated(const QString &link)
void setText(const QString &)
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:04 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.