summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuo Yunhe <[email protected]>2018-12-24 11:44:01 +0200
committerGuo Yunhe <[email protected]>2018-12-24 22:54:24 +0200
commit937e9c72fe94b098d349f19f231160a05521f3ee (patch)
treef3d0c8e6cd80a58fd2137c7a3fc0034cd6d9d9c6
parent12ec4c8cc079988b6f29449b088298f3c3c8acfd (diff)
Copy to Clipboard in English
Summary: Add a new button to copy to clipboard in English for usage in bug report. This doesn't affect existing copy button which copy translated information for usage in local forum, etc. {F6504795} Copied example: Operating System: openSUSE Tumbleweed 20181219 KDE Frameworks Version: 5.53.0 Qt Version: 5.12.0 Kernel Version: 4.19.8-1-default OS Type: 64-bit Processors: 8 × Intel® Core™ i7-4710MQ CPU @ 2.50GHz Memory: 7.7 GiB Reviewers: #plasma, ngraham Reviewed By: ngraham Subscribers: ngraham, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D17773
-rw-r--r--Modules/about-distro/src/Module.cpp25
-rw-r--r--Modules/about-distro/src/Module.h2
-rw-r--r--Modules/about-distro/src/Module.ui14
3 files changed, 39 insertions, 2 deletions
diff --git a/Modules/about-distro/src/Module.cpp b/Modules/about-distro/src/Module.cpp
index e5829a0..8edba44 100644
--- a/Modules/about-distro/src/Module.cpp
+++ b/Modules/about-distro/src/Module.cpp
@@ -23,6 +23,7 @@
#include <QClipboard>
#include <QIcon>
+#include <QLocale>
#include <QStandardPaths>
#include <KAboutData>
@@ -105,6 +106,10 @@ Module::Module(QWidget *parent, const QVariantList &args) :
// Setup Copy to Clipboard button
connect(ui->pushButtonCopyInfo, &QPushButton::clicked, this, &Module::copyToClipboard);
+ connect(ui->pushButtonCopyInfoInEnglish, &QPushButton::clicked, this, &Module::copyToClipboardInEnglish);
+ if (QLocale::system().language() == QLocale::English) {
+ ui->pushButtonCopyInfoInEnglish->hide();
+ }
ui->pushButtonCopyInfo->setShortcut(QKeySequence::Copy);
// https://bugs.kde.org/show_bug.cgi?id=366158
@@ -122,6 +127,7 @@ Module::~Module()
void Module::load()
{
labelsForClipboard.clear();
+ englishTextForClipboard = QStringLiteral("");
loadSoftware();
loadHardware();
}
@@ -157,11 +163,13 @@ void Module::loadSoftware()
// as a product brand is different from Kubuntu.
const QString distroName = cg.readEntry("Name", os.name);
const QString versionId = cg.readEntry("Version", os.versionId);
- ui->nameVersionLabel->setText(QStringLiteral("%1 %2").arg(distroName, versionId));
+ const QString distroNameVersion = QStringLiteral("%1 %2").arg(distroName, versionId);
+ ui->nameVersionLabel->setText(distroNameVersion);
const auto dummyDistroDescriptionLabel = new QLabel(i18nc("@title:row", "Operating System:"), this);
dummyDistroDescriptionLabel->hide();
labelsForClipboard << qMakePair(dummyDistroDescriptionLabel, ui->nameVersionLabel);
+ englishTextForClipboard += QStringLiteral("Operating System: %1\n").arg(distroNameVersion);
const QString variant = cg.readEntry("Variant", QString());
if (variant.isEmpty()) {
@@ -186,15 +194,18 @@ void Module::loadSoftware()
} else {
ui->plasmaLabel->setText(plasma);
labelsForClipboard << qMakePair(ui->plasma, ui->plasmaLabel);
+ englishTextForClipboard += QStringLiteral("KDE Plasma Version: %1\n").arg(plasma);
}
const QString frameworksVersion = KCoreAddons::versionString();
ui->frameworksLabel->setText(frameworksVersion);
labelsForClipboard << qMakePair(ui->frameworksLabelKey, ui->frameworksLabel);
+ englishTextForClipboard += QStringLiteral("KDE Frameworks Version: %1\n").arg(frameworksVersion);
const QString qversion = QString::fromLatin1(qVersion());
ui->qtLabel->setText(qversion);
labelsForClipboard << qMakePair(ui->qt, ui->qtLabel);
+ englishTextForClipboard += QStringLiteral("Qt Version: %1\n").arg(qversion);
}
void Module::loadHardware()
@@ -204,8 +215,10 @@ void Module::loadHardware()
ui->kernel->hide();
ui->kernelLabel->hide();
} else {
- ui->kernelLabel->setText(QString::fromLatin1(utsName.release));
+ QString kernelVersion = QString::fromLatin1(utsName.release);
+ ui->kernelLabel->setText(kernelVersion);
labelsForClipboard << qMakePair(ui->kernel, ui->kernelLabel);
+ englishTextForClipboard += QStringLiteral("Kernel Version: %1\n").arg(kernelVersion);
}
const int bits = QT_POINTER_SIZE == 8 ? 64 : 32;
@@ -213,6 +226,7 @@ void Module::loadHardware()
ui->bitsLabel->setText(i18nc("@label %1 is the CPU bit width (e.g. 32 or 64)",
"%1-bit", bitsStr));
labelsForClipboard << qMakePair(ui->bitsKey, ui->bitsLabel);
+ englishTextForClipboard += QStringLiteral("OS Type: %1-bit\n").arg(bitsStr);
const QList<Solid::Device> list = Solid::Device::listFromType(Solid::DeviceInterface::Processor);
ui->processor->setText(i18np("Processor:", "Processors:", list.count()));
@@ -247,6 +261,7 @@ void Module::loadHardware()
ui->processorLabel->setHidden(true);
} else {
labelsForClipboard << qMakePair(ui->processor, ui->processorLabel);
+ englishTextForClipboard += QStringLiteral("Processors: %1\n").arg(processorLabel);
}
const qlonglong totalRam = calculateTotalRam();
@@ -256,6 +271,7 @@ void Module::loadHardware()
: i18nc("Unknown amount of RAM", "Unknown");
ui->memoryLabel->setText(memoryLabel);
labelsForClipboard << qMakePair(ui->memory, ui->memoryLabel);
+ englishTextForClipboard += QStringLiteral("Memory: %1\n").arg(KFormat().formatByteSize(totalRam));
}
void Module::copyToClipboard()
@@ -274,6 +290,11 @@ void Module::copyToClipboard()
QGuiApplication::clipboard()->setText(text);
}
+void Module::copyToClipboardInEnglish()
+{
+ QGuiApplication::clipboard()->setText(englishTextForClipboard);
+}
+
QString Module::plasmaVersion() const
{
const QStringList &filePaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,
diff --git a/Modules/about-distro/src/Module.h b/Modules/about-distro/src/Module.h
index 79dd2a8..848068c 100644
--- a/Modules/about-distro/src/Module.h
+++ b/Modules/about-distro/src/Module.h
@@ -69,8 +69,10 @@ private:
* Copies the software and hardware information to clipboard.
*/
void copyToClipboard();
+ void copyToClipboardInEnglish();
QVector<QPair<QLabel*, QLabel*> > labelsForClipboard;
+ QString englishTextForClipboard;
/**
* UI
diff --git a/Modules/about-distro/src/Module.ui b/Modules/about-distro/src/Module.ui
index 0ae9e2f..9d40549 100644
--- a/Modules/about-distro/src/Module.ui
+++ b/Modules/about-distro/src/Module.ui
@@ -367,6 +367,20 @@
</widget>
</item>
<item row="0" column="1">
+ <widget class="QPushButton" name="pushButtonCopyInfoInEnglish">
+ <property name="toolTip">
+ <string>Copy software and hardware information to clipboard in English</string>
+ </property>
+ <property name="text">
+ <string>Copy to Clipboard in English</string>
+ </property>
+ <property name="icon">
+ <iconset theme="edit-copy">
+ <normaloff>.</normaloff>.</iconset>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>