Skip to content

Commit

Permalink
A new approach to make the EditDialog appear centered over the main w…
Browse files Browse the repository at this point in the history
…indow.

See issue sqlitebrowser#633 for details.
  • Loading branch information
DelphiGit committed Jul 9, 2016
1 parent 3b3d4b4 commit b72bcd7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/EditDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit b72bcd7

Please sign in to comment.