UI: Fix window start pos when not inside a monitor

Commit 8932bd39 attempted to fix the starting position when the program
started up inside of a monitor that no longer exists, but it was
incorrectly assumed that it would cause the program to automatically
center its position.  Instead it set its position to {0,0}, which is a
really awkward position.

This fixes that commit and ensures the window starts up centered to the
primary display when its saved starting position is invalid.
master
jp9000 2016-07-04 22:34:56 -07:00
parent ee4febcd06
commit e9087cfdc9
1 changed files with 10 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include <QShowEvent> #include <QShowEvent>
#include <QDesktopServices> #include <QDesktopServices>
#include <QFileDialog> #include <QFileDialog>
#include <QDesktopWidget>
#include <util/dstr.h> #include <util/dstr.h>
#include <util/util.hpp> #include <util/util.hpp>
@ -132,10 +133,15 @@ OBSBasic::OBSBasic(QWidget *parent)
int posy = config_get_int(App()->GlobalConfig(), "BasicWindow", int posy = config_get_int(App()->GlobalConfig(), "BasicWindow",
"posy"); "posy");
if (!WindowPositionValid(posx, posy)) if (!WindowPositionValid(posx, posy)) {
posx = posy = 0; QRect rect = App()->desktop()->availableGeometry();
setGeometry(QStyle::alignedRect(
setGeometry(posx, posy, width, height); Qt::LeftToRight,
Qt::AlignCenter,
size(), rect));
} else {
setGeometry(posx, posy, width, height);
}
} }
char styleSheetPath[512]; char styleSheetPath[512];