File: softwareinfo.cpp

package info (click to toggle)
plasma-settings 23.01.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 5,256 kB
  • sloc: cpp: 4,943; xml: 42; sh: 6; makefile: 3
file content (63 lines) | stat: -rw-r--r-- 1,635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
    SPDX-FileCopyrightText: 2019 Jonah BrĂ¼chert <jbb@kaidan.im>
    SPDX-FileCopyrightText: 2012-2019 Harald Sitter <sitter@kde.org>

    SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/

#include "softwareinfo.h"
#include <sys/utsname.h>

#include <KConfigGroup>
#include <KCoreAddons>
#include <KDesktopFile>
#include <KLocalizedString>
#include <QDebug>
#include <QStandardPaths>

SoftwareInfo::SoftwareInfo(QObject *parent)
    : QObject(parent)
{
}

QString SoftwareInfo::kernelRelease() const
{
    struct utsname utsName {
    };
    uname(&utsName);

    return QString::fromLatin1(utsName.release);
}

QString SoftwareInfo::frameworksVersion() const
{
    return KCoreAddons::versionString();
}

QString SoftwareInfo::qtVersion() const
{
    return QString::fromLatin1(qVersion());
}

QString SoftwareInfo::plasmaVersion() const
{
    const QStringList &filePaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("xsessions/plasma.desktop"));

    if (filePaths.length() < 1) {
        return QString();
    }

    // Despite the fact that there can be multiple desktop files we simply take
    // the first one as users usually don't have xsessions/ in their $HOME
    // data location, so the first match should (usually) be the only one and
    // reflect the plasma session run.
    KDesktopFile desktopFile(filePaths.first());
    return desktopFile.desktopGroup().readEntry("X-KDE-PluginInfo-Version", QString());
}

QString SoftwareInfo::osType() const
{
    const int bits = QT_POINTER_SIZE == 8 ? 64 : 32;

    return QString::number(bits);
}