mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2024-11-26 13:27:05 +08:00
update
This commit is contained in:
parent
08c458c2a1
commit
5787e308dd
@ -8,6 +8,7 @@
|
||||
#include <QStandardPaths>
|
||||
#include <QDir>
|
||||
#include <QThread>
|
||||
#include <QSettings>
|
||||
#include "Version.h"
|
||||
#ifdef WIN32
|
||||
#include <process.h>
|
||||
@ -40,6 +41,55 @@ std::map<QtMsgType, int> logLevelMap = {
|
||||
{QtDebugMsg,4}
|
||||
};
|
||||
|
||||
QString Log::prettyProductInfoWrapper()
|
||||
{
|
||||
auto productName = QSysInfo::prettyProductName();
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0)
|
||||
#if defined(Q_OS_MACOS)
|
||||
auto macosVersionFile = QString::fromUtf8("/System/Library/CoreServices/.SystemVersionPlatform.plist");
|
||||
auto fi = QFileInfo (macosVersionFile);
|
||||
if (fi.exists() && fi.isReadable()) {
|
||||
auto plistFile = QFile(macosVersionFile);
|
||||
plistFile.open(QIODevice::ReadOnly);
|
||||
while (!plistFile.atEnd()) {
|
||||
auto line = plistFile.readLine();
|
||||
if (line.contains("ProductUserVisibleVersion")) {
|
||||
auto nextLine = plistFile.readLine();
|
||||
if (nextLine.contains("<string>")) {
|
||||
QRegularExpression re(QString::fromUtf8("\\s*<string>(.*)</string>"));
|
||||
auto matches = re.match(QString::fromUtf8(nextLine));
|
||||
if (matches.hasMatch()) {
|
||||
productName = QString::fromUtf8("macOS ") + matches.captured(1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
QSettings regKey {QString::fromUtf8("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), QSettings::NativeFormat};
|
||||
if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) {
|
||||
auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt();
|
||||
if (buildNumber > 0) {
|
||||
if (buildNumber < 9200) {
|
||||
productName = QString::fromUtf8("Windows 7 build %1").arg(buildNumber);
|
||||
}
|
||||
else if (buildNumber < 10240) {
|
||||
productName = QString::fromUtf8("Windows 8 build %1").arg(buildNumber);
|
||||
}
|
||||
else if (buildNumber < 22000) {
|
||||
productName = QString::fromUtf8("Windows 10 build %1").arg(buildNumber);
|
||||
}
|
||||
else {
|
||||
productName = QString::fromUtf8("Windows 11 build %1").arg(buildNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return productName;
|
||||
}
|
||||
|
||||
static inline void myMessageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message)
|
||||
{
|
||||
@ -145,7 +195,7 @@ void Log::setup(const QString &app)
|
||||
qInfo()<<"[GitHashCode]"<<COMMIT_HASH;
|
||||
qInfo()<<"[DeviceInfo]";
|
||||
qInfo()<<" [DeviceId]"<<QSysInfo::machineUniqueId();
|
||||
qInfo()<<" [Manufacturer]"<<QSysInfo::prettyProductName();
|
||||
qInfo()<<" [Manufacturer]"<<prettyProductInfoWrapper();
|
||||
qInfo()<<" [CPU_ABI]"<<QSysInfo::currentCpuArchitecture();
|
||||
qInfo()<<"[LOG_LEVEL]"<<g_logLevel;
|
||||
qInfo()<<"[LOG_PATH]"<<g_file_path;
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
namespace Log
|
||||
{
|
||||
QString prettyProductInfoWrapper();
|
||||
void setup(const QString &app);
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,12 @@ Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
qputenv("QT_QUICK_CONTROLS_STYLE","Basic");
|
||||
//UOSv20 does not print logs
|
||||
#ifdef Q_OS_LINUX
|
||||
//fix bug UOSv20 does not print logs
|
||||
qputenv("QT_LOGGING_RULES","");
|
||||
//v-sync does not work
|
||||
//fix bug UOSv20 v-sync does not work
|
||||
qputenv("QSG_RENDER_LOOP","basic");
|
||||
#endif
|
||||
QGuiApplication::setOrganizationName("ZhuZiChu");
|
||||
QGuiApplication::setOrganizationDomain("https://zhuzichu520.github.io");
|
||||
QGuiApplication::setApplicationName("FluentUI");
|
||||
|
Loading…
Reference in New Issue
Block a user