def __init__(self, parent=None): super().__init__() # If a <Tab> is present then it should be of width 4 try: _distance = QFontMetricsF(self.font()).horizontalAdvance(" ") except AttributeError: # PyQt5 version < 5.11 _distance = QFontMetricsF(self.font()).boundingRect(" ").width() self.setTabStopDistance(_distance * self.spaces_per_tab) # Line number area self.line_number_area = LineNumberArea(self) self.blockCountChanged.connect(self.update_line_number_area_width) self.updateRequest.connect(self.update_line_number_area) self.update_line_number_area_width() # Start with a default dictionary based on the current locale. self.highlighter = PythonEnchantHighlighter(self.document()) if enchant is not None: try: self.highlighter.setDict(enchant.Dict()) except Exception as err: # There are some weird enchant issues on different platforms. # One of those has occured. warn(str(err), ImportWarning)
def setupSceneItems(self): if Colors.showFps: self.fpsLabel = DemoTextItem("FPS: --", Colors.buttonFont(), Qt.white, -1, None, DemoTextItem.DYNAMIC_TEXT) self.fpsLabel.setZValue(1000) self.fpsLabel.setPos( Colors.stageStartX, 600 - QFontMetricsF(Colors.buttonFont()).height() - 5) self.mainSceneRoot = QGraphicsWidget() self.scene.addItem(self.mainSceneRoot) self.companyLogo = ImageItem( QImage(self.imagesDir + '/trolltech-logo.png'), 1000, 1000, None, True, 0.5) self.qtLogo = ImageItem(QImage(self.imagesDir + '/qtlogo_small.png'), 1000, 1000, None, True, 0.5) self.companyLogo.setZValue(100) self.qtLogo.setZValue(100) self.pausedLabel = DemoTextItem("PAUSED", Colors.buttonFont(), Qt.white, -1, None) self.pausedLabel.setZValue(100) fm = QFontMetricsF(Colors.buttonFont()) self.pausedLabel.setPos(Colors.stageWidth - fm.width("PAUSED"), 590 - fm.height()) self.pausedLabel.setRecursiveVisible(False)
def calculateHeight(self): """ Calculate window height adjusting to sequence height with possible ions and set default setting in case of no ions. """ prefix = self._pep.prefix suffix = self._pep.suffix if suffix == {}: max_ion_suff = 1 else: max_ion_suff = len(suffix[max(suffix, key=lambda key: len(suffix[key]))]) if prefix == {}: max_ion_pre = 1 else: max_ion_pre = len(prefix[max(prefix, key=lambda key: len(prefix[key]))]) metrics_pep = QFontMetricsF(self._pep.getFont_Pep()) height_pep = metrics_pep.height() metrics_ion = QFontMetricsF(self._pep.getFont_Ion()) height_ion = metrics_ion.height() # window height calculated with the sum of max prefix and suffix height height_ion_pre = (height_ion * max_ion_pre + 15) SequenceIonsWidget.SUFFIX_HEIGHT = (height_ion * max_ion_suff + 5) SequenceIonsWidget.HEIGHT = height_pep + height_ion_pre + SequenceIonsWidget.SUFFIX_HEIGHT
def setPaintDevice(device): """ Used to setup font metrics correctly """ Constants.nodeItemFontNameMetrics = QFontMetricsF( Constants.nodeItemFontName, device) Constants.nodeItemFontTypeMetrics = QFontMetricsF( Constants.nodeItemFontType, device) Constants.nodeItemFontBlobMetrics = QFontMetricsF( Constants.nodeItemFontBlob, device)
def drawTwoTexts( self, p: QPainter, firstRect: QRectF, secondRect: QRectF, innerRadius: float, value: float, ): if not self.m_format: return if self.useSystemFont: font = QFont(self.font()) else: font = QFont('Noto Sans') font.setPixelSize(10) fm = QFontMetricsF(font) maxWidth = fm.width(self.valueToText(self.m_max)) delta = innerRadius / maxWidth timeFontSize = font.pixelSize() * delta * 0.75 font.setPixelSize(int(timeFontSize)) p.setFont(font) timeTextRect = QRectF(firstRect) tomatoesTextRect = QRectF(secondRect) p.setPen(self.palette().text().color()) p.drawText(timeTextRect, Qt.AlignCenter | Qt.AlignBottom, self.valueToText(value)) tomatoesFontSize = timeFontSize * 0.3 font.setPixelSize(int(tomatoesFontSize)) p.setFont(font) p.drawText(tomatoesTextRect, Qt.AlignHCenter, self.m_second_format)
def drawDirections(self, painter): painter.save() painter.translate(self.width() / 2, self.height() / 2) # Centers the position on the widget. scale = min((self.width() - self.margins) / 120, (self.height() - self.margins) / 120) painter.scale(scale, scale) font = QFont(self.font()) font.setPixelSize(10) metrics = QFontMetricsF(font) painter.setFont(font) painter.setPen(self.palette().color(QPalette.Shadow)) i = 0 while i < 360: # Check if it should draw the directions or if it should draw the lines between the directions. if i % 45 == 0: painter.drawLine(0, -40, 0, -50) painter.drawText(-metrics.width(self.directions[i]) / 2, -52, self.directions[i]) else: painter.drawLine(0, -45, 0, -50) painter.rotate(15) i += 15 painter.restore()
def _drawLabels(self, painter: QPainter): """отображение подписей на осях""" f_m = QFontMetricsF(self._style['grid']['font']) pen = painter.pen() text = 'Расход, м³/сутки' offset_x = self._margins[0] + self.getDrawArea().width() / 2 offset_x -= f_m.width(text) / 2 offset_y = self.height() - self._margins[3] + f_m.height() offset_y += 20 painter.setPen(self._style['grid']['border']) painter.drawText(QPointF(offset_x, offset_y), text) text = 'Напор, м' offset_x = 0 - f_m.height() - 5 self._drawLabel(painter, f_m, offset_x, text) text = 'Мощность, кВт' offset_x = self._margins[0] + self.getDrawArea().width() + 10 painter.setPen(self._charts['etl_pwr'].pen) self._drawLabel(painter, f_m, offset_x, text) text = 'КПД, %' offset_x = self._margins[0] + self.getDrawArea().width() + \ self._grid_divs['y1'].width + 40 painter.setPen(self._charts['etl_eff'].pen) self._drawLabel(painter, f_m, offset_x, text) painter.setPen(pen)
def setFontMetrics(): """ Application must be running before you mess too much with Fonts in Qt5 """ global SEQUENCEFONT global SEQUENCEFONTMETRICS global SEQUENCEFONTCHARWIDTH global SEQUENCEFONTCHARHEIGHT global SEQUENCEFONTEXTRAWIDTH global SEQUENCETEXTXCENTERINGOFFSET global SEQUENCETEXTYCENTERINGOFFSET SEQUENCEFONT = QFont("Monaco") if hasattr(QFont, 'Monospace'): SEQUENCEFONT.setStyleHint(QFont.Monospace) SEQUENCEFONT.setFixedPitch(True) SEQUENCEFONTH = int(PATH_BASE_WIDTH / 3.) SEQUENCEFONT.setPixelSize(SEQUENCEFONTH) SEQUENCEFONTMETRICS = QFontMetricsF(SEQUENCEFONT) SEQUENCEFONTCHARWIDTH = SEQUENCEFONTMETRICS.width("A") SEQUENCEFONTCHARHEIGHT = SEQUENCEFONTMETRICS.height() SEQUENCEFONTEXTRAWIDTH = PATH_BASE_WIDTH - SEQUENCEFONTCHARWIDTH SEQUENCEFONT.setLetterSpacing(QFont.AbsoluteSpacing, SEQUENCEFONTEXTRAWIDTH) SEQUENCETEXTXCENTERINGOFFSET = SEQUENCEFONTEXTRAWIDTH / 4. SEQUENCETEXTYCENTERINGOFFSET = PATH_BASE_WIDTH * 0.6
def __init__(self, lbl='', onColor='green', offColor='red', initialState=False, maxSize=50, position=1, parent=None, callback=None, alignment=1, valignment=1): QFrame.__init__(self, parent) self.numberControl = ToggleSwitch(onColor, offColor, initialState, maxSize, parent, callback) if position < 3: layout = QVBoxLayout() else: layout = QHBoxLayout() self.lbl = lbl self.lblcontrol = QLabel(lbl, self) if position == 3: # left of switch self.lblcontrol.setAlignment(Qtc.AlignRight) elif position == 4: # right of switch self.lblcontrol.setAlignment(Qtc.AlignLeft) else: # Above or below self.lblcontrol.setAlignment(Qtc.AlignCenter) # add top or left if len(lbl) > 0: if position == 1 or position == 3: layout.addWidget(self.lblcontrol) layout.addWidget(self.numberControl) # Add bottom or right if len(lbl) > 0: if position == 2 or position == 4: layout.addWidget(self.lblcontrol) if alignment == 1: halign = Qtc.AlignCenter elif alignment == 2: halign = Qtc.AlignLeft else: halign = Qtc.AlignRight if valignment == 1: valign = Qtc.AlignVCenter elif valignment == 2: valign = Qtc.AlignTop else: valign = Qtc.AlignBottom layout.setAlignment(halign | valign) # layout.setAlignment(Qtc.AlignCenter | Qtc.AlignVCenter) self.setLayout(layout) textfont = self.lblcontrol.font() metrics = QFontMetricsF(textfont) maxWidth = max( (maxSize+4),(maxSize*2 + metrics.width(lbl)) ) maxHeight = max( (maxSize/2+4),(maxSize/2 + metrics.height()+2) ) #print('Min size: ' + str(maxWidth) + " x " + str(maxHeight)) self.setMinimumSize(int(maxWidth), int(maxHeight)) self.show()
def drawMarkings(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(8) metrics = QFontMetricsF(font) painter.setFont(font) painter.setPen(QPen(QColor(self.scaleColor))) tickInterval = 5 i = 0 while i < 360: if i % 45 == 0: painter.drawLine(0, -40, 0, -50) painter.drawText(int(-metrics.width(self._pointText[i]) / 2.0), -52, self._pointText[i]) else: painter.drawLine(0, -45, 0, -50) painter.rotate(tickInterval) i += tickInterval painter.restore()
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()
def draw_markings(self, painter): """ draw markings""" 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(10) metrics = QFontMetricsF(font) painter.setFont(font) painter.setPen(QPen(QBrush(Qt.black), 1, Qt.SolidLine)) i = 0 while i < 360: if i % 45 == 0: painter.drawLine(0, -40, 0, -50) painter.drawText(-metrics.width(self._pointText[i]) / 2.0, -52, self._pointText[i]) else: painter.drawLine(0, -45, 0, -50) painter.rotate(15) i += 15 painter.restore()
def __init__(self, leftFlow=0, rightFlow=0, maxFlow=100, parent=None): super(YPipeWidget, self).__init__(parent) self.leftSpinBox = QSpinBox(self) self.leftSpinBox.setRange(0, maxFlow) self.leftSpinBox.setValue(leftFlow) self.leftSpinBox.setSuffix(" l/s") self.leftSpinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.leftSpinBox.valueChanged.connect(self.valueChanged) self.rightSpinBox = QSpinBox(self) self.rightSpinBox.setRange(0, maxFlow) self.rightSpinBox.setValue(rightFlow) self.rightSpinBox.setSuffix(" l/s") self.rightSpinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.rightSpinBox.valueChanged.connect(self.valueChanged) self.label = QLabel(self) self.label.setFrameStyle(QFrame.StyledPanel | QFrame.Sunken) self.label.setAlignment(Qt.AlignCenter) fm = QFontMetricsF(self.font()) self.label.setMinimumWidth(fm.width(" 999 l/s ")) self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.setMinimumSize(self.minimumSizeHint()) self.valueChanged()
def __init__(self, leftFlow=0, rightFlow=0, maxFlow=100, parent=None): super(YPipeWidget, self).__init__(parent) self.leftSpinBox = QSpinBox( self) # 因为不会对其进行布局,所以使用self将其父声明为YPipeWidget self.leftSpinBox.setRange(0, maxFlow) self.leftSpinBox.setValue(leftFlow) self.leftSpinBox.setSuffix(" 升每秒") self.leftSpinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.leftSpinBox.valueChanged.connect(self.valueChanged) self.rightSpinBox = QSpinBox(self) self.rightSpinBox.setRange(0, maxFlow) self.rightSpinBox.setValue(rightFlow) self.rightSpinBox.setSuffix(" 升每秒") self.rightSpinBox.setAlignment(Qt.AlignRight | Qt.AlignVCenter) self.rightSpinBox.valueChanged.connect(self.valueChanged) self.label = QLabel(self) self.label.setFrameStyle( QFrame.WinPanel | QFrame.Raised) #其接受两个对象,第一个是frame sharp,第二个是shadow style。 self.label.setLineWidth(2) self.label.setAlignment(Qt.AlignCenter) fm = QFontMetricsF(self.font()) self.label.setMinimumWidth(fm.width(" 666999 升每秒666 ")) #设置下方最大宽度 self.setSizePolicy( QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.setMinimumSize(self.minimumSizeHint()) self.valueChanged()
def minimumSizeHint(self): font = QFont(self.font()) font.setPointSize(font.pointSize() - 1) fm = QFontMetricsF(font) return QSize( fm.width(FractionSlider.WSTRING) * self.__denominator, (fm.height() * 4) + FractionSlider.YMARGIN)
def sizeHint(self): metrics = QFontMetricsF(self.editor.font()) size_hint = QSize(metrics.height(), metrics.height()) if size_hint.width() > 16: size_hint.setWidth(16) return size_hint
def setFontSize(self, size): """ Updates the symbol font size too -- make sure it matches. """ font = self.font() font.setPointSize(size) self.ssFontWidth = QFontMetricsF(QFont("Default-Noto", size)).averageCharWidth() self.setFont(font) del size, font
def __init__(self, parent=None): super().__init__() # If a <Tab> is present then it should be of width 4 try: _distance = QFontMetricsF(self.font()).horizontalAdvance(" ") except AttributeError: # PyQt5 version < 5.11 _distance = QFontMetricsF(self.font()).boundingRect(" ").width() self.setTabStopDistance(_distance * self.spaces_per_tab) # Start with a default dictionary based on the current locale. self.highlighter = PythonEnchantHighlighter(self.document()) if enchant is not None: self.highlighter.setDict(enchant.Dict())
def reposition(self): fm = QFontMetricsF(self._font, self) rect = fm.boundingRect(QRectF(self.rect()), Qt.AlignCenter, str(self._value)) self._xpos = -rect.width() / 2.0 self._ypos = rect.height() / 2.0 - fm.descent() self.update()
def rescale(self): fm = QFontMetricsF(self._font, self) maxRect = fm.boundingRect(QRectF(self.rect()), Qt.AlignCenter, str(self._maximum)) xscale = float(self.width()) / maxRect.width() yscale = float(self.height()) / maxRect.height() self._scale = min(xscale, yscale)
def __outline_rect(self): """:rtype QRectF""" padding = 8 metrics = QFontMetricsF() rect = metrics.boundingRect(self.text) """:type rect: QRectF""" rect.adjust(-padding, -padding, padding, padding) rect.translate(-rect.center()) return rect
def __init__(self, lbl='', onColor='green', offColor='red', initialState=False, maxSize=80, position=1, alignment=1, valignment=1, parent=None): QFrame.__init__(self, parent) self.numberControl = LEDIndicator(onColor, offColor, initialState, maxSize, parent) if position < 3: layout = QVBoxLayout() else: layout = QHBoxLayout() if len(lbl) == 0: lbl = " " self.lbl = lbl self.lblcontrol = QLabel(lbl, self) self.lblcontrol.setAlignment(Qtc.AlignCenter) # add top or left if len(lbl) > 0: if position == 1 or position == 3: layout.addWidget(self.lblcontrol) else: self.hasLabel = False layout.addWidget(self.numberControl) # Add bottom or right if len(lbl) > 0: if position == 2 or position == 4: layout.addWidget(self.lblcontrol) if alignment == 1: halign = Qtc.AlignCenter elif alignment == 2: halign = Qtc.AlignLeft else: halign = Qtc.AlignRight if valignment == 1: valign = Qtc.AlignVCenter elif valignment == 2: valign = Qtc.AlignTop else: valign = Qtc.AlignBottom layout.setAlignment(halign | valign) self.setLayout(layout) if (len(lbl) > 0): textfont = self.lblcontrol.font() metrics = QFontMetricsF(textfont) maxWidth = max( (maxSize+30),(maxSize + metrics.width(lbl)+4) ) maxHeight = max( (maxSize+35),(maxSize + metrics.height()+2) ) self.setMinimumSize(maxWidth, maxHeight) else: self.setMinimumSize(maxSize+2, maxSize+2) self.show()
def updateTabWidth(self): if not hasattr(self, "_tabWidth"): return fM = QFontMetricsF(self.font()) pixelWidth = fM.width(' ') * self._tabWidth document = self.document() opt = document.defaultTextOption() opt.setTabStop(pixelWidth) document.setDefaultTextOption(opt)
def resizeEvent(self, event=None): fm = QFontMetricsF(self.font()) x = (self.width() - self.label.width()) / 2 y = self.height() - (fm.height() * 2) self.label.move(x, y) y = self.height() / 60.0 x = (self.width() / 4.0) - self.leftSpinBox.width() self.leftSpinBox.move(x, y) x = self.width() - (self.width() / 4.0) self.rightSpinBox.move(x, y) # 左上角为(0,0)移动点以左上角为标准
def __init__(self, seqs, params): super(self.__class__, self).__init__() self.done = False # Construct the window self.alignLogger = logging.getLogger("AlignWindow") self.alignPane = widgets.AlignPane(self) self.rulerPane = QTextEdit() self.commentPane = CommentsPane() self.commentButton = QPushButton("Save") # Init functional variables self.fmF = None self._seqs = seqs self.dssps = {} self.splitNames = [] self.splitSeqs = [] self.userIsResizing = False self.refseq = None self.last = 0 self.maxlen = 0 self.maxname = 0 self.lines = 0 self.comments = {} self.showRuler = False self.showColors = False self.consvColors = False self.showDSSP = True self.ssFontWidth = None # Draw the window self.setupUi(self) self.setupCustomUi() # Connect all slots and start #self.rulerPane.verticalScrollBar().valueChanged.connect(self.alignPane.verticalScrollBar().setValue) self.alignPane.verticalScrollBar().valueChanged.connect( self.rulerPane.verticalScrollBar().setValue) self.alignPane.verticalScrollBar().valueChanged.connect( self.namePane.verticalScrollBar().setValue) #self.namePane.verticalScrollBar().valueChanged.connect(self.alignPane.verticalScrollBar().setValue) self.nameChange.connect(self.updateName) self.lineChange.connect(self.nameArrange) #self.alignPane.commentAdded.connect(self.showCommentWindow) # Initialize settings self.theme = lookupTheme('Default').theme self.params = {} self.setParams(params) self.ssFontWidth = QFontMetricsF( QFont("Default-Noto", self.params['fontsize'])).averageCharWidth() # print("Setting ssFONT Width to %s" % self.ssFontWidth) self.done = True self.seqInit()
def prepare(self, axis: Axis): """подготовка делений для оси""" # logger.debug(f"{self.prepare.__doc__} {self.name}") f_m = QFontMetricsF(self.font) self.divs.clear() for _, div in axis.generateDivSteps(): div = round(div, 7) self.divs.append(div) self.updateWidth(str(div), f_m) self.height = f_m.height() self.is_ready = True
def paintEvent(self, event=None): font = QFont(self.font()) font.setPointSize(font.pointSize() - 1) fm = QFontMetricsF(font) fracWidth = fm.width(FractionSlider.WSTRING) indent = fm.boundingRect("9").width() / 2.0 if not X11: fracWidth *= 1.5 span = self.width() - (FractionSlider.XMARGIN * 2) value = self.__numerator / float(self.__denominator) painter = QPainter(self) painter.setRenderHint(QPainter.Antialiasing) painter.setRenderHint(QPainter.TextAntialiasing) painter.setPen(self.palette().color(QPalette.Mid)) painter.setBrush(self.palette().brush(QPalette.AlternateBase)) painter.drawRect(self.rect()) segColor = QColor(Qt.green).darker(120) segLineColor = segColor.darker() painter.setPen(segLineColor) painter.setBrush(segColor) painter.drawRect(FractionSlider.XMARGIN, FractionSlider.YMARGIN, span, fm.height()) textColor = self.palette().color(QPalette.Text) segWidth = span / self.__denominator segHeight = fm.height() * 2 nRect = fm.boundingRect(FractionSlider.WSTRING) x = FractionSlider.XMARGIN yOffset = segHeight + fm.height() for i in range(self.__denominator + 1): painter.setPen(segLineColor) painter.drawLine(x, FractionSlider.YMARGIN, x, segHeight) painter.setPen(textColor) y = segHeight rect = QRectF(nRect) rect.moveCenter(QPointF(x, y + fm.height() / 2.0)) # painter.drawText(rect, Qt.AlignCenter, # QString.number(i)) painter.drawText(rect, Qt.AlignCenter, str(i)) y = yOffset rect.moveCenter(QPointF(x, y + fm.height() / 2.0)) painter.drawText(rect, Qt.AlignCenter, str(self.__denominator)) painter.drawLine(QPointF(rect.left() + indent, y), QPointF(rect.right() - indent, y)) x += segWidth span = int(span) y = FractionSlider.YMARGIN - 0.5 triangle = [ QPointF(value * span, y), QPointF((value * span) + (2 * FractionSlider.XMARGIN), y), QPointF((value * span) + FractionSlider.XMARGIN, fm.height()) ] painter.setPen(Qt.yellow) painter.setBrush(Qt.darkYellow) painter.drawPolygon(QPolygonF(triangle))
def minimumSizeHint(self): '''定义字体、字体大小、根据字体Metrics的大小返回一个QSize对象,设置最小的尺寸''' font = QFont(self.font()) # 这声明了和没有声明有什么区别?Constructs a font that is a copy of font. # self.font() This property describes the widget's requested font. # font = QFont() # 只需要一个实例,因为此函数的目的是返回一个QSize font.setPointSize(font.pointSize() - 1) # The point size must be greater than zero. # pointSize() Returns -1 if the font size was specified in pixels. fm = QFontMetricsF(font) # print(fm.height(),fm.width(FractionSlider.WSTRING),fm.width(FractionSlider.WSTRING+'666')) # Return 11.0 18.0 36.0 return QSize(fm.width(FractionSlider.WSTRING) * self.__denominator, (fm.height() * 4) + FractionSlider.YMARGIN)
def __init__(self, manager: "Manager", *args: Any) -> None: super().__init__(list(*args)) self.manager = manager self.dialogs = dict() self.osi = self.manager.osi self.setWindowIcon(QIcon(self.get_window_icon())) self.setApplicationName(manager.app_name) self._init_translator() self.setQuitOnLastWindowClosed(False) self._delegator = None self.filters_dlg = None self._conflicts_modals = dict() self.current_notification = None self.default_tooltip = self.manager.app_name font = QFont("Helvetica, Arial, sans-serif", 12) self.setFont(font) self.ratio = sqrt(QFontMetricsF(font).height() / 12) self.init_gui() self.aboutToQuit.connect(self.manager.stop) self.manager.dropEngine.connect(self.dropped_engine) # This is a windowless application mostly using the system tray self.setQuitOnLastWindowClosed(False) self.setup_systray() # Direct Edit self.manager.direct_edit.directEditConflict.connect( self._direct_edit_conflict) self.manager.direct_edit.directEditError.connect( self._direct_edit_error) # Check if actions is required, separate method so it can be overridden self.init_checks() # Setup notification center for macOS if MAC: self._setup_notification_center() # Application update self.manager.updater.appUpdated.connect(self.quit) # Display release notes on new version if self.manager.old_version != self.manager.version: self.show_release_notes(self.manager.version) # Listen for nxdrive:// sent by a new instance self.init_nxdrive_listener()
def draw(self): painter = QPainter(self._neditor.viewport()) painter.setPen(self.__color) metrics = QFontMetricsF(self._neditor.font()) doc_margin = self._neditor.document().documentMargin() offset = self._neditor.contentOffset().x() + doc_margin x = round(metrics.width(' ') * self.__position) + offset if self.__background: width = self._neditor.viewport().width() - x rect = QRect(x, 0, width, self._neditor.height()) painter.fillRect(rect, self.__background_color) painter.drawLine(x, 0, x, self._neditor.height())