Exemple #1
0
    def __init__(self, dev, part, rootWidget):
        QtGui.QWidget.__init__(self, ctx.mainScreen)
        self.ui = Ui_PartResizeWidget()
        self.ui.setupUi(self)
        self.rootWidget = rootWidget
        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#PartResizeWidget {
                    background-image: url(:/gui/pics/trans.png);
                }
        """)

        self.resize(ctx.mainScreen.size())
        self.dev = dev
        self.part = part
        minSize = self.part.getMinResizeMB() + 40

        if minSize == 0:
            self.ui.resizeMB.setVisible(False)
            self.ui.resizeMBSlider.setVisible(False)
            self.ui.resizeButton.setVisible(False)
            self.ui.label.setText(_("""<p><span style="color:#FFF"><b>It seems that this partition is not ready for resizing.</b></span></p>"""))
        else:
            maxSize = self.part.getMB()
            self.ui.resizeMB.setMaximum(maxSize)
            self.ui.resizeMBSlider.setMaximum(maxSize)
            self.ui.resizeMB.setMinimum(minSize)
            self.ui.resizeMBSlider.setMinimum(minSize)
            self.connect(self.ui.resizeButton, SIGNAL("clicked()"), self.slotResize)

        self.connect(self.ui.cancelButton, SIGNAL("clicked()"), self.hide)
Exemple #2
0
class ResizeWidget(QtGui.QWidget):

    def __init__(self, dev, part, rootWidget):
        QtGui.QWidget.__init__(self, ctx.mainScreen)
        self.ui = Ui_PartResizeWidget()
        self.ui.setupUi(self)
        self.rootWidget = rootWidget
        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#PartResizeWidget {
                    background-image: url(:/gui/pics/trans.png);
                }
        """)

        self.resize(ctx.mainScreen.size())
        self.dev = dev
        self.part = part
        minSize = self.part.getMinResizeMB() + 40

        if minSize == 0:
            self.ui.resizeMB.setVisible(False)
            self.ui.resizeMBSlider.setVisible(False)
            self.ui.resizeButton.setVisible(False)
            self.ui.label.setText(_("""<p><span style="color:#FFF"><b>It seems that this partition is not ready for resizing.</b></span></p>"""))
        else:
            maxSize = self.part.getMB()
            self.ui.resizeMB.setMaximum(maxSize)
            self.ui.resizeMBSlider.setMaximum(maxSize)
            self.ui.resizeMB.setMinimum(minSize)
            self.ui.resizeMBSlider.setMinimum(minSize)
            self.connect(self.ui.resizeButton, SIGNAL("clicked()"), self.slotResize)

        self.connect(self.ui.cancelButton, SIGNAL("clicked()"), self.hide)

    def slotResize(self):
        self.hide()
        ctx.yali.info.updateAndShow(_("Resizing to %s MB...") % (self.ui.resizeMB.value()))
        ctx.debugger.log("Resize started on partition %s " % self.part.getPath())
        QTimer.singleShot(500,self.res)

    def res(self):
        resizeTo = int(self.ui.resizeMB.value())
        try:
            self.dev.resizePartition(self.part._fsname, resizeTo,self.part)
        except FSCheckError, message:
            InfoDialog(unicode(message), title = _("Filesystem Error"))
            return

        _sum = {"partition":self.part.getName(),
                "currentSize":self.part.getMB(),
                "resizeTo":resizeTo,
                "fs":self.part._fsname}
        ctx.partSum.append(_("Partition <b>%(partition)s</b> (%(fs)s) has been resized to <b>%(resizeTo)s MB</b> (Old size: %(currentSize)s MB)") % _sum)

        self.rootWidget.update()
        ctx.yali.info.hide()