Commit 55912f12 authored by Harald Sitter's avatar Harald Sitter 🦄

add gpu entry to about system

Summary:
simply queries gl_renderer from gl

also refactor string processing for (R) and (TM) replacement so
it can be shared for cpu and gpu entries

I do wonder if we need to blacklist software gl somehow though

BUG: 355053
FIXED-IN: 5.19.0

Test Plan:
shows something of value on amd and intel

depends on D26667

Reviewers: davidedmundson, ngraham

Reviewed By: davidedmundson, ngraham

Subscribers: ngraham, broulik, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26709
parent 4b4f6a3f
......@@ -11,6 +11,8 @@ set(kcm_SRCS
BitEntry.cpp
MemoryEntry.cpp
CPUEntry.cpp
GPUEntry.cpp
FancyString.cpp
)
ki18n_wrap_ui(kcm_SRCS Module.ui)
......
......@@ -10,6 +10,8 @@
#include <solid/device.h>
#include <solid/processor.h>
#include "FancyString.h"
CPUEntry::CPUEntry()
: Entry(KLocalizedString(), QString())
{
......@@ -34,10 +36,7 @@ CPUEntry::CPUEntry()
names.reserve(processorMap.count());
for (auto it = processorMap.constBegin(); it != processorMap.constEnd(); ++it) {
const int count = it.value();
QString name = it.key();
name.replace(QStringLiteral("(TM)"), QChar(8482));
name.replace(QStringLiteral("(R)"), QChar(174));
name = name.simplified();
QString name = FancyString::fromUgly(it.key());
names.append(QStringLiteral("%1 × %2").arg(count).arg(name));
}
......
/*
SPDX-FileCopyrightText: 2012-2020 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "FancyString.h"
namespace FancyString
{
QString fromUgly(const QString &string)
{
QString ugly(string);
ugly.replace(QStringLiteral("(TM)"), QChar(8482));
ugly.replace(QStringLiteral("(R)"), QChar(174));
return ugly.simplified();
}
} // namespace FancyString
/*
SPDX-FileCopyrightText: 2012-2020 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef FANCYSTRING_H
#define FANCYSTRING_H
#include <QString>
namespace FancyString
{
// Turns ugly '(R)' '(TM)' ascii into unicode.
QString fromUgly(const QString &string);
}
#endif // FANCYSTRING_H
/*
SPDX-FileCopyrightText: 2016 Rohan Garg <rohan@kde.org>
SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "GPUEntry.h"
#include <QDebug>
#include <QOffscreenSurface>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <KLocalizedString>
#include "FancyString.h"
GPUEntry::GPUEntry()
: Entry(ki18n("Graphics Processor:"), QString())
{
QOpenGLContext context;
QOffscreenSurface surface;
surface.create();
if (!context.create()) {
qWarning() << "Failed create QOpenGLContext";
return;
}
if (context.makeCurrent(&surface)) {
value = QString::fromLatin1(reinterpret_cast<const char*>(
context.functions()->glGetString(GL_RENDERER)));
value = FancyString::fromUgly(value);
// It seems the renderer value may have excess information in parentheses ->
// strip that. Elide would probably be nicer, a bit meh with QWidgets though.
value = value.mid(0, value.indexOf('('));
context.doneCurrent();
} else {
qWarning() << "Failed to make QOpenGLContext current";
return;
}
}
/*
SPDX-FileCopyrightText: 2016 Rohan Garg <rohan@kde.org>
SPDX-FileCopyrightText: 2020 Harald Sitter <sitter@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#ifndef GPUENTRY_H
#define GPUENTRY_H
#include "Entry.h"
class GPUEntry : public Entry
{
public:
GPUEntry();
};
#endif // GPUENTRY_H
......@@ -20,6 +20,7 @@
#include "CPUEntry.h"
#include "BitEntry.h"
#include "GPUEntry.h"
#include "KernelEntry.h"
#include "MemoryEntry.h"
#include "PlasmaEntry.h"
......@@ -189,7 +190,8 @@ void Module::loadEntries()
addSectionHeader(i18nc("@title:group", "Hardware"));
addEntriesToGrid({
new CPUEntry(),
new MemoryEntry()
new MemoryEntry(),
new GPUEntry()
});
}
......
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