better mtsgui behavior with multi-screen setups
parent
14b65e4d94
commit
39b16c5234
|
@ -764,10 +764,12 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) {
|
||||||
/* Re-center cursor as needed */
|
/* Re-center cursor as needed */
|
||||||
QPoint global = mapToGlobal(m_mousePos);
|
QPoint global = mapToGlobal(m_mousePos);
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
|
QRect geo = desktop->screenGeometry(global);
|
||||||
|
|
||||||
if (global.x() < 50 || global.y() < 50 ||
|
if (global.x() < 50 || global.y() < 50 ||
|
||||||
global.x() > desktop->width()-50 ||
|
global.x() > desktop->width()-50 ||
|
||||||
global.y() > desktop->height()-50) {
|
global.y() > desktop->height()-50) {
|
||||||
QPoint target(desktop->width()/2, desktop->height()/2);
|
QPoint target = geo.center();
|
||||||
m_ignoreMouseEvent = target - global;
|
m_ignoreMouseEvent = target - global;
|
||||||
QCursor::setPos(target);
|
QCursor::setPos(target);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,9 +100,15 @@ void LogWidget::show() {
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
raise();
|
raise();
|
||||||
} else {
|
} else {
|
||||||
|
/* Center the dialog */
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
move((desktop->width() - width())/2,
|
QRect geo = desktop->screenGeometry(
|
||||||
(desktop->height() - height())/2);
|
static_cast<QWidget *>(parent())->geometry().center());
|
||||||
|
QPoint windowPos(
|
||||||
|
geo.left() + (geo.width() - width()) / 2,
|
||||||
|
geo.top() + (geo.height() - height())/2
|
||||||
|
);
|
||||||
|
move(windowPos);
|
||||||
QMainWindow::show();
|
QMainWindow::show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,11 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
windowPos = settings.value("pos").toPoint();
|
windowPos = settings.value("pos").toPoint();
|
||||||
} else {
|
} else {
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
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__)
|
#if defined(__OSX__)
|
||||||
|
@ -521,8 +525,16 @@ void MainWindow::on_actionSceneDescription_triggered() {
|
||||||
SceneContext *context= m_context[currentIndex];
|
SceneContext *context= m_context[currentIndex];
|
||||||
SceneInformationDialog *dialog = new SceneInformationDialog(this,
|
SceneInformationDialog *dialog = new SceneInformationDialog(this,
|
||||||
context->scene);
|
context->scene);
|
||||||
|
|
||||||
|
/* Center the dialog */
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
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)));
|
connect(dialog, SIGNAL(finished(int)), this, SLOT(onSceneInformationClose(int)));
|
||||||
m_currentChild = dialog;
|
m_currentChild = dialog;
|
||||||
// prevent a tab drawing artifact on Qt/OSX
|
// prevent a tab drawing artifact on Qt/OSX
|
||||||
|
|
|
@ -212,9 +212,15 @@ void ServerWidget::show() {
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
raise();
|
raise();
|
||||||
} else {
|
} else {
|
||||||
|
/* Center the dialog */
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
move((desktop->width() - width())/2,
|
QRect geo = desktop->screenGeometry(
|
||||||
(desktop->height() - height())/2);
|
static_cast<QWidget *>(parent())->geometry().center());
|
||||||
|
QPoint windowPos(
|
||||||
|
geo.left() + (geo.width() - width()) / 2,
|
||||||
|
geo.top() + (geo.height() - height())/2
|
||||||
|
);
|
||||||
|
move(windowPos);
|
||||||
QMainWindow::show();
|
QMainWindow::show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue