qDebug等输出显示来源

dev-VirtualTexture
wuyize 2023-02-20 22:26:29 +08:00
parent f0ab4115c3
commit ff848b1443
2 changed files with 54 additions and 21 deletions

View File

@ -37,15 +37,15 @@ std::vector<glm::vec2> generatePathBuffer(const QPainterPath& path)
switch (element.type) switch (element.type)
{ {
case QPainterPath::MoveToElement: case QPainterPath::MoveToElement:
qDebug() << "MoveToElement"; //qDebug() << "MoveToElement";
qDebug() << element; //qDebug() << element;
pathBuffer.push_back(glm::vec2(std::numeric_limits<float>::infinity())); pathBuffer.push_back(glm::vec2(std::numeric_limits<float>::infinity()));
pathBuffer.push_back(glm::vec2(element.x, element.y)); pathBuffer.push_back(glm::vec2(element.x, element.y));
break; break;
case QPainterPath::LineToElement: case QPainterPath::LineToElement:
{ {
qDebug() << "LineToElement"; //qDebug() << "LineToElement";
qDebug() << element; //qDebug() << element;
glm::vec2 end = glm::vec2(element.x, element.y); glm::vec2 end = glm::vec2(element.x, element.y);
glm::vec2 mid = (pathBuffer.back() + end) / 2.f; glm::vec2 mid = (pathBuffer.back() + end) / 2.f;
pathBuffer.push_back(mid); pathBuffer.push_back(mid);
@ -55,14 +55,14 @@ std::vector<glm::vec2> generatePathBuffer(const QPainterPath& path)
} }
case QPainterPath::CurveToElement: case QPainterPath::CurveToElement:
{ {
qDebug() << "CurveToElement"; //qDebug() << "CurveToElement";
qDebug() << element; //qDebug() << element;
glm::vec2 p1 = glm::vec2(element.x, element.y); glm::vec2 p1 = glm::vec2(element.x, element.y);
element = path.elementAt(++i); element = path.elementAt(++i);
qDebug() << element; //qDebug() << element;
glm::vec2 p2 = glm::vec2(element.x, element.y); glm::vec2 p2 = glm::vec2(element.x, element.y);
element = path.elementAt(++i); element = path.elementAt(++i);
qDebug() << element; //qDebug() << element;
glm::vec2 p3 = glm::vec2(element.x, element.y); glm::vec2 p3 = glm::vec2(element.x, element.y);
if (p3 != pathBuffer.back()) if (p3 != pathBuffer.back())
{ {

View File

@ -2,26 +2,59 @@
#include <QGuiApplication> #include <QGuiApplication>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <FramelessHelper/Core/private/framelessconfig_p.h> #include <FramelessHelper/Core/private/framelessconfig_p.h>
#include <iostream>
#include <format>
#include "consoleapi2.h"
extern "C" extern "C"
{ {
_declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; _declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
} }
FRAMELESSHELPER_USE_NAMESPACE FRAMELESSHELPER_USE_NAMESPACE
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg)
{
switch (type)
{
case QtInfoMsg:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY);
break;
case QtDebugMsg:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
break;
case QtWarningMsg:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN);
break;
case QtCriticalMsg:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_BLUE);
break;
case QtFatalMsg:
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED);
break;
}
std::cout << std::format("{}({},{}) {}\n",
QString(context.file).splitRef("\\").back().toLocal8Bit().data(),
context.line,
QString(context.function).splitRef("(").first().split(" ").back().split(":").back().toLocal8Bit().data(),
msg.toStdString());
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
}
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
//FramelessHelper::Widgets::initialize(); qInstallMessageHandler(messageHandler);
FramelessHelper::Core::initialize(); //FramelessHelper::Widgets::initialize();
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); FramelessHelper::Core::initialize();
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv); QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
//FramelessHelper::Core::setApplicationOSThemeAware(); QApplication a(argc, argv);
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); //FramelessHelper::Core::setApplicationOSThemeAware();
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
MainWindow w; FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
w.show(); MainWindow w;
return a.exec(); w.show();
return a.exec();
} }