diff options
Diffstat (limited to 'qml/mageiawelcome.py')
-rw-r--r-- | qml/mageiawelcome.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/qml/mageiawelcome.py b/qml/mageiawelcome.py index fa1ed46..da3fec6 100644 --- a/qml/mageiawelcome.py +++ b/qml/mageiawelcome.py @@ -28,6 +28,16 @@ from OpenGL import GL translate = QCoreApplication.translate +class Networkstate(QObject): + def __init__(self): + QObject.__init__(self) + + @pyqtSlot(result=bool) + def isOffLine(self): + # Search active network connections + net = QNetworkConfigurationManager() + return not net.isOnline() + class ConfList(QAbstractListModel): NameRole = Qt.UserRole + 1 @@ -166,10 +176,13 @@ class Launcher(QObject): cmd = [] for i in range(0, app.property("length").toInt()): cmd.append(app.property(i).toString()) + self._command(cmd[0]) + + def _command(self, cmd): try: subprocess.Popen(cmd) except: - print(f"Exception running {cmd[0]}") + print(f"Exception running {cmd}") self.noprogram.emit() return @@ -239,6 +252,22 @@ class Launcher(QObject): self.installed.emit() return + @pyqtSlot(QVariant) + def install_and_launch(self, app): + """ + app should be an array with the package name to install and then the command to launch + """ + if app.isArray(): + cmd = [] + # app should contain package, repository + for i in range(0, app.property("length").toInt()): + cmd.append(app.property(i).toString()) + print(cmd) + is_app_installed, inst_repo = is_installed(cmd[0]) + if not is_app_installed: + proc = subprocess.Popen(["/usr/bin/gurpmi", cmd[0]]) + proc.wait() + self._command(cmd[1]) class Norun(QObject): def __init__(self): @@ -310,6 +339,7 @@ if __name__ == "__main__": ins = Installable() cl = ConfList() nr = Norun() + ns = Networkstate() sc = nr.startupcheck() factor = cl.factor(app) screen = app.primaryScreen() @@ -332,6 +362,7 @@ if __name__ == "__main__": view.rootContext().setContextProperty("pyinstallable", ins) view.rootContext().setContextProperty("startupcheck", sc) view.rootContext().setContextProperty("norun", nr) + view.rootContext().setContextProperty("networkstate", ns) current_path = os.path.abspath(os.path.dirname(__file__)) qml_file = os.path.join(current_path, "mw-ui.qml") view.setSource(QUrl.fromLocalFile(qml_file)) |