new Checkbox

This commit is contained in:
Kellermorph
2026-08-06 21:37:40 +02:00
parent 979df376d1
commit b3a4a41ad9
10 changed files with 64 additions and 6 deletions
+17
View File
@@ -67,6 +67,7 @@ Diagram::Diagram(QETProject *project) :
m_project (project),
use_border_ (true),
draw_terminals_ (true),
draw_terminal_names_ (true),
draw_colored_conductors_ (true),
m_event_interface (nullptr),
m_freeze_new_elements (false),
@@ -2319,6 +2320,7 @@ ExportProperties Diagram::applyProperties(
old_properties.draw_border = border_and_titleblock.borderIsDisplayed();
old_properties.draw_titleblock = border_and_titleblock.titleBlockIsDisplayed();
old_properties.draw_terminals = drawTerminals();
old_properties.draw_terminal_names = drawTerminalNames();
old_properties.draw_colored_conductors = drawColoredConductors();
old_properties.exported_area = useBorder() ? QET::BorderArea
: QET::ElementsArea;
@@ -2327,6 +2329,7 @@ ExportProperties Diagram::applyProperties(
// applique les nouvelles options de rendu
setUseBorder (new_properties.exported_area == QET::BorderArea);
setDrawTerminals (new_properties.draw_terminals);
setDrawTerminalNames (new_properties.draw_terminal_names);
setDrawColoredConductors (new_properties.draw_colored_conductors);
setDisplayGrid (new_properties.draw_grid);
setDisplayGuides (new_properties.draw_guides);
@@ -2405,6 +2408,20 @@ void Diagram::setDrawTerminals(bool dt) {
}
}
/**
@brief Diagram::setDrawTerminalNames
Defines whether or not to display the terminal names/labels
@param dt : true to display the terminal names, false otherwise
*/
void Diagram::setDrawTerminalNames(bool dt) {
draw_terminal_names_ = dt;
foreach(QGraphicsItem *qgi, items()) {
if (Terminal *t = qgraphicsitem_cast<Terminal *>(qgi)) {
t -> update();
}
}
}
/**
@brief Diagram::setDrawColoredConductors
Defines whether or not to respect the colors of the conductors.
+14 -2
View File
@@ -126,8 +126,9 @@ class Diagram : public QGraphicsScene
bool use_border_;
bool draw_guides_;
QList<Diagram::Guide> m_guides_list;
bool draw_terminals_;
bool draw_colored_conductors_;
bool draw_terminals_;
bool draw_terminal_names_;
bool draw_colored_conductors_;
QString m_conductors_autonum_name;
DiagramEventInterface *m_event_interface;
@@ -226,6 +227,8 @@ class Diagram : public QGraphicsScene
bool drawTerminals() const;
void setDrawTerminals(bool);
bool drawTerminalNames() const;
void setDrawTerminalNames(bool);
bool drawColoredConductors() const;
void setDrawColoredConductors(bool);
@@ -426,6 +429,15 @@ inline bool Diagram::drawTerminals() const
return(draw_terminals_);
}
/**
@brief Diagram::drawTerminalNames
@return true if terminal names are rendered, false otherwise
*/
inline bool Diagram::drawTerminalNames() const
{
return(draw_terminal_names_);
}
/**
@brief Diagram::drawColoredConductors
@return true if conductors colors are rendered, false otherwise.
+5
View File
@@ -34,6 +34,7 @@ ExportProperties::ExportProperties() :
draw_border(true),
draw_titleblock(true),
draw_terminals(false),
draw_terminal_names(true),
draw_bg_transparent(false),
draw_colored_conductors(true),
exported_area(QET::BorderArea)
@@ -70,6 +71,8 @@ void ExportProperties::toSettings(QSettings &settings,
draw_titleblock);
settings.setValue(prefix % "drawterminals",
draw_terminals);
settings.setValue(prefix % "drawterminalnames",
draw_terminal_names);
settings.setValue(prefix % "drawbgtransparent",
draw_bg_transparent);
settings.setValue(prefix % "drawcoloredconductors",
@@ -105,6 +108,8 @@ void ExportProperties::fromSettings(QSettings &settings,
true ).toBool();
draw_terminals = settings.value(prefix % "drawterminals",
false).toBool();
draw_terminal_names = settings.value(prefix % "drawterminalnames",
true).toBool();
draw_bg_transparent = settings.value(prefix % "drawbgtransparent",
false).toBool();
draw_colored_conductors = settings.value(
+1
View File
@@ -47,6 +47,7 @@ class ExportProperties {
bool draw_border; ///< Whether to render the border (along with rows/columns headers)
bool draw_titleblock; ///< Whether to render the title block
bool draw_terminals; ///< Whether to render terminals
bool draw_terminal_names; ///< Whether to render terminal names/labels
bool draw_bg_transparent; ///< Whether to use transparency for SVG-Export
bool draw_colored_conductors; ///< Whether to render conductors colors
QET::DiagramArea exported_area; ///< Area of diagrams to be rendered
+9 -2
View File
@@ -63,6 +63,7 @@ ExportProperties ExportPropertiesWidget::exportProperties() const
export_properties.draw_border = draw_border -> isChecked();
export_properties.draw_titleblock = draw_titleblock -> isChecked();
export_properties.draw_terminals = draw_terminals -> isChecked();
export_properties.draw_terminal_names = draw_terminal_names -> isChecked();
export_properties.draw_bg_transparent = draw_bg_transparent -> isChecked();
export_properties.draw_colored_conductors = draw_colored_conductors -> isChecked();
export_properties.exported_area = export_border -> isChecked() ? QET::BorderArea : QET::ElementsArea;
@@ -85,6 +86,7 @@ void ExportPropertiesWidget::setExportProperties(const ExportProperties &export_
draw_border -> setChecked(export_properties.draw_border);
draw_titleblock -> setChecked(export_properties.draw_titleblock);
draw_terminals -> setChecked(export_properties.draw_terminals);
draw_terminal_names -> setChecked(export_properties.draw_terminal_names);
draw_bg_transparent -> setChecked(export_properties.draw_bg_transparent);
draw_colored_conductors -> setChecked(export_properties.draw_colored_conductors);
@@ -206,13 +208,17 @@ void ExportPropertiesWidget::build()
draw_terminals = new QCheckBox(tr("Dessiner les bornes"), groupbox_options);
optionshlayout -> addWidget(draw_terminals, 2, 1);
// dessiner les noms des bornes
draw_terminal_names = new QCheckBox(tr("Dessiner les noms des bornes"), groupbox_options);
optionshlayout -> addWidget(draw_terminal_names, 3, 0);
// conserver les couleurs des conducteurs
draw_colored_conductors = new QCheckBox(tr("Conserver les couleurs des conducteurs"), groupbox_options);
optionshlayout -> addWidget(draw_colored_conductors, 3, 0);
optionshlayout -> addWidget(draw_colored_conductors, 3, 1);
// use transparent background for SVG-Export
draw_bg_transparent = new QCheckBox(tr("SVG: fond transparent"), groupbox_options);
optionshlayout -> addWidget(draw_bg_transparent, 3, 1);
optionshlayout -> addWidget(draw_bg_transparent, 4, 0);
vboxLayout -> addWidget(groupbox_options);
@@ -239,6 +245,7 @@ void ExportPropertiesWidget::build()
connect(draw_border, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
connect(draw_titleblock, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
connect(draw_terminals, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
connect(draw_terminal_names, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
connect(draw_bg_transparent, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
connect(draw_colored_conductors, SIGNAL(stateChanged(int)), this, SIGNAL(optionChanged()));
}
+1
View File
@@ -62,6 +62,7 @@ class ExportPropertiesWidget : public QWidget {
QCheckBox *draw_border;
QCheckBox *draw_titleblock;
QCheckBox *draw_terminals;
QCheckBox *draw_terminal_names;
QCheckBox *draw_bg_transparent;
QCheckBox *draw_colored_conductors;
QRadioButton *export_border;
+3
View File
@@ -161,6 +161,7 @@ ProjectPrintWindow::ProjectPrintWindow(QETProject *project, QPrinter *printer, Q
ui->m_draw_border_cb->setChecked(exp.draw_border);
ui->m_draw_titleblock_cb->setChecked(exp.draw_titleblock);
ui->m_draw_terminal_cb->setChecked(exp.draw_terminals);
ui->m_draw_terminal_names_cb->setChecked(exp.draw_terminal_names);
ui->m_keep_conductor_color_cb->setChecked(exp.draw_colored_conductors);
ui->m_date_cb->blockSignals(true);
@@ -523,6 +524,7 @@ ExportProperties ProjectPrintWindow::exportProperties() const
exp.draw_border = ui->m_draw_border_cb->isChecked();
exp.draw_titleblock = ui->m_draw_titleblock_cb->isChecked();
exp.draw_terminals = ui->m_draw_terminal_cb->isChecked();
exp.draw_terminal_names = ui->m_draw_terminal_names_cb->isChecked();
exp.draw_colored_conductors = ui->m_keep_conductor_color_cb->isChecked();
exp.draw_grid = false;
exp.draw_guides = false;
@@ -796,6 +798,7 @@ void ProjectPrintWindow::on_m_draw_border_cb_clicked() { m_preview->upd
void ProjectPrintWindow::on_m_draw_titleblock_cb_clicked() { m_preview->updatePreview(); }
void ProjectPrintWindow::on_m_keep_conductor_color_cb_clicked() { m_preview->updatePreview(); }
void ProjectPrintWindow::on_m_draw_terminal_cb_clicked() { m_preview->updatePreview(); }
void ProjectPrintWindow::on_m_draw_terminal_names_cb_clicked() { m_preview->updatePreview(); }
void ProjectPrintWindow::on_m_fit_in_page_cb_clicked() { m_preview->updatePreview(); }
void ProjectPrintWindow::on_m_use_full_page_cb_clicked()
{
+1
View File
@@ -55,6 +55,7 @@ class ProjectPrintWindow : public QMainWindow
void on_m_draw_titleblock_cb_clicked();
void on_m_keep_conductor_color_cb_clicked();
void on_m_draw_terminal_cb_clicked();
void on_m_draw_terminal_names_cb_clicked();
void on_m_fit_in_page_cb_clicked();
void on_m_use_full_page_cb_clicked();
void on_m_zoom_out_action_triggered();
+10
View File
@@ -183,6 +183,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_draw_terminal_names_cb">
<property name="text">
<string>Dessiner les noms des bornes</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
+3 -2
View File
@@ -275,9 +275,10 @@ void Terminal::paint(
m_help_line_a -> setLine(line);
}
// Draw label if show_name is enabled
// Draw label if show_name is enabled and terminal names are allowed
const QString display_name = name();
if (d->m_show_name && !display_name.isEmpty()) {
if (d->m_show_name && !display_name.isEmpty()
&& (!diagram() || diagram()->drawTerminalNames())) {
painter->setRenderHint(QPainter::Antialiasing, true);
painter->setRenderHint(QPainter::TextAntialiasing, true);
painter->setFont(d->m_label_font);