mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-09-30 23:04: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>
97 lines
2.6 KiB
C++
97 lines
2.6 KiB
C++
#include "compositetexteditdialog.h"
|
|
|
|
#include "../qetapp.h"
|
|
#include "../qetgraphicsitem/conductor.h"
|
|
#include "../qetgraphicsitem/dynamicelementtextitem.h"
|
|
#include "../qetgraphicsitem/element.h"
|
|
#include "../qetinformation.h"
|
|
#include "../qet.h"
|
|
#include "ui_compositetexteditdialog.h"
|
|
|
|
#include <utility>
|
|
|
|
CompositeTextEditDialog::CompositeTextEditDialog(DynamicElementTextItem *text, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::CompositeTextEditDialog),
|
|
m_text(text)
|
|
{
|
|
ui->setupUi(this);
|
|
QET::trackDialogGeometry(this);
|
|
m_default_text = m_text->compositeText();
|
|
ui->m_plain_text_edit->setPlainText(m_default_text);
|
|
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
|
|
bool report = false;
|
|
if ((m_text) &&(m_text->parentElement()->linkType()) & (Element::AllReport))
|
|
{
|
|
report = true;
|
|
}
|
|
setUpComboBox(report);
|
|
}
|
|
|
|
CompositeTextEditDialog::CompositeTextEditDialog(QString text, bool report, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::CompositeTextEditDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
QET::trackDialogGeometry(this);
|
|
m_default_text = std::move(text);
|
|
ui->m_plain_text_edit->setPlainText(m_default_text);
|
|
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
|
|
setUpComboBox(report);
|
|
}
|
|
|
|
CompositeTextEditDialog::~CompositeTextEditDialog()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
/**
|
|
@brief CompositeTextEditDialog::plainText
|
|
@return The edited text
|
|
*/
|
|
QString CompositeTextEditDialog::plainText() const
|
|
{
|
|
return ui->m_plain_text_edit->toPlainText();
|
|
}
|
|
|
|
/**
|
|
@brief CompositeTextEditDialog::setUpComboBox
|
|
Add the available element information in the combo box
|
|
*/
|
|
void CompositeTextEditDialog::setUpComboBox(bool is_report)
|
|
{
|
|
QStringList qstrl;
|
|
|
|
if(is_report) //Special treatment for text owned by a folio report
|
|
{
|
|
qstrl = QETInformation::folioReportInfoKeys();
|
|
}
|
|
else
|
|
{
|
|
qstrl = QETInformation::elementInfoKeys();
|
|
qstrl.removeAll("formula");
|
|
}
|
|
|
|
for (int i=0; i<qstrl.size();++i) {
|
|
ui -> m_info_cb -> addItem(QETInformation::translatedInfoKey(qstrl[i]),
|
|
is_report ? QETInformation::folioReportInfoToVar(qstrl[i]) : QETInformation::elementInfoToVar(qstrl[i]));
|
|
}
|
|
}
|
|
|
|
void CompositeTextEditDialog::on_m_info_cb_activated(const QString &arg1)
|
|
{
|
|
Q_UNUSED(arg1)
|
|
ui->m_plain_text_edit->insertPlainText(ui->m_info_cb->currentData().toString());
|
|
}
|
|
|
|
/**
|
|
@brief CompositeTextEditDialog::focusInEvent
|
|
Reimplemented from QWidget::focusInEvent
|
|
@param event
|
|
*/
|
|
void CompositeTextEditDialog::focusInEvent(QFocusEvent *event)
|
|
{
|
|
ui->m_plain_text_edit->setFocus();
|
|
QDialog::focusInEvent(event);
|
|
}
|