Exemplo n.º 1
0
 def getConfig(self, level=None, exclude=[]):
     self._debug("Getting config for level {}".format(level))
     self._debug("Exclude keys: {}".format(exclude))
     cursor = QtGui.QCursor(Qt.WaitCursor)
     self.setCursor(cursor)
     data = {'system': {}, 'user': {}, 'n4d': {}}
     self._debug("Refresh: {}".format(self.refresh))
     self._debug("Changes: {}".format(self.changes))
     if self.refresh or self.changes:
         if level:
             data = self.appConfig.getConfig(level, exclude)
         else:
             data = self.appConfig.getConfig('system', exclude)
             #				self._debug("Data: %s"%data)
             self.level = data['system'].get('config', 'user')
             if self.level != 'system':
                 data = self.appConfig.getConfig(self.level, exclude)
                 level = data[self.level].get('config', 'n4d')
                 if level != self.level:
                     self.level = level
                     data = self.appConfig.getConfig(level, exclude)
                     data[self.level]['config'] = self.level
     else:
         if self.config[self.level]:
             data[self.level] = self.config[self.level].copy()
     self._debug("Read level from config: {}".format(self.level))
     self.refresh = False
     cursor = QtGui.QCursor(Qt.PointingHandCursor)
     self.setCursor(cursor)
     return (data)
Exemplo n.º 2
0
    def Top_Buttons(self):

        button_height = 35
        button_h_offset = 20
        button_width = (self.attribute_viewer.width()) / 2 - button_h_offset

        font = QtGui.QFont()
        font.setPointSize(15)

        self.Add_Variable = QtWidgets.QLabel(self.attribute_viewer)
        self.Add_Variable.setObjectName("Add@Attr_Variable")
        self.Add_Variable.setGeometry(
            QtCore.QRect(button_h_offset, 45, button_width, button_height))
        self.Add_Variable.setFrameStyle(QtWidgets.QFrame.Panel
                                        | QtWidgets.QFrame.Raised)
        self.Add_Variable.setText("Add Variable")
        self.Add_Variable.setAlignment(QtCore.Qt.AlignCenter)
        self.Add_Variable.setFont(font)
        self.Add_Variable.setCursor(QtGui.QCursor(
            QtCore.Qt.PointingHandCursor))

        self.Add_Group = QtWidgets.QLabel(self.attribute_viewer)
        self.Add_Group.setObjectName("Add@Attr_Group")
        self.Add_Group.setGeometry(
            QtCore.QRect(button_h_offset + button_width, 45, button_width,
                         button_height))
        self.Add_Group.setFrameStyle(QtWidgets.QFrame.Panel
                                     | QtWidgets.QFrame.Raised)
        self.Add_Group.setText("Add Group")
        self.Add_Group.setAlignment(QtCore.Qt.AlignCenter)
        self.Add_Group.setFont(font)
        self.Add_Group.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
Exemplo n.º 3
0
    def getMapCursor(self):

        # PySide and Shiboken APIs were updated in
        # Maya 2017, so the correct versions must be
        # imported based on the Maya API version.
        mayaVersion = cmds.about(apiVersion=True)

        if mayaVersion >= 201700:

            # Import Qt libraries.
            from PySide2 import QtGui, QtCore, QtWidgets
            from shiboken2 import wrapInstance

            # Get the map image as a Qt widget.
            ptr = omui.MQtUtil.findControl(self.map)
            map =  wrapInstance(long(ptr), QtWidgets.QWidget)

            # Transform the cursor into map widget space.
            cursor = QtGui.QCursor().pos()
            return map.mapFromGlobal(cursor)

        else:

            # Import Qt libraries.
            from PySide import QtGui, QtCore
            from shiboken import wrapInstance

            # Get the map image as a Qt widget.
            ptr = omui.MQtUtil.findControl(self.map)
            map = wrapInstance(long(ptr), QtGui.QWidget)

            # Transform the cursor into map widget space.
            cursor = QtGui.QCursor().pos()
            return map.mapFromGlobal(cursor)
Exemplo n.º 4
0
 def _updateRepos(self):
     cursor = QtGui.QCursor(Qt.WaitCursor)
     self.setCursor(cursor)
     self._debug("Updating repos")
     ret = self.appConfig.n4dQuery("RepoManager", "update_repos")
     errList = []
     for line in ret.split("\n"):
         if line.startswith("E: ") or line.startswith("W:"):
             for name, data in self.defaultRepos.items():
                 for repoLine in data.get('repos', []):
                     repoItems = repoLine.split(" ")
                     if repoItems:
                         if repoItems[0] in line:
                             if "NODATA" in line:
                                 continue
                             err = " *{}".format(name)
                             if err not in errList:
                                 errList.append(err)
     ret = ("\n").join(errList)
     if ret:
         #self.showMsg(_("Repositories updated succesfully"))
         self._debug("Error updating: %s" % ret)
         ret = _("Failed to update: ") + "\n" + "{}".format(ret)
         self.showMsg("{}".format(ret), 'RepoMan')
         self.refresh = True
         self.changes = False
     else:
         self.showMsg(_("Repositories updated succesfully"))
     cursor = QtGui.QCursor(Qt.PointingHandCursor)
     self.setCursor(cursor)
Exemplo n.º 5
0
class Cursors:

    _eraserPixmap = QtGui.QPixmap(ctx.get_resource("icons/eraser.png"))
    _zoomPixmap = QtGui.QPixmap(ctx.get_resource("icons/zoom.png"))

    eraser = QtGui.QCursor(_eraserPixmap, hotx=0, hoty=_eraserPixmap.height())
    zoom = QtGui.QCursor(_zoomPixmap, hotx=0, hoty=0)
Exemplo n.º 6
0
 def enterEvent(self, event):
     app = QtWidgets.QApplication.instance()
     if app.overrideCursor():
         app.changeOverrideCursor(
             QtGui.QCursor(QtCore.Qt.PointingHandCursor))
     else:
         app.restoreOverrideCursor()
         app.setOverrideCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
     self.update()
     super(DropWidget, self).enterEvent(event)
Exemplo n.º 7
0
    def enterEvent(self, event):
        app = QtWidgets.QApplication.instance()
        if self.isEnabled():
            if app.overrideCursor():
                app.changeOverrideCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))
            else:
                app.restoreOverrideCursor()
                app.setOverrideCursor(QtGui.QCursor(QtCore.Qt.CrossCursor))

        super(ThumbnailEditorWidget, self).enterEvent(event)
Exemplo n.º 8
0
 def states():
     cursor = QtGui.QCursor(Qt.WaitCursor)
     self.setCursor(cursor)
     func()
     self.btn_ok.setEnabled(False)
     self.btn_cancel.setEnabled(False)
     self.refresh = True
     self.changes = False
     cursor = QtGui.QCursor(Qt.PointingHandCursor)
     self.setCursor(cursor)
Exemplo n.º 9
0
 def getCursor(self, isInversed):
     if (isInversed):
         pm = QtGui.QPixmap('./assets/shovel-mouse-inversed.png')
         pm.scaledToWidth(20)
         pm.scaledToHeight(20)
         return QtGui.QCursor(pm)
     else:
         pm = QtGui.QPixmap('./assets/shovel-mouse.png')
         pm.scaledToWidth(20)
         pm.scaledToHeight(20)
         return QtGui.QCursor(pm)
Exemplo n.º 10
0
 def on_frameChanged(self):
     pixmap = self._movie.currentPixmap()
     cursor = QtGui.QCursor(pixmap)
     if self._widget is not None:
         if self._last_cursor is None:
             self._last_cursor = self._widget.cursor()
         self._widget.setCursor(cursor)
Exemplo n.º 11
0
def wait_cursor():
    try:
        QtWidgets.QApplication.setOverrideCursor(
            QtGui.QCursor((QtCore.Qt.WaitCursor)))
        yield
    finally:
        QtWidgets.QApplication.restoreOverrideCursor()
Exemplo n.º 12
0
    def RightButton_Move(self, x, y):
        Space["CoreControl"].stopAllAction.emit()
        self.move(x, y)
        self.setCursor(QtGui.QCursor(QtCore.Qt.OpenHandCursor))

        if self.Setbox.MoveWithPerson:
            self.Setbox.move(x - 800, y)
Exemplo n.º 13
0
 def center(self):
     """make sure the window in the middle of the screen?"""
     screen = QtGui.QGuiApplication.screenAt(QtGui.QCursor().pos())
     x = screen.geometry().center().x() - 200
     y = screen.geometry().center().y()
     self.move(x - self.geometry().width() / 2,
               y - self.geometry().height() / 2)
Exemplo n.º 14
0
    def mouseMoveEvent(self,
                       event: QtGui.QMouseEvent) -> None:  # pragma: no cover
        if (not event.buttons() & QtCore.Qt.LeftButton
                or (event.pos() - self.drag_start_pos).manhattanLength() <
                QtWidgets.QApplication.startDragDistance()):
            return super().mouseMoveEvent(event)
        index = self.tabAt(event.pos())
        if index == -1:
            return super().mouseMoveEvent(event)

        rect = self.tabRect(index)
        pixmap = QtGui.QPixmap(rect.size())
        self.render(pixmap, QtCore.QPoint(), QtGui.QRegion(rect))

        mime_data = QtCore.QMimeData()
        mime_data.setData("application/x-pew2tabbar",
                          QtCore.QByteArray().number(index))

        drag = QtGui.QDrag(self)
        drag.setMimeData(mime_data)
        drag.setPixmap(pixmap)
        drag.setDragCursor(
            QtGui.QCursor(QtCore.Qt.DragMoveCursor).pixmap(),
            QtCore.Qt.MoveAction)
        drag.exec_(QtCore.Qt.MoveAction)
Exemplo n.º 15
0
 def mouseMoveEvent(self, event):
     current_position = QtGui.QCursor().pos()
     offset_pixel = self._drag_origin.y() - current_position.y()
     offset = offset_pixel / self.DIVIDED_INCREMENT
     self.value = self._start_origin + offset
     self.sliderMoved.emit(self.value)
     self.repaint()
Exemplo n.º 16
0
 def botaoReceberParcela(self, tabela, row, col, funcao, texto, status):
     item = QtWidgets.QPushButton()
     # item.setFixedWidth(70)
     # item.setFixedHeight(30)
     item.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
     if status == 1:
         item.setDisabled(True)
     item.setFocusPolicy(QtCore.Qt.NoFocus)
     item.setFlat(QtCore.Qt.NoItemFlags)
     item.setStyleSheet("QPushButton{\n"
                        "background-color: #7AB32E;\n"
                        "border-radius: 2px;\n"
                        "padding: 2px;\n"
                        "border: none;\n"
                        "text-transform: uppercase;\n"
                        "font: 10px \"Arial\";\n"
                        "}\n"
                        "QPushButton:hover{\n"
                        "background-color: #40a286\n"
                        "}"
                        )
     item.setText(texto)
     font = QtGui.QFont()
     font.setFamily("Tahoma")
     font.setPointSize(10)
     item.setFont(font)
     icon1 = QtGui.QIcon()
     icon1.addPixmap(QtGui.QPixmap(
         self.resourcepath('Images/money.png')), QtGui.QIcon.Normal, QtGui.QIcon.Off)
     item.setIcon(icon1)
     tabela.setCellWidget(row, col, item)
     item.clicked.connect(funcao)
Exemplo n.º 17
0
    def mousePressEvent(self, event):
        logger.debug('CLICK')
        self.setPixmap(self.pxm_pressed)
        modifiers = QtWidgets.QApplication.keyboardModifiers()
        # let Shift act as if Control
        if modifiers & QtCore.Qt.ShiftModifier:
            event.setModifiers(QtCore.Qt.ControlModifier)
        super(PixmapItem, self).mousePressEvent(event)

        if (event.button() == QtCore.Qt.LeftButton
                and modifiers == QtCore.Qt.ControlModifier):
            logger.debug('CONTROL COMBO')

        elif (event.button() == QtCore.Qt.LeftButton
              and modifiers == QtCore.Qt.ShiftModifier):
            logger.debug('SHIFT COMBO')

        elif event.button() == QtCore.Qt.LeftButton:
            logger.debug('LEFT')

        elif event.button() == QtCore.Qt.RightButton:
            logger.debug('RIGHT')

        elif event.button() == QtCore.Qt.MidButton:
            logger.debug('DRAG')
            # change cursor to quad arrow
            cursor = QtGui.QCursor(QtCore.Qt.SizeAllCursor)
            QtWidgets.QApplication.instance().setOverrideCursor(cursor)
            self._drag = True
        '''
        stops event propagation using event.accept()
        UI events get propagated up to ascending widgets
        until one of them accepts it
        '''
        event.accept()
Exemplo n.º 18
0
 def context_menu2(self):
     menu = QtWidgets.QMenu()
     open = menu.addAction("Open")
     cursor = QtGui.QCursor()
     action = menu.exec_(cursor.pos())
     if action == open:
         self.open_file2()
Exemplo n.º 19
0
 def set_resize_icon(self, event, clamp=True):
     """Sets an override icon to indicate the draggable area."""
     app = QtWidgets.QApplication.instance()
     k = self.get_resize_hotspot(event, clamp=clamp)
     if k:
         self.grabMouse()
         icon = self.resize_override_icons[k]
         if app.overrideCursor():
             app.changeOverrideCursor(QtGui.QCursor(icon))
             return k
         app.restoreOverrideCursor()
         app.setOverrideCursor(QtGui.QCursor(icon))
         return k
     self.releaseMouse()
     app.restoreOverrideCursor()
     return k
 def mouseReleaseEvent(self, event):
     if event.button() == QtCore.Qt.MiddleButton:
         self.value_at_press = None
         self.pos_at_press = None
         self.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor))
         return
     super(AttributeBox, self).mouseReleaseEvent(event)
    def Create_Cell(self, xPos, yPos, type, name, location):

        cell1 = QtWidgets.QLabel(location)
        cell1.setGeometry(QtCore.QRect(xPos, yPos, 51, VHeight))
        cell1.setText(name)
        font = QtGui.QFont()
        font.setFamily("Helvetica")
        font.setBold(False)
        font.setWeight(60)
        font.setPointSize(15)
        cell1.setFont(font)
        cell1.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
        cell1.setToolTipDuration(1)
        cell1.setFrameShape(QtWidgets.QFrame.Box)
        cell1.setFrameShadow(QtWidgets.QFrame.Raised)
        cell1.setStyleSheet('''background-color: rgb(248,248,248);''')
        cell1.setLineWidth(2)
        cell1.setTextFormat(QtCore.Qt.RichText)
        cell1.setScaledContents(True)
        cell1.setAlignment(QtCore.Qt.AlignCenter)
        cell1.adjustSize()
        cell1.resize(cell1.width() + 10, VHeight - 5)
        cell1.setObjectName(type + "@" + name)
        cell1.setVisible(True)

        #status = 0 means the button is unpressed, 1 means it is pressed
        cell1.status = 0

        return cell1
Exemplo n.º 22
0
def channelBox_row_rect():
    '''Get the geometry of the currently hovered row in the channelBox.

    We know the Dash line is only requested when when right clicking over the
    channelBox, so this should be stable enough in practice.
    '''

    # Get the channel box TableView
    app = QtWidgets.QApplication.instance()
    pos = QtGui.QCursor().pos()
    widget = app.widgetAt(pos)
    table = widget.parent()

    # parse out some important info
    local_pos = table.mapFromGlobal(pos)
    row = table.rowAt(local_pos.y())
    cols = table.model().columnCount()

    # Return the rect for the current row
    top = 0
    for i in range(row):
        top += table.rowHeight(row)
    width = 0
    for i in range(cols):
        width += table.columnWidth(i)
    height = table.rowHeight(row)
    topLeft = table.mapToGlobal(QtCore.QPoint(0, top))

    return QtCore.QRect(topLeft.x(), topLeft.y(), width, height)
Exemplo n.º 23
0
    def __init__(self, view):
        super(BucketTool, self).__init__(view)

        self.tolerance = 20
        self.default_cursor = QtGui.QCursor(
            QtGui.QPixmap(os.path.join(RESSOURCES_DIR, "BucketFill.png")), 23,
            20)
Exemplo n.º 24
0
 def __init__(self, parent=None):
     super(HandGest, self).__init__(parent)
     self.x = 0
     self.y = 0
     self.z = 0
     self.old_gest = 0
     self._gest = 0
     self.cursor = qtg.QCursor()
Exemplo n.º 25
0
 def __init__(self, parent=None, size=6.0):
     super(BackdropSizer, self).__init__(parent)
     self.setFlag(self.ItemIsSelectable, True)
     self.setFlag(self.ItemIsMovable, True)
     self.setFlag(self.ItemSendsScenePositionChanges, True)
     self.setCursor(QtGui.QCursor(QtCore.Qt.SizeFDiagCursor))
     self.setToolTip('double-click auto resize')
     self._size = size
Exemplo n.º 26
0
    def update_cursor(self):
        pix = QtGui.QPixmap(self.size, self.size)
        pix.fill(QtCore.Qt.transparent)

        with PainterContext(pix) as painter:
            painter.drawEllipse(1, 1, self.size - 2, self.size - 2)

        self.default_cursor = QtGui.QCursor(pix)
 def mousePressEvent(self, event):
     if event.buttons() == QtCore.Qt.MiddleButton:
         self.value_at_press = self.value()
         self.pos_at_press = event.pos()
         self.setCursor(QtGui.QCursor(QtCore.Qt.SizeHorCursor))
     else:
         super(AttributeBox, self).mousePressEvent(event)
         self.selectAll()
 def start(self):
     self.setWindowFlags(Qt.WindowStaysOnTopHint)
     SnippingWidget.background = False
     SnippingWidget.is_snipping = True
     self.setWindowOpacity(0.2)
     QtWidgets.QApplication.setOverrideCursor(
         QtGui.QCursor(QtCore.Qt.CrossCursor))
     self.show()
Exemplo n.º 29
0
    def __init__(self, image_path, link, *args, **kwargs):

        self.link = link

        QtWidgets.QLabel.__init__(self, *args, **kwargs)

        self.setPixmap(QtGui.QPixmap(image_path))
        self.setCursor(QtGui.QCursor(QtCore.Qt.PointingHandCursor))
Exemplo n.º 30
0
    def load_blocks(self, set_blocks):

        editor = self.main.tabWidget_files.currentWidget()
        editor.graphical_area.isOpening = True

        toFitInside = []
        #restaurPos = []
        #all_icons = []

        #dummy, pos = editor.graphical_area.new_bloq("output", all_sets["convert_"], QtCore.QPoint(), "dummy_block", "dummy_block")
        #dummy.metadata.self_id = self.serialize_widgets([dummy])[0]

        for block in set_blocks:
            name = block["name"]
            args = ["", ""] + block["constructor"]
            pos = QtCore.QPoint(*block["position"])
            basename = block["basename"]
            ID = block["self_id"]

            newIcon = editor.graphical_area.new_bloq(name, args, pos,
                                                     basename)[0]
            newIcon.metadata.self_id = ID

            newIcon.move(pos)
            newIcon.setCursor(QtGui.QCursor(OPENHANDCURSOR))

            newIcon.metadata.to = block["to"]
            newIcon.metadata.from_ = block["from"]
            newIcon.metadata.inside = block["inside"]
            #for i in range(newIcon.metadata.inside.count(None)):
            #newIcon.metadata.inside.remove(None)
            newIcon.metadata.nested = block["nested"]

        self.replace_id_by_widgets()

        for block in editor.graphical_area.get_project_blocks():
            if block.metadata.inside:
                toFitInside.append([block, block.metadata.inside[:]])
                #self.force_inside(block, block.metadata.inside)

        all_dummies = []
        for parent, toFit in toFitInside:
            for ins in toFit:
                wdg = self.get_widget_from_id(ins)
                if wdg:
                    wdg.metadata.add_parent([parent, wdg], force=True)
                else:
                    dummy, pos = editor.graphical_area.new_bloq(
                        "output", all_sets["convert_"], QtCore.QPoint(),
                        "dummy_block", "dummy_block")
                    dummy.metadata.self_id = self.serialize_widgets([dummy])[0]
                    dummy.metadata.add_parent([parent, dummy], force=True)
                    all_dummies.append(dummy)
                    #dummy.

        for dummy in all_dummies:
            dummy.metadata.remove_parent()
            dummy.metadata.destroy_this()