summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPapoteur <papoteur@mageia.org>2018-12-09 10:16:02 +0100
committerPapoteur <papoteur@mageia.org>2018-12-17 10:19:29 +0100
commit17e9e64cfced1efa89aac1599d5b50a718bff38e (patch)
treeb52f6a022a7ec013aa14f9e88994928beac0be67
parentc468ac8b953cea3ca5fee4480893014a3d373058 (diff)
downloadmageiawelcome-17e9e64cfced1efa89aac1599d5b50a718bff38e.tar
mageiawelcome-17e9e64cfced1efa89aac1599d5b50a718bff38e.tar.gz
mageiawelcome-17e9e64cfced1efa89aac1599d5b50a718bff38e.tar.bz2
mageiawelcome-17e9e64cfced1efa89aac1599d5b50a718bff38e.tar.xz
mageiawelcome-17e9e64cfced1efa89aac1599d5b50a718bff38e.zip
Add info about startup at boot
-rw-r--r--qml/mw.py87
1 files changed, 12 insertions, 75 deletions
diff --git a/qml/mw.py b/qml/mw.py
index 91d1974..5608ca1 100644
--- a/qml/mw.py
+++ b/qml/mw.py
@@ -3,85 +3,14 @@
from PyQt5.QtGui import QGuiApplication
from PyQt5.QtQuick import QQuickView
from PyQt5.QtQml import qmlRegisterType
-from PyQt5.QtCore import QUrl, QLocale, QTranslator, QLibraryInfo, QAbstractListModel, QVariant, \
- QModelIndex, Qt, QObject, pyqtSlot, pyqtProperty, qInstallMessageHandler, QSortFilterProxyModel, QRegExp, QByteArray
+from PyQt5.QtCore import QUrl, QLocale, QTranslator, QLibraryInfo, QVariant, QAbstractListModel, \
+ QModelIndex, Qt, QObject, pyqtSlot, pyqtProperty
import sys
import os
import subprocess
from helpers import *
import pwd
-class AppList(QAbstractListModel):
-
- IconRole = Qt.UserRole + 1
- NameRole = Qt.UserRole + 2
- TitleRole = Qt.UserRole + 3
- GroupRole = Qt.UserRole + 4
- DescriptionRole = Qt.UserRole + 5
- RepoRole = Qt.UserRole + 6
- InstallableRole = Qt.UserRole + 7
- InstalledRepoRole = Qt.UserRole + 8
- listapp = []
- def __init__(self, parent=None):
- super().__init__(parent)
- self.get_listapp()
-
- def get_listapp(self):
- with open("apps.csv", 'rt') as f:
- mycsv = csv.reader(f,delimiter='|')
- next(mycsv)
- for r in mycsv:
- if (r[5] == 'false'):
- r[5] = ""
- is_app_installed, repo = is_installed(r[1])
- installable = (not is_app_installed) or (r[6] != repo and repo != "")
- app = { 'icon': "img/{}.png".format(r[0]),
- 'name': r[1],
- 'title': r[2],
- 'group':r[3],
- 'description': r[4],
- 'command': r[5],
- 'repo':r[6],
- 'installable': installable,
- 'inst_repo': repo}
- self.listapp.append(app)
-
- def data(self, index, role=Qt.DisplayRole):
- row = index.row()
- if role == AppList.IconRole:
- return AppList.listapp[row]["icon"]
- elif role == AppList.NameRole:
- return AppList.listapp[row]["name"]
- elif role == AppList.TitleRole:
- return AppList.listapp[row]["title"]
- elif role == AppList.GroupRole:
- return AppList.listapp[row]["group"]
- elif role == AppList.DescriptionRole:
- return AppList.listapp[row]["description"]
- elif role == AppList.RepoRole:
- return AppList.listapp[row]["repo"]
- elif role == AppList.InstallableRole:
- return AppList.listapp[row]["installable"]
- elif role == AppList.InstalledRepoRole:
- return AppList.listapp[row]["installedRepo"]
- else:
- print("Not found")
-
- def rowCount(self, parent=QModelIndex()):
- return len(AppList.listapp)
-
- def roleNames(self):
- return {
- AppList.IconRole: b'icon',
- AppList.NameRole: b'name',
- AppList.TitleRole: b'title',
- AppList.GroupRole: b'group',
- AppList.DescriptionRole: b'description',
- AppList.RepoRole: b'repo',
- AppList.InstallableRole: b'installable',
- AppList.InstalledRepoRole: b'installedRepo'
- }
-
class ConfList(QAbstractListModel):
NameRole = Qt.UserRole + 1
def __init__(self, parent=None):
@@ -160,6 +89,7 @@ class Norun(QObject):
QObject.__init__(self)
self.home = os.getenv("HOME")
self.conffile = self.home + "/.config/mageiawelcome/norun.flag"
+ print(self.conffile, os.path.exists(self.conffile))
@pyqtSlot()
def setRunAtLaunch(self):
@@ -169,7 +99,11 @@ class Norun(QObject):
def setNoRunAtLaunch(self):
os.makedirs(self.home + "/.config/mageiawelcome", exist_ok=True)
with open( self.conffile, w) as f:
- pass
+ pass
+
+ @pyqtSlot(result=bool)
+ def startupcheck(self):
+ return not os.path.exists(self.conffile)
class Installable(QObject):
def __init__(self):
@@ -204,14 +138,17 @@ if __name__ == '__main__':
us = username()
ins = Installable()
cl = ConfList()
+ nr = Norun()
+ sc = nr.startupcheck()
view.rootContext().setContextProperty('link', cb)
view.rootContext().setContextProperty('launch', la)
view.rootContext().setContextProperty('user', us)
view.rootContext().setContextProperty('ConfList', cl)
view.rootContext().setContextProperty('installable', ins)
+ view.rootContext().setContextProperty('startupcheck', sc)
+ view.rootContext().setContextProperty('norun', nr)
current_path = os.path.abspath(os.path.dirname(__file__))
qml_file = os.path.join(current_path, 'mw-ui.qml')
- print("Loading")
view.setSource(QUrl.fromLocalFile(qml_file))
if view.status() == QQuickView.Error:
for error in view.errors():