summaryrefslogtreecommitdiffstats
path: root/qml
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2019-02-22 19:26:55 +0100
committerPapoteur <papoteur@mageia.org>2019-02-22 19:27:12 +0100
commit3a3ec04461025c0459aab85813c5787144db79c5 (patch)
treed6c06336fe82aa6ff302507800181e5d1c49c094 /qml
parent175ea7cd649a0d2c2b64e118121c47e70eaa03c1 (diff)
downloadmageiawelcome-3a3ec04461025c0459aab85813c5787144db79c5.tar
mageiawelcome-3a3ec04461025c0459aab85813c5787144db79c5.tar.gz
mageiawelcome-3a3ec04461025c0459aab85813c5787144db79c5.tar.bz2
mageiawelcome-3a3ec04461025c0459aab85813c5787144db79c5.tar.xz
mageiawelcome-3a3ec04461025c0459aab85813c5787144db79c5.zip
Adapt the window size to Gnome Wayland settings (mga#24200)
Diffstat (limited to 'qml')
-rw-r--r--qml/mageiawelcome.py29
1 files changed, 24 insertions, 5 deletions
diff --git a/qml/mageiawelcome.py b/qml/mageiawelcome.py
index f19a49f..415c70f 100644
--- a/qml/mageiawelcome.py
+++ b/qml/mageiawelcome.py
@@ -43,6 +43,15 @@ class ConfList(QAbstractListModel):
desktop = get_desktop_name2(os.getenv("XDG_CURRENT_DESKTOP"))
if desktop == 'unknown':
desktop = os.getenv("XDG_CURRENT_DESKTOP")
+ self.screen_factor = 0.0
+ if desktop == 'Gnome Wayland':
+ from gi.repository.Gio import Settings
+ gso = Settings.new("org.gnome.desktop.interface")
+ val = gso.get_uint("scaling-factor")
+ if val == 0:
+ self.screen_factor = 1.0
+ else:
+ self.screen_factor = float(val)
# Search active network connections
net = QNetworkConfigurationManager()
@@ -68,6 +77,15 @@ class ConfList(QAbstractListModel):
else:
self.configuration.append({'name': translate('ConfList',"You have no network connection")})
+ def factor(self, app):
+ '''
+ Determine screen factor
+ Can be specific for Gnome Wayland
+ '''
+ if self.screen_factor == 0 :
+ screen = app.primaryScreen()
+ self.screen_factor = screen.devicePixelRatio()
+ return self.screen_factor
def data(self, index, role=Qt.DisplayRole):
row = index.row()
@@ -165,11 +183,6 @@ if __name__ == '__main__':
view.setResizeMode(QQuickView.SizeRootObjectToView)
view.setTitle(app.translate('app',"Welcome to Mageia"))
app.setWindowIcon(QIcon("/usr/share/mageiawelcome/icons/32x32/apps/mageiawelcome.png"))
- screen = app.primaryScreen()
- defaultHeight = 700 * screen.devicePixelRatio()
- defaultWidth = 1000 * screen.devicePixelRatio()
- centerPoint = screen.availableGeometry().center()
- view.setGeometry(centerPoint.x() -defaultWidth/2, centerPoint.y() - defaultHeight/2, defaultWidth,defaultHeight)
cb = Callbrowser()
la = Launcher()
us = username()
@@ -177,6 +190,12 @@ if __name__ == '__main__':
cl = ConfList()
nr = Norun()
sc = nr.startupcheck()
+ factor = cl.factor(app)
+ screen = app.primaryScreen()
+ defaultHeight = 700 * factor
+ defaultWidth = 1000 * factor
+ centerPoint = screen.availableGeometry().center()
+ view.setGeometry(centerPoint.x() -defaultWidth/2, centerPoint.y() - defaultHeight/2, defaultWidth,defaultHeight)
view.rootContext().setContextProperty('link', cb)
view.rootContext().setContextProperty('launch', la)
view.rootContext().setContextProperty('user', us)