Verified Commit 99779f88 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

info: Move copy to clipboard function to c++

parent 70fa38fb
Pipeline #35556 passed with stage
in 21 minutes and 17 seconds
......@@ -32,62 +32,46 @@ class DistroInfo : public QObject
Q_OBJECT
Q_PROPERTY(QString name READ name CONSTANT)
PROPERTY(QString, name)
Q_PROPERTY(QString version READ version CONSTANT)
PROPERTY(QString, version)
Q_PROPERTY(QString id READ id CONSTANT)
PROPERTY(QString, id)
Q_PROPERTY(QStringList idLike READ idLike CONSTANT)
PROPERTY(QStringList, idLike)
Q_PROPERTY(QString versionCodename READ versionCodename CONSTANT)
PROPERTY(QString, versionCodename)
Q_PROPERTY(QString versionId READ versionId CONSTANT)
PROPERTY(QString, versionId)
Q_PROPERTY(QString prettyName READ prettyName CONSTANT)
PROPERTY(QString, prettyName)
Q_PROPERTY(QString ansiColor READ ansiColor CONSTANT)
PROPERTY(QString, ansiColor)
Q_PROPERTY(QString cpeName READ cpeName CONSTANT)
PROPERTY(QString, cpeName)
Q_PROPERTY(QString homeUrl READ homeUrl CONSTANT)
PROPERTY(QString, homeUrl)
Q_PROPERTY(QString documentationUrl READ documentationUrl CONSTANT)
PROPERTY(QString, documentationUrl)
Q_PROPERTY(QString supportUrl READ supportUrl CONSTANT)
PROPERTY(QString, supportUrl)
Q_PROPERTY(QString bugReportUrl READ bugReportUrl CONSTANT)
PROPERTY(QString, bugReportUrl)
Q_PROPERTY(QString privacyPolicyUrl READ privacyPolicyUrl CONSTANT)
PROPERTY(QString, privacyPolicyUrl)
Q_PROPERTY(QString buildId READ buildId CONSTANT)
PROPERTY(QString, buildId)
Q_PROPERTY(QString variant READ variant CONSTANT)
PROPERTY(QString, variant)
Q_PROPERTY(QString variantId READ variantId CONSTANT)
PROPERTY(QString, variantId)
Q_PROPERTY(QString logo READ logo CONSTANT)
PROPERTY(QString, logo)
public:
DistroInfo(QObject *parent = nullptr);
PROPERTY(QString, name)
PROPERTY(QString, version)
PROPERTY(QString, id)
PROPERTY(QStringList, idLike)
PROPERTY(QString, versionCodename)
PROPERTY(QString, versionId)
PROPERTY(QString, prettyName)
PROPERTY(QString, ansiColor)
PROPERTY(QString, cpeName)
PROPERTY(QString, homeUrl)
PROPERTY(QString, documentationUrl)
PROPERTY(QString, supportUrl)
PROPERTY(QString, bugReportUrl)
PROPERTY(QString, privacyPolicyUrl)
PROPERTY(QString, buildId)
PROPERTY(QString, variant)
PROPERTY(QString, variantId)
PROPERTY(QString, logo)
private:
KOSRelease m_osrelease;
......
......@@ -28,16 +28,15 @@ class HardwareInfo : public QObject
Q_OBJECT
Q_PROPERTY(QString processors READ processors CONSTANT)
QString processors() const;
Q_PROPERTY(QString processorCount READ processorCount CONSTANT)
int processorCount() const;
Q_PROPERTY(QString memory READ memory CONSTANT)
QString memory() const;
public:
HardwareInfo(QObject *parent = nullptr);
QString processors() const;
int processorCount() const;
QString memory() const;
};
#endif // HARDWAREINFO_H
......@@ -45,9 +45,27 @@ Info::Info(QObject *parent, const QVariantList &args)
}
void Info::copyToClipboard(const QString& text) const
void Info::copyInfoToClipboard() const
{
QGuiApplication::clipboard()->setText(text);
const QString clipboardText = QStringLiteral("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()
);
QGuiApplication::clipboard()->setText(clipboardText);
}
DistroInfo* Info::distroInfo() const
......
......@@ -40,7 +40,7 @@ class Info : public KQuickAddons::ConfigModule {
public:
Info(QObject* parent, const QVariantList& args);
Q_INVOKABLE void copyToClipboard(const QString& text) const;
Q_INVOKABLE void copyInfoToClipboard() const;
Q_SIGNALS:
void distroInfoChanged();
......
......@@ -14,27 +14,10 @@ KCM.SimpleKCM {
Kirigami.Action {
text: i18n("Copy to clipboard")
icon.name: "edit-copy"
onTriggered: copyInfoToClipboard()
onTriggered: kcm.copyInfoToClipboard()
}
]
function copyInfoToClipboard() {
var clipboardText = ""
clipboardText += "Operating System " + kcm.distroInfo.name + "\n"
clipboardText += "KDE Plasma Version: " + kcm.softwareInfo.plasmaVersion + "\n"
clipboardText += "KDE Frameworks Version: " + kcm.softwareInfo.frameworksVersion + "\n"
clipboardText += "Qt Version: " + kcm.softwareInfo.qtVersion + "\n"
clipboardText += "Kernel Version: " + kcm.softwareInfo.kernelRelease + "\n"
clipboardText += "OS-Type: " + kcm.softwareInfo.osType + "-bit\n"
clipboardText += "Processor: " + kcm.hardwareInfo.processors + "\n"
clipboardText += "Memory: " + kcm.hardwareInfo.memory + "\n"
kcm.copyToClipboard(clipboardText)
}
ColumnLayout {
width: parent.width
spacing: Kirigami.Units.largeSpacing
......@@ -121,6 +104,6 @@ KCM.SimpleKCM {
text: i18n("Copy to clipboard")
icon.name: "edit-copy"
onClicked: copyInfoToClipboard()
onClicked: kcm.copyInfoToClipboard()
}
}
......@@ -38,6 +38,7 @@ QString SoftwareInfo::kernelRelease() const
{
struct utsname utsName{};
uname(&utsName);
return QString::fromLatin1(utsName.release);
}
......
......@@ -28,22 +28,18 @@ class SoftwareInfo : public QObject
Q_OBJECT
Q_PROPERTY(QString kernelRelease READ kernelRelease CONSTANT)
QString kernelRelease() const;
Q_PROPERTY(QString frameworksVersion READ frameworksVersion CONSTANT)
QString frameworksVersion() const;
Q_PROPERTY(QString qtVersion READ qtVersion CONSTANT)
QString qtVersion() const;
Q_PROPERTY(QString plasmaVersion READ plasmaVersion CONSTANT)
QString plasmaVersion() const;
Q_PROPERTY(QString osType READ osType CONSTANT)
QString osType() const;
public:
SoftwareInfo(QObject *parent = nullptr);
QString kernelRelease() const;
QString frameworksVersion() const;
QString qtVersion() const;
QString plasmaVersion() const;
QString osType() const;
};
#endif // SOFTWAREINFO_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment