class UndoViewer(QDockWidget): """A dockwidget able to view the entire undo history of given undo stack. """ def __init__(self): super(UndoViewer, self).__init__() self.setObjectName("Undo Viewer dock widget") self.setWindowTitle("Undo Viewer") # main undo view self.view = QUndoView() self.view.setCleanIcon(QIcon("icons/clean_undo_state.png")) # root widget and layout contentsWidget = QWidget() contentsLayout = QVBoxLayout() contentsWidget.setLayout(contentsLayout) margins = contentsLayout.contentsMargins() margins.setTop(0) contentsLayout.setContentsMargins(margins) contentsLayout.addWidget(self.view) self.setWidget(contentsWidget) def setUndoStack(self, stack): self.view.setStack(stack) # if stack is None this effectively disables the entire dock widget to improve UX self.setEnabled(stack is not None)
def __init__(self, iconDirectory, widgetToFocus, parent=None, flags=Qt.WindowFlags()): """ TOWRITE :param `iconDirectory`: TOWRITE :type `iconDirectory`: QString :param `widgetToFocus`: TOWRITE :type `widgetToFocus`: `QWidget`_ :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ :param `flags`: TOWRITE :type `flags`: Qt.WindowFlags """ super(UndoEditor, self).__init__(parent, flags) self.iconDir = iconDirectory self.iconSize = 16 self.setMinimumSize(100, 100) self.undoGroup = QUndoGroup(self) self.undoView = QUndoView(self.undoGroup, self) self.undoView.setEmptyLabel(self.tr("New")) self.undoView.setCleanIcon(QIcon(self.iconDir + os.sep + "new.png")) # TODO: new.png for new drawings, open.png for opened drawings, save.png for saved/cleared drawings? self.setWidget(self.undoView) self.setWindowTitle(self.tr("History")) self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.setFocusProxy(widgetToFocus) self.undoView.setFocusProxy(widgetToFocus)
def __init__(self): super(UndoViewer, self).__init__() self.setObjectName("Undo Viewer dock widget") self.setWindowTitle("Undo Viewer") # main undo view self.view = QUndoView() self.view.setCleanIcon(QIcon("icons/clean_undo_state.png")) # root widget and layout contentsWidget = QWidget() contentsLayout = QVBoxLayout() contentsWidget.setLayout(contentsLayout) margins = contentsLayout.contentsMargins() margins.setTop(0) contentsLayout.setContentsMargins(margins) contentsLayout.addWidget(self.view) self.setWidget(contentsWidget)
def __init__(self, iconDirectory, widgetToFocus, parent=None, flags=Qt.WindowFlags()): """ TOWRITE :param `iconDirectory`: TOWRITE :type `iconDirectory`: QString :param `widgetToFocus`: TOWRITE :type `widgetToFocus`: QWidget :param `parent`: TOWRITE :type `parent`: QWidget :param `flags`: TOWRITE :type `flags`: Qt.WindowFlags """ super(UndoEditor, self).__init__(parent, flags) self.iconDir = iconDirectory self.iconSize = 16 self.setMinimumSize(100, 100) self.undoGroup = QUndoGroup(self) self.undoView = QUndoView(self.undoGroup, self) self.undoView.setEmptyLabel(self.tr("New")) self.undoView.setCleanIcon( QIcon(self.iconDir + os.sep + "new.png") ) # TODO: new.png for new drawings, open.png for opened drawings, save.png for saved/cleared drawings? self.setWidget(self.undoView) self.setWindowTitle(self.tr("History")) self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.setFocusProxy(widgetToFocus) self.undoView.setFocusProxy(widgetToFocus)
class UndoEditor(QDockWidget): """ Subclass of `QDockWidget`_ TOWRITE .. sphinx_generate_methods_summary:: UndoEditor """ def __init__(self, iconDirectory, widgetToFocus, parent=None, flags=Qt.WindowFlags()): """ TOWRITE :param `iconDirectory`: TOWRITE :type `iconDirectory`: QString :param `widgetToFocus`: TOWRITE :type `widgetToFocus`: `QWidget`_ :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ :param `flags`: TOWRITE :type `flags`: Qt.WindowFlags """ super(UndoEditor, self).__init__(parent, flags) self.iconDir = iconDirectory self.iconSize = 16 self.setMinimumSize(100, 100) self.undoGroup = QUndoGroup(self) self.undoView = QUndoView(self.undoGroup, self) self.undoView.setEmptyLabel(self.tr("New")) self.undoView.setCleanIcon( QIcon(self.iconDir + os.sep + "new.png") ) # TODO: new.png for new drawings, open.png for opened drawings, save.png for saved/cleared drawings? self.setWidget(self.undoView) self.setWindowTitle(self.tr("History")) self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.setFocusProxy(widgetToFocus) self.undoView.setFocusProxy(widgetToFocus) def addStack(self, stack): """ TOWRITE :param `stack`: TOWRITE :type `stack`: `QUndoStack`_ """ self.undoGroup.addStack(stack) def canUndo(self): """TOWRITE""" return self.undoGroup.canUndo() def canRedo(self): """TOWRITE""" return self.undoGroup.canRedo() def undoText(self): """TOWRITE""" return self.undoGroup.undoText() def redoText(self): """TOWRITE""" return self.undoGroup.redoText() def undo(self): """TOWRITE""" self.undoGroup.undo() def redo(self): """TOWRITE""" self.undoGroup.redo()
class UndoEditor(QDockWidget): """ Subclass of `QDockWidget`_ TOWRITE .. sphinx_generate_methods_summary:: UndoEditor """ def __init__(self, iconDirectory, widgetToFocus, parent=None, flags=Qt.WindowFlags()): """ TOWRITE :param `iconDirectory`: TOWRITE :type `iconDirectory`: QString :param `widgetToFocus`: TOWRITE :type `widgetToFocus`: `QWidget`_ :param `parent`: Pointer to a parent widget instance. :type `parent`: `QWidget`_ :param `flags`: TOWRITE :type `flags`: Qt.WindowFlags """ super(UndoEditor, self).__init__(parent, flags) self.iconDir = iconDirectory self.iconSize = 16 self.setMinimumSize(100, 100) self.undoGroup = QUndoGroup(self) self.undoView = QUndoView(self.undoGroup, self) self.undoView.setEmptyLabel(self.tr("New")) self.undoView.setCleanIcon(QIcon(self.iconDir + os.sep + "new.png")) # TODO: new.png for new drawings, open.png for opened drawings, save.png for saved/cleared drawings? self.setWidget(self.undoView) self.setWindowTitle(self.tr("History")) self.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea) self.setFocusProxy(widgetToFocus) self.undoView.setFocusProxy(widgetToFocus) def addStack(self, stack): """ TOWRITE :param `stack`: TOWRITE :type `stack`: `QUndoStack`_ """ self.undoGroup.addStack(stack) def canUndo(self): """TOWRITE""" return self.undoGroup.canUndo() def canRedo(self): """TOWRITE""" return self.undoGroup.canRedo() def undoText(self): """TOWRITE""" return self.undoGroup.undoText() def redoText(self): """TOWRITE""" return self.undoGroup.redoText() def undo(self): """TOWRITE""" self.undoGroup.undo() def redo(self): """TOWRITE""" self.undoGroup.redo()