def onAddField(self): diag = QDialog(self) form = aqt.forms.addfield.Ui_Dialog() form.setupUi(diag) fields = [f['name'] for f in self.model['flds']] form.fields.addItems(fields) form.font.setCurrentFont(QFont("Arial")) form.size.setValue(20) diag.show() # Work around a Qt bug, # https://bugreports.qt-project.org/browse/QTBUG-1894 if isMac or isWin: # No problems on Macs or Windows. form.fields.showPopup() else: # Delay showing the pop-up. self.mw.progress.timer(200, form.fields.showPopup, False) if not diag.exec_(): return if form.radioQ.isChecked(): obj = self.tform.front else: obj = self.tform.back self._addField(obj, fields[form.fields.currentIndex()], form.font.currentFont().family(), form.size.value())
def loadField(self, idx): self.currentIdx = idx fld = self.model['flds'][idx] f = self.form f.fontFamily.setCurrentFont(QFont(fld['font'])) f.fontSize.setValue(fld['size']) f.sticky.setChecked(fld['sticky']) f.sortField.setChecked(self.model['sortf'] == fld['ord']) f.rtl.setChecked(fld['rtl'])
def setup_personal_field_selection(self): heading_font = QFont() heading_font.setBold(True) heading_font.setUnderline(True) def add_header(name): heading_ui = QListWidgetItem(name) heading_ui.setFlags(Qt.ItemIsEnabled) heading_ui.setSizeHint( QSize(self.form.list_personal_fields.width(), 30)) heading_ui.setFont(heading_font) self.form.list_personal_fields.addItem(heading_ui) def add_field(name, is_personal) -> QListWidgetItem: field_ui = QListWidgetItem(name) field_ui.setCheckState(Qt.Checked if is_personal else Qt.Unchecked) field_ui.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable) self.form.list_personal_fields.addItem(field_ui) return field_ui for model in self.deck_json["note_models"]: model_name = model["name"] model_id = model[UUID_FIELD_NAME] add_header(model_name) for field in model["flds"]: field_name = field["name"] field_ui = add_field( field_name, self.import_defaults.is_personal_field( model_name, field_name)) self.personal_field_ui_dict[model_name].setdefault( field_name, field_ui)
def onBrowserDisplay(self): d = QDialog() f = aqt.forms.browserdisp.Ui_Dialog() f.setupUi(d) t = self.card.template() f.qfmt.setText(t.get('bqfmt', "")) f.afmt.setText(t.get('bafmt', "")) if t.get("bfont"): f.overrideFont.setChecked(True) f.font.setCurrentFont(QFont(t.get('bfont', "Arial"))) f.fontSize.setValue(t.get('bsize', 12)) f.buttonBox.accepted.connect(lambda: self.onBrowserDisplayOk(f)) d.exec_()
def additional_menu_basic(editor): config = getconfig() # mod of onAdvanced from editor.py m = QMenu(editor.mw) # m.setStyleSheet(basic_stylesheet) m.setFont(QFont('Courier New', 11)) a = m.addAction("Clear more formatting (Classes, etc.)") a.triggered.connect(lambda _: classes_addon_rangy_remove_all(editor)) m.addSeparator() for e in config['v3']: if e.get('Show_in_menu', False): text = editor.my_label_text(e, False) a = m.addAction(text) cat = e["Category"] se = e.get("Setting", e.get("Category", False)) a.triggered.connect( lambda _, a=cat, b=se: my_highlight_helper(editor, a, b)) m.exec_(QCursor.pos())
def gameOver(self, event: QPaintEvent, painter: QPainter): info = "" if self.score > self.highscore: self.lives += 1 self.highscore = self.score info = "\n\nNew high score! 1 life replenished." font_size = 10 if not is_mac else 12 painter.setPen(QColor(0, 34, 3)) painter.setFont(QFont("Decorative", font_size)) if self.lives > 0: msg = "GAME OVER{}\n\nPress space to play again".format(info) else: self.setCursor(Qt.CursorShape.PointingHandCursor) msg = ("GAME OVER\n\nYou're out of lives for today,\n" "but tomorrow is another day :)\n\n" "Tip: Get more lives by\nkeeping up with your reviews!\n\n" "Pro-Tip: Pledge your support on Patreon\n" "and get access to other secret\n" "features and add-ons :)" "\n\nClick here to go to\n" "patreon.com/glutanimate") painter.drawText(event.rect(), Qt.AlignmentFlag.AlignCenter, msg)
def scoreText(self, event: QPaintEvent, painter: QPainter): painter.setPen(QColor("#ffffff")) painter.setFont(QFont("Decorative", 10)) painter.drawText(4, 17, "LIVES: " + str(self.lives)) painter.drawText(120, 17, "SCORE: " + str(self.score)) painter.drawText(230, 17, "BEST: " + str(self.highscore))