mirror of
https://github.com/cmclark00/retro-imager.git
synced 2025-05-18 07:55:21 +01:00
Do not use saved position if it falls outside of primary screen
- Only use saved position if the coordinates fall inside of the primary screen Prevents problems for people with laptops that sometimes but not always use external screens. - Since we now set window position in C++ instead of QML, drop the dependency on qml-module-qt-labs-settings module. Closes #91
This commit is contained in:
parent
65c6377052
commit
c08887f788
4 changed files with 45 additions and 11 deletions
|
@ -18,7 +18,7 @@ Install the build dependencies:
|
|||
```
|
||||
sudo apt install --no-install-recommends build-essential devscripts debhelper cmake git libarchive-dev libcurl4-openssl-dev \
|
||||
qtbase5-dev qtbase5-dev-tools qtdeclarative5-dev libqt5svg5-dev qttools5-dev qt5-default libssl-dev \
|
||||
qml-module-qtquick2 qml-module-qtquick-controls2 qml-module-qt-labs-settings qml-module-qtquick-layouts qml-module-qtquick-templates2 qml-module-qtquick-window2 qml-module-qtgraphicaleffects
|
||||
qml-module-qtquick2 qml-module-qtquick-controls2 qml-module-qtquick-layouts qml-module-qtquick-templates2 qml-module-qtquick-window2 qml-module-qtgraphicaleffects
|
||||
```
|
||||
|
||||
#### Get the source
|
||||
|
|
4
debian/control
vendored
4
debian/control
vendored
|
@ -4,14 +4,14 @@ Priority: optional
|
|||
Maintainer: Floris Bos <bos@je-eigen-domein.nl>
|
||||
Build-Depends: debhelper (>= 10), cmake, libarchive-dev, libcurl4-openssl-dev | libcurl4-gnutls-dev,
|
||||
qtbase5-dev, qtbase5-dev-tools, qtdeclarative5-dev, libqt5svg5-dev, qttools5-dev, libssl-dev,
|
||||
qml-module-qtquick2, qml-module-qtquick-controls2, qml-module-qt-labs-settings, qml-module-qtquick-layouts, qml-module-qtquick-templates2, qml-module-qtquick-window2, qml-module-qtgraphicaleffects
|
||||
qml-module-qtquick2, qml-module-qtquick-controls2, qml-module-qtquick-layouts, qml-module-qtquick-templates2, qml-module-qtquick-window2, qml-module-qtgraphicaleffects
|
||||
Standards-Version: 4.1.2
|
||||
Homepage: https://www.raspberrypi.org/
|
||||
|
||||
Package: rpi-imager
|
||||
Architecture: any
|
||||
Depends: ${shlibs:Depends}, ${misc:Depends},
|
||||
qml-module-qtquick2, qml-module-qtquick-controls2, qml-module-qt-labs-settings, qml-module-qtquick-layouts, qml-module-qtquick-templates2, qml-module-qtquick-window2, qml-module-qtgraphicaleffects,
|
||||
qml-module-qtquick2, qml-module-qtquick-controls2, qml-module-qtquick-layouts, qml-module-qtquick-templates2, qml-module-qtquick-window2, qml-module-qtgraphicaleffects,
|
||||
dosfstools, fdisk
|
||||
Recommends: udisks2
|
||||
Description: Raspberry Pi imaging utility
|
||||
|
|
42
main.cpp
42
main.cpp
|
@ -18,6 +18,7 @@
|
|||
#include <QTranslator>
|
||||
#include <QLocale>
|
||||
#include <QScreen>
|
||||
#include <QSettings>
|
||||
#ifndef QT_NO_WIDGETS
|
||||
#include <QtWidgets/QApplication>
|
||||
#endif
|
||||
|
@ -164,7 +165,48 @@ int main(int argc, char *argv[])
|
|||
qmlwindow->connect(&imageWriter, SIGNAL(finalizing()), qmlwindow, SLOT(onFinalizing()));
|
||||
qmlwindow->connect(&imageWriter, SIGNAL(networkOnline()), qmlwindow, SLOT(fetchOSlist()));
|
||||
|
||||
#ifndef QT_NO_WIDGETS
|
||||
QSettings settings;
|
||||
|
||||
/* Set window position */
|
||||
auto screensize = app.primaryScreen()->geometry();
|
||||
int x = settings.value("General/x", -1).toInt();
|
||||
int y = settings.value("General/y", -1).toInt();
|
||||
int w = qmlwindow->property("width").toInt();
|
||||
int h = qmlwindow->property("height").toInt();
|
||||
|
||||
if (x != -1 && y != -1)
|
||||
{
|
||||
if ( (screensize.width()-x) < w || (screensize.height()-y) < h)
|
||||
{
|
||||
qDebug() << "Not restoring saved window position as it falls outside of primary screen";
|
||||
x = y = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (x == -1 || y == -1)
|
||||
{
|
||||
x = qMax(1, (screensize.width()-w)/2);
|
||||
y = qMax(1, (screensize.height()-h)/2);
|
||||
}
|
||||
|
||||
qmlwindow->setProperty("x", x);
|
||||
qmlwindow->setProperty("y", y);
|
||||
#endif
|
||||
|
||||
int rc = app.exec();
|
||||
|
||||
#ifndef QT_NO_WIDGETS
|
||||
int newX = qmlwindow->property("x").toInt();
|
||||
int newY = qmlwindow->property("y").toInt();
|
||||
if (x != newX || y != newY)
|
||||
{
|
||||
settings.setValue("General/x", newX);
|
||||
settings.setValue("General/y", newY);
|
||||
settings.sync();
|
||||
}
|
||||
#endif
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
8
main.qml
8
main.qml
|
@ -8,7 +8,6 @@ import QtQuick.Window 2.2
|
|||
import QtQuick.Controls 2.2
|
||||
import QtQuick.Layouts 1.0
|
||||
import QtQuick.Controls.Material 2.2
|
||||
import Qt.labs.settings 1.0
|
||||
|
||||
ApplicationWindow {
|
||||
id: window
|
||||
|
@ -768,13 +767,6 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
|
||||
/* Persistent settings */
|
||||
Settings {
|
||||
category: "General"
|
||||
property alias x: window.x
|
||||
property alias y: window.y
|
||||
}
|
||||
|
||||
/* Utility functions */
|
||||
function httpRequest(url, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue