Esempio n. 1
0
    def icon(cls, iconName, size=16):
        """Returns a QtGui.QIcon instance intialized to the icon path for the icon name if the icon name is found within
        the cache

        :param iconName: iconName_size or iconName, then it will resize the largest icon found
        :type iconName: str
        :param size: int, the size of the icon, the size will be used for both the width and height.
                     setting size=-1 will return the largest icon as well
        :type size: int
        :return QIcon: QtGui.Qicon
        :rtype QIcon: object
        """
        if env.isMayapy():
            return
        iconData = cls.iconDataForName(iconName, size)
        icon = iconData.get("icon")
        if icon and isinstance(icon, QtGui.QIcon) and not icon.isNull():
            if size != -1:
                icon = cls.resizeIcon(icon, QtCore.QSize(size, size))
            return icon
        newIcon = QtGui.QIcon(iconData.get("path", ""))
        if size != -1:
            newIcon = cls.resizeIcon(newIcon, QtCore.QSize(size, size))

        iconData["icon"] = newIcon
        return newIcon
Esempio n. 2
0
    def setFootprint(self, polygon):
        self.clear()
        if not polygon:
            return

        lon = np.asarray([p.x() for p in polygon])
        lat = np.asarray([p.y() for p in polygon])

        mlon = lon.mean()
        mlat = lat.mean()

        delta = mlon - utils.geonormalize(mlon)
        if delta:
            lon -= delta
            mlon -= delta
            polygon.translate(-delta, 0)

        self.box = self.plot(polygon)

        points = QtGui.QPolygonF([
            QtCore.QPointF(mlon - self.bigBoxSize / 2,
                           mlat - self.bigBoxSize / 2),
            QtCore.QPointF(mlon + self.bigBoxSize / 2,
                           mlat - self.bigBoxSize / 2),
            QtCore.QPointF(mlon + self.bigBoxSize / 2,
                           mlat + self.bigBoxSize / 2),
            QtCore.QPointF(mlon - self.bigBoxSize / 2,
                           mlat + self.bigBoxSize / 2),
        ])
        self.bigbox = self.plot(points)

        self.actionZoomIn.setEnabled(True)
Esempio n. 3
0
 def fetchMore(self, index=QtCore.QModelIndex()):
     reminder = len(self.items) - self.loadedCount
     itemsToFetch = min(reminder, self.chunkCount)
     self.beginInsertRows(QtCore.QModelIndex(), self.loadedCount,
                          self.loadedCount + itemsToFetch - 1)
     self.loadedCount += itemsToFetch
     self.endInsertRows()
Esempio n. 4
0
    def setupUi(self, ColPrefsDialog):
        ColPrefsDialog.setObjectName("ColPrefsDialog")
        ColPrefsDialog.resize(225, 402)
        ColPrefsDialog.setModal(True)
        self.verticalLayout = QtGui.QVBoxLayout(ColPrefsDialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtGui.QLabel(ColPrefsDialog)
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)
        self.list = QtGui.QListWidget(ColPrefsDialog)
        self.list.setObjectName("list")
        self.verticalLayout.addWidget(self.list)
        self.label_2 = QtGui.QLabel(ColPrefsDialog)
        self.label_2.setTextFormat(QtCore.Qt.PlainText)
        self.label_2.setWordWrap(True)
        self.label_2.setObjectName("label_2")
        self.verticalLayout.addWidget(self.label_2)
        self.buttonBox = QtGui.QDialogButtonBox(ColPrefsDialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel
                                          | QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.verticalLayout.addWidget(self.buttonBox)
        self.label.setBuddy(self.list)

        self.retranslateUi(ColPrefsDialog)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"),
                               ColPrefsDialog.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"),
                               ColPrefsDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(ColPrefsDialog)
Esempio n. 5
0
class OkCancelButtons(QtWidgets.QWidget):
    OkBtnPressed = QtCore.Signal()
    CancelBtnPressed = QtCore.Signal()

    def __init__(self, okText="OK", cancelTxt="Cancel", parent=None):
        """Creates OK Cancel Buttons bottom of window, can change the names

        :param okText: the text on the ok (first) button
        :type okText: str
        :param cancelTxt: the text on the cancel (second) button
        :type cancelTxt: str
        :param parent: the widget parent
        :type parent: class
        """
        super(OkCancelButtons, self).__init__(parent=parent)
        self.layout = QtWidgets.QHBoxLayout()
        self.okBtn = QtWidgets.QPushButton(okText, parent=self)
        self.cancelBtn = QtWidgets.QPushButton(cancelTxt, parent=self)
        self.layout.addWidget(self.okBtn)
        self.layout.addWidget(self.cancelBtn)
        self.setLayout(self.layout)
        self.connections()

    def connections(self):
        self.okBtn.clicked.connect(self.OkBtnPressed.emit)
        self.cancelBtn.clicked.connect(self.CancelBtnPressed.emit)
Esempio n. 6
0
    def itemsRect(items):
        sourceRect = QtCore.QRect()

        for item in items:
            sourceRect = sourceRect.united(
                QtCore.QRect(*item.sceneBoundingRect().getRect()))
        return sourceRect
Esempio n. 7
0
    def setupUi(self, TextInfoDialog):
        TextInfoDialog.setObjectName("TextInfoDialog")
        TextInfoDialog.resize(400, 300)
        TextInfoDialog.setModal(True)
        self.verticalLayout = QtGui.QVBoxLayout(TextInfoDialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.text = QtGui.QPlainTextEdit(TextInfoDialog)
        self.text.setReadOnly(True)
        self.text.setPlainText("None")
        self.text.setObjectName("text")
        self.verticalLayout.addWidget(self.text)
        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.selectAll = QtGui.QPushButton(TextInfoDialog)
        self.selectAll.setObjectName("selectAll")
        self.horizontalLayout.addWidget(self.selectAll)
        self.copy = QtGui.QPushButton(TextInfoDialog)
        self.copy.setObjectName("copy")
        self.horizontalLayout.addWidget(self.copy)
        self.buttonBox = QtGui.QDialogButtonBox(TextInfoDialog)
        self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
        self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.horizontalLayout.addWidget(self.buttonBox)
        self.verticalLayout.addLayout(self.horizontalLayout)

        self.retranslateUi(TextInfoDialog)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("accepted()"),
                               TextInfoDialog.accept)
        QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("rejected()"),
                               TextInfoDialog.reject)
        QtCore.QMetaObject.connectSlotsByName(TextInfoDialog)
Esempio n. 8
0
 def _updatePixmapSize(self):
     pixmap = self.pixmap()
     if not pixmap.isNull() and self._size.isValid():
         pixsize = QtCore.QSizeF(self.pixmap().size())
         pixsize.scale(self._size, QtCore.Qt.KeepAspectRatio)
     else:
         pixsize = QtCore.QSizeF()
     self.pixmapWidget.setPixmapSize(pixsize)
Esempio n. 9
0
 def _create_button(self, icon_directory, handler):
     button = QtGui.QPushButton(str(), self)
     button.setIcon(Resources(icon_directory))
     button.setIconSize(QtCore.QSize(26, 26))
     button.setFixedSize(QtCore.QSize(36, 36))
     button.setEnabled(False)
     connect(button.clicked, handler)
     self.__header_layout.addWidget(button)
     return button
Esempio n. 10
0
    def index(self, row, column, parent=QtCore.QModelIndex()):
        if not self.hasIndex(row, column, parent):
            return QtCore.QModelIndex()

        parentItem = self.itemFromIndex(parent)
        childItem = parentItem.child(row)
        if childItem:
            return self.createIndex(row, column, childItem)
        return QtCore.QModelIndex()
Esempio n. 11
0
    def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()

        childItem = index.internalPointer()
        parentItem = childItem.parentSource()
        if parentItem == self.root or parentItem is None:
            return QtCore.QModelIndex()

        return self.createIndex(parentItem.index(), 0, parentItem)
Esempio n. 12
0
    def heightForWidth(self, width):
        """Get the preferred height a layout item with the given width

        :param width (int)"""

        height = self.doLayout(QtCore.QRect(0, 0, width, 0), True)

        self.sizeHintLayout = QtCore.QSize(width, height)

        return height
Esempio n. 13
0
 def __init__(self, parent=None):
     super(View, self).__init__(parent)
     self.promptLength = 0
     self.__startOfInput = 0
     self.setUndoRedoEnabled(False)
     self.setAcceptRichText(False)
     self.setContextMenuPolicy(QtCore.Qt.NoContextMenu)
     self.tripleClickTimer = QtCore.QBasicTimer()
     self.tripleClickPoint = QtCore.QPoint()
     self._ignoreKeyPresses = True
Esempio n. 14
0
    def minimumSize(self):
        """ Get the minimum size of this layout

        :return (QSize)"""
        # Calculate the size
        size = QtCore.QSize()
        for item in self.itemList:
            size = size.expandedTo(item.minimumSize())
        # Add the margins
        size += QtCore.QSize(2, 2)
        return size
Esempio n. 15
0
 def getCheckBoxRect(self, option):
     check_box_style_option = QtWidgets.QStyleOptionButton()
     check_box_rect = QtWidgets.QApplication.style().subElementRect(
         QtWidgets.QStyle.SE_CheckBoxIndicator, check_box_style_option,
         None)
     check_box_point = QtCore.QPoint(
         option.rect.x() + option.rect.width() / 2 -
         check_box_rect.width() / 2,
         option.rect.y() + option.rect.height() / 2 -
         check_box_rect.height() / 2)
     return QtCore.QRect(check_box_point, check_box_rect.size())
Esempio n. 16
0
    def _drawMainAxis(self, painter, rect):

        painter.setPen(self.config.overlayAxisPen)

        xLine, yLine = QtCore.QLineF(), QtCore.QLineF()
        if rect.y() < 0 < (rect.height() - rect.y()):
            xLine = QtCore.QLineF(rect.x(), 0, rect.width() + rect.x(), 0)

        if rect.x() < 0 < (rect.height() - rect.x()):
            yLine = QtCore.QLineF(0, rect.y(), 0, rect.height() + rect.y())

        painter.drawLines([xLine, yLine])
Esempio n. 17
0
class NodeHeader(QtWidgets.QGraphicsWidget):
    headerButtonStateChanged = QtCore.Signal(int)
    headerTextChanged = QtCore.Signal(str)

    def __init__(self, node, text, secondaryText="", icon=None, parent=None):
        super(NodeHeader, self).__init__(parent)
        self._node = node

        self.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                  QtWidgets.QSizePolicy.Expanding))

        layout = QtWidgets.QGraphicsLinearLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.setOrientation(QtCore.Qt.Horizontal)
        self.setLayout(layout)
        self.headerIcon = HeaderPixmap(pixmap=icon or "", parent=self)
        layout.addItem(self.headerIcon)
        if not icon:
            self.headerIcon.hide()
        self._createLabels(text, secondaryText, layout)
        layout.addStretch(1)
        headerButton = NodeHeaderButton(size=12,
                                        color=node.model.headerButtonColor())
        headerButton.stateChanged.connect(self.headerButtonStateChanged.emit)
        layout.addItem(headerButton)
        layout.setAlignment(headerButton,
                            QtCore.Qt.AlignCenter | QtCore.Qt.AlignCenter)

    def setIcon(self, path):
        self.headerIcon.setPixmap(path)

    def _createLabels(self, primary, secondary, parentLayout):
        container = graphicitems.ItemContainer(QtCore.Qt.Vertical, parent=self)
        container.layout().setSpacing(0)
        self._titleWidget = graphicitems.GraphicsText(primary, self)
        self._titleWidget.textChanged.connect(self.headerTextChanged)
        self._titleWidget.font = QtGui.QFont("Roboto-Bold.ttf", 8)
        self._secondarytitle = graphicitems.GraphicsText(secondary, self)
        self._secondarytitle.setTextFlags(
            QtWidgets.QGraphicsItem.ItemIsSelectable
            & QtWidgets.QGraphicsItem.ItemIsFocusable
            & QtWidgets.QGraphicsItem.ItemIsMovable)
        self._secondarytitle.font = QtGui.QFont("Roboto-Bold.ttf", 6)
        container.addItem(self._titleWidget,
                          QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop)
        container.addItem(self._secondarytitle,
                          QtCore.Qt.AlignCenter | QtCore.Qt.AlignTop)
        parentLayout.addItem(container)

    def setText(self, text):
        self._titleWidget.setText(text)
Esempio n. 18
0
 def setIconSize(self, size):
     if size == self.listView.iconSize():
         return
     maxSize = self.listView.defaultMaxIconSize
     minSize = self.listView.defaultMinIconSize
     width = size.width()
     height = size.height()
     if width > maxSize or height > maxSize:
         size = QtCore.QSize(maxSize, maxSize)
     elif width < minSize or height > minSize:
         size = QtCore.QSize(minSize, minSize)
     self.listView.setIconSize(size)
Esempio n. 19
0
    def setAsCubicPath(self):
        path = QtGui.QPainterPath()

        path.moveTo(self._sourcePoint)
        dx = self._destinationPoint.x() - self._sourcePoint.x()
        dy = self._destinationPoint.y() - self._sourcePoint.y()
        ctrl1 = QtCore.QPointF(self._sourcePoint.x() + dx * 0.50,
                               self._sourcePoint.y() + dy * 0.1)
        ctrl2 = QtCore.QPointF(self._sourcePoint.x() + dx * 0.50,
                               self._sourcePoint.y() + dy * 0.9)
        path.cubicTo(ctrl1, ctrl2, self._destinationPoint)
        self.setPath(path)
Esempio n. 20
0
    def __init__(self, document, styles):
        """
        :param document:
        :type document: the textEdit document
        :param styles: The style dict
        :type styles: dict
        """
        QtGui.QSyntaxHighlighter.__init__(self, document)

        colors = styles["colors"]
        syntax = styles["syntax"]
        self.tri_single = (QtCore.QRegExp("'''"), 1, colors['string'])
        self.tri_double = (QtCore.QRegExp('"""'), 2, colors['string'])

        rules = [

            # 'self'
            (r'\bself\b', 0, colors['self']),

            # Double-quoted string, possibly containing escape sequences
            (r'"[^"\\]*(\\.[^"\\]*)*"', 0, colors['string']),
            # Single-quoted string, possibly containing escape sequences
            (r"'[^'\\]*(\\.[^'\\]*)*'", 0, colors['string']),

            # 'def' followed by an identifier
            (r'\bdef\b\s*(\w+)', 1, colors['methods']),
            # 'class' followed by an identifier
            (r'\bclass\b\s*(\w+)', 1, colors['defclass']),

            # From '#' until a newline
            (r'#[^\n]*', 0, colors['comment']),
            (r"\\b[A-Za-z0-9_]+(?=\\()", 0, colors['methods']),
            # Numeric literals
            (r'\b[+-]?[0-9]+[lL]?\b', 0, colors['numbers']),
            (r'\b[+-]?0[xX][0-9A-Fa-f]+[lL]?\b', 0, colors['numbers']),
            (r'\b[+-]?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\b', 0,
             colors['numbers']),
        ]
        # Keyword, operator, and brace rules
        rules += [(r'\b%s\b' % w, 0, colors['keyword'])
                  for w in syntax["keywords"]]
        rules += [(r'\b%s\b' % w, 0, colors['preprocessor'])
                  for w in syntax["preprocessors"]]
        rules += [(r'\b%s\b' % w, 0, colors['special'])
                  for w in syntax["specials"]]
        rules += [(r'%s' % o, 0, colors['operator'])
                  for o in syntax["operators"]]
        rules += [(r'%s' % b, 0, colors['brace']) for b in syntax["braces"]]

        # Build a QtCore.QRegExp for each pattern
        self.rules = [(QtCore.QRegExp(pat), index, fmt)
                      for (pat, index, fmt) in rules]
Esempio n. 21
0
    def doLayout(self, rect, testOnly):
        """ Layout all the items

        :param rect (QRect) Rect where in the items have to be laid out
        :param testOnly (boolean) Do the actual layout"""

        x = rect.x()
        y = rect.y()
        lineSize = 0
        orientation = self.orientation()

        for item in self.itemList:

            if item.widget().isHidden():
                continue

            spaceX = self.spacingX
            spaceY = self.spacingY

            if orientation == QtCore.Qt.Horizontal:
                nextX = x + item.sizeHint().width() + spaceX
                if nextX - spaceX > rect.right() and lineSize > 0:
                    if not self.overflow:
                        x = rect.x()
                        y = y + lineSize + (spaceY * 2)
                        nextX = x + item.sizeHint().width() + spaceX
                        lineSize = 0

                if not testOnly:
                    item.setGeometry(
                        QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint()))
                x = nextX
                lineSize = max(lineSize, item.sizeHint().height())
            else:
                nextY = y + item.sizeHint().height() + spaceY
                if nextY - spaceY > rect.bottom() and lineSize > 0:
                    if not self.overflow:
                        y = rect.y()
                        x = x + lineSize + (spaceX * 2)
                        nextY = y + item.sizeHint().height() + spaceY
                        lineSize = 0

                if not testOnly:
                    item.setGeometry(
                        QtCore.QRect(QtCore.QPoint(x, y), item.sizeHint()))
                x = nextY
                lineSize = max(lineSize, item.sizeHint().height())

        if orientation == QtCore.Qt.Horizontal:
            return y + lineSize - rect.y()
        else:
            return x + lineSize - rect.x()
Esempio n. 22
0
class CommandActionBase(QtCore.QObject):
    """CommandUi class deals with encapsulating a command as a widget
    """
    triggered = QtCore.Signal(str)
    triggeredUi = QtCore.Signal(str)

    def __init__(self, command):
        super(CommandActionBase, self).__init__()
        self.command = command
        self.item = None

    def create(self, parent=None):
        pass
Esempio n. 23
0
def drawRect(painter, option, color):
    points = (QtCore.QPoint(option.rect.x() + 5, option.rect.y()),
              QtCore.QPoint(option.rect.x(), option.rect.y()),
              QtCore.QPoint(option.rect.x(),
                            option.rect.y() + 5))
    polygonTriangle = QtGui.QPolygon.fromList(points)

    painter.save()
    painter.setRenderHint(painter.Antialiasing)
    painter.setBrush(QtGui.QBrush(color))
    painter.setPen(QtGui.QPen(color))
    painter.drawPolygon(polygonTriangle)
    painter.restore()
Esempio n. 24
0
 def gen_painterpath(self, exterior, interiors):
     path = qg.QPainterPath()
     center = numpy.array(exterior[0])
     edge = numpy.array(exterior[1])
     v = edge - center
     r = v.dot(v)**.5
     point1 = center - r
     point2 = center + r
     point1 = qc.QPointF(*point1)
     point2 = qc.QPointF(*point2)
     rect = qc.QRectF(point1, point2)
     path.addEllipse(rect)
     return path
Esempio n. 25
0
 def setDragPoint(self, dragPoint):
     topLeft = QtCore.QPointF(self._mouseDownPos)
     bottomRight = QtCore.QPointF(dragPoint)
     xdown = self._mouseDownPos.x()
     ydown = self._mouseDownPos.y()
     if dragPoint.x() < xdown:
         topLeft.setX(dragPoint.x())
         bottomRight.setX(xdown)
     if dragPoint.y() < ydown:
         topLeft.setY(dragPoint.y())
         bottomRight.setY(ydown)
     self.setPos(topLeft)
     self.resize(bottomRight.x() - topLeft.x(),
                 bottomRight.y() - topLeft.y())
Esempio n. 26
0
 def setColor(self, color, size=None):
     icon = self
     size = size or icon.actualSize(QtCore.QSize(256, 256))
     pixmap = icon.pixmap(size)
     rect = QtCore.QRect(0, 0, size.width(), size.height())
     if not self.isNull():
         painter = QtGui.QPainter(pixmap)
         painter.setCompositionMode(QtGui.QPainter.CompositionMode_SourceIn)
         painter.setBrush(color)
         painter.setPen(color)
         painter.drawRect(pixmap.rect())
         painter.end()
     icon = QtGui.QIcon(pixmap)
     self.swap(icon)
Esempio n. 27
0
class ListEditor(ListBase):
    signal_edit = qc.Signal(object)
    itemdeleted = qc.Signal(object)

    def __init__(self, *args, **kwargs):
        super(ListEditor, self).__init__(*args, **kwargs)
        self.setSelectionMode(qg.QAbstractItemView.SingleSelection)
        self.itemDoubleClicked.connect(self.itemDoubleClicked_method)

    def keyPressEvent(self, event):
        if event.key() == qc.Qt.Key_Delete:
            for item in self.selectedItems():
                self.removeitem(self.row(item))
                self.itemdeleted.emit(item.customdata)
Esempio n. 28
0
    def __init__(self, parent):
        QtWidgets.QDialog.__init__(self, parent)
        self._ui = Ui_WatchWindow()
        self._ui.setupUi(self)

        self._boxWithFocus = self._ui.unvaryingEdit
        self._prevDualScrollVal = 0

        self._parent = parent
        self._searchString = ""

        self.addAction(self._ui.actionFind)
        self.addAction(self._ui.actionFindNext)
        self.addAction(self._ui.actionFindPrevious)

        self._ui.doneButton.clicked.connect(self.accept)
        self.finished.connect(self._cleanUpAndClose)
        self._ui.dualScroller.valueChanged.connect(self._changeBothSliders)
        self._ui.diffButton.clicked.connect(self._diff)
        self._ui.actionFind.triggered.connect(self._find)
        self._ui.actionFindNext.triggered.connect(self._findNext)
        self._ui.actionFindPrevious.triggered.connect(self._findPrevious)
        self._ui.varyingEdit.cursorPositionChanged.connect(
            self._varyingCursorChanged)
        self._ui.unvaryingEdit.cursorPositionChanged.connect(
            self._unvaryingCursorChanged)
        # save splitter state
        self._ui.splitter.splitterMoved.connect(self._splitterMoved)

        #create a timer for saving splitter state only when it stops moving
        self._splitterTimer = QtCore.QTimer(self)
        self._splitterTimer.setInterval(500)
        self._splitterTimer.timeout.connect(self._saveSplitterState)

        self._resetSettings()
Esempio n. 29
0
 def data(self, index, role=None):
     """
     :type index: QtCore.QModelIndex
     :type role: int
     """
     if index.isValid() and index.row() < len(self._wafer_process):
         if role == QtCore.Qt.DisplayRole or role == QtCore.Qt.EditRole:
             stack_layer = self._wafer_process[index.row()]
             if index.column() == QProcessStackModel.columns["Step"]:
                 return str(len(self._wafer_process) - index.row())
             elif index.column() == QProcessStackModel.columns["Type"]:
                 return str(stack_layer.type)
             elif index.column() == QProcessStackModel.columns["Name"]:
                 return str(stack_layer.name)
             elif index.column() == QProcessStackModel.columns["Thickness"]:
                 if isinstance(stack_layer,
                               options.structures.StandardLayer):
                     return str(stack_layer.thickness)
                 elif isinstance(stack_layer, options.structures.Substrate):
                     return None
         elif role == QtCore.Qt.SizeHintRole:
             width = QProcessStackModel.columns.values()[
                 index.column()].width
             return QtCore.QSize(width, QProcessStackModel.height)
         elif role == QtCore.Qt.BackgroundColorRole:
             if index.column() == QProcessStackModel.columns["Step"]:
                 return QtGui.QColor(
                     QProcessStackModel.colormap[index.row()])
     return None
Esempio n. 30
0
    def sendBugReport(self):
        if not self._excInfoSet():
            exctype, excvalue, tracebackobj = sys.exc_info()
        else:
            exctype = self.exctype
            excvalue = self.excvalue
            tracebackobj = self.tracebackobj

        error = traceback.format_exception_only(exctype, excvalue)[-1].strip()
        appname = QtGui.QApplication.applicationName()
        if appname:
            subject = '[%s] Bug report - %s' % (appname, error)
        else:
            subject = 'Bug report - %s' % error
        body = '[Please instest your comments and additinal info here.]'
        body += '\n\n' + '-' * 80 + '\n'
        body += ''.join(utils.foramt_bugreport(exctype, excvalue,
                                               tracebackobj))

        url = QtCore.QUrl('mailto:%s <%s>' % (info.author, info.author_email))
        url.addQueryItem('subject', subject)
        url.addQueryItem('body', body)

        ret = QtGui.QDesktopServices.openUrl(url)
        if not ret:
            msg = self.tr('Unable to send the bug-report.\n'
                          'Please save the bug-report on file and send it '
                          'manually.')
            QtGui.QMessageBox.warning(self, self.tr('WARNING'), msg)
Esempio n. 31
0
    def attachToMdiArea(self, mdiArea):
        '''Instructs this menu to display navigation actions for the
        QMdiArea *mdiArea*.

        This should be done before this menu is shown.
        Specifying a null *mdiArea* is meaningless and will generate
        a warning.

        For special usecases, see the note about auto-attachment in the
        class description.

        '''

        if mdiArea == self.mdi:
            return

        acts = self._stdGroup.actions()
        acts = dict(zip(['CloseAction', 'CloseAllAction', '', 'TileAction',
                         'CascadeAction', '', 'NextAction', 'PrevAction'],
                        acts))

        if self.mdi:
            # i.e. we have previously been attached
            mdi = self.mdi
            acts['CloseAction'].triggered.disconnect(mdi.closeActiveSubWindow)
            acts['CloseAllAction'].triggered.disconnect(mdi.closeAllSubWindows)
            acts['TileAction'].triggered.disconnect(mdi.tileSubWindows)
            acts['CascadeAction'].triggered.disconnect(mdi.cascadeSubWindows)
            acts['NextAction'].triggered.disconnect(mdi.activateNextSubWindow)
            acts['PrevAction'].triggered.disconnect(
                                                mdi.activatePreviousSubWindow)

        self.mdi = mdiArea
        if not self.mdi:
            QtCore.qWarning('QtWindowListMenu::attachToMdiArea(): '
                            'mdiArea is 0; menu will be empty.')
            return

        acts['CloseAction'].triggered.connect(self.mdi.closeActiveSubWindow)
        acts['CloseAllAction'].triggered.connect(self.mdi.closeAllSubWindows)
        acts['TileAction'].triggered.connect(self.mdi.tileSubWindows)
        acts['CascadeAction'].triggered.connect(self.mdi.cascadeSubWindows)
        acts['NextAction'].triggered.connect(self.mdi.activateNextSubWindow)
        acts['PrevAction'].triggered.connect(
            self.mdi.activatePreviousSubWindow)
Esempio n. 32
0
 def _levelOfDetail(option, painter):
     # @COMPATIBILITY: since Qt v. 4.6.0 the levelOfDetail attribute of
     # QStyleOptionGraphicsItem is deprecated
     # @SEEALSO: ItemUsesExtendedStyleOption item at
     # http://doc.qt.nokia.com/4.6/qgraphicsitem.html#GraphicsItemFlag-enum
     if hasattr(option, 'levelOfDetailFromTransform'):
         levelOfDetail = option.levelOfDetailFromTransform(
                                                 painter.transform())
     elif QtCore.qVersion() >= '4.6.0':
         levelOfDetail = BaseGdalGraphicsItem._levelOfDetailFromTransform(
                                                     painter.transform())
     else:
         levelOfDetail = option.levelOfDetail
     return levelOfDetail
Esempio n. 33
0
def qInitResources():
    QtCore.qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
Esempio n. 34
0
def qCleanupResources():
    QtCore.qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data)
Esempio n. 35
0
'''

author = 'Antonio Valentino'
author_email = '*****@*****.**'
copyright = 'Copyright (C) 2008-2011 %s <%s>' % (author, author_email)
#license = _get_license()
license_type = 'GNU GPL'
website = 'http://gsdview.sourceforge.net'
website_label = website
download_url = 'http://sourceforge.net/projects/gsdview/files'


all_versions = [
    ('GSDView', version, website),
    ('Python', '.'.join(map(str, sys.version_info[:3])), 'www.python.org'),
    ('Qt', QtCore.qVersion(), 'http://qt.nokia.com'),
    ('numpy', np.version.version, 'http://www.scipy.org'),
]

if qt.qt_api == 'pyqt':
    import sip
    all_versions.append(('sip', sip.SIP_VERSION_STR,
                         'http://www.riverbankcomputing.co.uk/software/sip'))
    all_versions.append(('PyQt4', QtCore.PYQT_VERSION_STR,
                         'http://www.riverbankcomputing.co.uk/software/pyqt'))
    try:
        from PyQt4 import Qsci
    except ImportError:
        pass
    else:
        all_versions.append(('QScintilla', Qsci.QSCINTILLA_VERSION_STR,