Esempio n. 1
0
    def report_failed(self):
        """Show a warning message box if extension(s) could either not
        be loaded or produced errors while parsing the extension infos."""

        from PyQt5.QtCore import QCoreApplication
        import appinfo
        import qutil
        import widgets.dialog

        dlg = widgets.dialog.Dialog(
            self.mainwindow(),
            icon='warning',
            buttons=('ok',),
            title=appinfo.appname,
            message=_(
                "There were problems loading the extensions.\n"
                "The following details are also available from the "
                "Preferences dialog."))
        dlg.setMainWidget(FailedTree(self.mainwindow()))
        qutil.saveDialogSize(
            dlg, "extensions/error-dialog/size", QSize(600, 300))
        dlg.setGeometry(QStyle.alignedRect(
            Qt.RightToLeft,
            Qt.AlignCenter,
            dlg.size(),
            app.qApp.desktop().availableGeometry()))
        dlg.exec()
Esempio n. 2
0
    def _pixelPos2Value(self, pos):

        opt = QtWidgets.QStyleOptionSlider()
        self.initStyleOption(opt)

        gr = self.style().subControlRect(QStyle.CC_Slider, opt, QStyle.SC_SliderGroove, self)

        if self.orientation() == QtCore.Qt.Horizontal:
            min, max = gr.x(), gr.right()
        else:
            min, max = gr.y(), gr.bottom()

        return QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), pos - min, max - min, opt.upsideDown)
    def _get_textdoc(self, index):
        """Create the QTextDocument of an item.

        Args:
            index: The QModelIndex of the item to draw.
        """
        # FIXME we probably should do eliding here. See
        # qcommonstyle.cpp:viewItemDrawText
        # https://github.com/qutebrowser/qutebrowser/issues/118
        text_option = QTextOption()
        if self._opt.features & QStyleOptionViewItem.WrapText:
            text_option.setWrapMode(QTextOption.WordWrap)
        else:
            text_option.setWrapMode(QTextOption.ManualWrap)
        text_option.setTextDirection(self._opt.direction)
        text_option.setAlignment(QStyle.visualAlignment(
            self._opt.direction, self._opt.displayAlignment))

        if self._doc is not None:
            self._doc.deleteLater()
        self._doc = QTextDocument(self)
        self._doc.setDefaultFont(self._opt.font)
        self._doc.setDefaultTextOption(text_option)
        self._doc.setDocumentMargin(2)

        stylesheet = """
            .highlight {
                color: {{ conf.colors.completion.match.fg }};
            }
        """
        with jinja.environment.no_autoescape():
            template = jinja.environment.from_string(stylesheet)
        self._doc.setDefaultStyleSheet(template.render(conf=config.val))

        if index.parent().isValid():
            view = self.parent()
            pattern = view.pattern
            columns_to_filter = index.model().columns_to_filter(index)
            if index.column() in columns_to_filter and pattern:
                repl = r'<span class="highlight">\g<0></span>'
                text = re.sub(re.escape(pattern).replace(r'\ ', r'|'),
                              repl, self._opt.text, flags=re.IGNORECASE)
                self._doc.setHtml(text)
            else:
                self._doc.setPlainText(self._opt.text)
        else:
            self._doc.setHtml(
                '<span style="font: {};">{}</span>'.format(
                    html.escape(config.val.fonts.completion.category),
                    html.escape(self._opt.text)))
Esempio n. 4
0
File: app.py Progetto: ipapi/ipap
    def initui(self):
        self.setGeometry(
            QStyle.alignedRect(
                Qt.LeftToRight,
                Qt.AlignCenter,
                self.size(),
                self._app.desktop().availableGeometry()
            )
        )

        self.initmenubar()
        self.initoptionspanel()
        self.initinformationpanel()
        self.initlabels()
        centralwidget = self.initcentralwidget()
        self.setCentralWidget(centralwidget)
        self.statusBar()
        self.setWindowTitle("Ipap")
Esempio n. 5
0
    def pixelPosToRangeValue(self, pos):
        opt = QStyleOptionSlider()
        self.initStyleOption(opt)

        gr = self.style().subControlRect(QStyle.CC_Slider, opt,
                                         QStyle.SC_SliderGroove, self)
        sr = self.style().subControlRect(QStyle.CC_Slider, opt,
                                         QStyle.SC_SliderHandle, self)
        if self.orientation() == QtCore.Qt.Horizontal:
            slider_length = sr.width()
            slider_min = gr.x()
            slider_max = gr.right() - slider_length + 1
        else:
            slider_length = sr.height()
            slider_min = gr.y()
            slider_max = gr.bottom() - slider_length + 1

        return QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), pos - slider_min,
                                              slider_max - slider_min, opt.upsideDown)
Esempio n. 6
0
    def _get_textdoc(self, index):
        """Create the QTextDocument of an item.

        Args:
            index: The QModelIndex of the item to draw.
        """
        # FIXME we probably should do eliding here. See
        # qcommonstyle.cpp:viewItemDrawText
        text_option = QTextOption()
        if self._opt.features & QStyleOptionViewItem.WrapText:
            text_option.setWrapMode(QTextOption.WordWrap)
        else:
            text_option.setWrapMode(QTextOption.ManualWrap)
        text_option.setTextDirection(self._opt.direction)
        text_option.setAlignment(QStyle.visualAlignment(
            self._opt.direction, self._opt.displayAlignment))

        self._doc = QTextDocument(self)
        if index.parent().isValid():
            self._doc.setPlainText(self._opt.text)
        else:
            self._doc.setHtml('<b>{}</b>'.format(html.escape(self._opt.text)))
        self._doc.setDefaultFont(self._opt.font)
        self._doc.setDefaultTextOption(text_option)
        self._doc.setDefaultStyleSheet(style.get_stylesheet("""
            .highlight {
                {{ color['completion.match.fg'] }}
            }
        """))
        self._doc.setDocumentMargin(2)

        if index.column() == 0:
            marks = index.data(basecompletion.Role.marks)
            if marks is None:
                return
            for mark in marks:
                cur = QTextCursor(self._doc)
                cur.setPosition(mark[0])
                cur.setPosition(mark[1], QTextCursor.KeepAnchor)
                txt = cur.selectedText()
                cur.removeSelectedText()
                cur.insertHtml('<span class="highlight">{}</span>'.format(
                    html.escape(txt)))
    def _get_textdoc(self, index):
        """Create the QTextDocument of an item.

        Args:
            index: The QModelIndex of the item to draw.
        """
        # FIXME we probably should do eliding here. See
        # qcommonstyle.cpp:viewItemDrawText
        # https://github.com/qutebrowser/qutebrowser/issues/118
        text_option = QTextOption()
        if self._opt.features & QStyleOptionViewItem.WrapText:
            text_option.setWrapMode(QTextOption.WordWrap)
        else:
            text_option.setWrapMode(QTextOption.ManualWrap)
        text_option.setTextDirection(self._opt.direction)
        text_option.setAlignment(QStyle.visualAlignment(
            self._opt.direction, self._opt.displayAlignment))

        if self._doc is not None:
            self._doc.deleteLater()
        self._doc = QTextDocument(self)
        self._doc.setDefaultFont(self._opt.font)
        self._doc.setDefaultTextOption(text_option)
        self._doc.setDocumentMargin(2)

        if index.parent().isValid():
            view = self.parent()
            pattern = view.pattern
            columns_to_filter = index.model().columns_to_filter(index)
            if index.column() in columns_to_filter and pattern:
                pat = re.escape(pattern).replace(r'\ ', r'|')
                if self._opt.state & QStyle.State_Selected:
                    color = config.val.colors.completion.item.selected.match.fg
                else:
                    color = config.val.colors.completion.match.fg
                _Highlighter(self._doc, pat, color)
            self._doc.setPlainText(self._opt.text)
        else:
            self._doc.setHtml(
                '<span style="font: {};">{}</span>'.format(
                    html.escape(config.val.fonts.completion.category),
                    html.escape(self._opt.text)))
Esempio n. 8
0
    def _get_textdoc(self, index):
        """Create the QTextDocument of an item.

        Args:
            index: The QModelIndex of the item to draw.
        """
        # FIXME we probably should do eliding here. See
        # qcommonstyle.cpp:viewItemDrawText
        # https://github.com/The-Compiler/qutebrowser/issues/118
        text_option = QTextOption()
        if self._opt.features & QStyleOptionViewItem.WrapText:
            text_option.setWrapMode(QTextOption.WordWrap)
        else:
            text_option.setWrapMode(QTextOption.ManualWrap)
        text_option.setTextDirection(self._opt.direction)
        text_option.setAlignment(QStyle.visualAlignment(
            self._opt.direction, self._opt.displayAlignment))

        if self._doc is not None:
            self._doc.deleteLater()
        self._doc = QTextDocument(self)
        self._doc.setDefaultFont(self._opt.font)
        self._doc.setDefaultTextOption(text_option)
        self._doc.setDefaultStyleSheet(style.get_stylesheet("""
            .highlight {
                color: {{ color['completion.match.fg'] }};
            }
        """))
        self._doc.setDocumentMargin(2)

        if index.parent().isValid():
            pattern = index.model().pattern
            columns_to_filter = index.model().srcmodel.columns_to_filter
            if index.column() in columns_to_filter and pattern:
                repl = r'<span class="highlight">\g<0></span>'
                text = re.sub(re.escape(pattern).replace(r'\ ', r'.*'),
                              repl, self._opt.text, flags=re.IGNORECASE)
                self._doc.setHtml(text)
            else:
                self._doc.setPlainText(self._opt.text)
        else:
            self._doc.setHtml('<b>{}</b>'.format(html.escape(self._opt.text)))
Esempio n. 9
0
 def mouseMoveEvent(self, event):
     self.setValue(QStyle.sliderValueFromPosition(self.minimum(),
                   self.maximum(), event.x(), self.width()))
Esempio n. 10
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.save_perspective_action = None
        self.perspective_list_action = None
        self.perspective_combo_box = None
        self.dock_manager = None

        self.setupUi(self)
        self.create_actions()

        # uncomment the following line if the tab close button should be
        # a QToolButton instead of a QPushButton
        # QtAds.CDockManager.setConfigFlags(QtAds.CDockManager.configFlags() | QtAds.CDockManager.TabCloseButtonIsToolButton)

        # uncomment the following line if you want to use opaque undocking and
        # opaque splitter resizing
        #QtAds.CDockManager.setConfigFlags(QtAds.CDockManager.DefaultOpaqueConfig)

        # uncomment the following line if you want a fixed tab width that does
        # not change if the visibility of the close button changes
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.RetainTabSizeWhenCloseButtonHidden, True)

        # uncomment the following line if you don't want close button on DockArea's title bar
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.DockAreaHasCloseButton, False)

        # uncomment the following line if you don't want undock button on DockArea's title bar
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.DockAreaHasUndockButton, False)

        # uncomment the following line if you don't want tabs menu button on DockArea's title bar
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.DockAreaHasTabsMenuButton, False)

        # uncomment the following line if you don't want disabled buttons to appear on DockArea's title bar
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.DockAreaHideDisabledButtons, True)

        # uncomment the following line if you want to show tabs menu button on DockArea's title bar only when there are more than one tab and at least of them has elided title
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.DockAreaDynamicTabsMenuButtonVisibility, True)

        # uncomment the following line if you want floating container to always show application title instead of active dock widget's title
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.FloatingContainerHasWidgetTitle, False)

        # uncomment the following line if you want floating container to show active dock widget's icon instead of always showing application icon
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.FloatingContainerHasWidgetIcon, True)

        # uncomment the following line if you want a central widget in the main dock container (the dock manager) without a titlebar
        # If you enable this code, you can test it in the demo with the Calendar 0
        # dock widget.
        #QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.HideSingleCentralWidgetTitleBar, True)

        # uncomment the following line to enable focus highlighting of the dock
        # widget that has the focus
        QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.FocusHighlighting,
                                         True)

        # uncomment if you would like to enable an equal distribution of the
        # available size of a splitter to all contained dock widgets
        # QtAds.CDockManager.setConfigFlag(QtAds.CDockManager.EqualSplitOnInsertion, True)

        # Now create the dock manager and its content
        self.dock_manager = QtAds.CDockManager(self)

        # Uncomment the following line to have the old style where the dock
        # area close button closes the active tab
        # QtAds.CDockManager.setConfigFlags(QtAds.CDockManager.DockAreaHasCloseButton
        # | QtAds.CDockManager.DockAreaCloseButtonClosesTab)
        self.perspective_combo_box.activated[str].connect(
            self.dock_manager.openPerspective)

        self.create_content()
        # Default window geometry - center on screen
        self.resize(1280, 720)
        self.setGeometry(
            QStyle.alignedRect(
                Qt.LeftToRight, Qt.AlignCenter, self.frameSize(),
                QGuiApplication.primaryScreen().availableGeometry()))

        # self.restore_state()
        self.restore_perspectives()
Esempio n. 11
0
 def initUI(self):
     self.ui = loadUi(self.UIPath, self)
     self.setGeometry(
         QStyle.alignedRect(Qt.LeftToRight, Qt.AlignBottom, self.size(),
                            QApplication.desktop().availableGeometry()))
 def mousePressEvent(self, event):
     #Jump to click position
     pos = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(),
                                          event.x(), self.width())
     self.setValue(pos)
     self.mediaP.setPosition(pos)
Esempio n. 13
0
    def setup_ui(self):
        main_wrap = QVBoxLayout(self)
        main_wrap.setContentsMargins(0, 0, 0, 0)

        self.desktop_geom = qApp.desktop().availableGeometry()
        self.setFixedSize(self.desktop_geom.width() * .6,
                          self.desktop_geom.height() * .5)

        if self.device is None:
            self._dev_bar = DeviceBar(self, self.device_type)
            self._dev_bar.onDeviceUpdated.connect(self._update_device)
            self._dev_bar.onDeviceChanged.connect(self._changed_device)
            main_wrap.addWidget(self._dev_bar)
        """frm_lyt = QFormLayout()
        frm_lyt.setContentsMargins(10, 10, 10, 10)

        _label = QLabel('Script to load (optional)')
        frm_lyt.addRow(_label)

        user_script_path = QLineEdit()
        load_button = QPushButton('...')

        frm_lyt.addRow(load_button, user_script_path)

        main_wrap.addLayout(frm_lyt)"""

        # procs/spawns lists
        spawns_vbox = QVBoxLayout()

        spawns_label = QLabel('SPAWN')
        spawns_label.setFont(QFont('Anton', 20, QFont.Normal))
        spawns_vbox.addWidget(spawns_label)
        self.spawn_list = SpawnsList(device=self.device)
        self.spawn_list.onProcessSelected.connect(self._spawn_selected)
        self.spawn_list.onRefreshError.connect(self._on_spawn_error)
        spawns_vbox.addWidget(self.spawn_list)

        procs_vbox = QVBoxLayout()
        procs_label = QLabel('PROCS')
        procs_label.setFont(QFont('Anton', 20, QFont.Normal))
        procs_vbox.addWidget(procs_label)

        self.proc_list = ProcessList(device=self.device)
        self.proc_list.onProcessSelected.connect(self._pid_selected)
        self.proc_list.onRefreshError.connect(self._on_proc_error)
        procs_vbox.addWidget(self.proc_list)

        inner_hbox = QHBoxLayout()
        inner_hbox.setContentsMargins(10, 10, 10, 10)
        inner_hbox.addLayout(spawns_vbox)
        inner_hbox.addLayout(procs_vbox)

        vbox = QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)
        # vbox.addWidget(self._dev_bar)
        main_wrap.addLayout(inner_hbox)

        # center
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
Esempio n. 14
0
 def mousePressEvent(self, event):
     self.setValue(QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width()))
     self.sliderMoved.emit((event.x() / self.width()) * self.maximum())
Esempio n. 15
0
from PyQt5.QtWidgets import QGridLayout, QPushButton, QStyle

layout = QGridLayout()
iconIndex = 0

for row in range(7):
    for col in range(10):
        standardIcon = iconIndex
        layout.addWidget(QPushButton(QStyle.standardIcon(standardIcon)))
Esempio n. 16
0
 def mouseMoveEvent(self, ev):
     """ Jump to pointer position while moving """
     self.setValue(QStyle.sliderValueFromPosition(
         self.minimum(), self.maximum(), ev.x(), self.width())
     )
Esempio n. 17
0
    def paintEvent(self, e):

        super(LabeledSlider, self).paintEvent(e)

        style = self.slider.style()
        painter = QPainter(self)
        st_slider = QStyleOptionSlider()
        st_slider.initFrom(self.slider)
        st_slider.orientation = self.slider.orientation()

        length = style.pixelMetric(QStyle.PM_SliderLength, st_slider, self.slider)
        available = style.pixelMetric(QStyle.PM_SliderSpaceAvailable, st_slider, self.slider)

        for v, v_str in self.levels:

            # get the size of the label
            rect = painter.drawText(QRect(), Qt.TextDontPrint, v_str)

            if self.slider.orientation() == Qt.Horizontal:
                # I assume the offset is half the length of slider, therefore
                # + length//2
                x_loc = QStyle.sliderPositionFromValue(self.slider.minimum(),
                                                       self.slider.maximum(), v, available) + length // 2

                # left bound of the text = center - half of text width + L_margin
                left = x_loc - rect.width() // 2 + self.left_margin
                bottom = self.rect().bottom()

                # enlarge margins if clipping
                if v == self.slider.minimum():
                    if left <= 0:
                        self.left_margin = rect.width() // 2 - x_loc
                    if self.bottom_margin <= rect.height():
                        self.bottom_margin = rect.height()

                    self.layout.setContentsMargins(self.left_margin,
                                                   self.top_margin, self.right_margin,
                                                   self.bottom_margin)

                if v == self.slider.maximum() and rect.width() // 2 >= self.right_margin:
                    self.right_margin = rect.width() // 2
                    self.layout.setContentsMargins(self.left_margin,
                                                   self.top_margin, self.right_margin,
                                                   self.bottom_margin)

            else:
                y_loc = QStyle.sliderPositionFromValue(self.slider.minimum(),
                                                       self.slider.maximum(), v, available, upsideDown=True)

                bottom = y_loc + length // 2 + rect.height() // 2 + self.top_margin - 3
                # there is a 3 px offset that I can't attribute to any metric

                left = self.left_margin - rect.width()
                if left <= 0:
                    self.left_margin = rect.width() + 2
                    self.layout.setContentsMargins(self.left_margin,
                                                   self.top_margin, self.right_margin,
                                                   self.bottom_margin)

            pos = QPoint(left, bottom)
            painter.setFont(QFont("times", 12))
            painter.drawText(pos, v_str)

        return
Esempio n. 18
0
    def drawControl(
        self,
        element: QStyle.ControlElement,
        opt: Union[QStyleOption, QStyleOptionToolButton],
        p: QPainter,
        widget: QWidget,
    ):
        if element == QStyle.CE_ToolButtonLabel:
            toolbutton = opt
            rect = toolbutton.rect
            shift_x = 0
            shift_y = 0
            if toolbutton.state & (QStyle.State_Sunken | QStyle.State_On):  # type: ignore
                shift_x = super(TTToolButtonStyle, self).pixelMetric(
                    QStyle.PM_ButtonShiftHorizontal, toolbutton, widget
                )
                shift_y = super(TTToolButtonStyle, self).pixelMetric(
                    QStyle.PM_ButtonShiftVertical, toolbutton, widget
                )
            has_arrow = bool(toolbutton.features & QStyleOptionToolButton.Arrow)  # type: ignore

            if (
                (not has_arrow and toolbutton.icon.isNull()) and toolbutton.text  # type: ignore
            ) or toolbutton.toolButtonStyle == QtCore.Qt.ToolButtonTextOnly:  # type: ignore
                alignment = (
                    QtCore.Qt.AlignTop
                    | QtCore.Qt.AlignHCenter
                    | QtCore.Qt.TextShowMnemonic
                )
                if not self.proxy().styleHint(QStyle.SH_UnderlineShortcut, opt, widget):
                    alignment |= QtCore.Qt.TextHideMnemonic
                rect.translate(shift_x, shift_y)
                p.setFont(toolbutton.font)  # type: ignore
                self.proxy().drawItemText(
                    p,
                    rect,
                    alignment,
                    toolbutton.palette,
                    bool(opt.state & QStyle.State_Enabled),  # type: ignore
                    toolbutton.text,  # type: ignore
                    QPalette.ButtonText,
                )
            else:
                pm = QPixmap()
                pm_size = toolbutton.iconSize  # type: ignore
                if not toolbutton.icon.isNull():  # type: ignore
                    state = (
                        QIcon.On if (toolbutton.state & QStyle.State_On) else QIcon.Off  # type: ignore
                    )
                    mode = QIcon().Mode
                    if not toolbutton.state & QStyle.State_Enabled:  # type: ignore
                        mode = QIcon.Disabled
                    elif (opt.state & QStyle.State_MouseOver) and (  # type: ignore
                        opt.state & QStyle.State_AutoRaise
                    ):
                        mode = QIcon.Active
                    else:
                        mode = QIcon.Normal
                    pm = toolbutton.icon.pixmap(  # type: ignore
                        toolbutton.rect.size().boundedTo(toolbutton.iconSize),  # type: ignore
                        mode,
                        state,
                    )

                    pm_size = pm.size()

                if toolbutton.toolButtonStyle != QtCore.Qt.ToolButtonIconOnly:  # type: ignore
                    p.setFont(toolbutton.font)  # type: ignore
                    pr = QtCore.QRect(rect)
                    tr = QtCore.QRect(rect)
                    alignment = QtCore.Qt.TextShowMnemonic
                    if not self.proxy().styleHint(
                        QStyle.SH_UnderlineShortcut, opt, widget
                    ):
                        alignment |= QtCore.Qt.TextHideMnemonic
                    if toolbutton.toolButtonStyle == QtCore.Qt.ToolButtonTextUnderIcon:  # type: ignore

                        pr.setHeight(pm_size.height() + 6)
                        tr.adjust(0, pr.height() - 1, 0, -2)
                        pr.translate(shift_x, shift_y)

                        if not has_arrow:
                            self.proxy().drawItemPixmap(
                                p,
                                pr,
                                int(QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter),
                                pm,
                            )
                        alignment |= int(QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter)

                    else:
                        pr.setWidth(pm_size.width() + 8)
                        tr.adjust(pr.width(), 0, 0, 0)
                        pr.translate(shift_x, shift_y)
                        if not has_arrow:
                            self.proxy().drawItemPixmap(
                                p,
                                QStyle.visualRect(opt.direction, rect, pr),
                                QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter,
                                pm,
                            )
                        alignment |= int(QtCore.Qt.AlignTop) | int(
                            QtCore.Qt.AlignHCenter
                        )
                    tr.translate(shift_x, shift_y)
                    self.proxy().drawItemText(
                        p,
                        QStyle.visualRect(opt.direction, rect, tr),
                        alignment,
                        toolbutton.palette,
                        bool(toolbutton.state & QStyle.State_Enabled),  # type: ignore
                        toolbutton.text,  # type: ignore
                        QPalette.ButtonText,
                    )
                else:
                    rect.translate(shift_x, shift_y)

                    if not has_arrow:
                        self.proxy().drawItemPixmap(
                            p, rect, QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter, pm
                        )
            return
        super(TTToolButtonStyle, self).drawControl(element, opt, p, widget)
Esempio n. 19
0
    def initThumbs(self) -> None:
        framesize = self.parent.videoService.framesize()

        thumbsize = QSize(
            VideoService.config.thumbnails['TIMELINE'].height() *
            (framesize.width() / framesize.height()),
            VideoService.config.thumbnails['TIMELINE'].height())
        positions, frametimes = [], []
        thumbs = int(
            math.ceil(
                (self.rect().width() - (self.offset * 2)) / thumbsize.width()))
        for pos in range(thumbs):
            val = QStyle.sliderValueFromPosition(
                self.minimum(), self.maximum(),
                (thumbsize.width() * pos) - self.offset,
                self.rect().width() - (self.offset * 2))
            positions.append(val)
        positions[0] = 1000
        [
            frametimes.append(
                self.parent.delta2QTime(msec).toString(self.parent.timeformat))
            for msec in positions
        ]

        class ThumbWorker(QObject):
            completed = pyqtSignal(list)

            def __init__(self, settings: QSettings, media: str, times: list,
                         size: QSize):
                super(ThumbWorker, self).__init__()
                self.settings = settings
                self.media = media
                self.times = times
                self.size = size

            @pyqtSlot()
            def generate(self):
                frames = list()
                [
                    frames.append(
                        VideoService.captureFrame(self.settings, self.media,
                                                  frame, self.size))
                    for frame in self.times
                ]

                self.completed.emit(frames)

        self.thumbsThread = QThread(self)
        self.thumbsWorker = ThumbWorker(self.parent.settings,
                                        self.parent.currentMedia, frametimes,
                                        thumbsize)
        self.thumbsWorker.moveToThread(self.thumbsThread)
        self.thumbsThread.started.connect(self.parent.sliderWidget.setLoader)
        self.thumbsThread.started.connect(self.thumbsWorker.generate)
        self.thumbsThread.finished.connect(self.thumbsThread.deleteLater,
                                           Qt.DirectConnection)
        self.thumbsWorker.completed.connect(self.buildTimeline)
        self.thumbsWorker.completed.connect(self.thumbsWorker.deleteLater,
                                            Qt.DirectConnection)
        self.thumbsWorker.completed.connect(self.thumbsThread.quit,
                                            Qt.DirectConnection)
        self.thumbsThread.start()
Esempio n. 20
0
from PyQt5.QtWidgets import QApplication
from PyQt5.QtGui import QFontDatabase
from PyQt5.QtWidgets import QStyle
from PyQt5.QtCore import Qt

import Environment
from MainWindow import MainWindow

if __name__ == '__main__':
    logging.basicConfig(
        level=logging.DEBUG,
        format=
        '%(asctime)s - %(levelname)s - %(module)s - %(funcName)s - %(lineno)d - %(message)s'
    )

    app = QApplication(sys.argv)
    app.setStyleSheet("""
        QPushButton{
            outline: none
        }
    """)
    QFontDatabase.addApplicationFont(
        os.path.join(Environment.Resources.path(), "fonts", "Roboto",
                     "Roboto-Bold.ttf"))
    window = MainWindow()
    window.setGeometry(
        QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, window.size(),
                           app.desktop().availableGeometry()))
    window.show()
    sys.exit(app.exec_())
 def mouseMoveEvent(self, event):
     #Jump to pointer position while moving
     pos = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(),
                                          event.x(), self.width())
     self.setValue(pos)
     self.mediaP.setPosition(pos)
Esempio n. 22
0
 def mousePressEvent(self, ev):
     """ Jump to click position """
     value = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(),
                                            ev.y(), self.height(), True)
     self.setValue(value)
     self.change_volume(value)
Esempio n. 23
0
def UpdateObjectName(style: QStyle, widget: QWidget, objectName: str):
    widget.setObjectName(objectName)
    style.unpolish(widget)
    style.polish(widget)
Esempio n. 24
0
 def mouseMoveEvent(self, ev):
     """ Jump to pointer position while moving """
     value = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(),
                                            ev.y(), self.height(), True)
     self.setValue(value)
     self.change_volume(value)
Esempio n. 25
0
 def mouseMoveEvent(self, event):
     self.setValue(
         QStyle.sliderValueFromPosition(self.minimum(), self.maximum(),
                                        event.x(), self.width()))
     self.sliderMoved.emit((event.x() / self.width()) * self.maximum())
Esempio n. 26
0
	def mousePressEvent(self, ev):
		""" Jump to click position """
		self.setValue(QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), ev.x(), self.width()))
Esempio n. 27
0
 def mouseMoveEvent(self, event):
     if event.buttons() == Qt.LeftButton:
         ui.mediaPlayer.setPosition(
             QStyle.sliderValueFromPosition(self.minimum(), self.maximum(),
                                            event.x(), self.width()))
Esempio n. 28
0
	def mouseMoveEvent(self, ev):
		""" Jump to pointer position while moving """
		self.setValue(QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), ev.x(), self.width()))
Esempio n. 29
0
 def mousePressEvent(self, event):
     progress = QStyle.sliderValueFromPosition(self.minimum(), self.maximum(), event.x(), self.width())
     self.setValue(progress)
     self.should_change_video_position.emit(float(progress) / 1000.0)
Esempio n. 30
0
    def __init__(self, parent=None):
        super(WelcomeDialog, self).__init__(parent=parent)

        self._prefs = parent.prefs

        self._sub_titles = [
            ['duck', 'dumb', 'doctor', 'dutch', 'dark', 'dirty'],
            ['warriors', 'wardrobes', 'waffles', 'wishes'],
            ['are', 'aren\'t', 'ain\'t', 'appears to be'],
            ['rich', 'real', 'riffle', 'retarded', 'rock'],
            ['as f**k', 'fancy', 'f****d', 'front-ended', 'falafel', 'french fries'],
        ]

        self._recent_list_model = QStandardItemModel(0, 6)
        self._recent_list_model.setHeaderData(0, Qt.Horizontal, 'Path')
        self._recent_list_model.setHeaderData(1, Qt.Horizontal, 'Session')
        self._recent_list_model.setHeaderData(1, Qt.Horizontal, Qt.AlignCenter, Qt.TextAlignmentRole)
        self._recent_list_model.setHeaderData(2, Qt.Horizontal, 'Hooks')
        self._recent_list_model.setHeaderData(2, Qt.Horizontal, Qt.AlignCenter, Qt.TextAlignmentRole)
        self._recent_list_model.setHeaderData(3, Qt.Horizontal, 'Watchers')
        self._recent_list_model.setHeaderData(3, Qt.Horizontal, Qt.AlignCenter, Qt.TextAlignmentRole)
        self._recent_list_model.setHeaderData(4, Qt.Horizontal, 'OnLoads')
        self._recent_list_model.setHeaderData(4, Qt.Horizontal, Qt.AlignCenter, Qt.TextAlignmentRole)
        self._recent_list_model.setHeaderData(5, Qt.Horizontal, 'Bookmarks')
        self._recent_list_model.setHeaderData(5, Qt.Horizontal, Qt.AlignCenter, Qt.TextAlignmentRole)
        #self._recent_list_model.setHeaderData(6, Qt.Horizontal, 'Custom script')
        #self._recent_list_model.setHeaderData(6, Qt.Horizontal, Qt.AlignCenter, Qt.TextAlignmentRole)

        self._recent_list = DwarfListView(self)
        self._recent_list.setModel(self._recent_list_model)

        self._recent_list.header().setSectionResizeMode(0, QHeaderView.ResizeToContents | QHeaderView.Interactive)
        self._recent_list.header().setSectionResizeMode(1, QHeaderView.Stretch)
        self._recent_list.header().setSectionResizeMode(2, QHeaderView.Stretch)
        self._recent_list.header().setSectionResizeMode(3, QHeaderView.Stretch)
        self._recent_list.header().setSectionResizeMode(4, QHeaderView.Stretch)
        self._recent_list.header().setSectionResizeMode(5, QHeaderView.Stretch)
        #self._recent_list.header().setSectionResizeMode(6, QHeaderView.Stretch)

        self._recent_list.setContextMenuPolicy(Qt.CustomContextMenu)
        self._recent_list.customContextMenuRequested.connect(self._on_recent_sessions_context_menu)
        self._recent_list.doubleClicked.connect(self._on_recent_session_double_click)

        # setup size and remove/disable titlebuttons
        self.desktop_geom = qApp.desktop().availableGeometry()
        self.setFixedSize(self.desktop_geom.width() * .45, self.desktop_geom.height() * .38)
        self.setGeometry(QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry()))
        self.setSizeGripEnabled(False)
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setWindowFlag(Qt.WindowContextHelpButtonHint, False)
        self.setWindowFlag(Qt.WindowCloseButtonHint, True)
        self.setModal(True)

        # setup ui elements
        self.setup_ui()

        self.update_commits_thread = DwarfCommitsThread(parent)
        self.update_commits_thread.on_update_available.connect(self._on_dwarf_isupdate)
        self.update_commits_thread.start()
        # center
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(), qApp.desktop().availableGeometry()))
Esempio n. 31
0
    def __init__(self, parent=None):
        super(WelcomeDialog, self).__init__(parent=parent)

        self._prefs = parent.prefs

        self._sub_titles = [
            ['duck', 'dumb', 'doctor', 'dutch', 'dark', 'dirty', 'debugging'],
            ['warriors', 'wardrobes', 'waffles', 'wishes', 'worcestershire'],
            ['are', 'aren\'t', 'ain\'t', 'appears to be'],
            ['rich', 'real', 'riffle', 'retarded', 'rock'],
            [
                'as f**k', 'fancy', 'f****d', 'front-ended', 'falafel',
                'french fries'
            ],
        ]

        self._update_thread = None

        # setup size and remove/disable titlebuttons
        self.desktop_geom = qApp.desktop().availableGeometry()
        self.setFixedSize(self.desktop_geom.width() * .45,
                          self.desktop_geom.height() * .4)
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
        self.setSizeGripEnabled(False)
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        self.setWindowFlag(Qt.WindowContextHelpButtonHint, False)
        self.setWindowFlag(Qt.WindowCloseButtonHint, True)
        self.setModal(True)

        self._recent_list_model = QStandardItemModel(0, 2)
        self._recent_list_model.setHeaderData(0, Qt.Horizontal, 'Type')
        self._recent_list_model.setHeaderData(1, Qt.Horizontal, 'Path')

        self._recent_list = DwarfListView(self)
        self._recent_list.setModel(self._recent_list_model)

        self._recent_list.header().setSectionResizeMode(
            0, QHeaderView.ResizeToContents)
        self._recent_list.header().setSectionResizeMode(1, QHeaderView.Stretch)

        # setup ui elements
        self.setup_ui()

        random.seed(a=None, version=2)

        self._base_path = getattr(sys, '_MEIPASS',
                                  os.path.dirname(os.path.abspath(__file__)))
        path_to_gitignore = os.path.join(self._base_path, os.pardir, os.pardir,
                                         '.gitignore')
        is_git_version = os.path.exists(path_to_gitignore)

        if is_git_version and os.path.isfile(path_to_gitignore):
            self.update_commits_thread = DwarfCommitsThread(parent)
            self.update_commits_thread.on_update_available.connect(
                self._on_dwarf_isupdate)
            self.update_commits_thread.start()

        # center
        self.setGeometry(
            QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                               qApp.desktop().availableGeometry()))
Esempio n. 32
0
 def mousePressEvent(self, ev):
     """ Jump to click position """
     self.setValue(QStyle.sliderValueFromPosition(
         self.minimum(), self.maximum(), ev.x(), self.width())
     )