Changeset View
Changeset View
Standalone View
Standalone View
Modules/about-distro/src/PlasmaEntry.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | SPDX-FileCopyrightText: 2012-2020 Harald Sitter <sitter@kde.org> | ||||
3 | SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL | ||||
4 | */ | ||||
5 | | ||||
6 | #include "PlasmaEntry.h" | ||||
7 | | ||||
8 | #include <QStandardPaths> | ||||
9 | #include <KConfigGroup> | ||||
10 | #include <KDesktopFile> | ||||
11 | | ||||
12 | PlasmaEntry::PlasmaEntry() | ||||
13 | : Entry(ki18n("KDE Plasma Version:"), plasmaVersion()) | ||||
14 | { | ||||
15 | // Since Plasma version detection isn't based on a library query it can fail | ||||
16 | // in weird cases; instead of admitting defeat we simply hide everything :P | ||||
17 | if (value.isEmpty()) { | ||||
18 | return; | ||||
19 | } | ||||
20 | } | ||||
21 | | ||||
22 | QString PlasmaEntry::plasmaVersion() | ||||
23 | { | ||||
24 | const QStringList &filePaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, | ||||
25 | QStringLiteral("xsessions/plasma.desktop")); | ||||
26 | | ||||
27 | if (filePaths.length() < 1) { | ||||
28 | return QString(); | ||||
29 | } | ||||
30 | | ||||
31 | // Despite the fact that there can be multiple desktop files we simply take | ||||
32 | // the first one as users usually don't have xsessions/ in their $HOME | ||||
33 | // data location, so the first match should (usually) be the only one and | ||||
34 | // reflect the plasma session run. | ||||
35 | KDesktopFile desktopFile(filePaths.first()); | ||||
36 | return desktopFile.desktopGroup().readEntry("X-KDE-PluginInfo-Version", QString()); | ||||
37 | } |