Files
qelectrotech-source-mirror/sources/ui/conductorpropertiesdialog.cpp
T
ispyisail a28e834185 Remember dialog size and position across sessions
QETElementEditor, QETDiagramEditor and QETTemplateEditor already
persist their geometry via QSettings; none of the modal QDialog
subclasses did, so any dialog resized to see more of its content
(Search and Replace, Diagram properties, Export, ...) is back to its
default size the next time it's opened.

Adds QET::trackDialogGeometry(), one call at the end of each dialog
constructor (after any default resize()), following the same
restoreGeometry()/saveGeometry() pattern as the three editors above,
stored under [dialoggeometry] and keyed by class name by default. An
explicit key is used for PropertiesEditorDialog, a single class
templated over several unrelated wrapped editors, so they don't all
fight over one saved size.

Covers the 36 dialogs of the original change (#691) plus seven added
since: RenumberElementsDialog, MaterialEntryDialog, AiAssistantDialog,
DuplicateOffsetDialog, ImageTransparentColorDialog, PdfPagesDialog and
WiringListDialog.

Deliberately not touched: BackupDialog and ImageCropDialog, which
setFixedSize() themselves, and MaterialSelectionDialog, which already
restores its own size.

A size saved while the dialog sat partly off-screen is restored on
screen: restoreGeometry() moves it back inside the available screen
(checked: saved at 1502,972 on a 1600x1000 screen, reopened at 600,317).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 10:31:12 +13:00

113 lines
3.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 "conductorpropertiesdialog.h"
#include "../QPropertyUndoCommand/qpropertyundocommand.h"
#include "../diagram.h"
#include "../qetgraphicsitem/conductor.h"
#include "conductorpropertieswidget.h"
#include "ui_conductorpropertiesdialog.h"
#include "../qet.h"
/**
@brief ConductorPropertiesDialog::ConductorPropertiesDialog
Constructor
@param conductor : conductor to edit properties
@param parent : parent widget
*/
ConductorPropertiesDialog::ConductorPropertiesDialog(
Conductor *conductor, QWidget *parent) :
QDialog(parent),
ui(new Ui::ConductorPropertiesDialog)
{
ui->setupUi(this);
QET::trackDialogGeometry(this);
m_cpw = new ConductorPropertiesWidget(conductor->properties());
m_cpw -> setHiddenOneTextPerFolio(true);
m_cpw->setHiddenAvailableAutonum(true);
if (conductor -> diagram() -> defaultConductorProperties.m_one_text_per_folio == true &&
conductor -> relatedPotentialConductors().size()) {
m_cpw->setDisabledShowText();
}
ui -> main_layout -> insertWidget(0, m_cpw);
}
/**
@brief ConductorPropertiesDialog::~ConductorPropertiesDialog
*/
ConductorPropertiesDialog::~ConductorPropertiesDialog()
{
delete ui;
}
/**
@brief ConductorPropertiesDialog::PropertiesDialog
Static method for open and apply properties.
@param conductor : conductor to edit properties
@param parent : parent widget
*/
void ConductorPropertiesDialog::PropertiesDialog(Conductor *conductor,
QWidget *parent)
{
ConductorPropertiesDialog cpd (conductor, parent);
if (cpd.exec() == QDialog::Rejected
|| cpd.properties() == conductor->properties()) return;
QVariant old_value, new_value;
old_value.setValue(conductor->properties());
new_value.setValue(cpd.properties());
QPropertyUndoCommand *undo = new QPropertyUndoCommand(conductor, "properties", old_value, new_value);
undo->setText(tr("Modifier les propriétés d'un conducteur", "undo caption"));
if (!conductor->relatedPotentialConductors().isEmpty() && cpd.applyAll())
{
undo->setText(tr("Modifier les propriétés de plusieurs conducteurs", "undo caption"));
foreach (Conductor *potential_conductor, conductor->relatedPotentialConductors())
{
old_value.setValue(potential_conductor->properties());
new QPropertyUndoCommand (potential_conductor, "properties", old_value, new_value, undo);
}
}
conductor->diagram()->undoStack().push(undo);
}
/**
@brief ConductorPropertiesDialog::properties
@return the edited properties
*/
ConductorProperties ConductorPropertiesDialog::properties() const
{
return m_cpw -> properties();
}
/**
@brief ConductorPropertiesDialog::applyAll
@return
true -> must apply properties to all conductors at the same potential
false -> must apply properties only for the edited conductor
*/
bool ConductorPropertiesDialog::applyAll() const
{
return ui -> m_apply_all_cb -> isChecked();
}