diff --git a/Modules/about-distro/src/Module.h b/Modules/about-distro/src/Module.h --- a/Modules/about-distro/src/Module.h +++ b/Modules/about-distro/src/Module.h @@ -63,6 +63,13 @@ void loadSoftware(); void loadHardware(); + /** + * Copies the software and hardware information to clipboard. + * The label language is currently English only + * because the Plasma development language is English. + */ + void copyToClipboard(); + /** * UI */ diff --git a/Modules/about-distro/src/Module.cpp b/Modules/about-distro/src/Module.cpp --- a/Modules/about-distro/src/Module.cpp +++ b/Modules/about-distro/src/Module.cpp @@ -21,6 +21,7 @@ #include "Module.h" #include "ui_Module.h" +#include #include #include @@ -118,6 +119,8 @@ { loadSoftware(); loadHardware(); + + connect(ui->pushButtonCopyInfo, &QPushButton::clicked, this, &Module::copyToClipboard); } void Module::save() @@ -177,9 +180,11 @@ ui->plasmaLabel->setText(plasma); } - ui->qtLabel->setText(qVersion()); + const QString qversion = qVersion(); + ui->qtLabel->setText(qversion); - ui->frameworksLabel->setText(KCoreAddons::versionString()); + const QString frameworksVersion = KCoreAddons::versionString(); + ui->frameworksLabel->setText(frameworksVersion); } void Module::loadHardware() @@ -193,8 +198,9 @@ } const int bits = QT_POINTER_SIZE == 8 ? 64 : 32; + const QString bitsStr = QString::number(bits); ui->bitsLabel->setText(i18nc("@label %1 is the CPU bit width (e.g. 32 or 64)", - "%1-bit", QString::number(bits))); + "%1-bit", bitsStr)); const QList list = Solid::Device::listFromType(Solid::DeviceInterface::Processor); ui->processor->setText(i18np("Processor:", "Processors:", list.count())); @@ -221,17 +227,51 @@ name = name.simplified(); names.append(QStringLiteral("%1 × %2").arg(count).arg(name)); } - ui->processorLabel->setText(names.join(QStringLiteral(", "))); + + const QString processorLabel = names.join(QStringLiteral(", ")); + ui->processorLabel->setText(processorLabel); if (ui->processorLabel->text().isEmpty()) { ui->processor->setHidden(true); ui->processorLabel->setHidden(true); } const qlonglong totalRam = calculateTotalRam(); - ui->memoryLabel->setText(totalRam > 0 + const QString memoryLabel = totalRam > 0 ? i18nc("@label %1 is the formatted amount of system memory (e.g. 7,7 GiB)", "%1 of RAM", KFormat().formatByteSize(totalRam)) - : i18nc("Unknown amount of RAM", "Unknown")); + : i18nc("Unknown amount of RAM", "Unknown"); + ui->memoryLabel->setText(memoryLabel); +} + +void Module::copyToClipboard() +{ + QString text; + if (!ui->nameVersionLabel->isHidden()) { + text += i18n("%1 %2", QStringLiteral("Distro:"), ui->nameVersionLabel->text()) + QStringLiteral("\n"); + } + if (!ui->plasmaLabel->isHidden()) { + text += i18n("%1 %2", ui->plasma->text(), ui->plasmaLabel->text()) + QStringLiteral("\n"); + } + if (!ui->frameworksLabel->isHidden()) { + text += i18n("%1 %2", ui->frameworksLabelKey->text(), ui->frameworksLabel->text()) + QStringLiteral("\n"); + } + if (!ui->qtLabel->isHidden()) { + text += i18n("%1 %2", ui->qt->text(), ui->qtLabel->text()) + QStringLiteral("\n"); + } + if (!ui->kernelLabel->isHidden()) { + text += i18n("%1 %2", ui->kernel->text(), ui->kernelLabel->text()) + QStringLiteral("\n"); + } + if (!ui->bitsLabel->isHidden()) { + text += i18n("%1 %2", ui->bitsKey->text(), ui->bitsLabel->text()) + QStringLiteral("\n"); + } + if (!ui->processorLabel->isHidden()) { + text += i18n("%1 %2", ui->processor->text(), ui->processorLabel->text()) + QStringLiteral("\n"); + } + if (!ui->memoryLabel->isHidden()) { + text += i18n("%1 %2", ui->memory->text(), ui->memoryLabel->text()) + QStringLiteral("\n"); + } + + QGuiApplication::clipboard()->setText(text); } QString Module::plasmaVersion() const diff --git a/Modules/about-distro/src/Module.ui b/Modules/about-distro/src/Module.ui --- a/Modules/about-distro/src/Module.ui +++ b/Modules/about-distro/src/Module.ui @@ -150,19 +150,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -266,7 +253,7 @@ - + OS Type: @@ -341,6 +328,42 @@ + + + + + 0 + 0 + + + + Copy software and hardware information to clipboard + + + Copy Info + + + + .. + + + Ctrl+C + + + + + + + Qt::Vertical + + + + 20 + 40 + + + +