-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogressWindow.py
60 lines (48 loc) · 1.45 KB
/
progressWindow.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
48
49
50
51
52
53
54
55
56
57
58
59
60
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from aqt import mw
from aqt.qt import *
from .ordering import recalculate
from .preferences import *
class Thread(QThread):
_signal = pyqtSignal(int)
def __init__(self):
super(Thread, self).__init__()
def __del__(self):
self.wait()
def run(self):
# TODO make the progress bar reflect actual progress
recalculate()
self._signal.emit(100)
class RecalcBox(QDialog):
def __init__(self,parent=None):
super(RecalcBox,self).__init__(parent)
self.setModal(True)
self.resize(300,100)
self.setWindowTitle("Freqman")
self.pbar = QProgressBar(self)
self.pbar.setValue(10)
self.vbox = QVBoxLayout()
self.vbox.addWidget(self.pbar)
self.setLayout(self.vbox)
self.action()
def action(self):
self.thread = Thread()
self.thread._signal.connect(self.signal_accept)
self.thread.start()
def signal_accept(self, msg):
self.pbar.setValue(int(msg))
if self.pbar.value() >= 99:
self.close()
def openRecalc():
if getPrefs()['setDict'] == 'None':
err = QMessageBox()
err.setText('No dictionary selected')
err.exec()
else:
mw.fmRecalc = RecalcBox(mw)
mw.fmRecalc.show()
def afterSyncReorder():
if getGeneralOption('afterSync'):
openRecalc()