summaryrefslogtreecommitdiffstats
path: root/qml/mageiawelcome.py
diff options
context:
space:
mode:
Diffstat (limited to 'qml/mageiawelcome.py')
-rw-r--r--qml/mageiawelcome.py44
1 files changed, 37 insertions, 7 deletions
diff --git a/qml/mageiawelcome.py b/qml/mageiawelcome.py
index b5e13da..8986333 100644
--- a/qml/mageiawelcome.py
+++ b/qml/mageiawelcome.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
-from PyQt5.QtGui import QGuiApplication, QIcon
+from PyQt5.QtGui import QGuiApplication, QIcon, QScreen
from PyQt5.QtQuick import QQuickView
from PyQt5.QtCore import QUrl, QLocale, QTranslator, QLibraryInfo, QVariant, QAbstractListModel, \
QModelIndex, Qt, QObject, pyqtSlot, pyqtSignal, QCoreApplication
@@ -43,6 +43,14 @@ 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':
+ import gi
+ gi.require_version('Gdk', '3.0')
+ from gi.repository.Gdk import Display
+ # pre-3.22, otherwise deprecated
+ #factor = Gdk.Screen.get_default().get_monitor_scale_factor(0)
+ self.screen_factor = Display.get_default().get_monitor(0).get_scale_factor()
# Search active network connections
net = QNetworkConfigurationManager()
@@ -57,7 +65,7 @@ class ConfList(QAbstractListModel):
netconfs += ", " + conf.name()
self.configuration = [
- {'name': translate('ConfList',"<b>Congratulations!</b><BR />You have completed the installation of {}").format(release)},
+ {'name': translate('ConfList',"<b>Congratulations!</b><BR />You have are now running {}").format(release)},
{'name': translate('ConfList',"You are using linux kernel: {}").format(kernel)},
{'name': translate('ConfList',"Your system architecture is: {}").format(arch)},
{'name': translate('ConfList',"You are now using the Desktop: {}").format(desktop)},
@@ -68,6 +76,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()
@@ -104,9 +121,8 @@ class Launcher(QObject):
if cmd[0] == "gurpmi":
proc.wait()
print(proc.returncode)
- if (proc.returncode == 0):
- # Give the signal to reload the applist
- self.installed.emit()
+ # Give the signal to reload the applist
+ self.installed.emit()
class Norun(QObject):
def __init__(self):
@@ -136,9 +152,15 @@ class Installable(QObject):
@pyqtSlot(str, str, result=bool)
def installable(self, app,repo):
is_app_installed, inst_repo = is_installed(app)
- installable = (not is_app_installed) or (repo != inst_repo and inst_repo != "")
+ installable = (not is_app_installed) or (repo != inst_repo and inst_repo == "")
return installable
+ @pyqtSlot(str, str, result=bool)
+ def other(self, app, repo):
+ is_app_installed, inst_repo = is_installed(app)
+ return (is_app_installed and repo == '' and inst_repo != "")
+
+
def username():
user = pwd.getpwuid(os.getuid())[4] # pw_gecos, i e the real name
if user == "":
@@ -154,10 +176,12 @@ if __name__ == '__main__':
appTranslator = QTranslator()
if appTranslator.load(QLocale(),"mageiawelcome","_", '/usr/share/mageiawelcome/translations'):
app.installTranslator(appTranslator)
+ app.setOrganizationName("Mageia")
+ app.setApplicationName("Mageiawelcome")
view = QQuickView()
view.setResizeMode(QQuickView.SizeRootObjectToView)
view.setTitle(app.translate('app',"Welcome to Mageia"))
- app.setWindowIcon(QIcon("icons/32x32/apps/mageiawelcome.png"))
+ app.setWindowIcon(QIcon("/usr/share/icons/hicolor/32x32/apps/mageiawelcome.png"))
cb = Callbrowser()
la = Launcher()
us = username()
@@ -165,6 +189,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)