Skip to content

Commit

Permalink
fix fx dialog positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
DSCaskey committed Nov 26, 2024
1 parent ec1a058 commit 410a4bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/libs/vtools/dialogs/support/edit_formula_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ EditFormulaDialog::EditFormulaDialog(const VContainer *data, const quint32 &tool
ui->setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

// Resize the dialog based on last saved size.
const QSize size = qApp->Settings()->GetFormulaWizardDialogSize();
if (!size.isEmpty())
{
// Block signals to prevent a resize event that will only save the size again.
blockSignals(true);
resize(size);
blockSignals(false);
}

// Set the position that the dialog opens based on user preference.
setDialogPosition();

initializeVariables();
initializeFormulaUi(ui);
ui->plainTextEditFormula->installEventFilter(this);
Expand Down Expand Up @@ -462,42 +475,22 @@ void EditFormulaDialog::closeEvent(QCloseEvent *event)
DialogTool::closeEvent(event);
}

//---------------------------------------------------------------------------------------------------------------------
void EditFormulaDialog::showEvent(QShowEvent *event)
{
QDialog::showEvent(event);
if (event->spontaneous())
{
return;
}

if (isInitialized)
{
return;
}
// do your init stuff here

const QSize size = qApp->Settings()->GetFormulaWizardDialogSize();
if (!size.isEmpty())
{
resize(size);
}

// Set the position that the dialog opens based on user preference.
setDialogPosition();

isInitialized = true;//first show windows are held
}

//---------------------------------------------------------------------------------------------------------------------
void EditFormulaDialog::resizeEvent(QResizeEvent *event)
{
// remember the size for the next time this dialog is opened, but only
// if widget was already initialized.
if (isInitialized)
{
qApp->Settings()->SetFormulaWizardDialogSize(size());
}
qApp->Settings()->SetFormulaWizardDialogSize(size());

DialogTool::resizeEvent(event);
}

Expand Down
3 changes: 3 additions & 0 deletions src/libs/vtools/dialogs/support/edit_formula_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
<iconset resource="../../../vmisc/share/resources/icon.qrc">
<normaloff>:/icon/32x32/edit.png</normaloff>:/icon/32x32/edit.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<property name="modal">
<bool>true</bool>
</property>
Expand Down

0 comments on commit 410a4bf

Please sign in to comment.