def find(self): # hide replace stuff self.replaceLabel.hide() self.replaceEntry.hide() self.replaceButton.hide() self.replaceAllButton.hide() self._replace = False # we are not in replace mode visible = self.isVisible() if not visible: with util.signalsBlocked(self.searchEntry): self.searchEntry.clear() self.showWidget() if not visible and self.currentView(): # pick current word cursor = self.currentView().textCursor() cursor.movePosition(QTextCursor.StartOfWord) cursor.movePosition(QTextCursor.EndOfWord, QTextCursor.KeepAnchor) word = cursor.selection().toPlainText() if not re.search(r'\w', word): word = "" self.searchEntry.setText(word) self.searchEntry.selectAll() else: self.slotSearchChanged() self.searchEntry.setFocus()
def updateDisplay(self): data = self.data[self.scheme.currentScheme()] with util.signalsBlocked(self.fontChooser, self.fontSize): self.fontChooser.setCurrentFont(data.font) self.fontSize.setValue(data.font.pointSizeF()) with util.signalsBlocked(self): # update base colors for name in textformats.baseColors: self.baseColorsWidget.color[name].setColor(data.baseColors[name]) # update base colors for whole treewidget p = QApplication.palette() p.setColor(QPalette.Base, data.baseColors["background"]) p.setColor(QPalette.Text, data.baseColors["text"]) p.setColor(QPalette.Highlight, data.baseColors["selectionbackground"]) p.setColor(QPalette.HighlightedText, data.baseColors["selectiontext"]) self.tree.setPalette(p) def setItemTextFormat(item, f): font = QFont(data.font) if f.hasProperty(QTextFormat.ForegroundBrush): item.setForeground(0, f.foreground().color()) else: item.setForeground(0, data.baseColors["text"]) if f.hasProperty(QTextFormat.BackgroundBrush): item.setBackground(0, f.background().color()) else: item.setBackground(0, QBrush()) font.setWeight(f.fontWeight()) font.setItalic(f.fontItalic()) font.setUnderline(f.fontUnderline()) item.setFont(0, font) # update looks of default styles for name in textformats.defaultStyles: setItemTextFormat(self.defaultStyles[name], data.defaultStyles[name]) # update looks of all the specific styles for group, styles in textformats.allStyles: children = self.allStyles[group][1] for name in styles: inherit = textformats.inherits[group].get(name) f = QTextCharFormat(data.defaultStyles[inherit]) if inherit else QTextCharFormat() f.merge(data.allStyles[group][name]) setItemTextFormat(children[name], f)
def currentSchemeChanged(self): scheme = self.scheme.currentScheme() if scheme not in self.data: self.data[scheme] = textformats.TextFormatData(scheme) self.updateDisplay() if self.tree.currentItem(): self.currentItemChanged(self.tree.currentItem(), None) with util.signalsBlocked(self.printScheme): self.printScheme.setChecked(scheme == self._printScheme)
def loadSettings(self): s = QSettings() s.beginGroup("log") font = QFont(s.value("fontfamily", "monospace")) font.setPointSizeF(float(s.value("fontsize", 9.0))) with util.signalsBlocked(self.fontChooser, self.fontSize): self.fontChooser.setCurrentFont(font) self.fontSize.setValue(font.pointSizeF()) self.showlog.setChecked(s.value("show_on_start", True) not in (False, "false")) self.rawview.setChecked(s.value("rawview", True) not in (False, "false"))
def loadSettings(self): s = QSettings() s.beginGroup("charmaptool") font = self.font() family = s.value("fontfamily", "") if family: font.setFamily(family) font.setPointSizeF(float(s.value("fontsize", font.pointSizeF()))) with util.signalsBlocked(self.fontChooser, self.fontSize): self.fontChooser.setCurrentFont(font) self.fontSize.setValue(font.pointSizeF())
def populate(self): self._group = QSettings().value( "document_list/group_by_folder", False) in (True, "true") self.clear() self._paths = {} self._items = {} with util.signalsBlocked(self): # add all existing docs to the list for d in app.documents: self.addDocument(d) doc = self.parentWidget().mainwindow().currentDocument() if doc: self.selectDocument(doc)
def setPageCount(self, total): if total: self.setVisible(True) # L10N: page numbering: page {num} of {total} prefix, suffix = _("{num} of {total}").split('{num}') def adjust(w): w.setRange(1, total) w.setSuffix(suffix.format(total=total)) w.setPrefix(prefix.format(total=total)) else: self.setVisible(False) def adjust(w): w.setRange(0, 0) w.clear() for w in self.createdWidgets(): with util.signalsBlocked(w): adjust(w)
def loadSettings(self): s = QSettings() s.beginGroup("documentation") lang = s.value("language", "default") if lang in lilydoc.translations: i = lilydoc.translations.index(lang) + 2 elif lang == "C": i = 1 else: i = 0 self.languages.setCurrentIndex(i) font = self.font() family = s.value("fontfamily", "") if family: font.setFamily(family) size = int(s.value("fontsize", 16)) with util.signalsBlocked(self.fontChooser, self.fontSize): self.fontChooser.setCurrentFont(font) self.fontSize.setValue(size)
def updateTimeSlider(self): if not self._timeSlider.isSliderDown(): with util.signalsBlocked(self._timeSlider): self._timeSlider.setMaximum(self._player.total_time()) self._timeSlider.setValue(self._player.current_time())
def refreshMidiPorts(self): midihub.refresh_ports() with util.signalsBlocked(self): self.loadMidiPorts() self.loadSettings()
def setCurrentPage(self, num): if num: for w in self.createdWidgets(): with util.signalsBlocked(w): w.setValue(num) w.lineEdit().deselect()