File indexing completed on 2024-05-05 05:36:40
0001 /* 0002 SPDX-FileCopyrightText: 2019 Jonah BrĂ¼chert <jbb@kaidan.im> 0003 SPDX-FileCopyrightText: 2012-2019 Harald Sitter <sitter@kde.org> 0004 0005 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0006 */ 0007 0008 #include "softwareinfo.h" 0009 #include <sys/utsname.h> 0010 0011 #include <KConfigGroup> 0012 #include <KCoreAddons> 0013 #include <KDesktopFile> 0014 #include <KLocalizedString> 0015 #include <QDebug> 0016 #include <QStandardPaths> 0017 0018 SoftwareInfo::SoftwareInfo(QObject *parent) 0019 : QObject(parent) 0020 { 0021 } 0022 0023 QString SoftwareInfo::kernelRelease() const 0024 { 0025 struct utsname utsName { 0026 }; 0027 uname(&utsName); 0028 0029 return QString::fromLatin1(utsName.release); 0030 } 0031 0032 QString SoftwareInfo::frameworksVersion() const 0033 { 0034 return KCoreAddons::versionString(); 0035 } 0036 0037 QString SoftwareInfo::qtVersion() const 0038 { 0039 return QString::fromLatin1(qVersion()); 0040 } 0041 0042 QString SoftwareInfo::plasmaVersion() const 0043 { 0044 const QStringList &filePaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("wayland-sessions/plasma.desktop")); 0045 0046 if (filePaths.length() < 1) { 0047 return QString(); 0048 } 0049 0050 // Despite the fact that there can be multiple desktop files we simply take 0051 // the first one as users usually don't have xsessions/ in their $HOME 0052 // data location, so the first match should (usually) be the only one and 0053 // reflect the plasma session run. 0054 KDesktopFile desktopFile(filePaths.first()); 0055 return desktopFile.desktopGroup().readEntry("X-KDE-PluginInfo-Version", QString()); 0056 } 0057 0058 QString SoftwareInfo::osType() const 0059 { 0060 const int bits = QT_POINTER_SIZE == 8 ? 64 : 32; 0061 0062 return QString::number(bits); 0063 }