2023-03-14 01:45:47 +00:00
|
|
|
/*
|
|
|
|
|
SPDX-FileCopyrightText: 2019 Jonah Brüchert <jbb@kaidan.im>
|
|
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "info.h"
|
|
|
|
|
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
#include <KPluginFactory>
|
|
|
|
|
#include <QClipboard>
|
[info kcm]: add vendorinfo card
This change adds a card to the Information KCM which can be used to
display vendor-specific information (think of product info, serial or
model number, support info, etc.).
The information is read from a json file in /etc/vendorinfo.json, format
as follows:
'''
{
"Title" : "Vendor Information",
"Content" : [
{
"Key": "Model Number",
"Value": "24ABC-13N4"
},
{
"Key": "Serial Number",
"Value": "778899223344"
},
{
"Key": "Support Phone",
"Value": "+31 6 48370928"
}
]
}
'''
Title is the card header, each Key/Value block adds a TextDelegate. This
block is only displayed if the file actually exists and has a Title set.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
2025-01-14 15:46:12 +00:00
|
|
|
#include <QFile>
|
2023-03-14 01:45:47 +00:00
|
|
|
#include <QGuiApplication>
|
[info kcm]: add vendorinfo card
This change adds a card to the Information KCM which can be used to
display vendor-specific information (think of product info, serial or
model number, support info, etc.).
The information is read from a json file in /etc/vendorinfo.json, format
as follows:
'''
{
"Title" : "Vendor Information",
"Content" : [
{
"Key": "Model Number",
"Value": "24ABC-13N4"
},
{
"Key": "Serial Number",
"Value": "778899223344"
},
{
"Key": "Support Phone",
"Value": "+31 6 48370928"
}
]
}
'''
Title is the card header, each Key/Value block adds a TextDelegate. This
block is only displayed if the file actually exists and has a Title set.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
2025-01-14 15:46:12 +00:00
|
|
|
#include <QJsonArray>
|
2023-03-14 01:45:47 +00:00
|
|
|
|
2023-03-15 03:56:30 +00:00
|
|
|
K_PLUGIN_CLASS_WITH_JSON(Info, "kcm_mobile_info.json")
|
2023-03-14 01:45:47 +00:00
|
|
|
|
2023-06-10 08:50:37 +00:00
|
|
|
Info::Info(QObject *parent, const KPluginMetaData &metaData)
|
|
|
|
|
: KQuickConfigModule(parent, metaData)
|
2023-03-14 01:45:47 +00:00
|
|
|
, m_distroInfo(new DistroInfo(this))
|
|
|
|
|
, m_softwareInfo(new SoftwareInfo(this))
|
|
|
|
|
, m_hardwareInfo(new HardwareInfo(this))
|
|
|
|
|
{
|
2023-12-17 02:11:45 +00:00
|
|
|
setButtons({});
|
2023-03-14 01:45:47 +00:00
|
|
|
|
[info kcm]: add vendorinfo card
This change adds a card to the Information KCM which can be used to
display vendor-specific information (think of product info, serial or
model number, support info, etc.).
The information is read from a json file in /etc/vendorinfo.json, format
as follows:
'''
{
"Title" : "Vendor Information",
"Content" : [
{
"Key": "Model Number",
"Value": "24ABC-13N4"
},
{
"Key": "Serial Number",
"Value": "778899223344"
},
{
"Key": "Support Phone",
"Value": "+31 6 48370928"
}
]
}
'''
Title is the card header, each Key/Value block adds a TextDelegate. This
block is only displayed if the file actually exists and has a Title set.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
2025-01-14 15:46:12 +00:00
|
|
|
QFile vendorInfoFile;
|
|
|
|
|
|
|
|
|
|
vendorInfoFile.setFileName("/etc/vendorinfo.json");
|
|
|
|
|
vendorInfoFile.open(QIODevice::ReadOnly);
|
|
|
|
|
m_vendorInfo = QJsonDocument::fromJson(vendorInfoFile.readAll());
|
|
|
|
|
|
2023-03-14 01:45:47 +00:00
|
|
|
qDebug() << "Info module loaded.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Info::copyInfoToClipboard() const
|
|
|
|
|
{
|
[info kcm]: add vendorinfo card
This change adds a card to the Information KCM which can be used to
display vendor-specific information (think of product info, serial or
model number, support info, etc.).
The information is read from a json file in /etc/vendorinfo.json, format
as follows:
'''
{
"Title" : "Vendor Information",
"Content" : [
{
"Key": "Model Number",
"Value": "24ABC-13N4"
},
{
"Key": "Serial Number",
"Value": "778899223344"
},
{
"Key": "Support Phone",
"Value": "+31 6 48370928"
}
]
}
'''
Title is the card header, each Key/Value block adds a TextDelegate. This
block is only displayed if the file actually exists and has a Title set.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
2025-01-14 15:46:12 +00:00
|
|
|
QString clipboardText = QStringLiteral(
|
2023-03-14 01:45:47 +00:00
|
|
|
"Operating System: %1\n"
|
|
|
|
|
"KDE Plasma Version: %2\n"
|
|
|
|
|
"KDE Frameworks Version: %3\n"
|
|
|
|
|
"Qt Version: %4\n"
|
|
|
|
|
"Kernel Version: %5\n"
|
|
|
|
|
"OS-Type: %6\n"
|
|
|
|
|
"Processor: %7\n"
|
|
|
|
|
"Memory: %8\n")
|
|
|
|
|
.arg(distroInfo()->name(),
|
|
|
|
|
softwareInfo()->plasmaVersion(),
|
|
|
|
|
softwareInfo()->frameworksVersion(),
|
|
|
|
|
softwareInfo()->qtVersion(),
|
|
|
|
|
softwareInfo()->kernelRelease(),
|
|
|
|
|
softwareInfo()->osType(),
|
|
|
|
|
hardwareInfo()->processors(),
|
|
|
|
|
hardwareInfo()->memory());
|
|
|
|
|
|
[info kcm]: add vendorinfo card
This change adds a card to the Information KCM which can be used to
display vendor-specific information (think of product info, serial or
model number, support info, etc.).
The information is read from a json file in /etc/vendorinfo.json, format
as follows:
'''
{
"Title" : "Vendor Information",
"Content" : [
{
"Key": "Model Number",
"Value": "24ABC-13N4"
},
{
"Key": "Serial Number",
"Value": "778899223344"
},
{
"Key": "Support Phone",
"Value": "+31 6 48370928"
}
]
}
'''
Title is the card header, each Key/Value block adds a TextDelegate. This
block is only displayed if the file actually exists and has a Title set.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
2025-01-14 15:46:12 +00:00
|
|
|
// add vendor information if available
|
|
|
|
|
if (!vendorInfoTitle().isEmpty()) {
|
|
|
|
|
for (const auto &li : vendorInfo()) {
|
|
|
|
|
const auto &m = li.toMap();
|
|
|
|
|
clipboardText.append(QString("%1: %2\n").arg(
|
|
|
|
|
m[QStringLiteral("Key")].toString(),
|
|
|
|
|
m[QStringLiteral("Value")].toString()
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-14 01:45:47 +00:00
|
|
|
QGuiApplication::clipboard()->setText(clipboardText);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DistroInfo *Info::distroInfo() const
|
|
|
|
|
{
|
|
|
|
|
return m_distroInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SoftwareInfo *Info::softwareInfo() const
|
|
|
|
|
{
|
|
|
|
|
return m_softwareInfo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HardwareInfo *Info::hardwareInfo() const
|
|
|
|
|
{
|
|
|
|
|
return m_hardwareInfo;
|
|
|
|
|
}
|
|
|
|
|
|
[info kcm]: add vendorinfo card
This change adds a card to the Information KCM which can be used to
display vendor-specific information (think of product info, serial or
model number, support info, etc.).
The information is read from a json file in /etc/vendorinfo.json, format
as follows:
'''
{
"Title" : "Vendor Information",
"Content" : [
{
"Key": "Model Number",
"Value": "24ABC-13N4"
},
{
"Key": "Serial Number",
"Value": "778899223344"
},
{
"Key": "Support Phone",
"Value": "+31 6 48370928"
}
]
}
'''
Title is the card header, each Key/Value block adds a TextDelegate. This
block is only displayed if the file actually exists and has a Title set.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
2025-01-14 15:46:12 +00:00
|
|
|
QString Info::vendorInfoTitle() const
|
|
|
|
|
{
|
|
|
|
|
return m_vendorInfo[QStringLiteral("Title")].toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantList Info::vendorInfo() const
|
|
|
|
|
{
|
|
|
|
|
return m_vendorInfo[QStringLiteral("Content")].toArray().toVariantList();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-14 01:45:47 +00:00
|
|
|
#include "info.moc"
|