mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
use pyqt api2; move all imports into a single file for pyside
This commit is contained in:
parent
d02cfa28d9
commit
a253d756e3
34 changed files with 75 additions and 106 deletions
|
@ -2,8 +2,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
|
|
||||||
appName="Anki"
|
appName="Anki"
|
||||||
appVersion="1.99"
|
appVersion="1.99"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
import aqt.forms
|
import aqt.forms
|
||||||
from aqt import appVersion
|
from aqt import appVersion
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import aqt
|
import aqt
|
||||||
from anki.utils import parseTags, joinTags, canonifyTags
|
from anki.utils import parseTags, joinTags, canonifyTags
|
||||||
from aqt.ui.utils import saveGeom, restoreGeom
|
from aqt.ui.utils import saveGeom, restoreGeom
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import sys, re
|
import sys, re
|
||||||
import aqt.forms
|
import aqt.forms
|
||||||
import anki
|
import anki
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import sys, os, re, traceback
|
import sys, os, re, traceback
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from aqt.utils import showInfo, showWarning, openFolder, isWin
|
from aqt.utils import showInfo, showWarning, openFolder, isWin
|
||||||
from anki.hooks import runHook
|
from anki.hooks import runHook
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import sre_constants
|
import sre_constants
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from PyQt4.QtWebKit import QWebPage
|
|
||||||
import time, types, sys, re
|
import time, types, sys, re
|
||||||
from operator import attrgetter, itemgetter
|
from operator import attrgetter, itemgetter
|
||||||
import anki, anki.utils, aqt.forms
|
import anki, anki.utils, aqt.forms
|
||||||
|
@ -69,37 +67,37 @@ class DeckModel(QAbstractTableModel):
|
||||||
|
|
||||||
def data(self, index, role):
|
def data(self, index, role):
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
return QVariant()
|
return
|
||||||
if role == Qt.FontRole:
|
if role == Qt.FontRole:
|
||||||
f = QFont()
|
f = QFont()
|
||||||
f.setPixelSize(self.browser.mw.config['editFontSize'])
|
f.setPixelSize(self.browser.mw.config['editFontSize'])
|
||||||
return QVariant(f)
|
return f
|
||||||
if role == Qt.TextAlignmentRole:
|
if role == Qt.TextAlignmentRole:
|
||||||
align = Qt.AlignVCenter
|
align = Qt.AlignVCenter
|
||||||
if index.column() > 1:
|
if index.column() > 1:
|
||||||
align |= Qt.AlignHCenter
|
align |= Qt.AlignHCenter
|
||||||
return QVariant(align)
|
return align
|
||||||
elif role == Qt.DisplayRole or role == Qt.EditRole:
|
elif role == Qt.DisplayRole or role == Qt.EditRole:
|
||||||
return QVariant(self.columnData(index))
|
return self.columnData(index)
|
||||||
else:
|
else:
|
||||||
return QVariant()
|
return
|
||||||
|
|
||||||
def headerData(self, section, orientation, role):
|
def headerData(self, section, orientation, role):
|
||||||
if orientation == Qt.Vertical:
|
if orientation == Qt.Vertical:
|
||||||
return QVariant()
|
return
|
||||||
elif role == Qt.DisplayRole:
|
elif role == Qt.DisplayRole:
|
||||||
type = self.columnType(section)
|
type = self.columnType(section)
|
||||||
for stype, name in self.browser.columns:
|
for stype, name in self.browser.columns:
|
||||||
if type == stype:
|
if type == stype:
|
||||||
txt = name
|
txt = name
|
||||||
break
|
break
|
||||||
return QVariant(txt)
|
return txt
|
||||||
elif role == Qt.FontRole:
|
elif role == Qt.FontRole:
|
||||||
f = QFont()
|
f = QFont()
|
||||||
f.setPixelSize(10)
|
f.setPixelSize(10)
|
||||||
return QVariant(f)
|
return f
|
||||||
else:
|
else:
|
||||||
return QVariant()
|
return
|
||||||
|
|
||||||
def flags(self, index):
|
def flags(self, index):
|
||||||
return Qt.ItemFlag(Qt.ItemIsEnabled |
|
return Qt.ItemFlag(Qt.ItemIsEnabled |
|
||||||
|
@ -435,7 +433,7 @@ class Browser(QMainWindow):
|
||||||
self.onSearch)
|
self.onSearch)
|
||||||
self.setTabOrder(self.form.searchEdit, self.form.tableView)
|
self.setTabOrder(self.form.searchEdit, self.form.tableView)
|
||||||
self.compModel = QStringListModel()
|
self.compModel = QStringListModel()
|
||||||
self.compModel.setStringList(QStringList(self.mw.config['searchHistory']))
|
self.compModel.setStringList(self.mw.config['searchHistory'])
|
||||||
self.searchComp = QCompleter(self.compModel, self.form.searchEdit)
|
self.searchComp = QCompleter(self.compModel, self.form.searchEdit)
|
||||||
self.searchComp.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
|
self.searchComp.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
|
||||||
self.searchComp.setCaseSensitivity(Qt.CaseInsensitive)
|
self.searchComp.setCaseSensitivity(Qt.CaseInsensitive)
|
||||||
|
@ -448,7 +446,7 @@ class Browser(QMainWindow):
|
||||||
if txt not in sh:
|
if txt not in sh:
|
||||||
sh.insert(0, txt)
|
sh.insert(0, txt)
|
||||||
sh = sh[:30]
|
sh = sh[:30]
|
||||||
self.compModel.setStringList(QStringList(sh))
|
self.compModel.setStringList(sh)
|
||||||
self.mw.config['searchHistory'] = sh
|
self.mw.config['searchHistory'] = sh
|
||||||
self.model.search(txt, reset)
|
self.model.search(txt, reset)
|
||||||
if not self.model.cards:
|
if not self.model.cards:
|
||||||
|
@ -1096,7 +1094,7 @@ where id in %s""" % ids2str(self.selectedCards()), mod)
|
||||||
frm = aqt.forms.findreplace.Ui_Dialog()
|
frm = aqt.forms.findreplace.Ui_Dialog()
|
||||||
frm.setupUi(d)
|
frm.setupUi(d)
|
||||||
d.setWindowModality(Qt.WindowModal)
|
d.setWindowModality(Qt.WindowModal)
|
||||||
frm.field.addItems(QStringList([_("All Fields")] + fields))
|
frm.field.addItems([_("All Fields")] + fields)
|
||||||
self.connect(frm.buttonBox, SIGNAL("helpRequested()"),
|
self.connect(frm.buttonBox, SIGNAL("helpRequested()"),
|
||||||
self.onFindReplaceHelp)
|
self.onFindReplaceHelp)
|
||||||
if not d.exec_():
|
if not d.exec_():
|
||||||
|
@ -1162,7 +1160,7 @@ select fm.id, fm.name from fieldmodels fm""")
|
||||||
names = byName.keys()
|
names = byName.keys()
|
||||||
names.sort()
|
names.sort()
|
||||||
alldata = [(byName[n], n) for n in names] + data
|
alldata = [(byName[n], n) for n in names] + data
|
||||||
dialog.searchArea.addItems(QStringList([d[1] for d in alldata]))
|
dialog.searchArea.addItems([d[1] for d in alldata])
|
||||||
# links
|
# links
|
||||||
dialog.webView.page().setLinkDelegationPolicy(
|
dialog.webView.page().setLinkDelegationPolicy(
|
||||||
QWebPage.DelegateAllLinks)
|
QWebPage.DelegateAllLinks)
|
||||||
|
@ -1382,12 +1380,11 @@ class ChangeModel(QDialog):
|
||||||
l = QGridLayout()
|
l = QGridLayout()
|
||||||
combos = []
|
combos = []
|
||||||
targets = [x['name'] for x in dst] + [_("Nothing")]
|
targets = [x['name'] for x in dst] + [_("Nothing")]
|
||||||
qtargets = QStringList(targets)
|
|
||||||
indices = {}
|
indices = {}
|
||||||
for i, x in enumerate(src):
|
for i, x in enumerate(src):
|
||||||
l.addWidget(QLabel(_("Change %s to:") % x['name']), i, 0)
|
l.addWidget(QLabel(_("Change %s to:") % x['name']), i, 0)
|
||||||
cb = QComboBox()
|
cb = QComboBox()
|
||||||
cb.addItems(qtargets)
|
cb.addItems(targets)
|
||||||
idx = min(i, len(targets)-1)
|
idx = min(i, len(targets)-1)
|
||||||
cb.setCurrentIndex(idx)
|
cb.setCurrentIndex(idx)
|
||||||
indices[cb] = idx
|
indices[cb] = idx
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from PyQt4.QtWebKit import QWebPage, QWebView
|
|
||||||
import re
|
import re
|
||||||
from anki.consts import *
|
from anki.consts import *
|
||||||
import aqt
|
import aqt
|
||||||
|
@ -114,13 +112,12 @@ class CardLayout(QDialog):
|
||||||
linkClicked)
|
linkClicked)
|
||||||
if self.plastiqueStyle:
|
if self.plastiqueStyle:
|
||||||
f.background.setStyle(self.plastiqueStyle)
|
f.background.setStyle(self.plastiqueStyle)
|
||||||
f.alignment.addItems(
|
f.alignment.addItems(alignmentLabels().values())
|
||||||
QStringList(alignmentLabels().values()))
|
|
||||||
self.typeFieldNames = self.model.fieldMap()
|
self.typeFieldNames = self.model.fieldMap()
|
||||||
s = [_("Don't ask me to type in the answer")]
|
s = [_("Don't ask me to type in the answer")]
|
||||||
s += [_("Compare with field '%s'") % fi
|
s += [_("Compare with field '%s'") % fi
|
||||||
for fi in self.typeFieldNames.keys()]
|
for fi in self.typeFieldNames.keys()]
|
||||||
f.typeAnswer.insertItems(0, QStringList(s))
|
f.typeAnswer.insertItems(0, s)
|
||||||
|
|
||||||
def formatToScreen(self, fmt):
|
def formatToScreen(self, fmt):
|
||||||
fmt = fmt.replace("}}<br>", "}}\n")
|
fmt = fmt.replace("}}<br>", "}}\n")
|
||||||
|
@ -177,8 +174,7 @@ class CardLayout(QDialog):
|
||||||
idx = n
|
idx = n
|
||||||
else:
|
else:
|
||||||
cards.append(c.template()['name'])
|
cards.append(c.template()['name'])
|
||||||
self.form.cardList.addItems(
|
self.form.cardList.addItems(cards)
|
||||||
QStringList(cards))
|
|
||||||
self.form.cardList.setCurrentIndex(idx)
|
self.form.cardList.setCurrentIndex(idx)
|
||||||
self.cardChanged(idx)
|
self.cardChanged(idx)
|
||||||
self.form.cardList.setFocus()
|
self.form.cardList.setFocus()
|
||||||
|
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
import time, os, stat, shutil, re
|
import time, os, stat, shutil, re
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from anki import Deck
|
from anki import Deck
|
||||||
from anki.utils import fmtTimeSpan
|
from anki.utils import fmtTimeSpan
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import sys, re
|
import sys, re
|
||||||
import aqt
|
import aqt
|
||||||
from aqt.utils import maybeHideClose
|
from aqt.utils import maybeHideClose
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import aqt.editor
|
import aqt.editor
|
||||||
from aqt.utils import saveGeom, restoreGeom
|
from aqt.utils import saveGeom, restoreGeom
|
||||||
from anki.hooks import addHook, removeHook
|
from anki.hooks import addHook, removeHook
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from PyQt4.QtWebKit import QWebView, QWebPage
|
|
||||||
import re, os, sys, urllib2, ctypes, simplejson, traceback
|
import re, os, sys, urllib2, ctypes, simplejson, traceback
|
||||||
from anki.utils import stripHTML, parseTags, isWin, namedtmp
|
from anki.utils import stripHTML, parseTags, isWin, namedtmp
|
||||||
from anki.sound import play
|
from anki.sound import play
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
import sys
|
import sys
|
||||||
from aqt.utils import showText
|
from aqt.utils import showText
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import anki, aqt
|
import anki, aqt
|
||||||
from anki.exporting import exporters as exporters_
|
from anki.exporting import exporters as exporters_
|
||||||
from anki.utils import parseTags
|
from anki.utils import parseTags
|
||||||
|
@ -31,8 +30,7 @@ class ExportDialog(QDialog):
|
||||||
self.exec_()
|
self.exec_()
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.dialog.format.insertItems(
|
self.dialog.format.insertItems(0, list(zip(*exporters())[0]))
|
||||||
0, QStringList(list(zip(*exporters())[0])))
|
|
||||||
self.connect(self.dialog.format, SIGNAL("activated(int)"),
|
self.connect(self.dialog.format, SIGNAL("activated(int)"),
|
||||||
self.exporterChanged)
|
self.exporterChanged)
|
||||||
self.exporterChanged(0)
|
self.exporterChanged(0)
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import aqt, simplejson, time, cStringIO, zipfile, os, re, gzip
|
import aqt, simplejson, time, cStringIO, zipfile, os, re, gzip
|
||||||
import traceback, urllib2, socket, cgi
|
import traceback, urllib2, socket, cgi
|
||||||
from aqt.ui.utils import saveGeom, restoreGeom, showInfo
|
from aqt.ui.utils import saveGeom, restoreGeom, showInfo
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
import aqt, simplejson
|
import aqt, simplejson
|
||||||
from anki.utils import ids2str
|
from anki.utils import ids2str
|
||||||
from aqt.utils import showInfo, showWarning
|
from aqt.utils import showInfo, showWarning
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
import aqt
|
import aqt
|
||||||
from aqt.utils import showInfo, getOnlyText
|
from aqt.utils import showInfo, getOnlyText
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import os, copy, time, sys, re, traceback
|
import os, copy, time, sys, re, traceback
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import anki
|
import anki
|
||||||
import anki.importing as importing
|
import anki.importing as importing
|
||||||
from aqt.ui.utils import getOnlyText
|
from aqt.ui.utils import getOnlyText
|
||||||
|
|
|
@ -6,9 +6,7 @@ import os, sys, re, stat, traceback, signal
|
||||||
import shutil, time, zipfile
|
import shutil, time, zipfile
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from PyQt4 import pyqtconfig
|
|
||||||
QtConfig = pyqtconfig.Configuration()
|
QtConfig = pyqtconfig.Configuration()
|
||||||
|
|
||||||
from anki import Deck
|
from anki import Deck
|
||||||
|
@ -355,7 +353,7 @@ Debug info:\n%s""") % traceback.format_exc(), help="DeckErrors")
|
||||||
if not self.deck or self.deck.path != x and
|
if not self.deck or self.deck.path != x and
|
||||||
os.path.exists(x)])
|
os.path.exists(x)])
|
||||||
self.switchDecks.sort()
|
self.switchDecks.sort()
|
||||||
combo.addItems(QStringList([x[0] for x in self.switchDecks]))
|
combo.addItems([x[0] for x in self.switchDecks])
|
||||||
self.connect(combo, SIGNAL("activated(int)"),
|
self.connect(combo, SIGNAL("activated(int)"),
|
||||||
self.onSwitchActivated)
|
self.onSwitchActivated)
|
||||||
vbox.addWidget(combo)
|
vbox.addWidget(combo)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from anki import stdmodels
|
from anki import stdmodels
|
||||||
from anki.lang import ngettext
|
from anki.lang import ngettext
|
||||||
|
@ -94,8 +93,7 @@ class ModelChooser(QHBoxLayout):
|
||||||
self.models.clear()
|
self.models.clear()
|
||||||
self._models = sorted(self.deck.models().values(),
|
self._models = sorted(self.deck.models().values(),
|
||||||
key=attrgetter("name"))
|
key=attrgetter("name"))
|
||||||
self.models.addItems(QStringList(
|
self.models.addItems([m.name for m in self._models])
|
||||||
[m.name for m in self._models]))
|
|
||||||
for c, m in enumerate(self._models):
|
for c, m in enumerate(self._models):
|
||||||
if m.id == self.deck.conf['currentModelId']:
|
if m.id == self.deck.conf['currentModelId']:
|
||||||
self.models.setCurrentIndex(c)
|
self.models.setCurrentIndex(c)
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from aqt.utils import showInfo, askUser, getText, maybeHideClose
|
from aqt.utils import showInfo, askUser, getText, maybeHideClose
|
||||||
import aqt.modelchooser, aqt.clayout
|
import aqt.modelchooser, aqt.clayout
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import simplejson
|
import simplejson
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from anki.consts import NEW_CARDS_RANDOM
|
from anki.consts import NEW_CARDS_RANDOM
|
||||||
from anki.hooks import addHook
|
from anki.hooks import addHook
|
||||||
from aqt.utils import limitedCount
|
from aqt.utils import limitedCount
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from anki.lang import langs
|
from anki.lang import langs
|
||||||
from aqt.utils import openFolder, showWarning
|
from aqt.utils import openFolder, showWarning
|
||||||
import aqt
|
import aqt
|
||||||
|
@ -60,12 +59,11 @@ class Preferences(QDialog):
|
||||||
self.form.retranslateUi(self)
|
self.form.retranslateUi(self)
|
||||||
|
|
||||||
def setupMedia(self):
|
def setupMedia(self):
|
||||||
self.form.mediaChoice.addItems(
|
self.form.mediaChoice.addItems([
|
||||||
QStringList([
|
|
||||||
_("Keep media next to deck"),
|
_("Keep media next to deck"),
|
||||||
_("Keep media in DropBox"),
|
_("Keep media in DropBox"),
|
||||||
_("Keep media in custom folder"),
|
_("Keep media in custom folder"),
|
||||||
]))
|
])
|
||||||
if not self.config['mediaLocation']:
|
if not self.config['mediaLocation']:
|
||||||
idx = 0
|
idx = 0
|
||||||
elif self.config['mediaLocation'] == "dropbox":
|
elif self.config['mediaLocation'] == "dropbox":
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
|
|
||||||
# fixme: if mw->subwindow opens a progress dialog with mw as the parent, mw
|
# fixme: if mw->subwindow opens a progress dialog with mw as the parent, mw
|
||||||
# gets raised on finish on compiz. perhaps we should be using the progress
|
# gets raised on finish on compiz. perhaps we should be using the progress
|
||||||
|
|
13
aqt/qt.py
Normal file
13
aqt/qt.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
|
# imports are all in this file to make moving to pyside easier in the future
|
||||||
|
|
||||||
|
import sip
|
||||||
|
sip.setapi('QString', 2)
|
||||||
|
sip.setapi('QVariant', 2)
|
||||||
|
sip.setapi('QUrl', 2)
|
||||||
|
from PyQt4.QtCore import *
|
||||||
|
from PyQt4.QtGui import *
|
||||||
|
from PyQt4.QtWebKit import QWebPage, QWebView
|
||||||
|
from PyQt4 import pyqtconfig
|
|
@ -4,8 +4,7 @@
|
||||||
|
|
||||||
import time, os, stat, shutil, difflib, simplejson
|
import time, os, stat, shutil, difflib, simplejson
|
||||||
import unicodedata as ucd
|
import unicodedata as ucd
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from anki.utils import fmtTimeSpan, stripHTML
|
from anki.utils import fmtTimeSpan, stripHTML
|
||||||
from anki.hooks import addHook, runHook, runFilter
|
from anki.hooks import addHook, runHook, runFilter
|
||||||
from anki.sound import playFromText, clearAudioQueue, hasSound
|
from anki.sound import playFromText, clearAudioQueue, hasSound
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
|
|
||||||
import time
|
import time
|
||||||
from anki.sound import Recorder, play
|
from anki.sound import Recorder, play
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import os
|
import os
|
||||||
from aqt.webview import AnkiWebView
|
from aqt.webview import AnkiWebView
|
||||||
from aqt.utils import saveGeom, restoreGeom, maybeHideClose
|
from aqt.utils import saveGeom, restoreGeom, maybeHideClose
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
import datetime, time, aqt
|
import datetime, time, aqt
|
||||||
|
|
||||||
class StudyOptions(QDialog):
|
class StudyOptions(QDialog):
|
||||||
|
@ -20,11 +19,11 @@ class StudyOptions(QDialog):
|
||||||
def setup(self):
|
def setup(self):
|
||||||
import anki.consts as c
|
import anki.consts as c
|
||||||
self.form.newOrder.insertItems(
|
self.form.newOrder.insertItems(
|
||||||
0, QStringList(c.newCardOrderLabels().values()))
|
0, c.newCardOrderLabels().values())
|
||||||
self.form.newSpread.insertItems(
|
self.form.newSpread.insertItems(
|
||||||
0, QStringList(c.newCardSchedulingLabels().values()))
|
0, c.newCardSchedulingLabels().values())
|
||||||
self.form.revOrder.insertItems(
|
self.form.revOrder.insertItems(
|
||||||
0, QStringList(c.revCardOrderLabels().values()))
|
0, c.revCardOrderLabels().values())
|
||||||
self.connect(self.form.buttonBox,
|
self.connect(self.form.buttonBox,
|
||||||
SIGNAL("helpRequested()"),
|
SIGNAL("helpRequested()"),
|
||||||
lambda: aqt.openHelp("StudyOptions"))
|
lambda: aqt.openHelp("StudyOptions"))
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import os, types, socket, time, traceback
|
import os, types, socket, time, traceback
|
||||||
import aqt
|
import aqt
|
||||||
import anki
|
import anki
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
from anki.utils import parseTags, canonifyTags, joinTags
|
from anki.utils import parseTags, canonifyTags, joinTags
|
||||||
import re, sys
|
import re, sys
|
||||||
|
|
||||||
|
@ -29,13 +28,13 @@ class TagEdit(QLineEdit):
|
||||||
l = self.deck.tagList()
|
l = self.deck.tagList()
|
||||||
else:
|
else:
|
||||||
l = self.deck.groups()
|
l = self.deck.groups()
|
||||||
self.model.setStringList(QStringList(l))
|
self.model.setStringList(l)
|
||||||
|
|
||||||
def addTags(self, tags):
|
def addTags(self, tags):
|
||||||
l = list(set([unicode(x) for x in list(self.model.stringList())] +
|
l = list(set([unicode(x) for x in list(self.model.stringList())] +
|
||||||
tags))
|
tags))
|
||||||
l.sort(key=lambda x: x.lower())
|
l.sort(key=lambda x: x.lower())
|
||||||
self.model.setStringList(QStringList(l))
|
self.model.setStringList(l)
|
||||||
|
|
||||||
def focusOutEvent(self, evt):
|
def focusOutEvent(self, evt):
|
||||||
QLineEdit.focusOutEvent(self, evt)
|
QLineEdit.focusOutEvent(self, evt)
|
||||||
|
@ -56,7 +55,7 @@ class TagCompleter(QCompleter):
|
||||||
self.tags.append(u"")
|
self.tags.append(u"")
|
||||||
p = self.edit.cursorPosition()
|
p = self.edit.cursorPosition()
|
||||||
self.cursor = str.count(" ", 0, p)
|
self.cursor = str.count(" ", 0, p)
|
||||||
return QStringList(self.tags[self.cursor])
|
return self.tags[self.cursor]
|
||||||
|
|
||||||
def pathFromIndex(self, idx):
|
def pathFromIndex(self, idx):
|
||||||
if self.cursor is None:
|
if self.cursor is None:
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import aqt
|
import aqt
|
||||||
from aqt.utils import saveGeom, restoreGeom, askUser, getText
|
from aqt.utils import saveGeom, restoreGeom, askUser, getText
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
import urllib, urllib2, os, sys, time, httplib
|
import urllib, urllib2, os, sys, time, httplib
|
||||||
import anki, anki.utils, anki.lang, anki.stats
|
import anki, anki.utils, anki.lang, anki.stats
|
||||||
import aqt
|
import aqt
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
# Copyright: Damien Elmes <anki@ichi2.net>
|
# Copyright: Damien Elmes <anki@ichi2.net>
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
from PyQt4.QtGui import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtCore import *
|
|
||||||
import re, os, sys, urllib, time
|
import re, os, sys, urllib, time
|
||||||
import aqt
|
import aqt
|
||||||
from anki.sound import playFromText, stripSounds
|
from anki.sound import playFromText, stripSounds
|
||||||
|
@ -188,7 +187,7 @@ def chooseList(prompt, choices, startrow=0, parent=None):
|
||||||
t = QLabel(prompt)
|
t = QLabel(prompt)
|
||||||
l.addWidget(t)
|
l.addWidget(t)
|
||||||
c = QListWidget()
|
c = QListWidget()
|
||||||
c.addItems(QStringList(choices))
|
c.addItems(choices)
|
||||||
c.setCurrentRow(startrow)
|
c.setCurrentRow(startrow)
|
||||||
l.addWidget(c)
|
l.addWidget(c)
|
||||||
bb = QDialogButtonBox(QDialogButtonBox.Ok)
|
bb = QDialogButtonBox(QDialogButtonBox.Ok)
|
||||||
|
|
|
@ -3,10 +3,7 @@
|
||||||
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from PyQt4.QtCore import *
|
from aqt.qt import *
|
||||||
from PyQt4.QtGui import *
|
|
||||||
from PyQt4.QtWebKit import QWebPage, QWebView
|
|
||||||
from PyQt4 import pyqtconfig
|
|
||||||
import anki.js
|
import anki.js
|
||||||
QtConfig = pyqtconfig.Configuration()
|
QtConfig = pyqtconfig.Configuration()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue