diff --git a/ankiqt/ui/facteditor.py b/ankiqt/ui/facteditor.py
index e39cb0263..9abcfb4e7 100644
--- a/ankiqt/ui/facteditor.py
+++ b/ankiqt/ui/facteditor.py
@@ -7,6 +7,7 @@ from PyQt4.QtCore import *
import re, os, sys, tempfile, urllib2
from anki.utils import stripHTML, tidyHTML, canonifyTags
from anki.sound import playFromText
+from ankiqt.ui.sound import getAudio
import anki.sound
from ankiqt import ui
import ankiqt
@@ -172,6 +173,16 @@ class FactEditor(object):
self.addSound.setToolTip(_("Add audio (F4)"))
self.iconsBox.addWidget(self.addSound)
self.addSound.setStyle(self.plastiqueStyle)
+ # sounds
+ self.recSound = QPushButton(self.widget)
+ self.recSound.connect(self.recSound, SIGNAL("clicked()"), self.onRecSound)
+ self.recSound.setFocusPolicy(Qt.NoFocus)
+ self.recSound.setShortcut(_("F5"))
+ self.recSound.setEnabled(False)
+ self.recSound.setIcon(QIcon(":/icons/media-record.png"))
+ self.recSound.setToolTip(_("Record audio (F5)"))
+ self.iconsBox.addWidget(self.recSound)
+ self.recSound.setStyle(self.plastiqueStyle)
# latex
spc = QSpacerItem(10,10)
self.iconsBox.addItem(spc)
@@ -450,6 +461,7 @@ class FactEditor(object):
self.latexMathEnv.setEnabled(val)
self.preview.setEnabled(val)
self.htmlEdit.setEnabled(val)
+ self.recSound.setEnabled(val)
def disableButtons(self):
self.enableButtons(False)
@@ -587,6 +599,12 @@ class FactEditor(object):
anki.sound.play(path)
w.insertHtml('[sound:%s]' % path)
+ def onRecSound(self):
+ w = self.focusedEdit()
+ file = getAudio(self.parent)
+ if file:
+ self._addSound(file, widget=w)
+
class FactEdit(QTextEdit):
def __init__(self, parent, *args):
diff --git a/ankiqt/ui/graphs.py b/ankiqt/ui/graphs.py
index 0c1586597..2b1b6955a 100644
--- a/ankiqt/ui/graphs.py
+++ b/ankiqt/ui/graphs.py
@@ -210,9 +210,9 @@ def intervalGraph(parent, deck):
hbox = QHBoxLayout()
def showHideAll():
- deck.startProgress(_("Graphs"), 0, len(widgets))
+ deck.startProgress(len(widgets))
for w in widgets:
- deck.updateProgress(_("Preparing..."))
+ deck.updateProgress(_("Processing..."))
w.showHide()
frame.adjustSize()
deck.finishProgress()
@@ -250,10 +250,10 @@ def intervalGraph(parent, deck):
QDesktopServices.openUrl(QUrl(ankiqt.appWiki + "Graphs"))
def onRefresh():
- deck.startProgress(_("Graphs"), 0, len(widgets))
+ deck.startProgress(len(widgets))
dg.stats = None
for w in widgets:
- deck.updateProgress(_("Preparing..."))
+ deck.updateProgress(_("Processing..."))
w.updateFigure()
deck.finishProgress()
diff --git a/ankiqt/ui/main.py b/ankiqt/ui/main.py
index 2dbc3eed1..93570aec2 100644
--- a/ankiqt/ui/main.py
+++ b/ankiqt/ui/main.py
@@ -43,6 +43,7 @@ class AnkiQt(QMainWindow):
self.setLang()
self.setupDocumentDir()
self.setupFonts()
+ self.setupSound()
self.setupBackupDir()
self.setupMainWindow()
self.alterShortcuts()
@@ -1360,12 +1361,6 @@ day = :d""", d=yesterday)
s = unicode(s)
self.deck.save()
# open tmp deck
- if self.config['randomizeOnCram']:
- n = 5
- else:
- n = 3
- p = ui.utils.ProgressWin(self, _("Cram"), 0, n)
- p.update(_("Copying cards..."))
ndir = tempfile.mkdtemp(prefix="anki-cram")
path = os.path.join(ndir, "cram.anki")
from anki.exporting import AnkiExporter
@@ -1378,6 +1373,11 @@ day = :d""", d=yesterday)
ui.utils.showInfo(_("No cards matched the provided tags."))
p.finish()
return
+ if self.config['randomizeOnCram']:
+ n = 4
+ else:
+ n = 2
+ p = ui.utils.ProgressWin(self, n, 0, _("Cram"))
p.update(_("Loading deck..."))
self.deck.close()
self.deck = None
@@ -1677,6 +1677,7 @@ day = :d""", d=yesterday)
self.connect(m.actionUncacheLatex, s, self.onUncacheLatex)
self.connect(m.actionStudyOptions, s, self.onStudyOptions)
self.connect(m.actionDonate, s, self.onDonate)
+ self.connect(m.actionRecordNoiseProfile, s, self.onRecordNoiseProfile)
def enableDeckMenuItems(self, enabled=True):
"setEnabled deck-related items."
@@ -1830,7 +1831,6 @@ day = :d""", d=yesterday)
def pluginsFolder(self):
dir = self.config.configPath
- file = os.path.join(dir, "custom.py")
return os.path.join(dir, "plugins")
def loadPlugins(self):
@@ -1924,11 +1924,20 @@ day = :d""", d=yesterday)
# Sounds
##########################################################################
+ def setupSound(self):
+ anki.sound.noiseProfile = os.path.join(
+ self.config.configPath, "noise.profile")
+ anki.sound.checkForNoiseProfile()
+
def onRepeatAudio(self):
playFromText(self.currentCard.question)
if self.state != "showQuestion":
playFromText(self.currentCard.answer)
+ def onRecordNoiseProfile(self):
+ from ui.sound import recordNoiseProfile
+ recordNoiseProfile(self)
+
# Progress info
##########################################################################
@@ -1937,9 +1946,9 @@ day = :d""", d=yesterday)
addHook("updateProgress", self.onUpdateProgress)
addHook("finishProgress", self.onFinishProgress)
- def onStartProgress(self, title, min, max):
+ def onStartProgress(self, max=100, min=0, title=None):
self.progressWin = ui.utils.ProgressWin(self.app.activeWindow() or self,
- title, min, max)
+ max, min, title)
def onUpdateProgress(self, label=None, value=None):
if self.progressWin:
diff --git a/ankiqt/ui/sound.py b/ankiqt/ui/sound.py
new file mode 120000
index 000000000..137c7c171
--- /dev/null
+++ b/ankiqt/ui/sound.py
@@ -0,0 +1 @@
+resolve@twitch.ichi2.net.12462:1231199561
\ No newline at end of file
diff --git a/ankiqt/ui/utils.py b/ankiqt/ui/utils.py
index 2d58f1e59..ba82da287 100644
--- a/ankiqt/ui/utils.py
+++ b/ankiqt/ui/utils.py
@@ -188,7 +188,10 @@ def mungeQA(deck, txt):
class ProgressWin(object):
- def __init__(self, parent, title, min, max):
+ def __init__(self, parent, max=100, min=0, title=None):
+ if not title:
+ title = "Anki"
+ print parent, max, min, title
self.diag = QProgressDialog("", "", min, max, parent)
self.diag.setWindowTitle(title)
self.diag.setCancelButton(None)
@@ -220,4 +223,5 @@ class ProgressWin(object):
def finish(self):
self.diag.setValue(self.max)
self.app.processEvents()
+ time.sleep(0.1)
self.diag.cancel()
diff --git a/designer/main.ui b/designer/main.ui
index 6e45a8db3..779fe17d0 100644
--- a/designer/main.ui
+++ b/designer/main.ui
@@ -1217,6 +1217,7 @@
+
@@ -1863,6 +1864,11 @@
&Donate...
+
+
+ &Record Noise Profile...
+
+
newPerDay
diff --git a/icons.qrc b/icons.qrc
index 6ad58d9a9..7a7b53f30 100644
--- a/icons.qrc
+++ b/icons.qrc
@@ -1,5 +1,7 @@
+ icons/media-playback-stop.png
+ icons/media-record.png
icons/view-calendar-tasks.png
icons/help-hint.png
icons/go-first.png