mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-08 04:44:13 +02:00
2752e6705c
A "Format" choice in the folio dimensions box sets the columns and rows so the whole folio, title block included, has the size of an ISO A sheet at the 96 dpi the PDF export uses. A4 landscape keeps 60 px columns and 80 px rows and comes out as an A4 page in the PDF. Nothing new is stored: the choice only fills in the columns and rows. A folio whose size already matches a paper shows that paper; any other shows "Custom". Changing the title block template after picking a paper fits the folio again; a template too tall for the paper falls back to "Custom". The same box is in Folio properties and in the new-folio defaults of the project and application settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
180 lines
6.5 KiB
C++
180 lines
6.5 KiB
C++
/*
|
|
Copyright 2006-2026 The QElectroTech Team
|
|
This file is part of QElectroTech.
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "diagrampropertiesdialog.h"
|
|
|
|
#include "../diagram.h"
|
|
#include "../diagramcommands.h"
|
|
#include "../qetgraphicsitem/conductor.h"
|
|
#include "../qetgraphicsitem/conductortextitem.h"
|
|
#include "../undocommand/changetitleblockcommand.h"
|
|
#include "borderpropertieswidget.h"
|
|
#include "conductorpropertieswidget.h"
|
|
#include "projectpropertiesdialog.h"
|
|
#include "titleblockpropertieswidget.h"
|
|
|
|
/**
|
|
@brief DiagramPropertiesDialog::DiagramPropertiesDialog
|
|
Default constructor
|
|
@param diagram : diagram to edit properties
|
|
@param parent : parent widget
|
|
*/
|
|
DiagramPropertiesDialog::DiagramPropertiesDialog(Diagram *diagram, QWidget *parent) :
|
|
QDialog (parent),
|
|
m_diagram (diagram)
|
|
{
|
|
bool diagram_is_read_only = diagram -> isReadOnly();
|
|
|
|
// Get some properties of edited diagram
|
|
TitleBlockProperties titleblock = diagram -> border_and_titleblock.exportTitleBlock();
|
|
BorderProperties border = diagram -> border_and_titleblock.exportBorder();
|
|
ConductorProperties conductors = diagram -> defaultConductorProperties;
|
|
|
|
setWindowModality(Qt::WindowModal);
|
|
#ifdef Q_OS_MACOS
|
|
setWindowFlags(Qt::Sheet);
|
|
#endif
|
|
|
|
setWindowTitle(tr("Propriétés du folio", "window title"));
|
|
|
|
//Border widget
|
|
BorderPropertiesWidget *border_infos = new BorderPropertiesWidget(border, this);
|
|
border_infos -> setReadOnly(diagram_is_read_only);
|
|
|
|
//Title block widget
|
|
TitleBlockPropertiesWidget *titleblock_infos;
|
|
|
|
if (QETProject *parent_project = diagram -> project())
|
|
titleblock_infos = new TitleBlockPropertiesWidget(parent_project -> embeddedTitleBlockTemplatesCollection(), titleblock, false, diagram->project(), this);
|
|
else
|
|
titleblock_infos = new TitleBlockPropertiesWidget(titleblock, false, diagram->project(), this);
|
|
|
|
titleblock_infos -> setReadOnly(diagram_is_read_only);
|
|
connect(titleblock_infos, &TitleBlockPropertiesWidget::openAutoNumFolioEditor, this, &DiagramPropertiesDialog::editAutoFolioNum);
|
|
border_infos -> setTitleBlockSize(titleblock_infos -> currentTitleBlockHeight(),
|
|
titleblock_infos -> currentTitleBlockEdge());
|
|
connect(titleblock_infos, &TitleBlockPropertiesWidget::titleBlockSizeChanged,
|
|
border_infos, &BorderPropertiesWidget::setTitleBlockSize);
|
|
//titleblock_infos->setMinimumSize(590,480); //Minimum Size needed for correct display
|
|
|
|
//Conductor widget
|
|
m_cpw = new ConductorPropertiesWidget(conductors, this);
|
|
m_cpw -> setReadOnly(diagram_is_read_only);
|
|
|
|
QComboBox *autonum_combobox = m_cpw->autonumComboBox();
|
|
autonum_combobox->addItems(diagram->project()->conductorAutoNum().keys());
|
|
autonum_combobox->setCurrentIndex(autonum_combobox->findText(diagram->conductorsAutonumName()));
|
|
|
|
connect(m_cpw->editAutonumPushButton(), &QPushButton::clicked, this, &DiagramPropertiesDialog::editAutonum);
|
|
|
|
// Buttons
|
|
QDialogButtonBox boutons(diagram_is_read_only ? QDialogButtonBox::Ok : QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
connect(&boutons, &QDialogButtonBox::accepted, this, &DiagramPropertiesDialog::accept);
|
|
connect(&boutons, &QDialogButtonBox::rejected, this, &DiagramPropertiesDialog::reject);
|
|
|
|
QGridLayout *glayout = new QGridLayout;
|
|
glayout->addWidget(border_infos,0,0);
|
|
glayout->addWidget(titleblock_infos, 1, 0);
|
|
glayout->addWidget(m_cpw, 0, 1, 0, 1);
|
|
|
|
QVBoxLayout vlayout(this);
|
|
vlayout.addLayout(glayout);
|
|
vlayout.addWidget(&boutons);
|
|
|
|
QET::trackDialogGeometry(this);
|
|
|
|
// if dialog is accepted
|
|
if (this -> exec() == QDialog::Accepted && !diagram_is_read_only)
|
|
{
|
|
TitleBlockProperties new_titleblock = titleblock_infos -> properties();
|
|
BorderProperties new_border = border_infos -> properties();
|
|
ConductorProperties new_conductors = m_cpw -> properties();
|
|
|
|
// Title block have change
|
|
if (new_titleblock != titleblock) {
|
|
diagram -> undoStack().push(new ChangeTitleBlockCommand(diagram, titleblock, new_titleblock));
|
|
}
|
|
|
|
// Border have change
|
|
if (new_border != border) {
|
|
diagram -> undoStack().push(new ChangeBorderCommand(diagram, border, new_border));
|
|
}
|
|
|
|
// Conducteur have change
|
|
if (new_conductors != conductors) {
|
|
#if TODO_LIST
|
|
#pragma message("@TODO implement an undo command to allow the user to undo/redo this action")
|
|
#endif
|
|
/// TODO implement an undo command to allow the user to undo/redo this action
|
|
diagram -> defaultConductorProperties = new_conductors;
|
|
|
|
// "One text per potential" changed: show or hide the
|
|
// conductor texts now, not at the next edit or reload.
|
|
if (new_conductors.m_one_text_per_folio != conductors.m_one_text_per_folio)
|
|
{
|
|
const QList<Conductor *> conductor_list = diagram -> conductors();
|
|
for (Conductor *c : conductor_list)
|
|
c -> updateTextVisibility();
|
|
for (Conductor *c : conductor_list)
|
|
c -> calculateTextItemPosition();
|
|
}
|
|
}
|
|
|
|
// Conductor autonum name
|
|
if (autonum_combobox->currentText() != diagram->conductorsAutonumName())
|
|
{
|
|
diagram->setConductorsAutonumName (autonum_combobox->currentText());
|
|
diagram->project()->conductorAutoNumChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
@brief DiagramPropertiesDialog::diagramPropertiesDialog
|
|
Static method to get a DiagramPropertiesDialog.
|
|
@param diagram : diagram to edit properties
|
|
@param parent : parent widget
|
|
*/
|
|
void DiagramPropertiesDialog::diagramPropertiesDialog(Diagram *diagram, QWidget *parent) {
|
|
DiagramPropertiesDialog dialog(diagram, parent);
|
|
}
|
|
|
|
/**
|
|
@brief DiagramPropertiesDialog::editAutonum
|
|
Open conductor autonum editor
|
|
*/
|
|
void DiagramPropertiesDialog::editAutonum()
|
|
{
|
|
ProjectPropertiesDialog ppd (m_diagram->project(), this);
|
|
ppd.setCurrentPage(ProjectPropertiesDialog::Autonum);
|
|
ppd.exec();
|
|
m_cpw->autonumComboBox()->clear();
|
|
m_cpw->autonumComboBox()->addItems(m_diagram->project()->conductorAutoNum().keys());
|
|
}
|
|
|
|
/**
|
|
@brief DiagramPropertiesDialog::editAutonum
|
|
Open folio autonum editor
|
|
*/
|
|
void DiagramPropertiesDialog::editAutoFolioNum ()
|
|
{
|
|
ProjectPropertiesDialog ppd (m_diagram->project(), this);
|
|
ppd.setCurrentPage(ProjectPropertiesDialog::Autonum);
|
|
ppd.changeToFolio();
|
|
ppd.exec();
|
|
}
|