forked from zync/zync-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pvm_consent_dialog.py
80 lines (64 loc) · 2.33 KB
/
pvm_consent_dialog.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
"""Dialog to express consent to use PVM instances
"""
import os
# Try importing from PySide (Maya 2016) first, then from PySide2 (Maya 2017)
# Alias the classes since some of them have been moved from PyGui to PyWidgets
try:
import pysideuic
import PySide.QtGui
import PySide.QtCore as QtCore
QCheckBox = PySide.QtGui.QCheckBox
QDialog = PySide.QtGui.QDialog
QDir = QtCore.QDir
QDialogButtonBox = PySide.QtGui.QDialogButtonBox
QFileSystemModel = PySide.QtGui.QFileSystemModel
QHeaderView = PySide.QtGui.QHeaderView
QTreeView = PySide.QtGui.QTreeView
QPushButton = PySide.QtGui.QPushButton
pysideVersion = PySide.__version__
except:
import pyside2uic as pysideuic
import PySide2.QtCore as QtCore
import PySide2.QtWidgets
QCheckBox = PySide2.QtWidgets.QCheckBox
QDialog = PySide2.QtWidgets.QDialog
QDir = QtCore.QDir
QFileSystemModel = PySide2.QtWidgets.QFileSystemModel
QHeaderView = PySide2.QtWidgets.QHeaderView
QTreeView = PySide2.QtWidgets.QTreeView
QPushButton = PySide2.QtWidgets.QPushButton
pysideVersion = PySide2.__version__
import dialog_helper
from settings import Settings
UI_PVM_CONSENT = '%s/resources/pvm_consent.ui' % os.path.dirname(__file__)
class PvmConsentDialog(QtCore.QObject):
"""Displays dialog allowing user to select files or directories"""
def __init__(self, parent=None):
"""Constructs file selection dialog
Params:
project_name: str, name of Zync project
"""
super(PvmConsentDialog, self).__init__(parent)
self.settings = Settings.get()
FormClass = dialog_helper.load_ui_type(UI_PVM_CONSENT)
form_class = FormClass()
self.dialog = QDialog()
if parent:
self.dialog.setParent(parent, QtCore.Qt.Window)
form_class.setupUi(self.dialog)
pushButton_yes = self.dialog.findChild(QPushButton, 'pushButton_yes')
pushButton_yes.clicked.connect(self.accept)
pushButton_no = self.dialog.findChild(QPushButton, 'pushButton_no')
pushButton_no.clicked.connect(self.reject)
def prompt(self):
self.dialog.show()
return self.dialog.exec_()
def accept(self):
checkBox_dontAsk = self.dialog.findChild(QCheckBox, 'checkBox_dontAsk')
if checkBox_dontAsk.checkState():
self.settings.put_pvm_ack(True)
self.dialog.accept()
self.dialog = None
def reject(self):
self.dialog.reject()
self.dialog = None