mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
new undo links; disable individual actions instead of menus to work around osx issue
This commit is contained in:
parent
3142be2023
commit
827b22c88c
3 changed files with 6 additions and 38 deletions
30
aqt/main.py
30
aqt/main.py
|
|
@ -243,7 +243,6 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
return 0
|
return 0
|
||||||
self.config.addRecentDeck(self.deck.path)
|
self.config.addRecentDeck(self.deck.path)
|
||||||
self.setupMedia(self.deck)
|
self.setupMedia(self.deck)
|
||||||
self.deck.initUndo()
|
|
||||||
self.progress.setupDB()
|
self.progress.setupDB()
|
||||||
self.moveToState("deckLoading")
|
self.moveToState("deckLoading")
|
||||||
return True
|
return True
|
||||||
|
|
@ -481,7 +480,6 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
return
|
return
|
||||||
self.closeAllDeckWindows()
|
self.closeAllDeckWindows()
|
||||||
self.deck = self.deck.saveAs(file)
|
self.deck = self.deck.saveAs(file)
|
||||||
self.deck.initUndo()
|
|
||||||
self.updateTitleBar()
|
self.updateTitleBar()
|
||||||
self.updateRecentFiles(self.deck.path)
|
self.updateRecentFiles(self.deck.path)
|
||||||
self.browserLastRefreshed = 0
|
self.browserLastRefreshed = 0
|
||||||
|
|
@ -604,33 +602,20 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
self.reset()
|
self.reset()
|
||||||
self.deck.setUndoEnd(undo)
|
self.deck.setUndoEnd(undo)
|
||||||
|
|
||||||
# Undo/redo
|
# Undo
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
def onUndo(self):
|
def onUndo(self):
|
||||||
name = self.deck.undoName()
|
|
||||||
self.deck.undo()
|
self.deck.undo()
|
||||||
self.reset()
|
self.reset()
|
||||||
if name == "Answer Card":
|
|
||||||
self.setStatus(_("Card placed back in queue."))
|
|
||||||
|
|
||||||
def onRedo(self):
|
|
||||||
self.deck.redo()
|
|
||||||
self.reset()
|
|
||||||
|
|
||||||
def maybeEnableUndo(self):
|
def maybeEnableUndo(self):
|
||||||
if self.deck and self.deck.undoAvailable():
|
if self.deck and self.deck.undoName():
|
||||||
self.form.actionUndo.setText(_("Undo %s") %
|
self.form.actionUndo.setText(_("Undo %s") %
|
||||||
self.deck.undoName())
|
self.deck.undoName())
|
||||||
self.form.actionUndo.setEnabled(True)
|
self.form.actionUndo.setEnabled(True)
|
||||||
else:
|
else:
|
||||||
self.form.actionUndo.setEnabled(False)
|
self.form.actionUndo.setEnabled(False)
|
||||||
if self.deck and self.deck.redoAvailable():
|
|
||||||
self.form.actionRedo.setText(_("Redo %s") %
|
|
||||||
self.deck.redoName())
|
|
||||||
self.form.actionRedo.setEnabled(True)
|
|
||||||
else:
|
|
||||||
self.form.actionRedo.setEnabled(False)
|
|
||||||
|
|
||||||
# Other menu operations
|
# Other menu operations
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
@ -741,7 +726,6 @@ Please give your deck a name:"""))
|
||||||
"Editdeck",
|
"Editdeck",
|
||||||
"DeckProperties",
|
"DeckProperties",
|
||||||
"Undo",
|
"Undo",
|
||||||
"Redo",
|
|
||||||
"Export",
|
"Export",
|
||||||
"Graphs",
|
"Graphs",
|
||||||
"Dstats",
|
"Dstats",
|
||||||
|
|
@ -750,11 +734,6 @@ Please give your deck a name:"""))
|
||||||
"Overview",
|
"Overview",
|
||||||
)
|
)
|
||||||
|
|
||||||
deckRelatedMenus = (
|
|
||||||
"Edit",
|
|
||||||
"Tools",
|
|
||||||
)
|
|
||||||
|
|
||||||
def setupMenus(self):
|
def setupMenus(self):
|
||||||
m = self.form
|
m = self.form
|
||||||
s = SIGNAL("triggered()")
|
s = SIGNAL("triggered()")
|
||||||
|
|
@ -785,7 +764,6 @@ Please give your deck a name:"""))
|
||||||
self.connect(m.actionDelete, s, self.onDelete)
|
self.connect(m.actionDelete, s, self.onDelete)
|
||||||
self.connect(m.actionRepeatAudio, s, self.onRepeatAudio)
|
self.connect(m.actionRepeatAudio, s, self.onRepeatAudio)
|
||||||
self.connect(m.actionUndo, s, self.onUndo)
|
self.connect(m.actionUndo, s, self.onUndo)
|
||||||
self.connect(m.actionRedo, s, self.onRedo)
|
|
||||||
self.connect(m.actionFullDatabaseCheck, s, self.onCheckDB)
|
self.connect(m.actionFullDatabaseCheck, s, self.onCheckDB)
|
||||||
self.connect(m.actionCheckMediaDatabase, s, self.onCheckMediaDB)
|
self.connect(m.actionCheckMediaDatabase, s, self.onCheckMediaDB)
|
||||||
self.connect(m.actionDownloadMissingMedia, s, self.onDownloadMissingMedia)
|
self.connect(m.actionDownloadMissingMedia, s, self.onDownloadMissingMedia)
|
||||||
|
|
@ -797,12 +775,12 @@ Please give your deck a name:"""))
|
||||||
|
|
||||||
def enableDeckMenuItems(self, enabled=True):
|
def enableDeckMenuItems(self, enabled=True):
|
||||||
"setEnabled deck-related items."
|
"setEnabled deck-related items."
|
||||||
for item in self.deckRelatedMenus:
|
|
||||||
getattr(self.form, "menu" + item).setEnabled(enabled)
|
|
||||||
for item in self.deckRelatedMenuItems:
|
for item in self.deckRelatedMenuItems:
|
||||||
getattr(self.form, "action" + item).setEnabled(enabled)
|
getattr(self.form, "action" + item).setEnabled(enabled)
|
||||||
|
self.form.menuAdvanced.setEnabled(enabled)
|
||||||
if not enabled:
|
if not enabled:
|
||||||
self.disableCardMenuItems()
|
self.disableCardMenuItems()
|
||||||
|
self.maybeEnableUndo()
|
||||||
runHook("enableDeckMenuItems", enabled)
|
runHook("enableDeckMenuItems", enabled)
|
||||||
|
|
||||||
def disableDeckMenuItems(self):
|
def disableDeckMenuItems(self):
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@
|
||||||
<string>&Edit</string>
|
<string>&Edit</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionUndo"/>
|
<addaction name="actionUndo"/>
|
||||||
<addaction name="actionRedo"/>
|
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionAddcards"/>
|
<addaction name="actionAddcards"/>
|
||||||
<addaction name="actionEditCurrent"/>
|
<addaction name="actionEditCurrent"/>
|
||||||
|
|
@ -526,15 +525,6 @@
|
||||||
<string>Ctrl+E</string>
|
<string>Ctrl+E</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionRedo">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="icons.qrc">
|
|
||||||
<normaloff>:/icons/edit-redo.png</normaloff>:/icons/edit-redo.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>&Redo</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionDelete">
|
<action name="actionDelete">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
<iconset resource="icons.qrc">
|
<iconset resource="icons.qrc">
|
||||||
|
|
|
||||||
|
|
@ -145,14 +145,14 @@
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,0">
|
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Help|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue