-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcolumn.py
47 lines (37 loc) · 1.22 KB
/
column.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from anki.lang import _
from aqt.deckbrowser import DeckBrowser
from aqt.qt import *
from aqt.utils import askUser
from .config import getUserOption, writeConfig
lastHandler = DeckBrowser._linkHandler
def _linkHandler(self, url):
if ":" in url:
(cmd, arg) = url.split(":")
if cmd == "dragColumn":
return columnHandler(self, arg)
elif cmd == "optsColumn":
return columnOptions(self, arg)
return lastHandler(self, url)
def columnHandler(self, arg):
draggedDeckId, ontoDeckId = arg.split(",")
draggedDeckId = int(draggedDeckId)
ontoDeckId = int(ontoDeckId)
columns = getUserOption("columns")
columns.insert(draggedDeckId, columns.pop(ontoDeckId))
writeConfig()
self.show()
def columnOptions(self, colpos):
m = QMenu(self.mw)
a = m.addAction(_("Delete"))
a.triggered.connect(lambda: deleteColumn(self, colpos))
m.exec_(QCursor.pos())
def deleteColumn(self, colpos):
if not askUser(_("""Are you sure you wish to delete this column ?""")):
return
colpos = int(colpos)
print("They are sure.")
columns = getUserOption("columns")
column = columns[colpos]
column["present"] = False
writeConfig()
self.show()