add browser font configurator

This commit is contained in:
Damien Elmes 2009-04-18 23:27:01 +09:00
parent 091b84956f
commit 1da04aca5d
3 changed files with 172 additions and 14 deletions

View file

@ -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
######################################################################

View file

@ -13,14 +13,6 @@
<string>Browse Items</string>
</property>
<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" >
<property name="spacing" >
<number>0</number>
@ -170,7 +162,7 @@
<x>0</x>
<y>0</y>
<width>599</width>
<height>23</height>
<height>22</height>
</rect>
</property>
<widget class="QMenu" name="menuEdit" >
@ -187,6 +179,8 @@
<addaction name="actionFindReplace" />
<addaction name="separator" />
<addaction name="actionReverseOrder" />
<addaction name="separator" />
<addaction name="actionFont" />
</widget>
<widget class="QMenu" name="menuActions" >
<property name="title" >
@ -419,6 +413,11 @@
<string>&amp;Cram...</string>
</property>
</action>
<action name="actionFont" >
<property name="text" >
<string>Font...</string>
</property>
</action>
</widget>
<resources>
<include location="../icons.qrc" />

134
designer/editfont.ui Normal file
View 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>&lt;b>Font&lt;/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>&lt;b>Font Size&lt;/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>&lt;b>Line Size&lt;/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>