Beispiel #1
0
    def data(self, index, role):
        source_index = self.mapToSource(index)
        source_model = self.sourceModel()
        if not source_index.isValid():
            return QVariant()
        source_data = source_model.data(source_index, role)
        if index.column() == source_model.columns_types.index('is_member') \
                and role == Qt.DisplayRole:
            value = {True: self.tr('yes'), False: self.tr('no'), None: self.tr('offline')}
            return value[source_data]

        if index.column() == source_model.columns_types.index('pubkey') \
            and role == Qt.DisplayRole:
            return source_data[:5]

        if role == Qt.TextAlignmentRole:
            if source_index.column() == source_model.columns_types.index('address') or source_index.column() == self.sourceModel().columns_types.index('current_block'):
                return Qt.AlignRight | Qt.AlignVCenter
            if source_index.column() == source_model.columns_types.index('is_member'):
                return Qt.AlignCenter

        if role == Qt.FontRole:
            is_root_col = source_model.columns_types.index('is_root')
            index_root_col = source_model.index(source_index.row(), is_root_col)
            if source_model.data(index_root_col, Qt.DisplayRole):
                font = QFont()
                font.setBold(True)
                return font

        return source_data
Beispiel #2
0
    def __init__(self, url, color):
        QWidget.__init__(self)
        self.setStyleSheet("background-color: black")

        self.file_name_font = QFont()
        self.file_name_font.setPointSize(24)

        self.file_name_label = QLabel(self)
        self.file_name_label.setText(url)
        self.file_name_label.setFont(self.file_name_font)
        self.file_name_label.setAlignment(Qt.AlignCenter)
        self.file_name_label.setStyleSheet("color: #eee")

        self.qrcode_label = QLabel(self)

        self.notify_font = QFont()
        self.notify_font.setPointSize(12)
        self.notify_label = QLabel(self)
        self.notify_label.setText("Scan above QR to copy information")
        self.notify_label.setFont(self.notify_font)
        self.notify_label.setAlignment(Qt.AlignCenter)
        self.notify_label.setStyleSheet("color: #eee")

        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addStretch()
        layout.addWidget(self.qrcode_label, 0, Qt.AlignCenter)
        layout.addSpacing(20)
        layout.addWidget(self.file_name_label, 0, Qt.AlignCenter)
        layout.addSpacing(40)
        layout.addWidget(self.notify_label, 0, Qt.AlignCenter)
        layout.addStretch()

        self.qrcode_label.setPixmap(qrcode.make(url, image_factory=Image).pixmap())
Beispiel #3
0
    def convertParsedQFont(chars_sets, font):
        name = font['name']
        qfont = QFont( font['family'], int(font['pointsize']) )
        qfont.setBold( font['bold'] )

        # convert and return
        return NFontConverter.convertQFont( chars_sets, name, qfont )
Beispiel #4
0
 def __init__(self, bookmark, parent=None):
     """
     Constructor
     
     @param bookmark reference to the bookmark to be shown (Bookmark)
     @param parent reference to the parent widget (QWidget)
     """
     super(BookmarkInfoDialog, self).__init__(parent)
     self.setupUi(self)
     
     self.__bookmark = bookmark
     
     self.icon.setPixmap(UI.PixmapCache.getPixmap("bookmark32.png"))
     
     font = QFont()
     font.setPointSize(font.pointSize() + 2)
     self.title.setFont(font)
     
     if bookmark is None:
         self.titleEdit.setEnabled(False)
     else:
         self.titleEdit.setText(bookmark.title)
         self.titleEdit.setFocus()
     
     msh = self.minimumSizeHint()
     self.resize(max(self.width(), msh.width()), msh.height())
Beispiel #5
0
    def update_item(self):
        self.setText(0, self.download_info["name"])
        if self.download_info["name"] == u"<old version of your channel>":
            itfont = QFont(self.font(0))
            itfont.setItalic(True)
            self.setFont(0, itfont)
        else:
            self.font(0).setItalic(False)
        self.setText(1, format_size(float(self.download_info["size"])))

        try:
            self.progress_slider.setValue(int(self.download_info["progress"] * 100))
        except RuntimeError:
            self._logger.error("The underlying GUI widget has already been removed.")

        if self.download_info["vod_mode"]:
            self.setText(3, "Streaming")
        else:
            self.setText(3, DLSTATUS_STRINGS[eval(self.download_info["status"])])
        self.setText(4, "%s (%s)" % (self.download_info["num_connected_seeds"], self.download_info["num_seeds"]))
        self.setText(5, "%s (%s)" % (self.download_info["num_connected_peers"], self.download_info["num_peers"]))
        self.setText(6, format_speed(self.download_info["speed_down"]))
        self.setText(7, format_speed(self.download_info["speed_up"]))
        self.setText(8, "%.3f" % float(self.download_info["ratio"]))
        self.setText(9, "yes" if self.download_info["anon_download"] else "no")
        self.setText(10, str(self.download_info["hops"]) if self.download_info["anon_download"] else "-")
        self.setText(12, datetime.fromtimestamp(int(self.download_info["time_added"])).strftime('%Y-%m-%d %H:%M'))

        eta_text = "-"
        if self.get_raw_download_status() == DLSTATUS_DOWNLOADING:
            eta_text = duration_to_string(self.download_info["eta"])
        self.setText(11, eta_text)
Beispiel #6
0
 def __init__(self, parent=None, command="/bin/bash",
              font_name="Monospace", font_size=18):
     super(TerminalWidget, self).__init__(parent)
     self.parent().setTabOrder(self, self)
     self.setFocusPolicy(Qt.WheelFocus)
     self.setAutoFillBackground(False)
     self.setAttribute(Qt.WA_OpaquePaintEvent, True)
     self.setCursor(Qt.IBeamCursor)
     font = QFont(font_name)
     font.setPixelSize(font_size)
     self.setFont(font)
     self._session = None
     self._last_update = None
     self._screen = []
     self._text = []
     self._cursor_rect = None
     self._cursor_col = 0
     self._cursor_row = 0
     self._dirty = False
     self._blink = False
     self._press_pos = None
     self._selection = None
     self._clipboard = QApplication.clipboard()
     QApplication.instance().lastWindowClosed.connect(Session.close_all)
     if command:
         self.execute()
 def createLabel(self, text):
     lbl = QLabel(text)
     lbl.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter)
     font = QFont()
     font.setPointSize(12)
     lbl.setFont(font)
     return lbl
    def __init__(self):
        """The constructor initializes the class AboutDialog."""
        super().__init__()
        self.setAttribute(Qt.WA_DeleteOnClose)

        # initialize class constants
        self._BUTTON_MIN_WIDTH = 110
        self._OXYGEN_PATH_48 = os.path.join("resources", "icons", "oxygen", "48")

        # fonts and margins settings
        hlFont = QFont()
        hlFont.setBold(True)
        hlFont.setPointSize(14)

        # scientific logo
        logo = QLabel(pixmap=QPixmap(os.path.join(self._OXYGEN_PATH_48, "applications-science.png")))

        logoLayout = QVBoxLayout()
        logoLayout.addWidget(logo)
        logoLayout.addStretch()

        # begin the content
        # headline and description text
        self.headline = QLabel()
        self.headline.setFont(hlFont)
        self.description = QLabel(wordWrap=True)

        # the list with the open button
        self.listWidget = QListWidget()
        self.listWidget.setMinimumWidth(420)
        self.createArticles()

        self.openButton = QPushButton()
        self.openButton.clicked.connect(self.openAction)

        listLayout = QHBoxLayout()
        listLayout.addWidget(self.listWidget)
        listLayout.addWidget(self.openButton, alignment=Qt.AlignTop)

        # create a close button
        line = QFrame(frameShadow=QFrame.Sunken, frameShape=QFrame.HLine)
        self.closeButton = QPushButton()
        self.closeButton.setFixedWidth(self._BUTTON_MIN_WIDTH)
        self.closeButton.clicked.connect(self.close)

        # content layout
        contentLayout = QVBoxLayout()
        contentLayout.addWidget(self.headline)
        contentLayout.addWidget(self.description)
        contentLayout.addLayout(listLayout)
        contentLayout.addWidget(line)
        contentLayout.addWidget(self.closeButton, alignment=Qt.AlignRight)

        # main layout
        layout = QHBoxLayout(self)
        layout.addLayout(logoLayout)
        layout.addLayout(contentLayout)

        # translate the graphical user interface
        self.retranslateUi()
Beispiel #9
0
    def setNameAndBrush(self, sigma, color=Qt.black):
        self.sigma = sigma
        self.setText(f'σ{self.column}'.translate(self.sub_trans))
        if self.sigma is not None:
            total_window = (1 + 2 * int(self.sigma * self.window_size + 0.5))
            self.setToolTip(f'sigma = {sigma:.1f} pixels, window diameter = {total_window:.1f}')
        font = QFont()
        font.setPointSize(10)
        # font.setBold(True)
        self.setFont(font)
        self.setForeground(color)

        pixmap = QPixmap(self.pixmapSize)
        pixmap.fill(Qt.transparent)
        painter = QPainter()
        painter.begin(pixmap)
        painter.setRenderHint(QPainter.Antialiasing, True)
        painter.setPen(color)
        brush = QBrush(color)
        painter.setBrush(brush)
        painter.drawEllipse(QRect(old_div(self.pixmapSize.width(), 2) - old_div(self.brushSize, 2),
                                  old_div(self.pixmapSize.height(), 2) - old_div(self.brushSize, 2),
                                  self.brushSize, self.brushSize))
        painter.end()
        self.setIcon(QIcon(pixmap))
        self.setTextAlignment(Qt.AlignVCenter)
Beispiel #10
0
def setThemeEditorDatas(editor, themeDatas, pixmap, screenRect):
    textRect = themeTextRect(themeDatas, screenRect)
    x, y, width, height = themeEditorGeometry(themeDatas, textRect)
    editor.setGeometry(x, y, width, height)

    # p = editor.palette()
    ##p.setBrush(QPalette.Base, QBrush(pixmap.copy(x, y, width, height)))
    # p.setBrush(QPalette.Base, QColor(Qt.transparent))
    # p.setColor(QPalette.Text, QColor(themeDatas["Text/Color"]))
    # p.setColor(QPalette.Highlight, QColor(themeDatas["Text/Color"]))
    # p.setColor(QPalette.HighlightedText, Qt.black if qGray(QColor(themeDatas["Text/Color"]).rgb()) > 127 else Qt.white)
    # editor.setPalette(p)

    editor.setAttribute(Qt.WA_NoSystemBackground, True)

    bf = getThemeBlockFormat(themeDatas)
    editor.setDefaultBlockFormat(bf)

    # b = editor.document().firstBlock()
    # cursor = editor.textCursor()
    # cursor.setBlockFormat(bf)
    # while b.isValid():
    # bf2 = b.blockFormat()
    # bf2.merge(bf)
    # cursor.setPosition(b.position())
    ##cursor.setPosition(b.position(), QTextCursor.KeepAnchor)
    # cursor.setBlockFormat(bf2)
    # b = b.next()

    editor.setTabStopWidth(themeDatas["Spacings/TabWidth"])
    editor.document().setIndentWidth(themeDatas["Spacings/TabWidth"])

    editor.highlighter.setMisspelledColor(QColor(themeDatas["Text/Misspelled"]))

    cf = QTextCharFormat()
    # f = QFont()
    # f.fromString(themeDatas["Text/Font"])
    # cf.setFont(f)
    editor.highlighter.setDefaultCharFormat(cf)
    f = QFont()
    f.fromString(themeDatas["Text/Font"])
    # editor.setFont(f)

    editor.setStyleSheet("""
        background: transparent;
        color: {foreground};
        font-family: {ff};
        font-size: {fs};
        selection-color: {sc};
        selection-background-color: {sbc};
        """.format(
            foreground=themeDatas["Text/Color"],
            ff=f.family(),
            fs="{}pt".format(str(f.pointSize())),
            sc="black" if qGray(QColor(themeDatas["Text/Color"]).rgb()) > 127 else "white",
            sbc=themeDatas["Text/Color"],
    )
    )

    editor._fromTheme = True
    def generate_tree_model(self, data_dict):
        """Generate a tree model for specified dictionary

        :param data_dict: A dictionary
        :type data_dict: dict
        :return: list of QTreeWidgetItem
        :rtype list:
        """
        widget_items = []
        font = QFont()
        font.setBold(True)
        for key in data_dict.keys():
            entry = data_dict[key]
            key_item = QTreeWidgetItem()
            key_item.setText(0, str(key))
            key_item.setFont(0, font)
            if isinstance(entry, dict):
                items = self.generate_tree_model(entry)
                key_item.addChildren(items)
            else:
                # value_item = QTreeWidgetItem()
                key_item.setText(1, str(entry))
                key_item.setFlags(key_item.flags() | Qt.ItemIsEditable)
                # key_item.addChild(key_item)
            widget_items.append(key_item)

        return widget_items
            def cb_read(result):
                self.log_file.release()
                self.log_file = None

                self.label_download.setVisible(False)
                self.progress_download.setVisible(False)

                if result.error != None:
                    self.log('Error: ' + html.escape(str(result.error)), bold=True)
                    return

                try:
                    self.content = result.data.decode('utf-8')
                except UnicodeDecodeError:
                    # FIXME: maybe add a encoding guesser here or try some common encodings if UTF-8 fails
                    self.log('Error: Log file is not UTF-8 encoded', bold=True)
                    return

                self.button_save.setEnabled(True)

                if self.continuous:
                    content = self.content.lstrip()
                else:
                    content = self.content

                self.edit_content.setPlainText('')

                font = QFont('monospace')
                font.setStyleHint(QFont.TypeWriter)

                self.edit_content.setFont(font)
                self.edit_content.setPlainText(content)
Beispiel #13
0
    def __init__(self, engine, parent = None):
        super().__init__(parent)

        self._engine = engine
        self._styles = None
        self._path = ""
        self._icons = {}
        self._images = {}

        # Workaround for incorrect default font on Windows
        if sys.platform == "win32":
            default_font = QFont()
            default_font.setPointSize(9)
            QCoreApplication.instance().setFont(default_font)

        self._em_height = int(QFontMetrics(QCoreApplication.instance().font()).ascent())
        self._em_width = self._em_height;

        self._initializeDefaults()

        Preferences.getInstance().addPreference("general/theme", Application.getInstance().getApplicationName())
        try:
            theme_path = Resources.getPath(Resources.Themes, Preferences.getInstance().getValue("general/theme"))
            self.load(theme_path)
        except FileNotFoundError:
            Logger.log("e", "Could not find theme file.")
Beispiel #14
0
 def data(self, index: QModelIndex, role=Qt.DisplayRole):
     i, j = index.row(), index.column()
     if role == Qt.DisplayRole:
         try:
             lbl = self.message_type[i]
         except IndexError:
             return False
         if j == 0:
             return lbl.name
         elif j == 1:
             return self.message.get_label_range(lbl, view=self.proto_view, decode=True)[0] + 1
         elif j == 2:
             return self.message.get_label_range(lbl, view=self.proto_view, decode=True)[1]
         elif j == 3:
             return lbl.color_index
         elif j == 4:
             return lbl.apply_decoding
     elif role == Qt.TextAlignmentRole:
         return Qt.AlignCenter
     elif role == Qt.FontRole and j == 0:
         font = QFont()
         font.setItalic(self.message_type[i].field_type is None)
         return font
     else:
         return None
Beispiel #15
0
 def refresh(self):
     """
     Public method to refresh the tree.
     """
     QApplication.setOverrideCursor(Qt.WaitCursor)
     self.__itemChangingBlock = True
     self.clear()
     
     boldFont = QFont()
     boldFont.setBold(True)
     
     self.__topItem = QTreeWidgetItem(self)
     self.__topItem.setText(0, self.__subscription.title())
     self.__topItem.setFont(0, boldFont)
     self.addTopLevelItem(self.__topItem)
     
     allRules = self.__subscription.allRules()
     
     index = 0
     for rule in allRules:
         item = QTreeWidgetItem(self.__topItem)
         item.setText(0, rule.filter())
         item.setData(0, Qt.UserRole, index)
         if self.__subscription.canEditRules():
             item.setFlags(item.flags() | Qt.ItemIsEditable)
         self.__adjustItemFeatures(item, rule)
         index += 1
     
     self.expandAll()
     self.showRule(None)
     self.__itemChangingBlock = False
     QApplication.restoreOverrideCursor()
     QApplication.processEvents()
Beispiel #16
0
    def initUi(self, options, enabledOptions, headerOptions, singleSelectionMode):
        boldFont = QFont()
        boldFont.setBold(True)

        # set the selection mode
        if not singleSelectionMode:
            self.listView_options.setSelectionMode(QAbstractItemView.ExtendedSelection)

        # create enableItems if none
        if enabledOptions is None:
            enabledOptions = [True for idx in range(len(options))]

        # Insert the choices
        self.standaredItemModel = QStandardItemModel(self.listView_options)
        self.standaredItemModel.itemChanged.connect(self.onItemChanged)
        for idx in range(len(options)):
            standaredItem = QStandardItem(options[idx])
            standaredItem.setSelectable(enabledOptions[idx])
            if idx in headerOptions:
                standaredItem.setFont(boldFont)
            self.standaredItemModel.appendRow(standaredItem)

        self.listView_options.setModel(self.standaredItemModel)

        # disable select all / de select all buttons if in single selection
        # mode
        if singleSelectionMode:
            self.pushButton_sellectAll.setDisabled(True)
            self.pushButton_deSellectAll.setDisabled(True)
Beispiel #17
0
    def __init__(self, text, parent):
        super(DragLabel, self).__init__(parent)

        metric = QFontMetrics(self.font())
        size = metric.size(Qt.TextSingleLine, text)

        image = QImage(size.width() + 12, size.height() + 12, QImage.Format_ARGB32_Premultiplied)
        image.fill(qRgba(0, 0, 0, 0))

        font = QFont()
        font.setStyleStrategy(QFont.ForceOutline)

        painter = QPainter()
        painter.begin(image)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setBrush(Qt.white)
        painter.drawRoundedRect(QRectF(0.5, 0.5, image.width() - 1, image.height() - 1), 25, 25, Qt.RelativeSize)

        painter.setFont(font)
        painter.setBrush(Qt.black)
        painter.drawText(QRect(QPoint(6, 6), size), Qt.AlignCenter, text)
        painter.end()

        self.setPixmap(QPixmap.fromImage(image))
        self.labelText = text
Beispiel #18
0
class HelpLabel(QLabel):

    def __init__(self, text, help_text):
        QLabel.__init__(self, text)
        self.help_text = help_text
        self.app = QCoreApplication.instance()
        self.font = QFont()

    def mouseReleaseEvent(self, x):
        custom_message_box(icon=QMessageBox.Information,
                           parent=self,
                           title=_('Help'),
                           text=self.help_text)

    def enterEvent(self, event):
        self.font.setUnderline(True)
        self.setFont(self.font)
        self.app.setOverrideCursor(QCursor(Qt.PointingHandCursor))
        return QLabel.enterEvent(self, event)

    def leaveEvent(self, event):
        self.font.setUnderline(False)
        self.setFont(self.font)
        self.app.setOverrideCursor(QCursor(Qt.ArrowCursor))
        return QLabel.leaveEvent(self, event)
 def _setupUi(self):
     self.setWindowTitle(tr("Schedule Modification Scope"))
     self.resize(333, 133)
     self.verticalLayout = QVBoxLayout(self)
     self.label = QLabel(tr("Do you want this change to affect all future occurrences of this schedule?"))
     font = QFont()
     font.setWeight(75)
     font.setBold(True)
     self.label.setFont(font)
     self.label.setWordWrap(True)
     self.verticalLayout.addWidget(self.label)
     self.label_2 = QLabel(tr(
         "You can force global scope (in other words, changing all future occurrences) by "
         "holding Shift when you perform the change."
     ))
     self.label_2.setWordWrap(True)
     self.verticalLayout.addWidget(self.label_2)
     self.horizontalLayout = QHBoxLayout()
     self.cancelButton = QPushButton(tr("Cancel"))
     self.cancelButton.setShortcut("Esc")
     self.horizontalLayout.addWidget(self.cancelButton)
     spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
     self.horizontalLayout.addItem(spacerItem)
     self.globalScopeButton = QPushButton(tr("All future occurrences"))
     self.globalScopeButton.setAutoDefault(False)
     self.horizontalLayout.addWidget(self.globalScopeButton)
     self.localScopeButton = QPushButton(tr("Just this one"))
     self.localScopeButton.setAutoDefault(False)
     self.localScopeButton.setDefault(True)
     self.horizontalLayout.addWidget(self.localScopeButton)
     self.verticalLayout.addLayout(self.horizontalLayout)
Beispiel #20
0
    def __init__(self, engine, parent = None) -> None:
        super().__init__(parent)

        self._engine = engine
        self._styles = None  # type: Optional[QObject]
        self._path = ""
        self._icons = {}  # type: Dict[str, QUrl]
        self._images = {}  # type: Dict[str, QUrl]

        # Workaround for incorrect default font on Windows
        if sys.platform == "win32":
            default_font = QFont()
            default_font.setPointSize(9)
            QCoreApplication.instance().setFont(default_font)

        self._em_height = int(QFontMetrics(QCoreApplication.instance().font()).ascent())
        self._em_width = self._em_height

        # Cache the initial language in the preferences. For fonts, a special font can be defined with, for example,
        # "medium" and "medium_nl_NL". If the special one exists, getFont() will return that, otherwise the default
        # will be returned. We cache the initial language here is because Cura can only change its language if it gets
        # restarted, so we need to keep the fonts consistent in a single Cura run.
        self._preferences = UM.Application.Application.getInstance().getPreferences()
        self._lang_code = self._preferences.getValue("general/language")

        self._initializeDefaults()

        self.reload()
Beispiel #21
0
 def __createTexts(self):
     """
     Private method to create the text items of the module item.
     """
     if self.model is None:
         return
     
     boldFont = QFont(self.font)
     boldFont.setBold(True)
     
     classes = self.model.getClasses()
     
     x = self.margin + self.rect().x()
     y = self.margin + self.rect().y()
     self.header = QGraphicsSimpleTextItem(self)
     self.header.setFont(boldFont)
     self.header.setText(self.model.getName())
     self.header.setPos(x, y)
     y += self.header.boundingRect().height() + self.margin
     if classes:
         txt = "\n".join(classes)
     else:
         txt = " "
     self.classes = QGraphicsSimpleTextItem(self)
     self.classes.setFont(self.font)
     self.classes.setText(txt)
     self.classes.setPos(x, y)
Beispiel #22
0
	def __init__(self, parent=None):
		super().__init__(parent)
		QPixmapCache.setCacheLimit(app_constants.THUMBNAIL_CACHE_SIZE[0]*
							 app_constants.THUMBNAIL_CACHE_SIZE[1])
		self._painted_indexes = {}

		#misc.FileIcon.refresh_default_icon()
		self.file_icons = misc.FileIcon()
		if app_constants.USE_EXTERNAL_VIEWER:
			self.external_icon = self.file_icons.get_external_file_icon()
		else:
			self.external_icon = self.file_icons.get_default_file_icon()

		self.font_size = app_constants.GALLERY_FONT[1]
		self.font_name =0 # app_constants.GALLERY_FONT[0]
		if not self.font_name:
			self.font_name = QWidget().font().family()
		self.title_font = QFont()
		self.title_font.setBold(True)
		self.title_font.setFamily(self.font_name)
		self.artist_font = QFont()
		self.artist_font.setFamily(self.font_name)
		if self.font_size is not 0:
			self.title_font.setPixelSize(self.font_size)
			self.artist_font.setPixelSize(self.font_size)
		self.title_font_m = QFontMetrics(self.title_font)
		self.artist_font_m = QFontMetrics(self.artist_font)
		t_h = self.title_font_m.height()
		a_h = self.artist_font_m.height()
		self.text_label_h = a_h + t_h * 2
		self.W = app_constants.THUMB_W_SIZE
		self.H = app_constants.THUMB_H_SIZE + app_constants.GRIDBOX_LBL_H#self.text_label_h #+ app_constants.GRIDBOX_LBL_H
Beispiel #23
0
 def addGraphicsItems(self):
     self.mainRect = QGraphicsRectItem(QRectF(-15, -15, 30, 30), self)
     self.nodeTitle = QGraphicsTextItem(type(self).name, self)
     titleFont = QFont()
     titleFont.setBold(True)
     self.nodeTitle.setFont(titleFont)
     self.selectedChanged(self.isSelected())
Beispiel #24
0
    def paintEvent(self, event):
        # Check whether this orb is enhanced
        if type(self.parent) == Board:
            enh = self.parent.enhanced[self.position]
        else:
            enh = False

        painter = QPainter(self)
        painter.drawPixmap(event.rect().adjusted(2,2,-2,-2), self.pixmap())

        w = event.rect().width()

        if enh:
            path = QPainterPath()

            pen = QPen()
            pen.setWidth(1);
            pen.setBrush(Qt.white)

            brush = QBrush(Qt.yellow)

            font = QFont()
            font.setPointSize(20)
            font.setWeight(QFont.Black)
            
            path.addText(event.rect().x()+w-15,event.rect().y()+w-5,font,'+')

            painter.setPen(pen)
            painter.setBrush(brush)
            painter.setFont(font)

            painter.drawPath(path)
Beispiel #25
0
    def draw_markings(self, painter):
        painter.save()
        painter.translate(self.width()/2, self.height()/2)
        scale = min((self.width() - self._margins)/120.0, (self.height() - self._margins)/120.0)
        painter.scale(scale, scale)

        font = QFont(self.font())
        font.setPixelSize(12)
        metrics = QFontMetricsF(font)

        painter.setFont(font)
        painter.setPen(self.palette().color(QPalette.WindowText))

        i = 0
        while i < 360:
            if i % 45 == 0:
                painter.drawLine(0, -40, 0, -50)
                painter.drawText(-metrics.width(self._point_text[i])/2.0, -52, self._point_text[i])
            else:
                painter.drawLine(0, -45, 0, -50)

            painter.rotate(15)
            i += 15

        painter.restore()
Beispiel #26
0
def pixmap(cursor, num_lines=6, scale=0.8):
    """Return a QPixmap displaying the selected lines of the document.

    If the cursor has no selection, num_lines are drawn.

    By default the text is drawn 0.8 * the normal font size. You can change
    that by supplying the scale parameter.

    """
    block = cursor.document().findBlock(cursor.selectionStart())
    c2 = QTextCursor(block)
    if cursor.hasSelection():
        c2.setPosition(cursor.selectionEnd(), QTextCursor.KeepAnchor)
        c2.movePosition(QTextCursor.EndOfBlock, QTextCursor.KeepAnchor)
    else:
        c2.movePosition(QTextCursor.NextBlock, QTextCursor.KeepAnchor, num_lines)

    data = textformats.formatData('editor')
    doc = QTextDocument()
    font = QFont(data.font)
    font.setPointSizeF(font.pointSizeF() * scale)
    doc.setDefaultFont(font)
    doc.setPlainText(c2.selection().toPlainText())
    if metainfo.info(cursor.document()).highlighting:
        highlighter.highlight(doc, state=tokeniter.state(block))
    size = doc.size().toSize() + QSize(8, -4)
    pix = QPixmap(size)
    pix.fill(data.baseColors['background'])
    doc.drawContents(QPainter(pix))
    return pix
Beispiel #27
0
 def __init__(self, printViewModel, baseFont):
     self.printViewModel = printViewModel # From core.gui.transaction_print
     self._rowFont = QFont(baseFont)
     self._splitFont = QFont(baseFont)
     self._splitFont.setPointSize(self._splitFont.pointSize()-2)
     self._headerFont = QFont(self._rowFont)
     self._headerFont.setBold(True)
Beispiel #28
0
 def __adjustItemFeatures(self, itm, rule):
     """
     Private method to adjust an item.
     
     @param itm item to be adjusted (QTreeWidgetItem)
     @param rule rule for the adjustment (AdBlockRule)
     """
     if not rule.isEnabled():
         font = QFont()
         font.setItalic(True)
         itm.setForeground(0, QColor(Qt.gray))
         
         if not rule.isComment() and not rule.isHeader():
             itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
             itm.setCheckState(0, Qt.Unchecked)
             itm.setFont(0, font)
         
         return
     
     itm.setFlags(itm.flags() | Qt.ItemIsUserCheckable)
     itm.setCheckState(0, Qt.Checked)
     
     if rule.isCSSRule():
         itm.setForeground(0, QColor(Qt.darkBlue))
         itm.setFont(0, QFont())
     elif rule.isException():
         itm.setForeground(0, QColor(Qt.darkGreen))
         itm.setFont(0, QFont())
     else:
         itm.setForeground(0, QColor())
         itm.setFont(0, QFont())
Beispiel #29
0
    def __init__(self, parent=None, command="/bin/bash", font_size=14):
        super().__init__(parent)

        self._columns = 80
        self._rows = 24
        self._char_width = [0] * (self._columns + 1)
        self._char_height = [0] * (self._rows + 1)

        self.setFocusPolicy(Qt.StrongFocus)
        self.setAutoFillBackground(False)
        self.setAttribute(Qt.WA_OpaquePaintEvent, True)
        self.setCursor(Qt.IBeamCursor)
        font_name = "Monospace"

        if sys.platform == 'darwin':
            font_name = "Courier"

        font = QFont(font_name)
        font.setStyleHint(QFont.TypeWriter)
        font.setPixelSize(font_size)
        self.setFont(font)
        self._session = None
        self._last_update = 0
        self._screen = []
        self._text = []
        self._cursor_rect = None
        self._cursor_col = 0
        self._cursor_row = 0
        self._dirty = False
        self._blink = False
        self._press_pos = None
        self._selection = None
        self._clipboard = QApplication.clipboard()
        self._pixmap = None
    def show_modulation_info(self):
        show = not self.has_default_modulation or self.modulators[0] != Modulator("Modulation")

        if not show:
            self.ui.btnEditModulation.setStyleSheet("background: orange")
            font = QFont()
            font.setBold(True)
            self.ui.btnEditModulation.setFont(font)
        else:
            self.ui.btnEditModulation.setStyleSheet("")
            self.ui.btnEditModulation.setFont(QFont())

        cur_ind = self.ui.cBoxModulations.currentIndex()
        cur_mod = self.modulators[cur_ind]
        self.ui.lCarrierFreqValue.setText(cur_mod.carrier_frequency_str)
        self.ui.lCarrierPhaseValue.setText(cur_mod.carrier_phase_str)
        self.ui.lBitLenValue.setText(cur_mod.bit_len_str)
        self.ui.lSampleRateValue.setText(cur_mod.sample_rate_str)
        mod_type = cur_mod.modulation_type_str
        self.ui.lModTypeValue.setText(mod_type)
        if mod_type == "ASK":
            prefix = "Amplitude"
        elif mod_type == "PSK":
            prefix = "Phase"
        elif mod_type in ("FSK", "GFSK"):
            prefix = "Frequency"
        else:
            prefix = "Unknown Modulation Type (This should not happen...)"

        self.ui.lParamForZero.setText(prefix + " for 0:")
        self.ui.lParamForZeroValue.setText(cur_mod.param_for_zero_str)
        self.ui.lParamForOne.setText(prefix + " for 1:")
        self.ui.lParamForOneValue.setText(cur_mod.param_for_one_str)