mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
A new approach to make the EditDialog appear centered over the main window.
See issue #633 for details.
This commit is contained in:
@@ -54,12 +54,11 @@ void EditDialog::closeEvent(QCloseEvent*)
|
||||
void EditDialog::showEvent(QShowEvent*)
|
||||
{
|
||||
// Whenever the dialog is shown, position it at the center of the parent dialog
|
||||
QPoint center = mapToGlobal(rect().center());
|
||||
QMainWindow* parentDialog = qobject_cast<QMainWindow*>(parent());
|
||||
if(parentDialog)
|
||||
{
|
||||
QPoint parentCenter = parentDialog->window()->mapToGlobal(parentDialog->window()->rect().center());
|
||||
move(parentCenter - center);
|
||||
move(parentDialog->x() + parentDialog->width() / 2 - width() / 2,
|
||||
parentDialog->y() + parentDialog->height() / 2 - height() / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user