-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDialogs.py
144 lines (93 loc) · 4.71 KB
/
Dialogs.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
from PyQt5.QtWidgets import QDialog
from PyQt5.QtCore import QObject
import sys
sys.path.append("UiDesigner/UiDesignerFilePython/")
from Ui_WarningSaveDialog import Ui_WarningSaveDialog #WarningSaveDialog View.
from Ui_SuccessSaveDialog import Ui_SuccessSaveDialog #SuccesSaveDialog View.
from Ui_AutoSaveDialog import Ui_AutoSaveDialog #AutoSaveDialog View.
from Ui_WarningDeleteDialog import Ui_WarningDeleteDialog #WarningDeleteDialog View.
from Ui_RecordDialog import Ui_RecordDialog #RecordDialog View.
from Ui_ControlsDialog import Ui_ControlsDialog #ControlsDialog View.
class DialogModel(QObject):#Dialogs Model.
def __init__(self, lineEditObservable=None, buttonBoxObservable=None):
super().__init__()
if lineEditObservable is None:
self._lineEditObservable = None
else:
self._lineEditObservable = lineEditObservable #Only the RecordDialog needs this observable. This latter one is used if a user must insert a text on the dialog.
if buttonBoxObservable is None:
self._buttonBoxObservable = None #The SuccessSaveDialog and the ControlsDialog do not need this observable.
else:
self._buttonBoxObservable = buttonBoxObservable #This Observable is used to communicate if the user accepts the request of a dialog or not.
@property
def lineEditObservable(self):
return self._lineEditObservable
@property
def buttonBoxObservable(self):
return self._buttonBoxObservable
class WarningSaveDialog(QDialog):#WarningSaveDialog Controller.
def __init__(self, isReplacingObservable):
super().__init__()
self._model = DialogModel(buttonBoxObservable=isReplacingObservable)
self._ui = Ui_WarningSaveDialog()
self._ui.setupUi(self)
self._ui.buttonBox.accepted.connect(self.acceptReplacing)
self._ui.buttonBox.rejected.connect(self.rejectReplacing)
def acceptReplacing(self):
self._model.buttonBoxObservable.value = True
def rejectReplacing(self):
self._model.buttonBoxObservable.value = False
class SuccessSaveDialog(QDialog):#SuccessSaveDialog Controller.
def __init__(self):
super().__init__()
self._model = DialogModel()
self._ui = Ui_SuccessSaveDialog()
self._ui.setupUi(self)
class ControlsDialog(QDialog):#ControlsDialog Controller.
def __init__(self):
super().__init__()
self._model = DialogModel()
self._ui = Ui_ControlsDialog()
self._ui.setupUi(self)
class AutoSaveDialog(QDialog):#AutoSaveDialog Controller.
def __init__(self, isAutoLoadingObservable):
super().__init__()
self._model = DialogModel(buttonBoxObservable=isAutoLoadingObservable)
self._ui = Ui_AutoSaveDialog()
self._ui.setupUi(self)
self._ui.buttonBox.accepted.connect(self.acceptAutoLoading)
self._ui.buttonBox.rejected.connect(self.rejectAutoLoading)
def acceptAutoLoading(self):
self._model.buttonBoxObservable.value = True
def rejectAutoLoading(self):
self._model.buttonBoxObservable.value = False
class WarningDeleteDialog(QDialog):#WarningDeleteDialog Controller.
def __init__(self, isDeleteObservable):
super().__init__()
self._model = DialogModel(buttonBoxObservable=isDeleteObservable)
self._ui = Ui_WarningDeleteDialog()
self._ui.setupUi(self)
self._ui.buttonBox.accepted.connect(self.acceptDelete)
self._ui.buttonBox.rejected.connect(self.rejectDelete)
def acceptDelete(self):
self._model.buttonBoxObservable.value = True
def rejectDelete(self):
self._model.buttonBoxObservable.value = False
class RecordDialog(QDialog):#RecordDialog Controller.
def __init__(self, time, isRecordObservable, nameRecordObservable):
super().__init__()
self._model = DialogModel(nameRecordObservable, isRecordObservable)
self._ui = Ui_RecordDialog()
self._ui.setupUi(self)
self._ui.labelTimeRecord.setText("Time:" + str(time))
self._ui.buttonBox.accepted.connect(self.acceptRecord)
self._ui.buttonBox.rejected.connect(self.rejectRecord)
def acceptRecord(self):
if len(self._ui.nameRecord.text()) != 0:
self._model.buttonBoxObservable.value = True
self._model.lineEditObservable.value = self._ui.nameRecord.text().replace(" ", "")
else:
self._model.buttonBoxObservable.value = True
self._model.lineEditObservable.value = "unknown"
def rejectRecord(self):
self._model.buttonBoxObservable.value = False