mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-30 14:54:13 +02:00
a28e834185
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>
88 lines
2.4 KiB
C++
88 lines
2.4 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 "replaceelementdialog.h"
|
|
|
|
#include "../../qetapp.h"
|
|
#include "../../qetinformation.h"
|
|
#include "../../ui/elementinfopartwidget.h"
|
|
#include "../searchandreplaceworker.h"
|
|
#include "replaceelementdialog.h"
|
|
#include "ui_replaceelementdialog.h"
|
|
|
|
#include "../../qet.h"
|
|
#include <QAbstractButton>
|
|
|
|
ReplaceElementDialog::ReplaceElementDialog(DiagramContext context, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::ReplaceElementDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
QET::trackDialogGeometry(this);
|
|
buildWidget();
|
|
setContext(context);
|
|
}
|
|
|
|
ReplaceElementDialog::~ReplaceElementDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
/**
|
|
@brief ReplaceElementDialog::setContext
|
|
Set the current diagram context to be edited
|
|
@param context
|
|
*/
|
|
void ReplaceElementDialog::setContext(DiagramContext context)
|
|
{
|
|
m_context = context;
|
|
|
|
for (ElementInfoPartWidget *eipw : m_eipw_list) {
|
|
eipw->setText(m_context[eipw->key()].toString());
|
|
}
|
|
}
|
|
|
|
/**
|
|
@brief ReplaceElementDialog::context
|
|
@return The edited diagram context
|
|
*/
|
|
DiagramContext ReplaceElementDialog::context() const
|
|
{
|
|
DiagramContext context;
|
|
for (ElementInfoPartWidget *eipw : m_eipw_list) {
|
|
context.addValue(eipw->key(), eipw->text());
|
|
}
|
|
|
|
return context;
|
|
}
|
|
|
|
void ReplaceElementDialog::buildWidget()
|
|
{
|
|
connect(ui->m_button_box, &QDialogButtonBox::clicked, [this](QAbstractButton *button_) {
|
|
this->done(ui->m_button_box->buttonRole(button_));
|
|
});
|
|
|
|
for (QString str : QETInformation::elementInfoKeys())
|
|
{
|
|
ElementInfoPartWidget *eipw = new ElementInfoPartWidget(str, QETInformation::translatedInfoKey(str), this);
|
|
eipw->setEraseTextVisible(true);
|
|
eipw->setPlaceHolderText(tr("Ne pas modifier"));
|
|
ui->m_scroll_layout->addWidget(eipw);
|
|
m_eipw_list << eipw;
|
|
}
|
|
}
|