mambabase: scanning packages in welcome page with progress bar

This commit is contained in:
Silvan Calarco 2019-10-20 14:46:47 +02:00
parent 0d81a89138
commit 2ee7762745
2 changed files with 84 additions and 29 deletions

View File

@ -144,17 +144,30 @@
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_5">
<widget class="QLabel" name="progressLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>180</y>
<width>321</width>
<width>531</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Please, press the Next button to continue.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>10</x>
<y>150</y>
<width>531</width>
<height>23</height>
</rect>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</widget>

View File

@ -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):