From 33570ffceb0173ae4d2a82cabbfa5496e4514520 Mon Sep 17 00:00:00 2001 From: plc-user <74435298+plc-user@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:58:32 +0100 Subject: [PATCH 1/2] export: set maximum width / height according specifications of export-type --- sources/exportdialog.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index 552c24045..8946cb153 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -868,7 +868,25 @@ void ExportDialog::slot_changeFilesExtension(bool force_extension) { // recupere le format a utiliser (acronyme et extension) QString format_acronym = epw -> exportProperties().format; QString format_extension = "." + format_acronym.toLower(); - + + // set maximum width / height according specifications of export-type + if (format_extension == ".bmp") { + foreach (auto line, diagram_lines_.values() ) { + line->width ->setRange(1, 32768); + line->height->setRange(1, 32768); + } + } else if (format_extension == ".jpg") { + foreach (auto line, diagram_lines_.values() ) { + line->width ->setRange(1, 65535); + line->height->setRange(1, 65535); + } + } else { + foreach (auto line, diagram_lines_.values() ) { + line->width ->setRange(1, 100000); + line->height->setRange(1, 100000); + } + } + // parcourt les schemas a exporter foreach(ExportDiagramLine *diagram_line, diagram_lines_.values()) { QString diagram_filename = diagram_line -> file_name -> text(); From 924d1c1b05f9f675287cf976f3554c4a6e19f08c Mon Sep 17 00:00:00 2001 From: plc-user <74435298+plc-user@users.noreply.github.com> Date: Thu, 6 Feb 2025 15:16:19 +0100 Subject: [PATCH 2/2] =?UTF-8?q?use=20"static=20const"=20-=20variables=20in?= =?UTF-8?q?stead=20of=20multiple=20times=20values=20in=20source-code=20use?= =?UTF-8?q?=20multiplication-sign=20"=C3=97"=20instead=20of=20asterisk=20"?= =?UTF-8?q?*"=20between=20widht=20and=20height?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/exportdialog.cpp | 18 +++++++++--------- sources/exportdialog.h | 5 +++++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/sources/exportdialog.cpp b/sources/exportdialog.cpp index 8946cb153..9d171ad8a 100644 --- a/sources/exportdialog.cpp +++ b/sources/exportdialog.cpp @@ -872,18 +872,18 @@ void ExportDialog::slot_changeFilesExtension(bool force_extension) { // set maximum width / height according specifications of export-type if (format_extension == ".bmp") { foreach (auto line, diagram_lines_.values() ) { - line->width ->setRange(1, 32768); - line->height->setRange(1, 32768); + line->width ->setRange(1, BMPmaxSize); + line->height->setRange(1, BMPmaxSize); } } else if (format_extension == ".jpg") { foreach (auto line, diagram_lines_.values() ) { - line->width ->setRange(1, 65535); - line->height->setRange(1, 65535); + line->width ->setRange(1, JPGmaxSize); + line->height->setRange(1, JPGmaxSize); } } else { foreach (auto line, diagram_lines_.values() ) { - line->width ->setRange(1, 100000); - line->height->setRange(1, 100000); + line->width ->setRange(1, GeneralMaxSize); + line->height->setRange(1, GeneralMaxSize); } } @@ -1026,16 +1026,16 @@ ExportDialog::ExportDiagramLine::ExportDiagramLine(Diagram *dia, QSize diagram_s file_name -> setMinimumWidth(280); width = new QSpinBox(); - width -> setRange(1, 100000); + width -> setRange(1, GeneralMaxSize); width -> setSuffix(tr("px")); width -> setValue(diagram_size.width()); height = new QSpinBox(); - height -> setRange(1, 100000); + height -> setRange(1, GeneralMaxSize); height -> setSuffix(tr("px")); height -> setValue(diagram_size.height()); - x_label = new QLabel("*"); + x_label = new QLabel("×"); keep_ratio = new QPushButton(); keep_ratio -> setCheckable(true); diff --git a/sources/exportdialog.h b/sources/exportdialog.h index b0b19602a..31bef13f3 100644 --- a/sources/exportdialog.h +++ b/sources/exportdialog.h @@ -79,6 +79,11 @@ class ExportDialog : public QDialog { QSignalMapper *reset_mapper_; QSignalMapper *clipboard_mapper_; + // constants for exporting images: + static const int BMPmaxSize = 32767; + static const int JPGmaxSize = 65535; + static const int GeneralMaxSize = 100000; + // project whose diagrams are to be exported QETProject *project_;