Beispiel #1
0
 def showPopup(self):
     """
     Shows the popup for this button.
     """
     as_dialog = QApplication.keyboardModifiers()
     
     anchor = self.defaultAnchor()
     if anchor:
         self.popupWidget().setAnchor(anchor)
     else:
         anchor = self.popupWidget().anchor()
     
     if ( anchor & (XPopupWidget.Anchor.BottomLeft |
                    XPopupWidget.Anchor.BottomCenter |
                    XPopupWidget.Anchor.BottomRight) ):
         pos = QPoint(self.width() / 2, 0)
     else:
         pos = QPoint(self.width() / 2, self.height())
     
     pos = self.mapToGlobal(pos)
     
     if not self.signalsBlocked():
         self.popupAboutToShow.emit()
     self._popupWidget.popup(pos)
     
     if as_dialog:
         self._popupWidget.setCurrentMode(XPopupWidget.Mode.Dialog)
Beispiel #2
0
    def showPopup(self):
        """
        Displays a custom popup widget for this system if a checkable state \
        is setup.
        """
        if not self.isCheckable():
            return super(XComboBox, self).showPopup()

        if not self.isVisible():
            return

        # update the checkable widget popup
        point = self.mapToGlobal(QPoint(0, self.height() - 1))
        popup = self.checkablePopup()
        popup.setModel(self.model())
        popup.move(point)
        popup.setFixedWidth(self.width())

        height = (self.count() * 19) + 2
        if height > 400:
            height = 400
            popup.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        else:
            popup.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)

        popup.setFixedHeight(height)
        popup.show()
        popup.raise_()
Beispiel #3
0
    def showMethodToolTip(self):
        """
        Pops up a tooltip message with the help for the object under the \
        cursor.
        
        :return     <bool> success
        """
        self.cancelCompletion()

        obj, _ = self.objectAtCursor()
        if not obj:
            return False

        docs = inspect.getdoc(obj)
        if not docs:
            return False

        # determine the cursor position
        rect = self.cursorRect()
        cursor = self.textCursor()
        point = QPoint(rect.left(), rect.top() + 18)

        QToolTip.showText(self.mapToGlobal(point), docs, self)

        return True
    def showPopup(self):
        """
        Displays the popup associated with this navigator.
        """
        nav = self.navigator()

        nav.move(self.mapToGlobal(QPoint(0, self.height())))
        nav.resize(400, 250)
        nav.show()
Beispiel #5
0
    def viewportRect(self):
        """
        Returns the QRectF that represents the visible viewport rect for the
        current view.
        
        :return     <QRectF>
        """
        w = self.width()
        h = self.height()

        vbar = self.verticalScrollBar()
        hbar = self.horizontalScrollBar()

        if vbar.isVisible():
            w -= vbar.width()
        if hbar.isVisible():
            h -= hbar.height()

        top_l = self.mapToScene(QPoint(0, 0))
        bot_r = self.mapToScene(QPoint(w, h))

        return QRectF(top_l.x(), top_l.y(),
                      bot_r.x() - top_l.x(),
                      bot_r.y() - top_l.y())
Beispiel #6
0
    def emitOptionsRequested(self, point=None):
        """
        Emitted when the option menu button is clicked provided the signals \
        are not being blocked for this widget.
        
        :param      point | <QPoint>
        """
        if self.signalsBlocked():
            return

        if not point:
            btn = self._optionsButton
            point = btn.mapToGlobal(QPoint(0, btn.height()))

        self.optionsRequested.emit(point)
Beispiel #7
0
    def startCompletion(self, force=False):
        """
        Starts a new completion popup for the current object.
        
        :return     <bool> success
        """
        # add the top level items
        tree = self.completerTree()
        if not force and tree.isVisible():
            return

        tree.clear()

        # make sure we have a valid object
        obj, remain = self.objectAtCursor()

        if obj is None:
            tree.hide()
            return

        # determine the cursor position
        rect = self.cursorRect()
        cursor = self.textCursor()
        point = QPoint(rect.left(), rect.top() + 18)

        # compare the ids since some things might overload the __eq__
        # comparator
        if id(obj) == id(self._scope):
            o_keys = obj.keys()
        elif obj is not None:
            o_keys = dir(obj)

        keys = [key for key in sorted(o_keys) if not key.startswith('_')]
        if id(obj) == id(self._scope):
            if not remain:
                return False
            else:
                keys = filter(lambda x: x.startswith(remain[0]), keys)

        if not keys:
            return False

        for key in keys:
            tree.addTopLevelItem(QTreeWidgetItem([key]))

        tree.move(self.mapToGlobal(point))
        tree.show()
        return True
Beispiel #8
0
    def filterOptions(self, text):
        """
        Filters the searched actions based on the inputed text.
        
        :param      text | <str>
        """
        if not text:
            self._completer.hide()
            self._completer.setCurrentItem(None)
            return

        # block the signals
        self._completer.setUpdatesEnabled(False)
        self._completer.blockSignals(True)

        # initialize the actions
        menu = self.parent()
        if not self._initialized:
            self.addItems([menu] + menu.findChildren(QMenu))
            self._initialized = True

        # filter the actions in the search view
        visible_count = 0
        item_count = self._completer.topLevelItemCount()
        for i in range(item_count):
            item = self._completer.topLevelItem(i)
            check = nativestring(item.text(0)).lower()
            hidden = not nativestring(text).lower() in check
            item.setHidden(hidden)
            visible_count += 1 if not hidden else 0

        # show the popup widget if it is not visible
        if not self._completer.isVisible():
            point = QPoint(-1, self.height())
            width = menu.width()
            height = menu.height() - self.height() - 1
            height = max(height, 22 * min(visible_count, 5))

            self._completer.move(self.mapToGlobal(point))
            self._completer.resize(width, height)
            self._completer.show()

        # restore signals
        self._completer.setUpdatesEnabled(True)
        self._completer.blockSignals(False)
    def showOptionsMenu(self):
        """
        Displays the options menu.  If the option menu policy is set to 
        CustomContextMenu, then the optionMenuRequested signal will be emitted,
        otherwise the default context menu will be displayed.
        """
        point = QPoint(0, self._optionsButton.height())
        global_point = self._optionsButton.mapToGlobal(point)

        # prompt the custom context menu
        if self.optionsMenuPolicy() == Qt.CustomContextMenu:
            if not self.signalsBlocked():
                self.optionsMenuRequested.emit(global_point)
            return

        # use the default context menu
        menu = XViewProfileManagerMenu(self)
        menu.exec_(global_point)
Beispiel #10
0
 def showPopup(self):
     """
     Overloads the popup method from QComboBox to display an ORB tree widget
     when necessary.
     
     :sa     setShowTreePopup
     """
     if not self.showTreePopup():
         return super(XOrbRecordBox, self).showPopup()
     
     tree = self.treePopupWidget()
     
     if tree and not tree.isVisible():
         tree.move(self.mapToGlobal(QPoint(0, self.height())))
         tree.resize(self.width(), 250)
         tree.resizeToContents()
         tree.filterItems('')
         tree.setFilteredColumns(range(tree.columnCount()))
         tree.show()
Beispiel #11
0
    def showActionToolTip(self):
        """
        Shows the tool tip of the action that is currently being hovered over.
        
        :param      action | <QAction>
        """
        if (not self.isVisible()):
            return

        geom = self.actionGeometry(self._toolTipAction)
        pos = self.mapToGlobal(QPoint(geom.left(), geom.top()))
        pos.setY(pos.y() + geom.height())

        tip = nativestring(self._toolTipAction.toolTip()).strip().strip('.')
        text = nativestring(self._toolTipAction.text()).strip().strip('.')

        # don't waste time showing the user what they already see
        if (tip == text):
            return

        QToolTip.showText(pos, self._toolTipAction.toolTip())
 def showGroupMenu( self ):
     """
     Displays the group menu to the user for modification.
     """
     group_active = self.isGroupingActive()
     group_by     = self.groupBy()
     
     menu = XMenu(self)
     menu.setTitle('Grouping Options')
     menu.setShowTitle(True)
     menu.addAction('Edit Advanced Grouping')
     
     menu.addSeparator()
     
     action = menu.addAction('No Grouping')
     action.setCheckable(True)
     action.setChecked(not group_active)
     
     action = menu.addAction('Advanced')
     action.setCheckable(True)
     action.setChecked(group_by == self.GroupByAdvancedKey and group_active)
     if ( group_by == self.GroupByAdvancedKey ):
         font = action.font()
         font.setBold(True)
         action.setFont(font)
     
     menu.addSeparator()
     
     # add dynamic options from the table schema
     tableType = self.tableType()
     if ( tableType ):
         columns = tableType.schema().columns()
         columns.sort(key = lambda x: x.displayName())
         for column in columns:
             action = menu.addAction(column.displayName())
             action.setCheckable(True)
             action.setChecked(group_by == column.displayName() and
                               group_active)
             
             if ( column.displayName() == group_by ):
                 font = action.font()
                 font.setBold(True)
                 action.setFont(font)
     
     point = QPoint(0, self.uiGroupOptionsBTN.height())
     action = menu.exec_(self.uiGroupOptionsBTN.mapToGlobal(point))
     
     if ( not action ):
         return
     elif ( action.text() == 'Edit Advanced Grouping' ):
         print 'edit advanced grouping options'
     elif ( action.text() == 'No Grouping' ):
         self.setGroupingActive(False)
         
     elif ( action.text() == 'Advanced' ):
         self.uiGroupBTN.blockSignals(True)
         self.setGroupBy(self.GroupByAdvancedKey)
         self.setGroupingActive(True)
         self.uiGroupBTN.blockSignals(False)
         
         self.refreshResults()
     
     else:
         self.uiGroupBTN.blockSignals(True)
         self.setGroupBy(nativestring(action.text()))
         self.setGroupingActive(True)
         self.uiGroupBTN.blockSignals(False)
         
         self.refreshResults()
Beispiel #13
0
    def slideIn(self, index, direction=Direction.Automatic):
        """
        Slides in the panel at the inputed index in the given
        direction for this widget.
        
        :param      index | <int>
                    direction | <XStackedWidget.Direction>
        
        :return     <bool> | success
        """
        # do not allow multiple slides while it is active
        if self._active:
            return False

        # determine the proper index to calculate
        invert = False
        if self.count() <= index:
            if not self.wrap():
                return False
            index = self.count() % index
            invert = True
        elif index < 0:
            if not self.wrap():
                return False
            index = self.count() + index
            invert = True

        # define the direction information
        if index == self.currentIndex():
            return False
        elif self.currentIndex() < index:
            if direction == XStackedWidget.Direction.Automatic:
                if self.isVerticalMode():
                    direction = XStackedWidget.Direction.BottomToTop
                else:
                    direction = XStackedWidget.Direction.RightToLeft
        else:
            if direction == XStackedWidget.Direction.Automatic:
                if self.isVerticalMode():
                    direction = XStackedWidget.Direction.TopToBottom
                else:
                    direction = XStackedWidget.Direction.LeftToRight

        # invert the animation if we are wrapping
        if invert:
            if direction == XStackedWidget.Direction.BottomToTop:
                direction = XStackedWidget.Direction.TopToBottom
            elif direction == XStackedWidget.Direction.TopToBottom:
                direction = XStackedWidget.Direction.BottomToTop
            elif direction == XStackedWidget.Direction.LeftToRight:
                direction = XStackedWidget.Direction.RightToLeft
            else:
                direction = XStackedWidget.Direction.LeftToRight

        self._active = True
        offset_x = self.frameRect().width()
        offset_y = self.frameRect().height()

        next_widget = self.widget(index)
        curr_widget = self.widget(self.currentIndex())

        next_widget.setGeometry(0, 0, offset_x, offset_y)

        if direction == XStackedWidget.Direction.BottomToTop:
            offset_x = 0
            offset_y = -offset_y
        elif direction == XStackedWidget.Direction.TopToBottom:
            offset_x = 0
        elif direction == XStackedWidget.Direction.RightToLeft:
            offset_x = -offset_x
            offset_y = 0
        elif direction == XStackedWidget.Direction.LeftToRight:
            offset_y = 0

        next_point = next_widget.pos()
        curr_point = curr_widget.pos()

        self._nextIndex = index
        self._lastIndex = self.currentIndex()
        self._lastPoint = QPoint(curr_point)

        next_widget.move(next_point.x() - offset_x, next_point.y() - offset_y)
        next_widget.raise_()
        next_widget.show()

        curr_anim = QPropertyAnimation(curr_widget, 'pos')
        curr_anim.setDuration(self.speed())
        curr_anim.setEasingCurve(self.animationType())
        curr_anim.setStartValue(curr_point)
        curr_anim.setEndValue(
            QPoint(curr_point.x() + offset_x,
                   curr_point.y() + offset_y))

        next_anim = QPropertyAnimation(next_widget, 'pos')
        next_anim.setDuration(self.speed())
        next_anim.setEasingCurve(self.animationType())
        next_anim.setStartValue(
            QPoint(next_point.x() - offset_x,
                   next_point.y() - offset_y))
        next_anim.setEndValue(next_point)

        anim_group = QParallelAnimationGroup(self)
        anim_group.addAnimation(curr_anim)
        anim_group.addAnimation(next_anim)

        anim_group.finished.connect(self._finishAnimation)
        anim_group.finished.connect(anim_group.deleteLater)
        anim_group.start()

        return True