Address review feedback: double spinboxes, tabs, and fix export bug

This commit is contained in:
Kellermorph
2026-06-18 13:37:24 +02:00
parent 7a80ce40b7
commit 0555cd9045
7 changed files with 94 additions and 81 deletions
+3
View File
@@ -116,9 +116,12 @@ void renderDiagram(Diagram *diagram, QPainter &painter, const QRectF &target)
// draw_grid_ is set (default true), so toggle it off around the render // draw_grid_ is set (default true), so toggle it off around the render
// and restore it afterwards. // and restore it afterwards.
const bool was_drawing_grid = diagram->displayGrid(); const bool was_drawing_grid = diagram->displayGrid();
const bool was_drawing_guides = diagram->displayGuides();
diagram->setDisplayGrid(false); diagram->setDisplayGrid(false);
diagram->setDisplayGuides(false);
diagram->render(&painter, target, source, Qt::KeepAspectRatio); diagram->render(&painter, target, source, Qt::KeepAspectRatio);
diagram->setDisplayGrid(was_drawing_grid); diagram->setDisplayGrid(was_drawing_grid);
diagram->setDisplayGuides(was_drawing_guides);
} }
int exportPdf(QETProject &project, const QString &output) int exportPdf(QETProject &project, const QString &output)
+2
View File
@@ -2315,6 +2315,7 @@ ExportProperties Diagram::applyProperties(
// exporte les options de rendu en cours // exporte les options de rendu en cours
ExportProperties old_properties; ExportProperties old_properties;
old_properties.draw_grid = displayGrid(); old_properties.draw_grid = displayGrid();
old_properties.draw_guides = displayGuides();
old_properties.draw_border = border_and_titleblock.borderIsDisplayed(); old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed(); old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
old_properties.draw_terminals = drawTerminals(); old_properties.draw_terminals = drawTerminals();
@@ -2328,6 +2329,7 @@ ExportProperties Diagram::applyProperties(
setDrawTerminals (new_properties.draw_terminals); setDrawTerminals (new_properties.draw_terminals);
setDrawColoredConductors (new_properties.draw_colored_conductors); setDrawColoredConductors (new_properties.draw_colored_conductors);
setDisplayGrid (new_properties.draw_grid); setDisplayGrid (new_properties.draw_grid);
setDisplayGuides (new_properties.draw_guides);
border_and_titleblock.displayBorder(new_properties.draw_border); border_and_titleblock.displayBorder(new_properties.draw_border);
border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock); border_and_titleblock.displayTitleBlock (new_properties.draw_titleblock);
+5
View File
@@ -30,6 +30,7 @@ ExportProperties::ExportProperties() :
destination_directory(QETApp::documentDir()), destination_directory(QETApp::documentDir()),
format("PNG"), format("PNG"),
draw_grid(false), draw_grid(false),
draw_guides(false),
draw_border(true), draw_border(true),
draw_titleblock(true), draw_titleblock(true),
draw_terminals(false), draw_terminals(false),
@@ -61,6 +62,8 @@ void ExportProperties::toSettings(QSettings &settings,
format); format);
settings.setValue(prefix % "drawgrid", settings.setValue(prefix % "drawgrid",
draw_grid); draw_grid);
settings.setValue(prefix % "drawguides",
draw_guides);
settings.setValue(prefix % "drawborder", settings.setValue(prefix % "drawborder",
draw_border); draw_border);
settings.setValue(prefix % "drawtitleblock", settings.setValue(prefix % "drawtitleblock",
@@ -94,6 +97,8 @@ void ExportProperties::fromSettings(QSettings &settings,
draw_grid = settings.value(prefix % "drawgrid", draw_grid = settings.value(prefix % "drawgrid",
false).toBool(); false).toBool();
draw_guides = settings.value(prefix % "drawguides",
false).toBool();
draw_border = settings.value(prefix % "drawborder", draw_border = settings.value(prefix % "drawborder",
true ).toBool(); true ).toBool();
draw_titleblock = settings.value(prefix % "drawtitleblock", draw_titleblock = settings.value(prefix % "drawtitleblock",
+1
View File
@@ -43,6 +43,7 @@ class ExportProperties {
QDir destination_directory; ///< Target directory for generated files QDir destination_directory; ///< Target directory for generated files
QString format; ///< Image format of generated files QString format; ///< Image format of generated files
bool draw_grid; ///< Whether to render the diagram grid bool draw_grid; ///< Whether to render the diagram grid
bool draw_guides; ///< Whether to render the diagram guides
bool draw_border; ///< Whether to render the border (along with rows/columns headers) bool draw_border; ///< Whether to render the border (along with rows/columns headers)
bool draw_titleblock; ///< Whether to render the title block bool draw_titleblock; ///< Whether to render the title block
bool draw_terminals; ///< Whether to render terminals bool draw_terminals; ///< Whether to render terminals
+1
View File
@@ -519,6 +519,7 @@ ExportProperties ProjectPrintWindow::exportProperties() const
exp.draw_terminals = ui->m_draw_terminal_cb->isChecked(); exp.draw_terminals = ui->m_draw_terminal_cb->isChecked();
exp.draw_colored_conductors = ui->m_keep_conductor_color_cb->isChecked(); exp.draw_colored_conductors = ui->m_keep_conductor_color_cb->isChecked();
exp.draw_grid = false; exp.draw_grid = false;
exp.draw_guides = false;
return exp; return exp;
} }
@@ -5,7 +5,7 @@
#include <QTableWidget> #include <QTableWidget>
#include <QHeaderView> #include <QHeaderView>
#include <QComboBox> #include <QComboBox>
#include <QSpinBox> #include <QDoubleSpinBox>
#include <QColorDialog> #include <QColorDialog>
GuidesPropertiesWidget::GuidesPropertiesWidget(QWidget *parent) GuidesPropertiesWidget::GuidesPropertiesWidget(QWidget *parent)
@@ -43,7 +43,7 @@ QList<Diagram::Guide> GuidesPropertiesWidget::guides() const {
QList<Diagram::Guide> list; QList<Diagram::Guide> list;
for (int row = 0; row < m_table->rowCount(); ++row) { for (int row = 0; row < m_table->rowCount(); ++row) {
QComboBox *combo = qobject_cast<QComboBox*>(m_table->cellWidget(row, 0)); QComboBox *combo = qobject_cast<QComboBox*>(m_table->cellWidget(row, 0));
QSpinBox *spin = qobject_cast<QSpinBox*>(m_table->cellWidget(row, 1)); QDoubleSpinBox *spin = qobject_cast<QDoubleSpinBox*>(m_table->cellWidget(row, 1));
QPushButton *colorBtn = qobject_cast<QPushButton*>(m_table->cellWidget(row, 2)); QPushButton *colorBtn = qobject_cast<QPushButton*>(m_table->cellWidget(row, 2));
if (combo && spin && colorBtn) { if (combo && spin && colorBtn) {
@@ -64,12 +64,12 @@ void GuidesPropertiesWidget::setGuides(const QList<Diagram::Guide> &guides) {
int row = m_table->rowCount() - 1; int row = m_table->rowCount() - 1;
QComboBox *combo = qobject_cast<QComboBox*>(m_table->cellWidget(row, 0)); QComboBox *combo = qobject_cast<QComboBox*>(m_table->cellWidget(row, 0));
QSpinBox *spin = qobject_cast<QSpinBox*>(m_table->cellWidget(row, 1)); QDoubleSpinBox *spin = qobject_cast<QDoubleSpinBox*>(m_table->cellWidget(row, 1));
QPushButton *colorBtn = qobject_cast<QPushButton*>(m_table->cellWidget(row, 2)); QPushButton *colorBtn = qobject_cast<QPushButton*>(m_table->cellWidget(row, 2));
if (combo && spin && colorBtn) { if (combo && spin && colorBtn) {
combo->setCurrentIndex(g.orientation == Diagram::Guide::Horizontal ? 0 : 1); combo->setCurrentIndex(g.orientation == Diagram::Guide::Horizontal ? 0 : 1);
spin->setValue(qRound(g.position)); spin->setValue(g.position);
colorBtn->setProperty("color", g.color); colorBtn->setProperty("color", g.color);
colorBtn->setStyleSheet(QString("background-color: %1; color: white; font-weight: bold;").arg(g.color.name())); colorBtn->setStyleSheet(QString("background-color: %1; color: white; font-weight: bold;").arg(g.color.name()));
} }
@@ -84,9 +84,10 @@ void GuidesPropertiesWidget::addGuide() {
combo->addItems({tr("Horizontal"), tr("Vertical")}); combo->addItems({tr("Horizontal"), tr("Vertical")});
m_table->setCellWidget(row, 0, combo); m_table->setCellWidget(row, 0, combo);
QSpinBox *spin = new QSpinBox(this); QDoubleSpinBox *spin = new QDoubleSpinBox(this);
spin->setRange(-10000, 10000); spin->setRange(-10000.0, 10000.0);
spin->setValue(100); spin->setDecimals(2);
spin->setValue(100.0);
m_table->setCellWidget(row, 1, spin); m_table->setCellWidget(row, 1, spin);
QPushButton *colorBtn = new QPushButton(tr("Couleur"), this); QPushButton *colorBtn = new QPushButton(tr("Couleur"), this);