Ejemplo n.º 1
0
    def __setup_undo(self):
        undostack = QtWidgets.QUndoStack()

        undoaction = undostack.createUndoAction(self, "Undo")
        undoaction.pyqtConfigure(shortcut=QKeySequence.Undo,
                                 icon=icons.get(
                                     "undo", scale_factor=0.85,
                                     offset=(0, 0.1)),
                                 # icon=QIcon.fromTheme("edit-undo"),
                                 # triggered=self.undo
                                 )

        redoaction = undostack.createRedoAction(self, "Redo")
        redoaction.pyqtConfigure(shortcut=QKeySequence.Redo,
                                 icon=icons.get(
                                     "redo", scale_factor=0.85,
                                     offset=(0, 0.1)),
                                 # icon=QIcon.fromTheme("edit-redo"),
                                 # triggered=self.redo
                                 )

        # undoview = QtWidgets.QUndoView(undostack)
        # undoview.show()
        # undoview.setAttribute(Qt.WA_QuitOnClose, False)

        return undostack, undoaction, redoaction #, None# undoview
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.r_arrow = icons.get("c_right", scale_factor=0.5)
        self.ENABLED = type(self.r_arrow).Normal
        self.DISABLED = type(self.r_arrow).Disabled
        self.ON = type(self.r_arrow).On
Ejemplo n.º 3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self._owner = None
        self._model = None
        """:type: skymodman.interface.models.archivefs_treemodel.ModArchiveTreeModel"""

        self.views = {} # just a place to for them to hide from the GC
        # self._viewlist = self.views.values()
        self._widths = [120]*10

        self.setStyle(ColumnStyle(self.style()))

        # set a style to show a divider between two columns
        # (we hide the vertical scroll bar due to it being way fugly).
        # for some reason, just setting border-right didn't do anything;
        # but setting a whole border and turning the others off does work, so...
        self.setStyleSheet(
            """QColumnView QAbstractItemView {
                border: 2px solid palette(dark);
                border-left: none;
                border-top: none;
                border-bottom: none;
            }
            """)

        self._hiddeninode = -1
        self._icon = icons.get("c_right")

        self._expanded_inodes = set()
Ejemplo n.º 4
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.r_arrow = icons.get("c_right", scale_factor=0.5)
        self.ENABLED = type(self.r_arrow).Normal
        self.DISABLED = type(self.r_arrow).Disabled
        self.ON = type(self.r_arrow).On
Ejemplo n.º 5
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self._owner = None
        self._model = None
        """:type: skymodman.interface.models.archivefs_treemodel.ModArchiveTreeModel"""

        self.views = {} # just a place to for them to hide from the GC
        # self._viewlist = self.views.values()
        self._widths = [120]*10

        self.setStyle(ColumnStyle(self.style()))

        # set a style to show a divider between two columns
        # (we hide the vertical scroll bar due to it being way fugly).
        # for some reason, just setting border-right didn't do anything;
        # but setting a whole border and turning the others off does work, so...
        self.setStyleSheet(
            """QColumnView QAbstractItemView {
                border: 2px solid palette(dark);
                border-left: none;
                border-top: none;
                border-bottom: none;
            }
            """)

        self._hiddeninode = -1
        self._icon = icons.get("c_right")

        self._expanded_inodes = set()
Ejemplo n.º 6
0
    def __init__(self, owner, *args, **kwargs):
        """

        :param ArchiveFS mod_fs:
        :param undostack: QUndoStack instance to which we will push
            any actions performed by the model.
        """
        super().__init__(*args, **kwargs)

        self._fs = owner.structure # type: ArchiveFS
        self._backupfs = self._fs.mkdupefs()

        self._currentroot_inode = ArchiveFS.ROOT_INODE
        self._currentroot = self._fs.rootpath
        self._realroot = self._fs.rootpath

        # Have to keep these in the init() so that they're not
        # garbage collected (which apparently seems to delete them
        # from the entire application...)
        # color = QtGui.QPalette().color(QtGui.QPalette.WindowText)
        self.FOLDER_ICON = icons.get("folder")
        self.FOLDER_OPEN = icons.get("folder-open")
        self.FILE_ICON = icons.get("file")


        # self.FOLDER_ICON = QtGui.QIcon.fromTheme(
        #     "folder")  # type: QtGui.QIcon
        # self.FILE_ICON = QtGui.QIcon.fromTheme(
        #     "text-plain")  # type: QtGui.QIcon

        # set of unchecked inodes
        self._unchecked=set()

        # just tracking any functions with lru_caches
        self._caches=[self._sorted_dirlist, self._isdir]

        # create a 'Trash' folder to use for deletions
        # (and easy restorations)
        self._fs.mkdir("/.trash")
        self.trash = self._fs.get_path("/.trash")

        self.undostack = owner.undostack # type: QtWidgets.QUndoStack

        self._owner = owner
Ejemplo n.º 7
0
    def __init__(self, owner, *args, **kwargs):
        """

        :param ArchiveFS mod_fs:
        :param undostack: QUndoStack instance to which we will push
            any actions performed by the model.
        """
        super().__init__(*args, **kwargs)

        self._fs = owner.structure  # type: ArchiveFS
        self._backupfs = self._fs.mkdupefs()

        self._currentroot_inode = ArchiveFS.ROOT_INODE
        self._currentroot = self._fs.rootpath
        self._realroot = self._fs.rootpath

        # Have to keep these in the init() so that they're not
        # garbage collected (which apparently seems to delete them
        # from the entire application...)
        # color = QtGui.QPalette().color(QtGui.QPalette.WindowText)
        self.FOLDER_ICON = icons.get("folder")
        self.FOLDER_OPEN = icons.get("folder-open")
        self.FILE_ICON = icons.get("file")

        # self.FOLDER_ICON = QtGui.QIcon.fromTheme(
        #     "folder")  # type: QtGui.QIcon
        # self.FILE_ICON = QtGui.QIcon.fromTheme(
        #     "text-plain")  # type: QtGui.QIcon

        # set of unchecked inodes
        self._unchecked = set()

        # just tracking any functions with lru_caches
        self._caches = [self._sorted_dirlist, self._isdir]

        # create a 'Trash' folder to use for deletions
        # (and easy restorations)
        self._fs.mkdir("/.trash")
        self.trash = self._fs.get_path("/.trash")

        self.undostack = owner.undostack  # type: QtWidgets.QUndoStack

        self._owner = owner
Ejemplo n.º 8
0
    def __setup_undo(self):
        undostack = QtWidgets.QUndoStack()

        undoaction = undostack.createUndoAction(self, "Undo")
        undoaction.pyqtConfigure(
            shortcut=QKeySequence.Undo,
            icon=icons.get("undo", scale_factor=0.85, offset=(0, 0.1)),
            # icon=QIcon.fromTheme("edit-undo"),
            triggered=self.undo,
        )

        redoaction = undostack.createRedoAction(self, "Redo")
        redoaction.pyqtConfigure(
            shortcut=QKeySequence.Redo,
            icon=icons.get("redo", scale_factor=0.85, offset=(0, 0.1)),
            # icon=QIcon.fromTheme("edit-redo"),
            triggered=self.redo,
        )

        # undoview = QtWidgets.QUndoView(undostack)
        # undoview.show()
        # undoview.setAttribute(Qt.WA_QuitOnClose, False)

        return undostack, undoaction, redoaction  # , None# undoview
Ejemplo n.º 9
0
    def __init__(self, mod_fs, *args, **kwargs):
        """

        :param skymodman.utils.archivefs.ArchiveFS mod_fs: An
            instance of an ArchiveFS pseudo-filesystem.

        :param args: passed to base class constructors
        :param kwargs: passed to base class constructors
        :return:
        """
        super().__init__(*args, **kwargs)
        self.LOGGER << "init manual install dlg"

        self.setupUi(self)

        # self.resize(1200, self.height())

        self.structure = mod_fs
        self.num_to_copy = 0

        # create undo framework
        (
            self.undostack,
            self.action_undo,
            self.action_redo
            # , self.undoview
        ) = self.__setup_undo()

        # Create button overlay
        # self.main_overlay, self.tree_overlay, self.button_overlay = self.__setup_overlay()
        self.main_overlay = self.__setup_overlay()

        # initialize tree model from structure, give undostack ref
        self.modfsmodel = ModArchiveTreeModel(self)

        self.mod_structure_view.setModel(self.modfsmodel)
        self.mod_structure_view.customContextMenuRequested.connect(self.custom_context_menu)

        # set default for active_view
        self._active_view = self.mod_structure_view

        # self.mod_structure_column_view.setModel(self.modfsmodel)
        # self.mod_structure_column_view.owner = self
        # self.mod_structure_column_view.setResizeGripsVisible(False)

        # create custom context menu
        self.rclickmenu = self.__setup_context_menu()
        self.rclicked_inode = None

        ## connect actions
        self.__setup_actions()

        ## connect some more signals
        # noinspection PyUnresolvedReferences
        self.modfsmodel.rowsMoved.connect(self.check_top_level)
        # noinspection PyUnresolvedReferences
        self.modfsmodel.rowsInserted.connect(self.check_top_level)
        self.modfsmodel.folder_structure_changed.connect(self.check_top_level)

        self.mod_structure_view.setToolTip(_tree_tooltip)
        # self.mod_structure_column_view.setToolTip(_tree_tooltip)

        ## Hide the Trash folder
        self.mod_structure_view.setRowHidden(
            self.modfsmodel.row4path(self.modfsmodel.trash),
            self.mod_structure_view.rootIndex(),  # should still be "/" at this point
            True,
        )

        self._icon_ok = icons.get("status-ok")
        self._icon_notok = icons.get("status-bad")

        self.check_top_level()
Ejemplo n.º 10
0
    def __init__(self, mod_fs, *args, **kwargs):
        """

        :param skymodman.utils.archivefs.ArchiveFS mod_fs: An
            instance of an ArchiveFS pseudo-filesystem.

        :param args: passed to base class constructors
        :param kwargs: passed to base class constructors
        :return:
        """
        super().__init__(*args, **kwargs)
        self.LOGGER << "init manual install dlg"

        self.setupUi(self)

        # self.resize(1200, self.height())

        self.structure = mod_fs
        self.num_to_copy = 0

        # create undo framework
        (self.undostack
         , self.action_undo
         , self.action_redo
         # , self.undoview
         ) = self.__setup_undo()

        # Create button overlay
        # self.main_overlay, self.tree_overlay, self.button_overlay = self.__setup_overlay()
        self.main_overlay = self.__setup_overlay()

        # initialize tree model from structure, give undostack ref
        self.modfsmodel = ModArchiveTreeModel(self)

        self.mod_structure_view.setModel(self.modfsmodel)
        self.mod_structure_view.customContextMenuRequested.connect(
            self.custom_context_menu)

        # set default for active_view
        self._active_view = self.mod_structure_view

        # self.mod_structure_column_view.setModel(self.modfsmodel)
        # self.mod_structure_column_view.owner = self
        # self.mod_structure_column_view.setResizeGripsVisible(False)

        # create custom context menu
        self.rclickmenu = self.__setup_context_menu()
        self.rclicked_inode = None

        ## connect actions
        self.__setup_actions()

        ## connect some more signals
        # noinspection PyUnresolvedReferences
        self.modfsmodel.rowsMoved.connect(self.check_top_level)
        # noinspection PyUnresolvedReferences
        self.modfsmodel.rowsInserted.connect(self.check_top_level)
        self.modfsmodel.folder_structure_changed.connect(self.check_top_level)


        self.mod_structure_view.setToolTip(_tree_tooltip)
        # self.mod_structure_column_view.setToolTip(_tree_tooltip)

        ## Hide the Trash folder
        self.mod_structure_view.setRowHidden(
            self.modfsmodel.row4path(self.modfsmodel.trash),
            self.mod_structure_view.rootIndex(), # should still be "/" at this point
            True)


        self._icon_ok = icons.get("status-ok")
        self._icon_notok = icons.get("status-bad")

        self.check_top_level()