コード例 #1
0
def _dock(pb):
    """Dock for the progress bar. Giving it a blank title bar,
        making sure to set focus back to the reviewer."""
    dock = QDockWidget()
    tWidget = QWidget()
    dock.setObjectName("pbDock")
    dock.setWidget(pb)
    dock.setTitleBarWidget( tWidget )
    
    ## Note: if there is another widget already in this dock position, we have to add ourself to the list

    # first check existing widgets
    existing_widgets = [widget for widget in mw.findChildren(QDockWidget) if mw.dockWidgetArea(widget) == dockArea]

    # then add ourselves
    mw.addDockWidget(dockArea, dock)

    # stack with any existing widgets
    if len(existing_widgets) > 0:
        mw.setDockNestingEnabled(True)

        if dockArea == Qt.TopDockWidgetArea or dockArea == Qt.BottomDockWidgetArea:
            stack_method = Qt.Vertical
        if dockArea == Qt.LeftDockWidgetArea or dockArea == Qt.RightDockWidgetArea:
            stack_method = Qt.Horizontal
        mw.splitDockWidget(existing_widgets[0], dock, stack_method)

    if qbr > 0 or pbdStyle != None:
        # Matches background for round corners.
        # Also handles background for themes' percentage text.
        mw.setPalette(palette)
    mw.web.setFocus()
    return dock
コード例 #2
0
ファイル: bar.py プロジェクト: SebastienGllmt/Anki-Addons
    def dock(barList, dockArea):
        """Dock for the progress bar. Giving it a blank title bar,
        making sure to set focus back to the reviewer."""

        if len(barList) == 0:
            return

        mw.setDockNestingEnabled(True)
        dockWidgets = [QDockWidget() for _ in barList]
        widgets = [EmptyWidget() for _ in barList]

        prevWidget = None
        existing_widgets = [widget for widget in mw.findChildren(QDockWidget) if mw.dockWidgetArea(widget) == dockArea]
        if len(existing_widgets) > 0:
            prevWidget = existing_widgets[0]

        for i, bar in enumerate(barList):
            dock = dockWidgets[i]

            tWidget = widgets[i]
            dock.setWidget(bar)
            dock.setTitleBarWidget( tWidget )
            mw.addDockWidget(dockArea, dock)
            if prevWidget == None:
                prevWidget = dock
            else:
                # Moves second dock widget on top of first dock widget
                if dockArea == Qt.TopDockWidgetArea or dockArea == Qt.BottomDockWidgetArea:
                    stack_method = Qt.Vertical
                if dockArea == Qt.LeftDockWidgetArea or dockArea == Qt.RightDockWidgetArea:
                    stack_method = Qt.Horizontal
                mw.splitDockWidget(prevWidget, dock, stack_method)
                prevWidget = dock
        mw.web.setFocus()
コード例 #3
0
ファイル: TomatoClock.py プロジェクト: purequant/Pomodore
    def setup_progressbar(self):

        dockArea = Qt.TopDockWidgetArea
        # dockArea = Qt.LeftDockWidgetArea
        # dockArea = Qt.BottomDockWidgetArea

        self.pb_w = QDockWidget(mw)
        self.pb_w.setObjectName("progress_dock")
        if not self.pb:
            self.pb = ClockProgress(mw, dockArea)
            self.pb.tomato.connect(self.on_tomato)
        else:
            self.pb.reset()

        self.pb.set_seconds(self.dlg.min * MIN_SECS)
        self.pb_w.setWidget(self.pb)
        w = QWidget(self.pb_w)
        w.setFixedHeight(self.pb.height())
        self.pb_w.setTitleBarWidget(w)
        self.pb_w.setFeatures(QDockWidget.NoDockWidgetFeatures)

        # first check existing widgets
        existing_widgets = [widget for widget in mw.findChildren(QDockWidget) if mw.dockWidgetArea(widget) == dockArea]

        # then add ourselves
        mw.addDockWidget(dockArea, self.pb_w)

        # stack with any existing widgets
        if len(existing_widgets) > 0:
            mw.setDockNestingEnabled(True)

            if dockArea == Qt.TopDockWidgetArea or dockArea == Qt.BottomDockWidgetArea:
                stack_method = Qt.Vertical
            if dockArea == Qt.LeftDockWidgetArea or dockArea == Qt.RightDockWidgetArea:
                stack_method = Qt.Horizontal
            mw.splitDockWidget(existing_widgets[0], self.pb_w, stack_method)

        mw.web.setFocus()
        self._set_style_sheet(self.pb)
コード例 #4
0
    def dockAt(self, place):
        '''
        Docks the bar at the specified place in the Anki window.
        '''
        barVisible = self._qProgressBar.isVisible()

        if self._dock is not None:
            self._dock.close()

        place = POSITION_OPTIONS[place]

        if place not in POSITION_OPTIONS:
            place = DEFAULTS['barPosition']

        if place == 'Top':
            dockArea = qt.Qt.TopDockWidgetArea
        elif place == 'Bottom':
            dockArea = qt.Qt.BottomDockWidgetArea

        self._dock = qt.QDockWidget()
        tWidget = qt.QWidget()
        self._dock.setWidget(self._qProgressBar)
        self._dock.setTitleBarWidget(tWidget)

        existingWidgets = [
            widget for widget in mw.findChildren(qt.QDockWidget)
            if mw.dockWidgetArea(widget) == dockArea
        ]
        if not existingWidgets:
            mw.addDockWidget(dockArea, self._dock)
        else:
            mw.setDockNestingEnabled(True)
            mw.splitDockWidget(existingWidgets[0], self._dock, qt.Qt.Vertical)
        mw.web.setFocus()

        self._qProgressBar.setVisible(barVisible)