This commit is contained in:
朱子楚\zhuzi 2023-12-05 00:20:40 +08:00
parent f5a4fc1300
commit 711411f6a8
3 changed files with 18 additions and 2 deletions

View File

@ -253,6 +253,9 @@ FluWindow {
if(!FluTheme.enableAnimation || window.fitsAppBarWindows === false){ if(!FluTheme.enableAnimation || window.fitsAppBarWindows === false){
changeDark() changeDark()
}else{ }else{
if(loader_reveal.sourceComponent){
return
}
loader_reveal.sourceComponent = com_reveal loader_reveal.sourceComponent = com_reveal
var target = window.contentItem var target = window.contentItem
var pos = button.mapToItem(target,0,0) var pos = button.mapToItem(target,0,0)

View File

@ -256,6 +256,9 @@ FluWindow {
if(!FluTheme.enableAnimation || window.fitsAppBarWindows === false){ if(!FluTheme.enableAnimation || window.fitsAppBarWindows === false){
changeDark() changeDark()
}else{ }else{
if(loader_reveal.sourceComponent){
return
}
loader_reveal.sourceComponent = com_reveal loader_reveal.sourceComponent = com_reveal
var target = window.contentItem var target = window.contentItem
var pos = button.mapToItem(target,0,0) var pos = button.mapToItem(target,0,0)

View File

@ -3,6 +3,8 @@
#include <QtCore/qfile.h> #include <QtCore/qfile.h>
#include <QtCore/qtextstream.h> #include <QtCore/qtextstream.h>
#include <iostream> #include <iostream>
#include <QStandardPaths>
#include <QDir>
#ifndef QT_ENDL #ifndef QT_ENDL
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) # if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
@ -13,6 +15,7 @@
#endif #endif
static QString g_app = {}; static QString g_app = {};
static QString g_file_path= {};
static bool g_logError = false; static bool g_logError = false;
static std::unique_ptr<QFile> g_logFile = nullptr; static std::unique_ptr<QFile> g_logFile = nullptr;
@ -33,8 +36,7 @@ static inline void myMessageHandler(const QtMsgType type, const QMessageLogConte
return; return;
} }
if (!g_logFile) { if (!g_logFile) {
g_logFile = std::make_unique<QFile>(); g_logFile = std::make_unique<QFile>(g_file_path);
g_logFile->setFileName(QString("debug-%1.log").arg(g_app));
if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) { if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) {
std::cerr << "Can't open file to write: " << qPrintable(g_logFile->errorString()) << std::endl; std::cerr << "Can't open file to write: " << qPrintable(g_logFile->errorString()) << std::endl;
g_logFile.reset(); g_logFile.reset();
@ -61,9 +63,17 @@ void Log::setup(const QString &app)
} }
once = true; once = true;
g_app = app; g_app = app;
const QString logFileName = QString("debug-%1.log").arg(g_app);
const QString logDirPath = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
const QDir logDir(logDirPath);
if(!logDir.exists()){
logDir.mkpath(logDirPath);
}
g_file_path = logDir.filePath(logFileName);
qSetMessagePattern(QString( qSetMessagePattern(QString(
"[%{time yyyy/MM/dd hh:mm:ss.zzz}] <%{if-info}INFO%{endif}%{if-debug}DEBUG" "[%{time yyyy/MM/dd hh:mm:ss.zzz}] <%{if-info}INFO%{endif}%{if-debug}DEBUG"
"%{endif}%{if-warning}WARNING%{endif}%{if-critical}CRITICAL%{endif}%{if-fatal}" "%{endif}%{if-warning}WARNING%{endif}%{if-critical}CRITICAL%{endif}%{if-fatal}"
"FATAL%{endif}> %{if-category}%{category}: %{endif}%{message}")); "FATAL%{endif}> %{if-category}%{category}: %{endif}%{message}"));
qInstallMessageHandler(myMessageHandler); qInstallMessageHandler(myMessageHandler);
qDebug()<<"Application log file path->"<<g_file_path;
} }