From fef76683511f22634fec48dd025fe11e6ac54fb8 Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Mon, 20 Feb 2023 13:48:39 +0800 Subject: [PATCH 1/2] style dialog --- .../src/Editor/RightBar/InfoDisplayWidget.cpp | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp index b30074f..f197005 100644 --- a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp @@ -3,6 +3,8 @@ #include #include #include +#include +#include void InfoDisplayWidget::setLayer(LayerWrapper *layer) { @@ -88,19 +90,35 @@ void InfoDisplayWidget::generateLayerForm() QWidget* w = new QWidget; item->setSizeHint(QSize(50, 40)); QHBoxLayout* layout = new QHBoxLayout; - QPushButton* pushButton = new QPushButton(w); + QPushButton* deleteButton = new QPushButton(w); + QPushButton* detailButton = new QPushButton(w); QLabel* name = new QLabel(w); name->setText(styleNames[index]); - pushButton->setText("×"); - pushButton->setFixedSize(QSize(20, 20)); - connect(pushButton, &QPushButton::clicked, [styleList,item,this]() { + detailButton->setText("..."); + detailButton->setFixedSize(QSize(20, 20)); + deleteButton->setText("×"); + deleteButton->setFixedSize(QSize(20, 20)); + connect(detailButton, &QPushButton::clicked, [styleList, item, this]() { + QDialog dlg(this); + dlg.setWindowTitle("样式详情"); + dlg.resize(400, 200); + auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel, &dlg); + connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept); + connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject); + bool updateStyle = dlg.exec(); + if (updateStyle) { + // 在此处修改新样式信息至内存 + } + }); + connect(deleteButton, &QPushButton::clicked, [styleList,item,this]() { styleList->removeItemWidget(item); delete item; - // delete data in layer + // 删除layer对应样式 emit requireRefreshPreview(); }); layout->addWidget(name); - layout->addWidget(pushButton); + layout->addWidget(detailButton); + layout->addWidget(deleteButton); w->setLayout(layout); styleList->addItem(item); styleList->setItemWidget(item, w); From ff848b1443ef0d740973ac2232793bac4836eb0f Mon Sep 17 00:00:00 2001 From: wuyize Date: Mon, 20 Feb 2023 22:26:29 +0800 Subject: [PATCH 2/2] =?UTF-8?q?qDebug=E7=AD=89=E8=BE=93=E5=87=BA=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=9D=A5=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Renderer/Preview/ElementRenderer.cpp | 16 ++--- ArchitectureColoredPainting/src/main.cpp | 59 +++++++++++++++---- 2 files changed, 54 insertions(+), 21 deletions(-) diff --git a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp index 4405bd7..d8a7a92 100644 --- a/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp +++ b/ArchitectureColoredPainting/src/Renderer/Preview/ElementRenderer.cpp @@ -37,15 +37,15 @@ std::vector generatePathBuffer(const QPainterPath& path) switch (element.type) { case QPainterPath::MoveToElement: - qDebug() << "MoveToElement"; - qDebug() << element; + //qDebug() << "MoveToElement"; + //qDebug() << element; pathBuffer.push_back(glm::vec2(std::numeric_limits::infinity())); pathBuffer.push_back(glm::vec2(element.x, element.y)); break; case QPainterPath::LineToElement: { - qDebug() << "LineToElement"; - qDebug() << element; + //qDebug() << "LineToElement"; + //qDebug() << element; glm::vec2 end = glm::vec2(element.x, element.y); glm::vec2 mid = (pathBuffer.back() + end) / 2.f; pathBuffer.push_back(mid); @@ -55,14 +55,14 @@ std::vector generatePathBuffer(const QPainterPath& path) } case QPainterPath::CurveToElement: { - qDebug() << "CurveToElement"; - qDebug() << element; + //qDebug() << "CurveToElement"; + //qDebug() << element; glm::vec2 p1 = glm::vec2(element.x, element.y); element = path.elementAt(++i); - qDebug() << element; + //qDebug() << element; glm::vec2 p2 = glm::vec2(element.x, element.y); element = path.elementAt(++i); - qDebug() << element; + //qDebug() << element; glm::vec2 p3 = glm::vec2(element.x, element.y); if (p3 != pathBuffer.back()) { diff --git a/ArchitectureColoredPainting/src/main.cpp b/ArchitectureColoredPainting/src/main.cpp index ec0d673..0d8791b 100644 --- a/ArchitectureColoredPainting/src/main.cpp +++ b/ArchitectureColoredPainting/src/main.cpp @@ -2,26 +2,59 @@ #include #include #include +#include +#include +#include "consoleapi2.h" extern "C" { - _declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; + _declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; } 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[]) { - //FramelessHelper::Widgets::initialize(); - FramelessHelper::Core::initialize(); - //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); - QApplication a(argc, argv); - //FramelessHelper::Core::setApplicationOSThemeAware(); - FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); - FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); - FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); - MainWindow w; - w.show(); - return a.exec(); + qInstallMessageHandler(messageHandler); + //FramelessHelper::Widgets::initialize(); + FramelessHelper::Core::initialize(); + //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); + QApplication a(argc, argv); + //FramelessHelper::Core::setApplicationOSThemeAware(); + FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); + FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); + FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); + MainWindow w; + w.show(); + return a.exec(); }