Skip to content

Commit

Permalink
Move window to current screen if needed
Browse files Browse the repository at this point in the history
Fixes #616
  • Loading branch information
hluk committed Jan 6, 2017
1 parent aeb5cb0 commit b1ff012
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,17 @@ void restoreWindowGeometry(QWidget *w, bool openOnCurrentScreen)
QByteArray geometry = geometryOptionValue(optionName + tag).toByteArray();

// If geometry for screen resolution doesn't exist, use last saved one.
if (geometry.isEmpty())
if (geometry.isEmpty()) {
geometry = geometryOptionValue(optionName).toByteArray();

// If geometry for the screen doesn't exist, move window to the middle of the screen.
if (geometry.isEmpty()) {
const QRect availableGeometry = QApplication::desktop()->availableGeometry(QCursor::pos());
w->move( availableGeometry.center() - w->rect().center() );
geometry = w->saveGeometry();
}
}

if (w->saveGeometry() != geometry) {
w->restoreGeometry(geometry);

Expand Down

0 comments on commit b1ff012

Please sign in to comment.