class Widget(QtGui.QWidget, ScreenWidget): title = _('Choose Collections') desc = _('Auto or Manual installation...') icon = "iconPartition" help = _(''' <font size="+2">Automatic Installation</font> <font size="+1"> <p> </p> </font> ''') def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_AutoInstallationWidget() self.ui.setupUi(self) self.collections = None self.kernelType = None self.defaultChoice = None self.currentChoice = None self.previousChoice = None self.ui.kernelTypeGroupBox.setEnabled(False) self.connect(self.ui.radioManual, SIGNAL("clicked()"),self.slotClickedManual) self.connect(self.ui.radioManual, SIGNAL("toggled(bool)"),self.slotToggleManual) self.connect(self.ui.radioAutomatic, SIGNAL("toggled(bool)"),self.slotToggleAutomatic) self.connect(self.ui.radioAutomatic, SIGNAL("clicked()"),self.slotClickedAutomatic) self.connect(self.ui.radioDefaultKernel, SIGNAL("toggled(bool)"),self.slotToggleDefaultKernel) self.connect(self.ui.radioPAEKernel, SIGNAL("toggled(bool)"),self.slotTogglePAEKernel) def fillCollectionList(self): self.ui.collectionList.clear() self.collections = yali4.pisiiface.getCollection() selectedItem=None for collection in self.collections: item = QtGui.QListWidgetItem(self.ui.collectionList) #item.setFlags(Qt.NoItemFlags | Qt.ItemIsEnabled) item.setSizeHint(QSize(48,48)) if ctx.installData.autoInstallationCollection == collection: collectionItem = CollectionListItem(self, item, collection) selectedItem = collectionItem elif collection.default: collectionItem = CollectionListItem(self, item, collection) self.defaultChoice = collectionItem else: collectionItem = CollectionListItem(self, item, collection) self.ui.collectionList.setItemWidget(item, collectionItem) if selectedItem: self.currentChoice = selectedItem elif self.defaultChoice and not selectedItem: self.currentChoice = self.defaultChoice else: self.currentChoice = collectionItem self.currentChoice.setChecked(Qt.Checked) def shown(self): self.toggleAll() self.fillCollectionList() self.toggleAll(True) if len(self.collections) == 0: self.ui.radioManual.setEnabled(False) self.ui.collectionList.setEnabled(False) ctx.mainScreen.disableNext() if ctx.installData.autoInstallationMethod == methodInstallManual: self.slotClickedManual() else: self.slotClickedAutomatic() if platform.machine() == "x86_64": self.ui.kernelTypeGroupBox.hide() else: if ctx.installData.autoInstallationKernel == paeKernel: self.slotTogglePAEKernel(True) else: self.slotToggleDefaultKernel(True) self.update() def execute(self): ctx.installData.autoInstallationCollection = None if self.ui.radioAutomatic.isChecked(): ctx.installData.autoInstallationMethod = methodInstallAutomatic ctx.installData.autoInstallationCollection = self.defaultChoice.collection ctx.debugger.log("Automatic Installation selected..") else: ctx.installData.autoInstallationMethod = methodInstallManual ctx.installData.autoInstallationCollection = self.currentChoice.collection ctx.debugger.log("Manual Installation selected..") if self.ui.kernelTypeGroupBox.isVisible(): if self.ui.radioPAEKernel.isChecked(): ctx.installData.autoInstallationKernel = paeKernel else: ctx.installData.autoInstallationKernel = defaultKernel else: ctx.installData.autoInstallationKernel = defaultKernel ctx.debugger.log("Trying to Install selected Packages from %s Collection with %s Type" % \ (ctx.installData.autoInstallationCollection.title, kernels[ctx.installData.autoInstallationKernel])) return True def slotClickedAutomatic(self): self.ui.radioAutomatic.setChecked(True) self.ui.radioManual.setChecked(False) self.defaultChoice.setChecked(Qt.Checked) self.defaultChoice.setKernelType() self.update() def slotClickedManual(self): self.ui.radioManual.setChecked(True) self.ui.radioAutomatic.setChecked(False) if self.currentChoice: self.currentChoice.setChecked(Qt.Checked) self.currentChoice.setKernelType() self.update() def slotToggleAutomatic(self, checked): if checked: self.ui.collectionList.setEnabled(False) else: self.ui.collectionList.setEnabled(True) def slotToggleManual(self, checked): if checked: self.ui.collectionList.setEnabled(True) else: self.ui.collectionList.setEnabled(False) def slotToggleDefaultKernel(self, checked): if checked: self.kernelType = defaultKernel def slotTogglePAEKernel(self, checked): if checked: self.kernelType = paeKernel def update(self): if self.ui.radioAutomatic.isChecked() and self.defaultChoice: ctx.mainScreen.enableNext() elif self.ui.radioManual.isChecked() and self.currentChoice and self.currentChoice.isChecked(): ctx.mainScreen.enableNext() else: ctx.mainScreen.disableNext() def toggleAll(self, state=False): widgets = ["radioAutomatic", "radioManual"] for widget in widgets: getattr(self.ui, widget).setEnabled(state) ctx.mainScreen.processEvents()
class Widget(QtGui.QWidget, ScreenWidget): title = _('Choose Installation') desc = _('Auto or Manual installation...') icon = "iconPartition" help = _(''' <font size="+2">Automatic Installation</font> <font size="+1"> <p> </p> </font> ''') def __init__(self, *args): QtGui.QWidget.__init__(self,None) self.ui = Ui_AutoInstallationWidget() self.ui.setupUi(self) self.collections = None self.selectedKernelType = None self.selectedCollection = None self.defaultKernelType = None self.defaultCollection = None self.enable_next = False self.isManualInstallation = False self.lastChoice = None self.fillCollectionList() #if not self.ui.collectionList.count(): # raise YaliExceptionInfo, _("It seems that you don't have the collection of packages for Pardus installation.") self.connect(self.ui.radioManual, SIGNAL("clicked()"),self.slotClickedManual) self.connect(self.ui.radioManual, SIGNAL("toggled(bool)"),self.slotToggleManual) self.connect(self.ui.radioAutomatic, SIGNAL("toggled(bool)"),self.slotToggleAutomatic) self.connect(self.ui.radioAutomatic, SIGNAL("clicked()"),self.slotClickedAutomatic) self.connect(self.ui.radioDefaultKernel, SIGNAL("toggled(bool)"),self.slotToggleDefaultKernel) self.connect(self.ui.radioPAEKernel, SIGNAL("toggled(bool)"),self.slotTogglePAEKernel) self.connect(self.ui.radioRTKernel, SIGNAL("toggled(bool)"),self.slotToggleRTKernel) #self.connect(self.ui.collectionList, SIGNAL("currentItemChanged(QListWidgetItem *, QListWidgetItem *)"),self.slotCollectionItemChanged) def fillCollectionList(self): self.ui.collectionList.clear() for collection in yali4.pisiiface.getCollection(): item = QtGui.QListWidgetItem(self.ui.collectionList) item.setFlags(Qt.NoItemFlags | Qt.ItemIsEnabled) item.setSizeHint(QSize(48,48)) collectionItem = CollectionListItem(collection, self, item) self.ui.collectionList.setItemWidget(item, collectionItem) self.collections = yali4.pisiiface.getCollection() for collection in self.collections: if collection.default: self.defaultCollection = collection ctx.debugger.log("Default Collection : %s" % self.defaultCollection.title) self.ui.collectionList.setCurrentRow(0) def setDefaultKernelType(self): if yali4.sysutils.isLoadedKernelPAE() or yali4.sysutils.checkKernelFlags("pae"): self.defaultKernelType = paeKernel ctx.debugger.log("Kernel Type as PAE") else: self.defaultKernelType = defaultKernel ctx.debugger.log("Kernel Type as Default") def shown(self): # scan partitions for resizing self.toggleAll() self.fillCollectionList() self.setDefaultKernelType() self.toggleAll(True) if len(self.collections) == 0: self.isManualInstallation = False self.ui.radioManual.setEnabled(self.isManualInstallation) self.ui.radioAutomatic.toggle() elif len(self.collections) >= 1: self.isManualInstallation = True self.selectedCollection = self.defaultCollection if self.defaultKernelType == paeKernel: self.ui.radioPAEKernel.setEnabled(True) self.ui.radioPAEKernel.setChecked(True) else: self.ui.radioPAEKernel.setEnabled(False) self.ui.radioDefaultKernel.setChecked(True) ctx.mainScreen.disableNext() if ctx.installData.autoInstallationMethod == methodInstallAutomatic: self.ui.radioAutomatic.toggle() if ctx.installData.autoInstallationMethod == methodInstallManual: self.slotClickedManual() self.update() def execute(self): ctx.installData.autoInstallationCollection = None if self.ui.radioAutomatic.isChecked(): ctx.installData.autoInstallationMethod = methodInstallAutomatic ctx.installData.autoInstallationCollection = self.defaultCollection ctx.debugger.log("Automatic Installation selected..") else: ctx.installData.autoInstallationMethod = methodInstallManual ctx.installData.autoInstallationCollection = self.selectedCollection ctx.debugger.log("Manual Installation selected..") if self.ui.radioDefaultKernel.isChecked(): ctx.installData.autoInstallationKernel = defaultKernel elif self.ui.radioPAEtKernel.isChecked(): ctx.installData.autoInstallationKernel = paeKernel elif self.ui.radioRTKernel.isChecked(): ctx.installData.autoInstallationKernel = rtKernel ctx.debugger.log("Trying to Install selected Packages from %s Collection with %s Type" % \ (ctx.installData.autoInstallationCollection.title, kernels[ctx.installData.autoInstallationKernel])) return True #def slotCollectionItemChanged(self, current, previous): # if current: # self.collection = self.ui.collectionList.itemWidget(current).collection # ctx.debugger.log("Installation collection selected as %s" % self.collection.uniqueTag) def slotClickedAutomatic(self): self.ui.radioAutomatic.setChecked(True) self.ui.radioManual.setChecked(False) #ctx.installData.autoInstallationMethod = methodInstallAutomatic self.selectedCollection = self.defaultCollection self.collectionList.itemWidget(self.lastChoice).ui.checkToggler.setChecked(False) #self.setAutoExclusives(False) #self.lastChoice.setChecked(True) def slotClickedManual(self): self.ui.radioManual.setChecked(True) self.ui.radioAutomatic.setChecked(False) #self.setAutoExclusives(False) #ctx.installData.autoInstallationMethod = methodInstallManual self.enable_next = True self.update() def slotToggleAutomatic(self, checked): if checked: self.ui.collectionList.setEnabled(False) else: self.ui.collectionList.setEnabled(True) #self.ui.radioAutomatic.setChecked(True) #self.ui.radioManual.setChecked(False) def slotToggleManual(self, checked): if checked: self.ui.collectionList.setEnabled(True) else: self.ui.collectionList.setEnabled(False) #self.ui.radioAutomatic.setChecked(False) #self.ui.collectionList.setEnabled(True) def slotToggleDefaultKernel(self, checked): if checked: self.defaultKernelType = defaultKernel def slotTogglePAEKernel(self, checked): if checked: self.defaultKernelType = paeKernel def slotToggleRTKernel(self, checked): if checked: self.defaultKernelType = rtKernel # def setAutoExclusives(self, val=True): # self.ui.collectionList.setEnabled(val) # self.ui.radioAutomatic.setAutoExclusive(val) # self.ui.radioManual.setAutoExclusive(val) # if not val: # self.slotToggleManual(True) # else: # self.slotToggleAutomatic(True) def update(self): if self.ui.radioManual.isChecked(): self.enable_next = True if self.enable_next: ctx.mainScreen.enableNext() else: ctx.mainScreen.disableNext() def toggleAll(self, state=False): widgets = ["radioAutomatic", "radioManual"] for widget in widgets: getattr(self.ui, widget).setEnabled(state) ctx.mainScreen.processEvents()