Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fx dialog positioning #1225

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading