mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-30 20:34:27 +01:00
Fix a window placement bug.
Placing Eliot on a secondary monitor, and restarting it later when the monitor is unplugged, made the window invisible (it was still at the old position, thus off screen).
This commit is contained in:
parent
f267b045b6
commit
b0a9f44ab7
2 changed files with 22 additions and 2 deletions
|
@ -25,6 +25,7 @@
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QtGui/QVBoxLayout>
|
||||||
#include <QtGui/QCloseEvent>
|
#include <QtGui/QCloseEvent>
|
||||||
|
#include <QtGui/QDesktopWidget>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
|
||||||
#include "aux_window.h"
|
#include "aux_window.h"
|
||||||
|
@ -107,7 +108,16 @@ void AuxWindow::readSettings()
|
||||||
QSize size = settings.value("size").toSize();
|
QSize size = settings.value("size").toSize();
|
||||||
if (size.isValid())
|
if (size.isValid())
|
||||||
resize(size);
|
resize(size);
|
||||||
move(settings.value("pos", QPoint(200, 200)).toPoint());
|
const QRect &desktopRect = QApplication::desktop()->screenGeometry();
|
||||||
|
QPoint point = settings.value("pos", QPoint(20, 20)).toPoint();
|
||||||
|
// If the position was saved when an external monitor was plugged, and
|
||||||
|
// is restored when the monitor is not there anymore, the window could
|
||||||
|
// be off screen...
|
||||||
|
if (point.x() < 0 || point.x() > desktopRect.right())
|
||||||
|
point.setX(20);
|
||||||
|
if (point.y() < 0 || point.y() > desktopRect.bottom())
|
||||||
|
point.setY(20);
|
||||||
|
move(point);
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <QtGui/QPrinter>
|
#include <QtGui/QPrinter>
|
||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QDesktopServices>
|
#include <QtGui/QDesktopServices>
|
||||||
|
#include <QtGui/QDesktopWidget>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
|
@ -616,7 +617,16 @@ void MainWindow::readSettings()
|
||||||
QSize size = settings.value("size").toSize();
|
QSize size = settings.value("size").toSize();
|
||||||
if (size.isValid())
|
if (size.isValid())
|
||||||
resize(size);
|
resize(size);
|
||||||
move(settings.value("pos", QPoint(200, 200)).toPoint());
|
const QRect &desktopRect = QApplication::desktop()->screenGeometry();
|
||||||
|
QPoint point = settings.value("pos", QPoint(20, 20)).toPoint();
|
||||||
|
// If the position was saved when an external monitor was plugged, and
|
||||||
|
// is restored when the monitor is not there anymore, the window could
|
||||||
|
// be off screen...
|
||||||
|
if (point.x() < 0 || point.x() > desktopRect.right())
|
||||||
|
point.setX(20);
|
||||||
|
if (point.y() < 0 || point.y() > desktopRect.bottom())
|
||||||
|
point.setY(20);
|
||||||
|
move(point);
|
||||||
m_ui.splitterHoriz->restoreState(settings.value("splitterHoriz").toByteArray());
|
m_ui.splitterHoriz->restoreState(settings.value("splitterHoriz").toByteArray());
|
||||||
m_ui.splitterVert->restoreState(settings.value("splitterVert").toByteArray());
|
m_ui.splitterVert->restoreState(settings.value("splitterVert").toByteArray());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
|
|
Loading…
Add table
Reference in a new issue