Compare commits
No commits in common. "b4f2f6813544f8db5a8e9672aa10700df4d43d78" and "ee23554cb41c9294ced048d5a1241fa1abbb4ca7" have entirely different histories.
b4f2f68135
...
ee23554cb4
|
@ -1,70 +0,0 @@
|
||||||
#include "Log.h"
|
|
||||||
#include <QtCore/qdebug.h>
|
|
||||||
#include <QtCore/qfile.h>
|
|
||||||
#include <QtCore/qtextstream.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <framelesshelpercore_global.h>
|
|
||||||
|
|
||||||
#ifndef QT_ENDL
|
|
||||||
# if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
|
||||||
# define QT_ENDL Qt::endl
|
|
||||||
# else
|
|
||||||
# define QT_ENDL endl
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static QString g_app = {};
|
|
||||||
static bool g_logError = false;
|
|
||||||
|
|
||||||
static std::unique_ptr<QFile> g_logFile = nullptr;
|
|
||||||
static std::unique_ptr<QTextStream> g_logStream = nullptr;
|
|
||||||
|
|
||||||
static inline void myMessageHandler(const QtMsgType type, const QMessageLogContext &context, const QString &message)
|
|
||||||
{
|
|
||||||
if (message.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const QString finalMessage = qFormatLogMessage(type, context, message).trimmed();
|
|
||||||
if ((type == QtInfoMsg) || (type == QtDebugMsg)) {
|
|
||||||
std::cout << qUtf8Printable(finalMessage) << std::endl;
|
|
||||||
} else {
|
|
||||||
std::cerr << qUtf8Printable(finalMessage) << std::endl;
|
|
||||||
}
|
|
||||||
if (g_logError) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!g_logFile) {
|
|
||||||
g_logFile = std::make_unique<QFile>();
|
|
||||||
g_logFile->setFileName(FRAMELESSHELPER_STRING_LITERAL("debug-%1.log").arg(g_app));
|
|
||||||
if (!g_logFile->open(QFile::WriteOnly | QFile::Text | QFile::Append)) {
|
|
||||||
std::cerr << "Can't open file to write: " << qUtf8Printable(g_logFile->errorString()) << std::endl;
|
|
||||||
g_logFile.reset();
|
|
||||||
g_logError = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!g_logStream) {
|
|
||||||
g_logStream = std::make_unique<QTextStream>();
|
|
||||||
g_logStream->setDevice(g_logFile.get());
|
|
||||||
}
|
|
||||||
(*g_logStream) << finalMessage << QT_ENDL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Log::setup(const QString &app)
|
|
||||||
{
|
|
||||||
Q_ASSERT(!app.isEmpty());
|
|
||||||
if (app.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
static bool once = false;
|
|
||||||
if (once) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
once = true;
|
|
||||||
g_app = app;
|
|
||||||
qSetMessagePattern(FRAMELESSHELPER_STRING_LITERAL(
|
|
||||||
"[%{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}"
|
|
||||||
"FATAL%{endif}> %{if-category}%{category}: %{endif}%{message}"));
|
|
||||||
qInstallMessageHandler(myMessageHandler);
|
|
||||||
}
|
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef LOG_H
|
|
||||||
#define LOG_H
|
|
||||||
#include <QtCore/qstring.h>
|
|
||||||
|
|
||||||
namespace Log
|
|
||||||
{
|
|
||||||
void setup(const QString &app);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LOG_H
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <QtQml/qqmlextensionplugin.h>
|
#include <QtQml/qqmlextensionplugin.h>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include "AppInfo.h"
|
#include "AppInfo.h"
|
||||||
#include "helper/Log.h"
|
|
||||||
#include "src/component/CircularReveal.h"
|
#include "src/component/CircularReveal.h"
|
||||||
#include "src/component/FileWatcher.h"
|
#include "src/component/FileWatcher.h"
|
||||||
#include "src/component/FpsItem.h"
|
#include "src/component/FpsItem.h"
|
||||||
|
@ -24,7 +23,6 @@ Q_IMPORT_QML_PLUGIN(FluentUIPlugin)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
Log::setup("example");
|
|
||||||
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
|
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy);
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||||
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 27fcd913b4b21b51d5cca307e47e93d1ae75e1bb
|
Subproject commit 49c72fb4f85421f770a6a14657ba73a9912ee833
|
|
@ -24,7 +24,7 @@ FluApp::~FluApp(){
|
||||||
|
|
||||||
void FluApp::init(QObject *application){
|
void FluApp::init(QObject *application){
|
||||||
this->_application = application;
|
this->_application = application;
|
||||||
FramelessHelperQuickInitialize();
|
FramelessHelper::Quick::initialize();
|
||||||
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
FramelessConfig::instance()->set(Global::Option::DisableLazyInitializationForMicaMaterial);
|
||||||
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
|
||||||
QQmlEngine *engine = qmlEngine(_application);
|
QQmlEngine *engine = qmlEngine(_application);
|
||||||
|
|
Loading…
Reference in New Issue