示例#1
0
 def resizeEvent(self, event, *args, **kwargs):
     """
     When this widget is resized, it updates the sizes of the widgets
     to get the most possible space
     """
     main_widget = gUtils.getMainWidget(self, 'Library')
     self.update(selection_list=main_widget.temp_selection_list)
示例#2
0
 def hideEvent(self, *args, **kwargs):
     """
     When this widget is hidden from view, it returns the
     previous selection back to the user
     """
     main_widget = gUtils.getMainWidget(self, 'Library')
     main_widget.model.metadata[
         'selected'] = main_widget.temp_selection_list
     main_widget.model.updateViews()
     return ThumbnailViewWidget.hideEvent(self, *args, **kwargs)
示例#3
0
 def indexChanged(self):
     mode = self.currentText()
     main_widget = gUtils.getMainWidget(self, 'Library')
     model = iUtils.getModel(self)
     if mode == 'Publish':
         self.switchToPublishView(main_widget)
     elif mode == 'Thumbnail':
         self.switchToThumbnailView(main_widget, model)
     elif mode == 'Detailed':
         self.switchToDetailedView(main_widget, model)
     elif mode == 'List':
         self.switchToListView(main_widget, model)
示例#4
0
    def update(self):
        self.image_size = gUtils.getMainWidget(self, 'Library').image_size
        # update model
        try:
            self.setModel(self.model)
        except AttributeError:
            pass

        # update selected items...
        for widget in self.widget_list:
            if widget.image_widget.isSelected():
                widget.image_widget.setSelected()
            else:
                widget.image_widget.setUnselected()
示例#5
0
    def updateViews(self):
        """
        Updates all of the views, this is not attached to this model
        in any way... so I could probably just send this to a iUtils...
        """
        main_widget = gUtils.getMainWidget(self._parent_widget, 'Library')

        detailed_view = main_widget.detailed_view
        thumbnail_view = main_widget.thumbnail_view
        list_view = main_widget.list_view
        views = [detailed_view, thumbnail_view, list_view]

        for view in views:
            view.update()
示例#6
0
    def __init__(self, parent=None, model=None):
        super(DetailedViewWidget, self).__init__(parent)

        self.setStyleSheet("""
        border-width: 0px;
        border: None;
        margin: 0px;
        padding: 0px;
        """)
        # global attrs
        self.key_map = [
            'name', 'type', 'notes', 'data', 'frame', 'proxy', 'filepath'
        ]
        self._row_spacing = 15
        self._row_height = 100
        self._column_width = 100
        self._column_spacing = 5
        self._header_position = 40

        # main layout
        self.main_layout = QHBoxLayout()
        self.setLayout(self.main_layout)

        # create widgets
        self.hscrollbar = QScrollBar(Qt.Horizontal)
        self.vscrollbar = QScrollBar(Qt.Vertical)

        self.hheader = DetailedViewHorizontalHeader(self,
                                                    hscrollbar=self.hscrollbar)
        self.vheader = DetailedViewVerticalHeader(self,
                                                  vscrollbar=self.vscrollbar)
        self.main_table = DetailedViewTable(self,
                                            hscrollbar=self.hscrollbar,
                                            vscrollbar=self.vscrollbar)

        # set widget sizes
        main_widget = gUtils.getMainWidget(self, 'Library')
        self.main_layout.setSpacing(main_widget.main_splitter_handle_width)
        self.main_layout.setContentsMargins(0, 0, 0, 0)

        # add widgets to layout
        self.main_vlayout = QVBoxLayout()
        self.main_vlayout.addWidget(self.hheader)
        self.main_vlayout.addWidget(self.main_table)
        self.main_layout.addWidget(self.vheader)
        self.main_layout.addLayout(self.main_vlayout)
示例#7
0
    def mousePressEvent(self, event, *args, **kwargs):
        self.button = event.button()
        main_widget = gUtils.getMainWidget(self, 'Library')

        # set selection
        #selection_list = self.model.metadata['selected']
        if event.button() == Qt.LeftButton:

            # set initial postion for drag slider
            pos = QCursor.pos()
            self.initPos = pos
            # model.updateViews()
        elif event.button() == Qt.MiddleButton:
            self.setSelected()

        main_widget.imageClickedEvent(event, self)

        return QLabel.mousePressEvent(self, event, *args, **kwargs)
示例#8
0
    def update(self):
        # self.image_size = gUtils.getMainWidget(self, 'Library').image_size
        self.row_height = gUtils.getMainWidget(self, 'Library').image_size
        # update model
        try:
            self.setModel(self.model)
        except AttributeError:
            # model will not exist on init
            pass

        # update selected items...
        layout = self.vheader.main_layout
        for index in range(layout.count()):
            widget = layout.itemAt(index).widget()
            if widget.isSelected():
                widget.setSelected()
            else:
                widget.setUnselected()
示例#9
0
    def setSelected(self):
        """
        Updates the thumbnail size of the directory views
        """
        # set up main widget properties
        model = iUtils.getModel(self)
        self.clearUserSelection()
        self.setStyleSheet(iUtils.createThumbnailSS(self.border_width, True))
        main_widget = gUtils.getMainWidget(self, 'Library')

        scroll_bar_width = main_widget.detailed_view.vscrollbar.width()
        splitter_width = main_widget.main_splitter_handle_width
        main_widget.working_area_widget.setMinimumWidth(
            self.image_size + scroll_bar_width + splitter_width)

        main_widget.detailed_view.vheader.setMinimumWidth(self.image_size  + scroll_bar_width)

        main_widget.image_size = self.image_size
        # update models
        model.updateViews()
示例#10
0
    def selectionChanged(self, *args, **kwargs):
        """
        When the user clicks on a new location, this will update the
        views to display all of the images located in that directory
        and its subdirectories in the view
        """
        main_widget = gUtils.getMainWidget(self, 'Library')

        # get all items
        item = self.currentItem()
        children = self.getAllChildren(item, item_list=[])
        children.append(item)

        # populate views
        model = ImageListModel(
            parent_widget=self,
            filedirs_list=[item.getFileDir() for item in children])
        main_widget.model = model

        return QTreeWidget.selectionChanged(self, *args, **kwargs)
示例#11
0
 def leftMousePress():
     pos = QCursor.pos()
     init_pos = self.initPos.x()
     # mouse move distance
     mmd = init_pos - pos.x()
     activation_distance = 20
     """
     change the image to the next one in the sequence
     based off of how far the mouse moves
     @mmd: how far the mouse has moved
     @change_distance: how far the mouse has to move
         before an update is trigger
     """
     if mmd > activation_distance or mmd < -activation_distance:
         # Flip selected
         self.setSelected()
         self._activated = True
         # Activate full screen display
         main_widget = gUtils.getMainWidget(self, 'Library')
         main_widget.activateFullScreenDisplay()
示例#12
0
    def mouseMoveEvent(self, event, *args, **kwargs):
        try:
            pos = QCursor.pos()
            init_pos = self.initPos.x()
            # mouse move distance
            mmd = init_pos - pos.x()
            change_distance = 20
            if mmd > change_distance or mmd < -change_distance:
                self._activated = True
                modifiers = QApplication.keyboardModifiers()
                # Determine which image to use
                # control modifer, do single image
                if modifiers == Qt.ControlModifier:
                    # update the image
                    if mmd > change_distance:
                        self.previousImage()
                    elif mmd < -change_distance:
                        self.nextImage()
                    self.initPos = pos
                # do all images
                else:
                    # Alt modifer will toggle between all selected images and all images
                    if modifiers == Qt.AltModifier:
                        selected = True
                    else:
                        selected = False

                    # update the image
                    main_widget = gUtils.getMainWidget(self, 'Library')
                    full_screen_view = main_widget.full_screen_image
                    if mmd > change_distance:
                        full_screen_view.previousImage(selected=selected)
                    elif mmd < -change_distance:
                        full_screen_view.nextImage(selected=selected)
                    self.initPos = pos

        except AttributeError:
            # error if this is not a mmb event
            pass
        return QLabel.mouseMoveEvent(self, event, *args, **kwargs)
示例#13
0
    def getImageSize(self):
        """
        Gets the max image height/width based off of the algo here:
        https://math.stackexchange.com/questions/466198/algorithm-to-get-the-maximum-size-of-n-squares-that-fit-into-a-rectangle-with-a/466248
        """

        # get attributes
        n = len(gUtils.getMainWidget(self, 'Library').temp_selection_list)
        if n == 0:
            """
            small hack, when the widget is initializing it will try to divide by 0
            This is just a hack to force it not to make any errors... 
            """
            return 1
        x = self.width()
        y = self.height()

        # calculate offset for spacing + border widths
        image_selected_border_width = iUtils.getSetting(
            'IMAGE_SELECTED_BORDER_WIDTH')
        border_width = image_selected_border_width
        if n == 1:
            offset = border_width
        else:
            offset = (self.spacing * .5) + (border_width * .5)
        # Compute number of rows and columns, and cell size
        ratio = x / y
        ncols_float = math.sqrt(n * ratio)
        nrows_float = n / ncols_float

        # // Find best option filling the whole height
        nrows1 = math.ceil(nrows_float)
        ncols1 = math.ceil(n / nrows1)

        while nrows1 * ratio < ncols1:
            nrows1 += 1
            ncols1 = math.ceil(n / nrows1)

        cell_size1 = y / nrows1

        # Find best option filling the whole width
        ncols2 = math.ceil(ncols_float)
        nrows2 = math.ceil(n / ncols2)
        while (ncols2 < nrows2 * ratio):
            ncols2 += 1
            nrows2 = math.ceil(n / ncols2)

        cell_size2 = x / ncols2

        # Find best values
        if (cell_size1 < cell_size2):
            nrows = nrows2
            ncols = ncols2
            cell_size = cell_size2
        else:
            nrows = nrows1
            ncols = ncols1
            cell_size = cell_size1
        self.num_columns = ncols

        # something needs to happen here?
        if (ncols == 1 and nrows > 1) or (ncols > 1 and nrows == 1):
            #offset = ( n - 1 )* ((self.spacing*.5) + (border_width * .5))
            offset = ((n) * (border_width)) + 4
            #offset = border_width * 4
        cell_size -= offset

        return cell_size
示例#14
0
 def getModel(widget):
     main_widget = gUtils.getMainWidget(widget, 'Library')
     model = main_widget.model
     return model