mirror of
https://github.com/ankitects/anki.git
synced 2025-12-16 00:00:59 -05:00
add browser font configurator
This commit is contained in:
parent
091b84956f
commit
1da04aca5d
3 changed files with 172 additions and 14 deletions
|
|
@ -299,11 +299,9 @@ class EditDeck(QMainWindow):
|
||||||
SIGNAL("selectionChanged(QItemSelection,QItemSelection)"),
|
SIGNAL("selectionChanged(QItemSelection,QItemSelection)"),
|
||||||
self.updateFilterLabel)
|
self.updateFilterLabel)
|
||||||
self.dialog.tableView.setItemDelegate(StatusDelegate(self, self.model))
|
self.dialog.tableView.setItemDelegate(StatusDelegate(self, self.model))
|
||||||
self.dialog.tableView.setFont(QFont(
|
|
||||||
self.config['editFontFamily'],
|
|
||||||
self.config['editFontSize']))
|
|
||||||
if self.deck.getInt("reverseOrder"):
|
if self.deck.getInt("reverseOrder"):
|
||||||
self.dialog.actionReverseOrder.setChecked(True)
|
self.dialog.actionReverseOrder.setChecked(True)
|
||||||
|
self.updateFont()
|
||||||
self.setupMenus()
|
self.setupMenus()
|
||||||
self.setupFilter()
|
self.setupFilter()
|
||||||
self.setupSort()
|
self.setupSort()
|
||||||
|
|
@ -331,6 +329,14 @@ class EditDeck(QMainWindow):
|
||||||
return i
|
return i
|
||||||
return -1
|
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):
|
def setupFilter(self):
|
||||||
self.filterTimer = None
|
self.filterTimer = None
|
||||||
self.connect(self.dialog.filterEdit,
|
self.connect(self.dialog.filterEdit,
|
||||||
|
|
@ -528,8 +534,6 @@ class EditDeck(QMainWindow):
|
||||||
self.dialog.tableView.verticalHeader().hide()
|
self.dialog.tableView.verticalHeader().hide()
|
||||||
self.dialog.tableView.horizontalHeader().show()
|
self.dialog.tableView.horizontalHeader().show()
|
||||||
restoreHeader(self.dialog.tableView.horizontalHeader(), "editor")
|
restoreHeader(self.dialog.tableView.horizontalHeader(), "editor")
|
||||||
self.dialog.tableView.verticalHeader().setDefaultSectionSize(
|
|
||||||
self.parent.config['editLineSize'])
|
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
self.dialog.tableView.horizontalHeader().setResizeMode(i, QHeaderView.Stretch)
|
self.dialog.tableView.horizontalHeader().setResizeMode(i, QHeaderView.Stretch)
|
||||||
self.dialog.tableView.horizontalHeader().setResizeMode(2, QHeaderView.Interactive)
|
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.actionAddCards, SIGNAL("triggered()"), self.addCards)
|
||||||
self.connect(self.dialog.actionChangeModel, SIGNAL("triggered()"), self.onChangeModel)
|
self.connect(self.dialog.actionChangeModel, SIGNAL("triggered()"), self.onChangeModel)
|
||||||
# edit
|
# edit
|
||||||
|
self.connect(self.dialog.actionFont, SIGNAL("triggered()"), self.onFont)
|
||||||
self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo)
|
self.connect(self.dialog.actionUndo, SIGNAL("triggered()"), self.onUndo)
|
||||||
self.connect(self.dialog.actionRedo, SIGNAL("triggered()"), self.onRedo)
|
self.connect(self.dialog.actionRedo, SIGNAL("triggered()"), self.onRedo)
|
||||||
self.connect(self.dialog.actionInvertSelection, SIGNAL("triggered()"), self.invertSelection)
|
self.connect(self.dialog.actionInvertSelection, SIGNAL("triggered()"), self.invertSelection)
|
||||||
|
|
@ -840,6 +845,26 @@ where id in %s""" % ids2str(sf))
|
||||||
def onRedo(self):
|
def onRedo(self):
|
||||||
self.deck.redo()
|
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
|
# Edit: replacing
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,6 @@
|
||||||
<string>Browse Items</string>
|
<string>Browse Items</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget" >
|
<widget class="QWidget" name="centralwidget" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>23</y>
|
|
||||||
<width>599</width>
|
|
||||||
<height>439</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
|
@ -170,7 +162,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>599</width>
|
<width>599</width>
|
||||||
<height>23</height>
|
<height>22</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuEdit" >
|
<widget class="QMenu" name="menuEdit" >
|
||||||
|
|
@ -187,6 +179,8 @@
|
||||||
<addaction name="actionFindReplace" />
|
<addaction name="actionFindReplace" />
|
||||||
<addaction name="separator" />
|
<addaction name="separator" />
|
||||||
<addaction name="actionReverseOrder" />
|
<addaction name="actionReverseOrder" />
|
||||||
|
<addaction name="separator" />
|
||||||
|
<addaction name="actionFont" />
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuActions" >
|
<widget class="QMenu" name="menuActions" >
|
||||||
<property name="title" >
|
<property name="title" >
|
||||||
|
|
@ -419,6 +413,11 @@
|
||||||
<string>&Cram...</string>
|
<string>&Cram...</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionFont" >
|
||||||
|
<property name="text" >
|
||||||
|
<string>Font...</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../icons.qrc" />
|
<include location="../icons.qrc" />
|
||||||
|
|
|
||||||
134
designer/editfont.ui
Normal file
134
designer/editfont.ui
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
<ui version="4.0" >
|
||||||
|
<class>Dialog</class>
|
||||||
|
<widget class="QDialog" name="Dialog" >
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>205</width>
|
||||||
|
<height>139</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>Browser Font</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout" >
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label" >
|
||||||
|
<property name="text" >
|
||||||
|
<string><b>Font</b>:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFontComboBox" name="fontCombo" />
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout" >
|
||||||
|
<item row="0" column="0" >
|
||||||
|
<widget class="QLabel" name="label_2" >
|
||||||
|
<property name="text" >
|
||||||
|
<string><b>Font Size</b>:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1" >
|
||||||
|
<widget class="QSpinBox" name="fontSize" >
|
||||||
|
<property name="minimumSize" >
|
||||||
|
<size>
|
||||||
|
<width>75</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" >
|
||||||
|
<widget class="QLabel" name="label_3" >
|
||||||
|
<property name="text" >
|
||||||
|
<string><b>Line Size</b>:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1" >
|
||||||
|
<widget class="QSpinBox" name="lineSize" />
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2" >
|
||||||
|
<spacer name="horizontalSpacer_2" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0" >
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0" >
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox" >
|
||||||
|
<property name="orientation" >
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons" >
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel" >
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel" >
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>Dialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel" >
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel" >
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
||||||
Loading…
Reference in a new issue