Changeset View
Changeset View
Standalone View
Standalone View
Modules/about-distro/src/Module.cpp
Show First 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | 138 | { | |||
---|---|---|---|---|---|
152 | ui->logoLabel->setPixmap(logo); | 152 | ui->logoLabel->setPixmap(logo); | ||
153 | 153 | | |||
154 | OSRelease os; | 154 | OSRelease os; | ||
155 | // We allow overriding of the OS name for branding purposes. | 155 | // We allow overriding of the OS name for branding purposes. | ||
156 | // For example OS Ubuntu may be rebranded as Kubuntu. Also Kubuntu Active | 156 | // For example OS Ubuntu may be rebranded as Kubuntu. Also Kubuntu Active | ||
157 | // as a product brand is different from Kubuntu. | 157 | // as a product brand is different from Kubuntu. | ||
158 | const QString distroName = cg.readEntry("Name", os.name); | 158 | const QString distroName = cg.readEntry("Name", os.name); | ||
159 | const QString versionId = cg.readEntry("Version", os.versionId); | 159 | const QString versionId = cg.readEntry("Version", os.versionId); | ||
160 | ui->nameVersionLabel->setText(QStringLiteral("%1 %2").arg(distroName, versionId)); | 160 | const QString nameVersionText = QStringLiteral("%1 %2").arg(distroName, versionId); | ||
161 | ui->nameVersionLabel->setText(nameVersionText); | ||||
161 | 162 | | |||
162 | const auto dummyDistroDescriptionLabel = new QLabel(i18nc("@title:row", "Operating System:"), this); | 163 | labelsForClipboard << qMakePair(QStringLiteral("Operating System:"), nameVersionText); // Don't translate | ||
163 | dummyDistroDescriptionLabel->hide(); | | |||
164 | labelsForClipboard << qMakePair(dummyDistroDescriptionLabel, ui->nameVersionLabel); | | |||
165 | 164 | | |||
166 | const QString variant = cg.readEntry("Variant", QString()); | 165 | const QString variant = cg.readEntry("Variant", QString()); | ||
167 | if (variant.isEmpty()) { | 166 | if (variant.isEmpty()) { | ||
168 | ui->variantLabel->hide(); | 167 | ui->variantLabel->hide(); | ||
169 | } else { | 168 | } else { | ||
170 | ui->variantLabel->setText(variant); | 169 | ui->variantLabel->setText(variant); | ||
171 | } | 170 | } | ||
172 | 171 | | |||
173 | const QString url = cg.readEntry("Website", os.homeUrl); | 172 | const QString url = cg.readEntry("Website", os.homeUrl); | ||
174 | if (url.isEmpty()) { | 173 | if (url.isEmpty()) { | ||
175 | ui->urlLabel->hide(); | 174 | ui->urlLabel->hide(); | ||
176 | } else { | 175 | } else { | ||
177 | ui->urlLabel->setText(QStringLiteral("<a href='%1'>%1</a>").arg(url)); | 176 | ui->urlLabel->setText(QStringLiteral("<a href='%1'>%1</a>").arg(url)); | ||
178 | } | 177 | } | ||
179 | 178 | | |||
180 | // Since Plasma version detection isn't based on a library query it can fail | 179 | // Since Plasma version detection isn't based on a library query it can fail | ||
181 | // in weird cases; instead of admitting defeat we simply hide everything :P | 180 | // in weird cases; instead of admitting defeat we simply hide everything :P | ||
182 | const QString plasma = plasmaVersion(); | 181 | const QString plasma = plasmaVersion(); | ||
183 | if (plasma.isEmpty()) { | 182 | if (plasma.isEmpty()) { | ||
184 | ui->plasma->hide(); | 183 | ui->plasma->hide(); | ||
185 | ui->plasmaLabel->hide(); | 184 | ui->plasmaLabel->hide(); | ||
186 | } else { | 185 | } else { | ||
187 | ui->plasmaLabel->setText(plasma); | 186 | ui->plasmaLabel->setText(plasma); | ||
188 | labelsForClipboard << qMakePair(ui->plasma, ui->plasmaLabel); | 187 | labelsForClipboard << qMakePair(QStringLiteral("KDE Plasma version:"), plasma); // Don't translate | ||
189 | } | 188 | } | ||
190 | 189 | | |||
191 | const QString frameworksVersion = KCoreAddons::versionString(); | 190 | const QString frameworksVersion = KCoreAddons::versionString(); | ||
192 | ui->frameworksLabel->setText(frameworksVersion); | 191 | ui->frameworksLabel->setText(frameworksVersion); | ||
193 | labelsForClipboard << qMakePair(ui->frameworksLabelKey, ui->frameworksLabel); | 192 | labelsForClipboard << qMakePair(QStringLiteral("KDE Frameworks version:"), frameworksVersion); // Don't translate | ||
194 | 193 | | |||
195 | const QString qversion = QString::fromLatin1(qVersion()); | 194 | const QString qversion = QString::fromLatin1(qVersion()); | ||
196 | ui->qtLabel->setText(qversion); | 195 | ui->qtLabel->setText(qversion); | ||
197 | labelsForClipboard << qMakePair(ui->qt, ui->qtLabel); | 196 | labelsForClipboard << qMakePair(QStringLiteral("Qt version:"), qversion); // Don't translate | ||
198 | } | 197 | } | ||
199 | 198 | | |||
200 | void Module::loadHardware() | 199 | void Module::loadHardware() | ||
201 | { | 200 | { | ||
202 | struct utsname utsName; | 201 | struct utsname utsName; | ||
203 | if(uname(&utsName) != 0) { | 202 | if(uname(&utsName) != 0) { | ||
204 | ui->kernel->hide(); | 203 | ui->kernel->hide(); | ||
205 | ui->kernelLabel->hide(); | 204 | ui->kernelLabel->hide(); | ||
206 | } else { | 205 | } else { | ||
207 | ui->kernelLabel->setText(QString::fromLatin1(utsName.release)); | 206 | ui->kernelLabel->setText(QString::fromLatin1(utsName.release)); | ||
208 | labelsForClipboard << qMakePair(ui->kernel, ui->kernelLabel); | 207 | labelsForClipboard << qMakePair(QStringLiteral("Kernel version:"), QString::fromLatin1(utsName.release)); // Don't translate | ||
209 | } | 208 | } | ||
210 | 209 | | |||
211 | const int bits = QT_POINTER_SIZE == 8 ? 64 : 32; | 210 | const int bits = QT_POINTER_SIZE == 8 ? 64 : 32; | ||
212 | const QString bitsStr = QString::number(bits); | 211 | const QString bitsStr = QString::number(bits); | ||
213 | ui->bitsLabel->setText(i18nc("@label %1 is the CPU bit width (e.g. 32 or 64)", | 212 | ui->bitsLabel->setText(i18nc("@label %1 is the CPU bit width (e.g. 32 or 64)", | ||
214 | "%1-bit", bitsStr)); | 213 | "%1-bit", bitsStr)); | ||
215 | labelsForClipboard << qMakePair(ui->bitsKey, ui->bitsLabel); | 214 | labelsForClipboard << qMakePair(QStringLiteral("Operating System type:"), QStringLiteral("%1-bit").arg(bitsStr)); // Don't translate | ||
216 | 215 | | |||
217 | const QList<Solid::Device> list = Solid::Device::listFromType(Solid::DeviceInterface::Processor); | 216 | const QList<Solid::Device> list = Solid::Device::listFromType(Solid::DeviceInterface::Processor); | ||
218 | ui->processor->setText(i18np("Processor:", "Processors:", list.count())); | 217 | ui->processor->setText(i18np("Processor:", "Processors:", list.count())); | ||
219 | // Format processor string | 218 | // Format processor string | ||
220 | // Group by processor name | 219 | // Group by processor name | ||
221 | QMap<QString, int> processorMap; | 220 | QMap<QString, int> processorMap; | ||
222 | Q_FOREACH(const Solid::Device &device, list) { | 221 | Q_FOREACH(const Solid::Device &device, list) { | ||
223 | const QString name = device.product(); | 222 | const QString name = device.product(); | ||
Show All 17 Lines | |||||
241 | } | 240 | } | ||
242 | 241 | | |||
243 | const QString processorLabel = names.join(QStringLiteral(", ")); | 242 | const QString processorLabel = names.join(QStringLiteral(", ")); | ||
244 | ui->processorLabel->setText(processorLabel); | 243 | ui->processorLabel->setText(processorLabel); | ||
245 | if (ui->processorLabel->text().isEmpty()) { | 244 | if (ui->processorLabel->text().isEmpty()) { | ||
246 | ui->processor->setHidden(true); | 245 | ui->processor->setHidden(true); | ||
247 | ui->processorLabel->setHidden(true); | 246 | ui->processorLabel->setHidden(true); | ||
248 | } else { | 247 | } else { | ||
249 | labelsForClipboard << qMakePair(ui->processor, ui->processorLabel); | 248 | labelsForClipboard << qMakePair(QStringLiteral("Processor:"), processorLabel); // Don't translate | ||
250 | } | 249 | } | ||
251 | 250 | | |||
252 | const qlonglong totalRam = calculateTotalRam(); | 251 | const qlonglong totalRam = calculateTotalRam(); | ||
252 | const QString memoryText = KFormat().formatByteSize(totalRam); | ||||
253 | const QString memoryLabel = totalRam > 0 | 253 | const QString memoryLabel = totalRam > 0 | ||
254 | ? i18nc("@label %1 is the formatted amount of system memory (e.g. 7,7 GiB)", | 254 | ? i18nc("@label %1 is the formatted amount of system memory (e.g. 7,7 GiB)", | ||
255 | "%1 of RAM", KFormat().formatByteSize(totalRam)) | 255 | "%1 of RAM", memoryText) | ||
256 | : i18nc("Unknown amount of RAM", "Unknown"); | 256 | : i18nc("Unknown amount of RAM", "Unknown"); | ||
257 | ui->memoryLabel->setText(memoryLabel); | 257 | ui->memoryLabel->setText(memoryLabel); | ||
258 | labelsForClipboard << qMakePair(ui->memory, ui->memoryLabel); | 258 | labelsForClipboard << qMakePair(QStringLiteral("Memory:"), totalRam > 0 ? QStringLiteral("%1 of RAM").arg(memoryText) | ||
259 | : QStringLiteral("Unknown")); // Don't translate | ||||
259 | } | 260 | } | ||
260 | 261 | | |||
261 | void Module::copyToClipboard() | 262 | void Module::copyToClipboard() | ||
262 | { | 263 | { | ||
263 | QString text; | 264 | QString text; | ||
264 | // note that this loop does not necessarily represent the same order as in the GUI | 265 | // note that this loop does not necessarily represent the same order as in the GUI | ||
265 | for (auto labelPair : qAsConst(labelsForClipboard)) { | 266 | for (auto labelPair : qAsConst(labelsForClipboard)) { | ||
266 | const auto valueLabel = labelPair.second; | 267 | text += labelPair.first + QStringLiteral(" ") + labelPair.second + QStringLiteral("\n"); | ||
267 | if (!valueLabel->isHidden()) { | | |||
268 | const auto descriptionLabelText = labelPair.first->text(); | | |||
269 | const auto valueLabelText = valueLabel->text(); | | |||
270 | text += i18nc("%1 is a label already including a colon, %2 is the corresponding value", "%1 %2", descriptionLabelText, valueLabelText) + QStringLiteral("\n"); | | |||
271 | } | | |||
272 | } | 268 | } | ||
273 | 269 | | |||
274 | QGuiApplication::clipboard()->setText(text); | 270 | QGuiApplication::clipboard()->setText(text); | ||
275 | } | 271 | } | ||
276 | 272 | | |||
277 | QString Module::plasmaVersion() const | 273 | QString Module::plasmaVersion() const | ||
278 | { | 274 | { | ||
279 | const QStringList &filePaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | 275 | const QStringList &filePaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | ||
Show All 13 Lines |