From 489bf531b8f3a36a379d2f74f51a523b4a539185 Mon Sep 17 00:00:00 2001 From: Syping Date: Wed, 29 Mar 2023 21:10:33 +0200 Subject: [PATCH] fix Qt 5 build (force C++17), increase JsonEditorDialog height --- CMakeLists.txt | 2 +- src/JsonEditorDialog.cpp | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d29b3c4..5d9651a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17 CACHE STRING "gta5view C++ standard") set(CMAKE_CXX_STANDARD_REQUIRED ON) set(FORCE_QT_VERSION "" CACHE STRING "Force Qt Version") diff --git a/src/JsonEditorDialog.cpp b/src/JsonEditorDialog.cpp index 25c8ca0..36d0c92 100644 --- a/src/JsonEditorDialog.cpp +++ b/src/JsonEditorDialog.cpp @@ -66,14 +66,7 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) : jsonCode = picture->getJsonStdStr(); -#if QT_VERSION >= 0x050200 ui->txtJSON->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); -#else - QFont jsonFont = ui->txtJSON->font(); - jsonFont.setStyleHint(QFont::Monospace); - jsonFont.setFixedPitch(true); - ui->txtJSON->setFont(jsonFont); -#endif QFontMetrics fontMetrics(ui->txtJSON->font()); #if QT_VERSION >= 0x050B00 ui->txtJSON->setTabStopDistance(fontMetrics.horizontalAdvance(" ")); @@ -82,7 +75,7 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) : #endif const boost::json::value jsonValue = boost::json::parse(jsonCode); - ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color: rgb(46, 47, 48); color: rgb(238, 231, 172);}"); + ui->txtJSON->setStyleSheet("QPlainTextEdit{background-color:rgb(46,47,48);color:rgb(238,231,172);}"); ui->txtJSON->setPlainText(QString::fromUtf8(SnapmaticJson::serialize(jsonValue, true).c_str())); jsonHl = new JSHighlighter(ui->txtJSON->document()); @@ -102,7 +95,7 @@ JsonEditorDialog::JsonEditorDialog(SnapmaticPicture *picture, QWidget *parent) : ui->lineJSON->setMaximumHeight(qRound(1 * screenRatio)); ui->lineJSON->setLineWidth(qRound(1 * screenRatio)); } - resize(450 * screenRatio, 550 * screenRatio); + resize(450 * screenRatio, 560 * screenRatio); } JsonEditorDialog::~JsonEditorDialog() @@ -119,8 +112,6 @@ void JsonEditorDialog::closeEvent(QCloseEvent *ev) const boost::json::value jsonOriginal = boost::json::parse(jsonCode, ec); const std::string newCode = SnapmaticJson::serialize(jsonNew); const std::string originalCode = SnapmaticJson::serialize(jsonOriginal); - qDebug() << newCode.c_str(); - qDebug() << originalCode.c_str(); if (newCode != originalCode) { QMessageBox::StandardButton button = QMessageBox::warning(this, SnapmaticEditor::tr("Snapmatic Properties"), SnapmaticEditor::tr("

Unsaved changes detected

You want to save the JSON content before you quit?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel); if (button == QMessageBox::Yes) {