Kirigami-addons

aboutcomponent.cpp
1// SPDX-FileCopyrightText: 2024 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#include "aboutcomponent_p.h"
5
6#include <KLocalizedString>
7#include <QGuiApplication>
8#include <QClipboard>
9
10using namespace Qt::StringLiterals;
11
12AboutComponent::AboutComponent(QObject *parent)
13 : QObject(parent)
14{}
15
16AboutComponent::~AboutComponent() = default;
17
18QList<KAboutComponent> AboutComponent::components() const
19{
21 QString platformName;
22 auto platform = QGuiApplication::platformName();
23 platform.replace(0, 1, platform[0].toUpper());
24 if (platform == u"Wayland"_s || platform == u"Xcb"_s) {
25 platform = i18nc("@info Platform name", "%1 (%2)", QSysInfo::prettyProductName(), platform);
26 } else {
27 platform = QSysInfo::prettyProductName();
28 }
29 allComponents.append(KAboutComponent(i18n("KDE Frameworks"),
30 i18nc("@info", "Collection of libraries created by the KDE Community to extend Qt."),
31 QStringLiteral(KI18N_VERSION_STRING),
32 QStringLiteral("https://develop.kde.org/products/frameworks/"),
34
35 allComponents.append(KAboutComponent(i18n("Qt"),
36 i18nc("@info", "Cross-platform application development framework."),
37 i18n("Using %1 and built against %2", QString::fromLocal8Bit(qVersion()), QStringLiteral(QT_VERSION_STR)),
38 QStringLiteral("https://www.qt.io/"),
40
41 allComponents.prepend(KAboutComponent(platform, i18nc("@info", "Underlying platform.")));
42
43 return allComponents;
44}
45
46void AboutComponent::copyToClipboard()
47{
48 auto aboutData = KAboutData::applicationData();
49 QString info = aboutData.displayName() + u": "_s + aboutData.version() + u'\n';
50
51 const auto allComponents = components();
52 for (const auto &component : allComponents) {
53 info += component.name();
54 if (!component.version().isEmpty()) {
55 info += u": "_s + component.version();
56 }
57 info += u'\n';
58 }
59
60 info += u"Build ABI: "_s + QSysInfo::buildAbi() + u'\n';
61 info += u"Kernel: "_s + QSysInfo::kernelType() + u' ' + QSysInfo::kernelVersion() + u'\n';
62
64 clipboard->setText(info);
65}
QList< KAboutComponent > components() const
static KAboutData applicationData()
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
void setText(const QString &text, Mode mode)
QClipboard * clipboard()
void append(QList< T > &&value)
void prepend(parameter_type value)
QString fromLocal8Bit(QByteArrayView str)
QString buildAbi()
QString kernelType()
QString kernelVersion()
QString prettyProductName()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.