Krita Source Code Documentation
Loading...
Searching...
No Matches
systeminformation_p.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org>
3SPDX-FileCopyrightText: 2014 Alex Richardson <arichardson.kde@gmail.com>
4
5SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7#ifndef SYSTEMINFORMATION_P_H
8#define SYSTEMINFORMATION_P_H
9
10#include <QString>
11
13 QString userName();
14 QString operatingSystemVersion();
15}
16
17#if !defined(Q_OS_WIN)
18#include <pwd.h>
19#include <unistd.h>
20#include <sys/utsname.h>
22{
23 struct passwd *p = getpwuid(getuid());
24 return QString::fromLatin1(p->pw_name);
25}
26
28{
29 struct utsname unameBuf;
30 uname(&unameBuf);
31 return QString::fromUtf8(unameBuf.sysname) +
32 QStringLiteral(" (") + QString::fromUtf8(unameBuf.machine) + QLatin1String(") ") +
33 QStringLiteral("release ") + QString::fromUtf8(unameBuf.release);
34}
35#else
36#include <QSysInfo>
37#include <qt_windows.h>
38#define SECURITY_WIN32
39#include <security.h>
40//#include <secext.h> // GetUserNameEx
41
42inline QString SystemInformation::userName()
43{
44 WCHAR nameBuffer[256];
45 DWORD bufsize = 256;
46 if (!GetUserNameExW(NameDisplay, nameBuffer, &bufsize)) {
47 return QStringLiteral("Unknown User"); //should never happen (translate?)
48 }
49 return QString::fromWCharArray(nameBuffer);
50}
51
52static inline QString windowsVersionString() {
53 QString productVersion = QSysInfo::productVersion();
54 if (productVersion == "unknown") return QStringLiteral("Unknown Windows");
55 return "Windows " + productVersion;
56}
57
59{
60 SYSTEM_INFO info;
61 GetNativeSystemInfo(&info);
62 QString arch;
63 switch (info.wProcessorArchitecture) {
64 case PROCESSOR_ARCHITECTURE_AMD64:
65 case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64:
66 arch = QStringLiteral(" (x86_64)");
67 break;
68 case PROCESSOR_ARCHITECTURE_INTEL:
69 arch = QStringLiteral(" (x86)");
70 break;
71 case PROCESSOR_ARCHITECTURE_ARM:
72 arch = QStringLiteral(" (ARM)");
73 break;
74 case PROCESSOR_ARCHITECTURE_ARM64:
75 arch = QStringLiteral(" (ARM64)");
76 break;
77 default:
78 arch = QStringLiteral(" (unknown architecture)");
79 }
80 QString winVer;
81 //TODO: handle Service packs?
82 return windowsVersionString() + arch;
83}
84
85#endif
86
87#endif // SYSTEMINFORMATION_P_H
const Params2D p