mirror of
https://github.com/ankitects/anki.git
synced 2025-11-14 00:27:13 -05:00
use a popup menu for deck operations
This commit is contained in:
parent
441e459af5
commit
d4491869c1
1 changed files with 27 additions and 26 deletions
|
|
@ -1107,6 +1107,7 @@ your deck."""))
|
||||||
import sip
|
import sip
|
||||||
focusButton = None
|
focusButton = None
|
||||||
# remove all widgets from layout & layout itself
|
# remove all widgets from layout & layout itself
|
||||||
|
self.moreMenus = []
|
||||||
if self.decksFrame.layout():
|
if self.decksFrame.layout():
|
||||||
while 1:
|
while 1:
|
||||||
obj = self.decksFrame.layout().takeAt(0)
|
obj = self.decksFrame.layout().takeAt(0)
|
||||||
|
|
@ -1190,20 +1191,23 @@ your deck."""))
|
||||||
if c == 0:
|
if c == 0:
|
||||||
focusButton = openButton
|
focusButton = openButton
|
||||||
# more
|
# more
|
||||||
moreButton = QComboBox()
|
moreButton = QPushButton(_("More"))
|
||||||
if sys.platform.startswith("darwin"):
|
if sys.platform.startswith("darwin"):
|
||||||
moreButton.setFixedWidth(80)
|
moreButton.setFixedWidth(80)
|
||||||
if sys.platform.startswith("win32") and \
|
if sys.platform.startswith("win32") and \
|
||||||
self.config['alternativeTheme']:
|
self.config['alternativeTheme']:
|
||||||
moreButton.setFixedHeight(24)
|
moreButton.setFixedHeight(24)
|
||||||
moreButton.addItems(QStringList([
|
moreMenu = QMenu()
|
||||||
_("More"),
|
a = moreMenu.addAction(QIcon(":/icons/edit-undo.png"),
|
||||||
_("Forget"),
|
_("Hide from list"))
|
||||||
_("Delete")]))
|
a.connect(a, SIGNAL("activated()"),
|
||||||
moreButton.setToolTip(
|
lambda c=c: self.onDeckBrowserForget(c))
|
||||||
_("Forget removes the deck from the list without deleting."))
|
a = moreMenu.addAction(QIcon(":/icons/editdelete.png"),
|
||||||
self.connect(moreButton, SIGNAL("currentIndexChanged(int)"),
|
_("Delete"))
|
||||||
lambda idx, c=c: self.onDeckBrowserMore(idx, c))
|
a.connect(a, SIGNAL("activated()"),
|
||||||
|
lambda c=c: self.onDeckBrowserDelete(c))
|
||||||
|
moreButton.setMenu(moreMenu)
|
||||||
|
self.moreMenus.append(moreMenu)
|
||||||
layout.addWidget(moreButton, c+1, 6)
|
layout.addWidget(moreButton, c+1, 6)
|
||||||
refresh = QPushButton(_("Refresh"))
|
refresh = QPushButton(_("Refresh"))
|
||||||
refresh.setToolTip(_("Check due counts again (F5)"))
|
refresh.setToolTip(_("Check due counts again (F5)"))
|
||||||
|
|
@ -1246,23 +1250,20 @@ later by using File>Close.
|
||||||
# do this last
|
# do this last
|
||||||
self.switchToDecksScreen()
|
self.switchToDecksScreen()
|
||||||
|
|
||||||
def onDeckBrowserMore(self, idx, c):
|
def onDeckBrowserForget(self, c):
|
||||||
if idx == 0:
|
if ui.utils.askUser(_("Hide %s from the list?") % self.browserDecks[c]['name'],
|
||||||
return
|
help="DeckBrowser"):
|
||||||
elif idx == 1:
|
self.config['recentDeckPaths'].remove(self.browserDecks[c]['path'])
|
||||||
# forget
|
del self.browserDecks[c]
|
||||||
if ui.utils.askUser(_("Forget %s?") % self.browserDecks[c]['name']):
|
self.showDeckBrowser()
|
||||||
self.config['recentDeckPaths'].remove(self.browserDecks[c]['path'])
|
|
||||||
del self.browserDecks[c]
|
def onDeckBrowserDelete(self, c):
|
||||||
self.showDeckBrowser()
|
deck = self.browserDecks[c]['path']
|
||||||
elif idx == 2:
|
if ui.utils.askUser(_("Delete %s?") % self.browserDecks[c]['name']):
|
||||||
# delete
|
del self.browserDecks[c]
|
||||||
deck = self.browserDecks[c]['path']
|
os.unlink(deck)
|
||||||
if ui.utils.askUser(_("Delete %s?") % self.browserDecks[c]['name']):
|
self.config['recentDeckPaths'].remove(deck)
|
||||||
del self.browserDecks[c]
|
self.showDeckBrowser()
|
||||||
os.unlink(deck)
|
|
||||||
self.config['recentDeckPaths'].remove(deck)
|
|
||||||
self.showDeckBrowser()
|
|
||||||
|
|
||||||
# Opening and closing the app
|
# Opening and closing the app
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue