better mtsgui behavior with multi-screen setups

metadata
Wenzel Jakob 2011-09-14 11:39:25 -04:00
parent 14b65e4d94
commit 39b16c5234
4 changed files with 33 additions and 7 deletions

View File

@ -764,10 +764,12 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) {
/* Re-center cursor as needed */
QPoint global = mapToGlobal(m_mousePos);
QDesktopWidget *desktop = QApplication::desktop();
QRect geo = desktop->screenGeometry(global);
if (global.x() < 50 || global.y() < 50 ||
global.x() > desktop->width()-50 ||
global.y() > desktop->height()-50) {
QPoint target(desktop->width()/2, desktop->height()/2);
QPoint target = geo.center();
m_ignoreMouseEvent = target - global;
QCursor::setPos(target);
}

View File

@ -100,9 +100,15 @@ void LogWidget::show() {
if (isVisible()) {
raise();
} else {
/* Center the dialog */
QDesktopWidget *desktop = QApplication::desktop();
move((desktop->width() - width())/2,
(desktop->height() - height())/2);
QRect geo = desktop->screenGeometry(
static_cast<QWidget *>(parent())->geometry().center());
QPoint windowPos(
geo.left() + (geo.width() - width()) / 2,
geo.top() + (geo.height() - height())/2
);
move(windowPos);
QMainWindow::show();
}
}

View File

@ -180,7 +180,11 @@ MainWindow::MainWindow(QWidget *parent) :
windowPos = settings.value("pos").toPoint();
} else {
QDesktopWidget *desktop = QApplication::desktop();
windowPos = QPoint((desktop->width() - width()) / 2, (desktop->height() - height())/2);
QRect geo = desktop->screenGeometry();
windowPos = QPoint(
geo.left() + (geo.width() - width()) / 2,
geo.top() + (geo.height() - height())/2
);
}
#if defined(__OSX__)
@ -521,8 +525,16 @@ void MainWindow::on_actionSceneDescription_triggered() {
SceneContext *context= m_context[currentIndex];
SceneInformationDialog *dialog = new SceneInformationDialog(this,
context->scene);
/* Center the dialog */
QDesktopWidget *desktop = QApplication::desktop();
dialog->move(QPoint((desktop->width() - dialog->width()) / 2, (desktop->height() - dialog->height())/2));
QRect geo = desktop->screenGeometry(geometry().center());
QPoint windowPos(
geo.left() + (geo.width() - dialog->width()) / 2,
geo.top() + (geo.height() - dialog->height())/2
);
dialog->move(windowPos);
connect(dialog, SIGNAL(finished(int)), this, SLOT(onSceneInformationClose(int)));
m_currentChild = dialog;
// prevent a tab drawing artifact on Qt/OSX

View File

@ -212,9 +212,15 @@ void ServerWidget::show() {
if (isVisible()) {
raise();
} else {
/* Center the dialog */
QDesktopWidget *desktop = QApplication::desktop();
move((desktop->width() - width())/2,
(desktop->height() - height())/2);
QRect geo = desktop->screenGeometry(
static_cast<QWidget *>(parent())->geometry().center());
QPoint windowPos(
geo.left() + (geo.width() - width()) / 2,
geo.top() + (geo.height() - height())/2
);
move(windowPos);
QMainWindow::show();
}
}