def __init__(self, parent): QtGui.QWidget.__init__(self, ctx.mainScreen) self.parent = parent self.ui = Ui_PartShrinkWidget() self.ui.setupUi(self) self.setStyleSheet(""" QSlider::groove:horizontal { border: 1px solid #999999; height: 12px; background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4); margin: 2px 0; } QSlider::handle:horizontal { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); border: 1px solid #5c5c5c; width: 18px; margin: 0 0; border-radius: 2px; } QFrame#mainFrame { background-image: url(:/gui/pics/transBlack.png); border: 1px solid #BBB; border-radius:8px; } QWidget#Ui_PartShrinkWidget { background-image: url(:/gui/pics/trans.png); } """) self.operations = [] QObject.connect(self.ui.partitions, SIGNAL("currentRowChanged(int)"), self.updateSpin) self.connect(self.ui.shrinkButton, SIGNAL("clicked()"), self.slotShrink) self.connect(self.ui.cancelButton, SIGNAL("clicked()"), self.hide) self.fillPartitions()
class ShrinkWidget(QtGui.QWidget): def __init__(self, parent): QtGui.QWidget.__init__(self, ctx.mainScreen) self.parent = parent self.ui = Ui_PartShrinkWidget() self.ui.setupUi(self) self.setStyleSheet(""" QSlider::groove:horizontal { border: 1px solid #999999; height: 12px; background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4); margin: 2px 0; } QSlider::handle:horizontal { background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f); border: 1px solid #5c5c5c; width: 18px; margin: 0 0; border-radius: 2px; } QFrame#mainFrame { background-image: url(:/gui/pics/transBlack.png); border: 1px solid #BBB; border-radius:8px; } QWidget#Ui_PartShrinkWidget { background-image: url(:/gui/pics/trans.png); } """) self.operations = [] QObject.connect(self.ui.partitions, SIGNAL("currentRowChanged(int)"), self.updateSpin) self.connect(self.ui.shrinkButton, SIGNAL("clicked()"), self.slotShrink) self.connect(self.ui.cancelButton, SIGNAL("clicked()"), self.hide) self.fillPartitions() def check(self): return self.ui.partitions.count() == 0 def fillPartitions(self): biggest = -1 i = -1 for partition in self.parent.storage.partitions: if not partition.exists: continue if partition.resizable and partition.format.resizable: entry = PartitionItem(self.ui.partitions, partition) i += 1 if biggest == -1: biggest = i else: current = self.ui.partitions.item(biggest).partition if partition.format.targetSize > current.format.targetSize: biggest = i if biggest > -1: self.ui.partitions.setCurrentRow(biggest) def updateSpin(self, index): request = self.ui.partitions.item(index).partition try: reqlower = long(math.ceil(request.format.minSize)) except FilesystemError, msg: raise GUIError, msg else: