use "static const" - variables instead of multiple times values in source-code

use multiplication-sign "×" instead of asterisk "*" between widht and height
This commit is contained in:
plc-user
2025-02-06 15:16:19 +01:00
parent 33570ffceb
commit 924d1c1b05
2 changed files with 14 additions and 9 deletions

View File

@@ -872,18 +872,18 @@ void ExportDialog::slot_changeFilesExtension(bool force_extension) {
// set maximum width / height according specifications of export-type // set maximum width / height according specifications of export-type
if (format_extension == ".bmp") { if (format_extension == ".bmp") {
foreach (auto line, diagram_lines_.values() ) { foreach (auto line, diagram_lines_.values() ) {
line->width ->setRange(1, 32768); line->width ->setRange(1, BMPmaxSize);
line->height->setRange(1, 32768); line->height->setRange(1, BMPmaxSize);
} }
} else if (format_extension == ".jpg") { } else if (format_extension == ".jpg") {
foreach (auto line, diagram_lines_.values() ) { foreach (auto line, diagram_lines_.values() ) {
line->width ->setRange(1, 65535); line->width ->setRange(1, JPGmaxSize);
line->height->setRange(1, 65535); line->height->setRange(1, JPGmaxSize);
} }
} else { } else {
foreach (auto line, diagram_lines_.values() ) { foreach (auto line, diagram_lines_.values() ) {
line->width ->setRange(1, 100000); line->width ->setRange(1, GeneralMaxSize);
line->height->setRange(1, 100000); line->height->setRange(1, GeneralMaxSize);
} }
} }
@@ -1026,16 +1026,16 @@ ExportDialog::ExportDiagramLine::ExportDiagramLine(Diagram *dia, QSize diagram_s
file_name -> setMinimumWidth(280); file_name -> setMinimumWidth(280);
width = new QSpinBox(); width = new QSpinBox();
width -> setRange(1, 100000); width -> setRange(1, GeneralMaxSize);
width -> setSuffix(tr("px")); width -> setSuffix(tr("px"));
width -> setValue(diagram_size.width()); width -> setValue(diagram_size.width());
height = new QSpinBox(); height = new QSpinBox();
height -> setRange(1, 100000); height -> setRange(1, GeneralMaxSize);
height -> setSuffix(tr("px")); height -> setSuffix(tr("px"));
height -> setValue(diagram_size.height()); height -> setValue(diagram_size.height());
x_label = new QLabel("*"); x_label = new QLabel("×");
keep_ratio = new QPushButton(); keep_ratio = new QPushButton();
keep_ratio -> setCheckable(true); keep_ratio -> setCheckable(true);

View File

@@ -79,6 +79,11 @@ class ExportDialog : public QDialog {
QSignalMapper *reset_mapper_; QSignalMapper *reset_mapper_;
QSignalMapper *clipboard_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 // project whose diagrams are to be exported
QETProject *project_; QETProject *project_;