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.prepend(KAboutComponent(platform, i18nc("@info", "Underlying platform.")));
30 allComponents.prepend(KAboutComponent(i18n("Qt"),
31 i18nc("@info", "Cross-platform application development framework."),
32 i18n("Using %1 and built against %2", QString::fromLocal8Bit(qVersion()), QStringLiteral(QT_VERSION_STR)),
33 QStringLiteral("https://www.qt.io/"),
35 allComponents.prepend(KAboutComponent(i18n("KDE Frameworks"),
36 i18nc("@info", "Collection of libraries created by the KDE Community to extend Qt."),
37 QStringLiteral(KI18N_VERSION_STRING),
38 QStringLiteral("https://develop.kde.org/products/frameworks/"),
40
41 return allComponents;
42}
43
44void AboutComponent::copyToClipboard()
45{
46 auto aboutData = KAboutData::applicationData();
47 QString info = aboutData.displayName() + u": "_s + aboutData.version() + u'\n';
48
49 const auto allComponents = components();
50 for (const auto &component : allComponents) {
51 info += component.name();
52 if (!component.version().isEmpty()) {
53 info += u": "_s + component.version();
54 }
55 info += u'\n';
56 }
57
58 info += u"Build ABI: "_s + QSysInfo::buildAbi() + u'\n';
59 info += u"Kernel: "_s + QSysInfo::kernelType() + u' ' + QSysInfo::kernelVersion() + u'\n';
60
62 clipboard->setText(info);
63}
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 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 Fri Nov 29 2024 11:51:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.