mirror of
https://github.com/ankitects/anki.git
synced 2025-11-09 06:07:11 -05:00
add cancel button to recording window
This commit is contained in:
parent
4967275973
commit
7af591cfd7
2 changed files with 9 additions and 4 deletions
|
|
@ -891,7 +891,8 @@ to a cloze type first, via Edit>Change Note Type."""))
|
||||||
"Couldn't record audio. Have you installed lame and sox?") +
|
"Couldn't record audio. Have you installed lame and sox?") +
|
||||||
"\n\n" + repr(str(e)))
|
"\n\n" + repr(str(e)))
|
||||||
return
|
return
|
||||||
self.addMedia(file)
|
if file:
|
||||||
|
self.addMedia(file)
|
||||||
|
|
||||||
# Media downloads
|
# Media downloads
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
||||||
10
aqt/sound.py
10
aqt/sound.py
|
|
@ -15,10 +15,11 @@ def getAudio(parent, encode=True):
|
||||||
restoreGeom(mb, "audioRecorder")
|
restoreGeom(mb, "audioRecorder")
|
||||||
mb.setWindowTitle("Anki")
|
mb.setWindowTitle("Anki")
|
||||||
mb.setIconPixmap(QPixmap(":/icons/media-record.png"))
|
mb.setIconPixmap(QPixmap(":/icons/media-record.png"))
|
||||||
but = QPushButton(_(" Stop"))
|
but = QPushButton(_("Save"))
|
||||||
but.setIcon(QIcon(":/icons/media-playback-stop.png"))
|
mb.addButton(but, QMessageBox.AcceptRole)
|
||||||
#but.setIconSize(QSize(32, 32))
|
but = QPushButton(_("Cancel"))
|
||||||
mb.addButton(but, QMessageBox.RejectRole)
|
mb.addButton(but, QMessageBox.RejectRole)
|
||||||
|
mb.setEscapeButton(but)
|
||||||
t = time.time()
|
t = time.time()
|
||||||
r.start()
|
r.start()
|
||||||
QApplication.instance().processEvents()
|
QApplication.instance().processEvents()
|
||||||
|
|
@ -27,6 +28,9 @@ def getAudio(parent, encode=True):
|
||||||
mb.setText(txt % (time.time() - t))
|
mb.setText(txt % (time.time() - t))
|
||||||
mb.show()
|
mb.show()
|
||||||
QApplication.instance().processEvents()
|
QApplication.instance().processEvents()
|
||||||
|
if mb.clickedButton() == mb.escapeButton():
|
||||||
|
r.stop()
|
||||||
|
return
|
||||||
saveGeom(mb, "audioRecorder")
|
saveGeom(mb, "audioRecorder")
|
||||||
# ensure at least a second captured
|
# ensure at least a second captured
|
||||||
while time.time() - t < 1:
|
while time.time() - t < 1:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue