diff --git a/mambabase/WelcomePage.ui b/mambabase/WelcomePage.ui index 1118a67..0ef0c6b 100644 --- a/mambabase/WelcomePage.ui +++ b/mambabase/WelcomePage.ui @@ -144,17 +144,30 @@ true - + 10 180 - 321 + 531 20 - <html><head/><body><p><span style=" font-weight:600;">Please, press the Next button to continue.</span></p></body></html> + <html><head/><body><p><br/></p></body></html> + + + + + + 10 + 150 + 531 + 23 + + + + 0 diff --git a/mambabase/mambabase.py b/mambabase/mambabase.py index eb6dd9b..365cdee 100755 --- a/mambabase/mambabase.py +++ b/mambabase/mambabase.py @@ -18,6 +18,61 @@ from gi.repository import PackageKitGlib as packagekit DATADIR = os.path.dirname(os.path.realpath((__file__))) + "/" + +class MambabaseWizard(QtWidgets.QWizard): + def __init__(self, parent=None): + super(MambabaseWizard, self).__init__(parent) + self.welcomePage = WelcomePage(self) + self.addPage(self.welcomePage) + self.selectGroupsPage = SelectGroupsPage(self) + self.addPage(self.selectGroupsPage) + self.selectExtraPage = SelectExtraPage(self) + self.addPage(self.selectExtraPage) + self.installationPage = InstallationPage(self) + self.addPage(self.installationPage) + self.finishPage = FinishPage(self) + self.addPage(self.finishPage) + self.setWindowTitle(_("openmamba base network installations") + + " - openmamba.org") + self.setFixedSize(571,465) + self.currentIdChanged.connect(self.currentIdChangedSlot) + self.prepareThread = PrepareThread(self) + self.installThread = InstallThread(self, self.selectGroupsPage.pkggroups) + + def currentIdChangedSlot(self, currentId): + if currentId == 0: + self.prepareThread.start() + elif currentId == 3: + self.installThread.start() + + +class PrepareThread(QtCore.QThread): + parent = None + doneSignal = QtCore.pyqtSignal() + updateProgressSignal = QtCore.pyqtSignal(dict) + + def __init__(self, parent=None): + super(PrepareThread, self).__init__(parent) + self.parent = parent + self.doneSignal.connect(parent.welcomePage.completeChanged) + self.updateProgressSignal.connect( + parent.welcomePage.updateProgressSlot) + + def run(self): + # Update packages list + self.updateProgressSignal.emit({ 'value': 5, + 'label': _("Checking installed packages...")}) + self.parent.selectGroupsPage.loadPkgGroups() + self.updateProgressSignal.emit({ 'value': 55, + 'label': _("Checking installed extra components...")}) + self.parent.selectExtraPage.setExtras() + self.updateProgressSignal.emit({ 'value': 100, + 'label': _("Done. Please, press the Next button to continue.")}) + # Enable back and next buttons + self.parent.welcomePage.done = True + self.doneSignal.emit() + + class InstallThread(QtCore.QThread): parent = None doneSignal = QtCore.pyqtSignal() @@ -62,7 +117,7 @@ class InstallThread(QtCore.QThread): self.updateProgressSignal.emit({ 'value': 10, 'label': _("Updating installed packages...")}) - result = subprocess.run(['pkcon', 'update'], + result = subprocess.run(['pkcon', 'update', '-y'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if result.returncode == 0: if result.stdout: @@ -144,35 +199,24 @@ class InstallThread(QtCore.QThread): str(status.get_percentage())))}) -class MambabaseWizard(QtWidgets.QWizard): - def __init__(self, parent=None): - super(MambabaseWizard, self).__init__(parent) - self.addPage(WelcomePage(self)) - self.selectGroupsPage = SelectGroupsPage(self) - self.addPage(self.selectGroupsPage) - self.selectExtraPage = SelectExtraPage(self) - self.addPage(self.selectExtraPage) - self.installationPage = InstallationPage(self) - self.addPage(self.installationPage) - self.finishPage = FinishPage(self) - self.addPage(self.finishPage) - self.setWindowTitle(_("openmamba base network installations") + - " - openmamba.org") - self.setFixedSize(571,465) - self.currentIdChanged.connect(self.currentIdChangedSlot) - self.installThread = InstallThread(self, self.selectGroupsPage.pkggroups) - - def currentIdChangedSlot(self, currentId): - if currentId == 3: - self.installThread.start() - - class WelcomePage(QtWidgets.QWizardPage): + done = False + def __init__(self, parent=None): super(WelcomePage, self).__init__(parent) uic.loadUi(DATADIR + "WelcomePage.ui", self) self.show() + def isComplete(self): + return self.done + + @QtCore.pyqtSlot(dict) + def updateProgressSlot(self, dict): + if 'value' in dict: + self.progressBar.setValue(dict['value']) + if 'label' in dict: + self.progressLabel.setText(dict['label']) + class SelectGroupsPage(QtWidgets.QWizardPage): groups_checkboxes = {} @@ -181,7 +225,6 @@ class SelectGroupsPage(QtWidgets.QWizardPage): def __init__(self, parent=None): super(SelectGroupsPage, self).__init__(parent) uic.loadUi(DATADIR + "SelectGroupsPage.ui", self) - self.loadPkgGroups() self.show() def loadPkgGroups(self): @@ -240,7 +283,6 @@ class SelectExtraPage(QtWidgets.QWizardPage): super(SelectExtraPage, self).__init__(parent) uic.loadUi(DATADIR + "SelectExtraPage.ui", self) self.setCommitPage(True) - self.setExtras() self.show() def setExtras(self):