From 1da04aca5dec0dcfb83c889913c08c0479489c24 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 18 Apr 2009 23:27:01 +0900 Subject: [PATCH] add browser font configurator --- ankiqt/ui/cardlist.py | 35 +++++++++-- designer/cardlist.ui | 17 +++--- designer/editfont.ui | 134 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+), 14 deletions(-) create mode 100644 designer/editfont.ui diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py index 8393f0cc7..31327983a 100644 --- a/ankiqt/ui/cardlist.py +++ b/ankiqt/ui/cardlist.py @@ -299,11 +299,9 @@ class EditDeck(QMainWindow): SIGNAL("selectionChanged(QItemSelection,QItemSelection)"), self.updateFilterLabel) self.dialog.tableView.setItemDelegate(StatusDelegate(self, self.model)) - self.dialog.tableView.setFont(QFont( - self.config['editFontFamily'], - self.config['editFontSize'])) if self.deck.getInt("reverseOrder"): self.dialog.actionReverseOrder.setChecked(True) + self.updateFont() self.setupMenus() self.setupFilter() self.setupSort() @@ -331,6 +329,14 @@ class EditDeck(QMainWindow): return i return -1 + def updateFont(self): + self.dialog.tableView.setFont(QFont( + self.config['editFontFamily'], + self.config['editFontSize'])) + self.dialog.tableView.verticalHeader().setDefaultSectionSize( + self.parent.config['editLineSize']) + self.model.reset() + def setupFilter(self): self.filterTimer = None self.connect(self.dialog.filterEdit, @@ -528,8 +534,6 @@ class EditDeck(QMainWindow): self.dialog.tableView.verticalHeader().hide() self.dialog.tableView.horizontalHeader().show() restoreHeader(self.dialog.tableView.horizontalHeader(), "editor") - self.dialog.tableView.verticalHeader().setDefaultSectionSize( - self.parent.config['editLineSize']) for i in range(2): self.dialog.tableView.horizontalHeader().setResizeMode(i, QHeaderView.Stretch) self.dialog.tableView.horizontalHeader().setResizeMode(2, QHeaderView.Interactive) @@ -544,6 +548,7 @@ class EditDeck(QMainWindow): self.connect(self.dialog.actionAddCards, SIGNAL("triggered()"), self.addCards) self.connect(self.dialog.actionChangeModel, SIGNAL("triggered()"), self.onChangeModel) # edit + self.connect(self.dialog.actionFont, SIGNAL("triggered()"), self.onFont) self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo) self.connect(self.dialog.actionRedo, SIGNAL("triggered()"), self.onRedo) self.connect(self.dialog.actionInvertSelection, SIGNAL("triggered()"), self.invertSelection) @@ -840,6 +845,26 @@ where id in %s""" % ids2str(sf)) def onRedo(self): self.deck.redo() + # Edit: font + ###################################################################### + + def onFont(self): + d = QDialog(self) + frm = ankiqt.forms.editfont.Ui_Dialog() + frm.setupUi(d) + frm.fontCombo.setCurrentFont(QFont( + self.parent.config['editFontFamily'])) + frm.fontSize.setValue(self.parent.config['editFontSize']) + frm.lineSize.setValue(self.parent.config['editLineSize']) + if d.exec_(): + self.parent.config['editFontFamily'] = ( + unicode(frm.fontCombo.currentFont().family())) + self.parent.config['editFontSize'] = ( + int(frm.fontSize.value())) + self.parent.config['editLineSize'] = ( + int(frm.lineSize.value())) + self.updateFont() + # Edit: replacing ###################################################################### diff --git a/designer/cardlist.ui b/designer/cardlist.ui index 56c819c1f..4595230cd 100644 --- a/designer/cardlist.ui +++ b/designer/cardlist.ui @@ -13,14 +13,6 @@ Browse Items - - - 0 - 23 - 599 - 439 - - 0 @@ -170,7 +162,7 @@ 0 0 599 - 23 + 22 @@ -187,6 +179,8 @@ + + @@ -419,6 +413,11 @@ &Cram... + + + Font... + + diff --git a/designer/editfont.ui b/designer/editfont.ui new file mode 100644 index 000000000..b16447494 --- /dev/null +++ b/designer/editfont.ui @@ -0,0 +1,134 @@ + + Dialog + + + + 0 + 0 + 205 + 139 + + + + Browser Font + + + + + + + + <b>Font</b>: + + + + + + + + + + + + + + <b>Font Size</b>: + + + + + + + + 75 + 0 + + + + + + + + <b>Line Size</b>: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + Dialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + Dialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + +