mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
make ctrl-z work when answer layout focused
This commit is contained in:
parent
e708f72a17
commit
1a8884d595
3 changed files with 28 additions and 134 deletions
|
@ -436,6 +436,20 @@ new:
|
||||||
# editor
|
# editor
|
||||||
self.connect(self.mainWin.saveEditorButton, SIGNAL("clicked()"),
|
self.connect(self.mainWin.saveEditorButton, SIGNAL("clicked()"),
|
||||||
lambda: self.moveToState("saveEdit"))
|
lambda: self.moveToState("saveEdit"))
|
||||||
|
# type answer
|
||||||
|
class QLineEditNoUndo(QLineEdit):
|
||||||
|
def __init__(self, parent):
|
||||||
|
self.parent = parent
|
||||||
|
QLineEdit.__init__(self, parent)
|
||||||
|
def keyPressEvent(self, evt):
|
||||||
|
if evt.matches(QKeySequence.Undo):
|
||||||
|
evt.accept()
|
||||||
|
if self.parent.mainWin.actionUndo.isEnabled():
|
||||||
|
self.parent.onUndo()
|
||||||
|
else:
|
||||||
|
return QLineEdit.keyPressEvent(self, evt)
|
||||||
|
self.typeAnswerField = QLineEditNoUndo(self)
|
||||||
|
self.mainWin.typeAnswerLayout.addWidget(self.typeAnswerField)
|
||||||
|
|
||||||
def hideButtons(self):
|
def hideButtons(self):
|
||||||
self.mainWin.buttonStack.hide()
|
self.mainWin.buttonStack.hide()
|
||||||
|
@ -443,13 +457,13 @@ new:
|
||||||
def showAnswerButton(self):
|
def showAnswerButton(self):
|
||||||
if self.currentCard.cardModel.typeAnswer:
|
if self.currentCard.cardModel.typeAnswer:
|
||||||
self.mainWin.buttonStack.setCurrentIndex(4)
|
self.mainWin.buttonStack.setCurrentIndex(4)
|
||||||
self.mainWin.typeAnswerField.setFocus()
|
self.typeAnswerField.setFocus()
|
||||||
if not unicode(self.mainWin.typeAnswerField.text()):
|
if not unicode(self.typeAnswerField.text()):
|
||||||
self.mainWin.typeAnswerField.setText(_(
|
self.typeAnswerField.setText(_(
|
||||||
"Type in the answer and hit enter"))
|
"Type in the answer and hit enter"))
|
||||||
self.mainWin.typeAnswerField.selectAll()
|
self.typeAnswerField.selectAll()
|
||||||
else:
|
else:
|
||||||
self.mainWin.typeAnswerField.setText("")
|
self.typeAnswerField.setText("")
|
||||||
else:
|
else:
|
||||||
self.mainWin.buttonStack.setCurrentIndex(0)
|
self.mainWin.buttonStack.setCurrentIndex(0)
|
||||||
self.mainWin.showAnswerButton.setFocus()
|
self.mainWin.showAnswerButton.setFocus()
|
||||||
|
|
|
@ -151,7 +151,7 @@ class View(object):
|
||||||
a = self.main.currentCard.htmlAnswer()
|
a = self.main.currentCard.htmlAnswer()
|
||||||
if self.main.currentCard.cardModel.typeAnswer:
|
if self.main.currentCard.cardModel.typeAnswer:
|
||||||
cor = stripHTML(self.main.currentCard.answer)
|
cor = stripHTML(self.main.currentCard.answer)
|
||||||
given = unicode(self.main.mainWin.typeAnswerField.text())
|
given = unicode(self.main.typeAnswerField.text())
|
||||||
res = []
|
res = []
|
||||||
if len(given) < len(cor):
|
if len(given) < len(cor):
|
||||||
given += " " * (len(cor) - len(given))
|
given += " " * (len(cor) - len(given))
|
||||||
|
|
136
designer/main.ui
136
designer/main.ui
|
@ -5,8 +5,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>536</width>
|
<width>562</width>
|
||||||
<height>450</height>
|
<height>469</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy" >
|
||||||
|
@ -23,14 +23,6 @@
|
||||||
<normaloff>:/icons/anki.png</normaloff>:/icons/anki.png</iconset>
|
<normaloff>:/icons/anki.png</normaloff>:/icons/anki.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget" >
|
<widget class="QWidget" name="centralwidget" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>69</y>
|
|
||||||
<width>536</width>
|
|
||||||
<height>361</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy" >
|
||||||
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
|
||||||
<horstretch>1</horstretch>
|
<horstretch>1</horstretch>
|
||||||
|
@ -149,25 +141,8 @@
|
||||||
<property name="currentIndex" >
|
<property name="currentIndex" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="blankPage" >
|
<widget class="QWidget" name="blankPage" />
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>302</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QWidget" name="welcomePage" >
|
<widget class="QWidget" name="welcomePage" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>428</width>
|
|
||||||
<height>546</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_5" >
|
<layout class="QVBoxLayout" name="verticalLayout_5" >
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTextBrowser" name="welcomeText" >
|
<widget class="QTextBrowser" name="welcomeText" >
|
||||||
|
@ -182,14 +157,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="editPage" >
|
<widget class="QWidget" name="editPage" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>542</width>
|
|
||||||
<height>504</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -203,14 +170,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="optionsPage" >
|
<widget class="QWidget" name="optionsPage" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>302</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_5" >
|
<layout class="QHBoxLayout" name="horizontalLayout_5" >
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4" >
|
<layout class="QHBoxLayout" name="horizontalLayout_4" >
|
||||||
|
@ -538,14 +497,6 @@
|
||||||
<number>5</number>
|
<number>5</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="page1" >
|
<widget class="QWidget" name="page1" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>53</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer" >
|
<spacer name="verticalSpacer" >
|
||||||
|
@ -579,14 +530,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page2" >
|
<widget class="QWidget" name="page2" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>53</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3" >
|
<layout class="QVBoxLayout" name="verticalLayout_3" >
|
||||||
<property name="spacing" >
|
<property name="spacing" >
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -729,14 +672,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page3" >
|
<widget class="QWidget" name="page3" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>53</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4" >
|
<layout class="QVBoxLayout" name="verticalLayout_4" >
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_2" >
|
<spacer name="verticalSpacer_2" >
|
||||||
|
@ -764,14 +699,6 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page4" >
|
<widget class="QWidget" name="page4" >
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>53</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_6" >
|
<layout class="QVBoxLayout" name="verticalLayout_6" >
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_5" >
|
<spacer name="verticalSpacer_5" >
|
||||||
|
@ -806,15 +733,7 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page5" >
|
<widget class="QWidget" name="page5" >
|
||||||
<property name="geometry" >
|
<layout class="QVBoxLayout" name="typeAnswerLayout" >
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>53</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_7" >
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_6" >
|
<spacer name="verticalSpacer_6" >
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
|
@ -831,30 +750,9 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QLineEdit" name="typeAnswerField" >
|
|
||||||
<property name="font" >
|
|
||||||
<font>
|
|
||||||
<pointsize>12</pointsize>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="text" >
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="page" >
|
<widget class="QWidget" name="page" />
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>251</width>
|
|
||||||
<height>53</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -1048,8 +946,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>536</width>
|
<width>562</width>
|
||||||
<height>23</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuHelp" >
|
<widget class="QMenu" name="menuHelp" >
|
||||||
|
@ -1192,28 +1090,11 @@
|
||||||
<addaction name="menu_Settings" />
|
<addaction name="menu_Settings" />
|
||||||
<addaction name="menuHelp" />
|
<addaction name="menuHelp" />
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QStatusBar" name="statusbar" >
|
<widget class="QStatusBar" name="statusbar" />
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>430</y>
|
|
||||||
<width>536</width>
|
|
||||||
<height>20</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QToolBar" name="toolBar" >
|
<widget class="QToolBar" name="toolBar" >
|
||||||
<property name="enabled" >
|
<property name="enabled" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>23</y>
|
|
||||||
<width>536</width>
|
|
||||||
<height>46</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="orientation" >
|
<property name="orientation" >
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -1806,7 +1687,6 @@
|
||||||
<tabstop>delayLapsedCards</tabstop>
|
<tabstop>delayLapsedCards</tabstop>
|
||||||
<tabstop>startReviewingButton</tabstop>
|
<tabstop>startReviewingButton</tabstop>
|
||||||
<tabstop>showAnswerButton</tabstop>
|
<tabstop>showAnswerButton</tabstop>
|
||||||
<tabstop>typeAnswerField</tabstop>
|
|
||||||
<tabstop>help</tabstop>
|
<tabstop>help</tabstop>
|
||||||
<tabstop>saveEditorButton</tabstop>
|
<tabstop>saveEditorButton</tabstop>
|
||||||
<tabstop>welcomeText</tabstop>
|
<tabstop>welcomeText</tabstop>
|
||||||
|
|
Loading…
Reference in a new issue