diff options
author | Papoteur <papoteur@mageia.org> | 2018-12-09 10:16:02 +0100 |
---|---|---|
committer | Papoteur <papoteur@mageia.org> | 2018-12-15 15:46:34 +0100 |
commit | ebbce4c52f3e6f2888c105fe65fc772f40dff063 (patch) | |
tree | 6695dc673b36fd001a682dea4d1519bc3d75fbfe | |
parent | aaa42a183860f93c89d64a1ee1ffe25dd3cf41a1 (diff) | |
download | mageiawelcome-ebbce4c52f3e6f2888c105fe65fc772f40dff063.tar mageiawelcome-ebbce4c52f3e6f2888c105fe65fc772f40dff063.tar.gz mageiawelcome-ebbce4c52f3e6f2888c105fe65fc772f40dff063.tar.bz2 mageiawelcome-ebbce4c52f3e6f2888c105fe65fc772f40dff063.tar.xz mageiawelcome-ebbce4c52f3e6f2888c105fe65fc772f40dff063.zip |
Add info about startup at boot
-rw-r--r-- | qml/mw.py | 87 |
1 files changed, 12 insertions, 75 deletions
@@ -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(): |