mirror of
https://github.com/ankitects/anki.git
synced 2025-12-14 23:30:59 -05:00
add per-field rtl customization
This commit is contained in:
parent
1f16732dfc
commit
7265d13537
3 changed files with 244 additions and 236 deletions
|
|
@ -180,6 +180,10 @@ class DisplayProperties(QDialog):
|
|||
self.connect(w,
|
||||
SIGNAL("clicked()"),
|
||||
lambda w=w: self.chooseColour(w))
|
||||
elif type == "edit":
|
||||
self.connect(self.dialog.rtl,
|
||||
SIGNAL("stateChanged(int)"),
|
||||
self.saveField)
|
||||
self.currentField = None
|
||||
self.drawFields()
|
||||
|
||||
|
|
@ -229,8 +233,8 @@ class DisplayProperties(QDialog):
|
|||
else:
|
||||
self.fwidget("useSize", type).setCheckState(Qt.Unchecked)
|
||||
self.fwidget("fontSize", type).setEnabled(False)
|
||||
# colour
|
||||
if type == "quiz":
|
||||
# colour
|
||||
if getattr(field, type + 'FontColour'):
|
||||
self.fwidget("useColour", type).setCheckState(Qt.Checked)
|
||||
self.fwidget("fontColour", type).setPalette(QPalette(QColor(
|
||||
|
|
@ -239,6 +243,8 @@ class DisplayProperties(QDialog):
|
|||
else:
|
||||
self.fwidget("useColour", type).setCheckState(Qt.Unchecked)
|
||||
self.fwidget("fontColour", type).setEnabled(False)
|
||||
elif type == "edit":
|
||||
self.dialog.rtl.setChecked(not not field.features)
|
||||
self.currentField = field
|
||||
|
||||
def saveField(self, *args):
|
||||
|
|
@ -268,6 +274,11 @@ class DisplayProperties(QDialog):
|
|||
setattr(field, type + 'FontColour', str(c.name()))
|
||||
else:
|
||||
setattr(field, type + 'FontColour', None)
|
||||
elif type == "edit":
|
||||
if self.dialog.rtl.isChecked():
|
||||
field.features = u"rtl"
|
||||
else:
|
||||
field.features = u""
|
||||
field.model.setModified()
|
||||
self.deck.flushMod()
|
||||
self.drawQuestionAndAnswer()
|
||||
|
|
|
|||
|
|
@ -388,6 +388,10 @@ class FactEditor(object):
|
|||
w.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
||||
w.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
w.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
||||
if field.fieldModel.features:
|
||||
w.setLayoutDirection(Qt.RightToLeft)
|
||||
else:
|
||||
w.setLayoutDirection(Qt.LeftToRight)
|
||||
runHook("makeField", w, field)
|
||||
self.fieldsGrid.addWidget(w, n, 1)
|
||||
self.fields[field.name] = (field, w)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DisplayProperties</class>
|
||||
<widget class="QDialog" name="DisplayProperties">
|
||||
|
|
@ -10,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -40,7 +41,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -79,7 +80,7 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" native="1" name="modelArea" />
|
||||
<widget class="QWidget" name="modelArea" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout">
|
||||
|
|
@ -96,7 +97,7 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -105,14 +106,6 @@
|
|||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>348</width>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Cards</string>
|
||||
</attribute>
|
||||
|
|
@ -122,7 +115,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Fixed" >
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -254,7 +247,7 @@
|
|||
<item row="7" column="1">
|
||||
<widget class="QComboBox" name="answerAlign">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Preferred" hsizetype="Preferred" >
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -296,14 +289,6 @@
|
|||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>348</width>
|
||||
<height>317</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Fields</string>
|
||||
</attribute>
|
||||
|
|
@ -311,7 +296,7 @@
|
|||
<item>
|
||||
<widget class="QListWidget" name="fieldList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="MinimumExpanding" hsizetype="Preferred" >
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -327,7 +312,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string> <b>When reviewing and editing:</b></string>
|
||||
<string> <b>When reviewing and editing:</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -342,7 +327,7 @@
|
|||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="useSize">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -371,7 +356,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="useFamily">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -403,7 +388,7 @@
|
|||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="useColour">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -437,7 +422,7 @@
|
|||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string> <b>When editing (overrides above):</b></string>
|
||||
<string> <b>When editing (overrides above):</b></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
@ -462,7 +447,7 @@
|
|||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="useSizeEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -481,7 +466,7 @@
|
|||
<item row="0" column="1">
|
||||
<widget class="QFontComboBox" name="fontFamilyEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -491,7 +476,7 @@
|
|||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="useFamilyEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -507,6 +492,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="rtl">
|
||||
<property name="text">
|
||||
<string>Reverse text (RTL)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
@ -585,7 +577,7 @@
|
|||
<item>
|
||||
<widget class="QTextEdit" name="question">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -598,7 +590,7 @@
|
|||
<item>
|
||||
<widget class="QTextEdit" name="answer">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
|
|
@ -638,6 +630,7 @@
|
|||
<tabstop>fontFamilyEdit</tabstop>
|
||||
<tabstop>useSizeEdit</tabstop>
|
||||
<tabstop>fontSizeEdit</tabstop>
|
||||
<tabstop>rtl</tabstop>
|
||||
<tabstop>helpButton</tabstop>
|
||||
<tabstop>preview</tabstop>
|
||||
<tabstop>closeButton</tabstop>
|
||||
|
|
|
|||
Loading…
Reference in a new issue