fix Qt 5 build (force C++17), increase JsonEditorDialog height

This commit is contained in:
Syping 2023-03-29 21:10:33 +02:00
parent 7720fb2cac
commit 489bf531b8
2 changed files with 3 additions and 12 deletions

View file

@ -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")

View file

@ -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("<h4>Unsaved changes detected</h4>You want to save the JSON content before you quit?"), QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Cancel);
if (button == QMessageBox::Yes) {