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