Ejemplo n.º 1
0
class UndoDock(DockWidget):

    def __init__(self, parent=None):
        DockWidget.__init__(self, "历史", parent)
        self.setObjectName("undoViewDock")
        self._undo_view = QUndoView(self)
        self._clear_icon = QIcon(":/drive-harddisk.png")

        self._undo_view.setCleanIcon(self._clear_icon)
        self._undo_view.setUniformItemSizes(True)
        self._widget = QWidget(self)
        self._layout = QVBoxLayout(self._widget)
        self._layout.setStretch(0, 0)
        self._layout.setContentsMargins(0, 6, 6, 6)
        self._layout.addWidget(self._undo_view)
        self.setWidget(self._widget)
        self.retranslateUi()

    def set_stack(self, stack: QUndoStack):
        self._undo_view.setStack(stack)

    def set_group(self, group: QUndoGroup):
        self._undo_view.setGroup(group)

    def changeEvent(self, event: QEvent) -> None:
        pass
        # if e.type():
        # self.LanguageChange
        # self.retranslateUi()

    def retranslateUi(self):
        self.setWindowTitle("历史")
        self._undo_view.setEmptyLabel("<空>")
Ejemplo n.º 2
0
class UndoDock(QDockWidget):

    def __init__(self, undoGroup, parent = None):
        super().__init__(parent)

        self.setObjectName("undoViewDock")
        self.mUndoView = QUndoView(undoGroup, self)
        cleanIcon = QIcon(":images/16x16/drive-harddisk.png")
        self.mUndoView.setCleanIcon(cleanIcon)
        self.mUndoView.setUniformItemSizes(True)
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        layout.addWidget(self.mUndoView)
        self.setWidget(widget)
        self.retranslateUi()

    def changeEvent(self, e):
        super().changeEvent(e)
        x = e.type()
        if x==QEvent.LanguageChange:
            self.retranslateUi()
        else:
            pass

    def retranslateUi(self):
        self.setWindowTitle(self.tr("History"))
        self.mUndoView.setEmptyLabel(self.tr("<empty>"))
Ejemplo n.º 3
0
class UndoDock(QDockWidget):
    def __init__(self, undoGroup, parent=None):
        super().__init__(parent)

        self.setObjectName("undoViewDock")
        self.mUndoView = QUndoView(undoGroup, self)
        cleanIcon = QIcon(":images/16x16/drive-harddisk.png")
        self.mUndoView.setCleanIcon(cleanIcon)
        self.mUndoView.setUniformItemSizes(True)
        widget = QWidget(self)
        layout = QVBoxLayout(widget)
        layout.setContentsMargins(5, 5, 5, 5)
        layout.addWidget(self.mUndoView)
        self.setWidget(widget)
        self.retranslateUi()

    def changeEvent(self, e):
        super().changeEvent(e)
        x = e.type()
        if x == QEvent.LanguageChange:
            self.retranslateUi()
        else:
            pass

    def retranslateUi(self):
        self.setWindowTitle(self.tr("History"))
        self.mUndoView.setEmptyLabel(self.tr("<empty>"))
Ejemplo n.º 4
0
    def _createUndoView(self, history):
        undoGroup = QGroupBox(_("History of changes"), self)
        undoGroupLayout = QVBoxLayout()
        undoGroup.setLayout(undoGroupLayout)

        undoView = QUndoView(history, self)
        undoView.setEmptyLabel(_("<Original file>"))
        undoGroupLayout.addWidget(undoView)

        mainLayout = self.layout()
        mainLayout.addWidget(undoGroup)
Ejemplo n.º 5
0
 def setContent(self, widget):
     self.clear()
     undoview = QUndoView(widget.history, self)
     undoview.setEmptyLabel(_("<Original file>"))
     self.layout().addWidget(undoview)