diff --git a/modules/info/distroinfo.h b/modules/info/distroinfo.h index 1107164889f67aad3b8af0693fc7bb9262f747ae..9608dbd3efcca2946b0de99b43ebaf30d05d0616 100644 --- a/modules/info/distroinfo.h +++ b/modules/info/distroinfo.h @@ -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; diff --git a/modules/info/hardwareinfo.h b/modules/info/hardwareinfo.h index f802bfa22c7192337fb795718607b69fae6f468d..0ae06ce8d93e26c4c9d3b07782c239a91840feef 100644 --- a/modules/info/hardwareinfo.h +++ b/modules/info/hardwareinfo.h @@ -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 diff --git a/modules/info/info.cpp b/modules/info/info.cpp index 1a3c2eaba2ae1188d574f8e841de604c54b7ee46..e0f99fc476aab8298ce0125e2cea004e20667e50 100644 --- a/modules/info/info.cpp +++ b/modules/info/info.cpp @@ -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 diff --git a/modules/info/info.h b/modules/info/info.h index 7127a2386f9ad1aa1c0c7fd5ba5be39741b5575d..8b2beb77e60b247c698af7349b7ff009de141520 100644 --- a/modules/info/info.h +++ b/modules/info/info.h @@ -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(); diff --git a/modules/info/package/contents/ui/main.qml b/modules/info/package/contents/ui/main.qml index 0197da2c8aa100dfbb11ac8f74a60626b97fb0bb..92efd5767b5d42adf93ffb8a26bf41c76d557b2a 100644 --- a/modules/info/package/contents/ui/main.qml +++ b/modules/info/package/contents/ui/main.qml @@ -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() } } diff --git a/modules/info/softwareinfo.cpp b/modules/info/softwareinfo.cpp index 926afe31f79720029f3964f20dfc771ae2e88b5f..07cdc259de8d9dcffa261f6233af91c58dfe1c50 100644 --- a/modules/info/softwareinfo.cpp +++ b/modules/info/softwareinfo.cpp @@ -38,6 +38,7 @@ QString SoftwareInfo::kernelRelease() const { struct utsname utsName{}; uname(&utsName); + return QString::fromLatin1(utsName.release); } diff --git a/modules/info/softwareinfo.h b/modules/info/softwareinfo.h index 1631cd182440344c3fd944e61db81de35cd743ce..2db211e3e205dcc2ed87508c8aed19482e6b38b4 100644 --- a/modules/info/softwareinfo.h +++ b/modules/info/softwareinfo.h @@ -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