-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreferences.py
More file actions
159 lines (129 loc) · 6.87 KB
/
Copy pathpreferences.py
File metadata and controls
159 lines (129 loc) · 6.87 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5.QtWidgets import QTableWidget, QApplication, QMainWindow, QTableWidgetItem, \
QFileDialog, QComboBox, QDialog, QWidget, QListWidgetItem, QSizeGrip
from PyQt5.QtCore import QSettings, QDir, Qt
from gui.pref import Ui_Form
from PyQt5 import QtGui
class Preferences(QWidget, Ui_Form):
def __init__(self, parent):
super(Preferences, self).__init__()
self.setupUi(self)
self.setWindowTitle('Preferences')
self.btn_ok.clicked.connect(lambda: self.ok(parent))
self.btn_cancel.clicked.connect(self.cancel)
self.setWindowIcon(QtGui.QIcon('icons/icon.png'))
self.toolButton_indices_file.clicked.connect(self.open_indices_file_dialog)
self.toolButton_samplesheets_folder.clicked.connect(self.open_samplesheets_folder_dialog)
self.toolButton_config_file.clicked.connect(self.open_config_file_dialog)
self.pushButton_add_investigator.clicked.connect(self.add_investigator)
self.pushButton_remove_investigators.clicked.connect(self.remove_investigator)
SampleSheetCreator_settings = QSettings('vll', 'SampleSheetCreator')
institute = SampleSheetCreator_settings.value('institute', type=str)
path_indices_file = SampleSheetCreator_settings.value('path_indices_file', type=str)
path_config_file = SampleSheetCreator_settings.value('path_config_file', type=str)
path_samplesheets_folder = SampleSheetCreator_settings.value('path_samplesheets_folder', type=str)
investigators_list = SampleSheetCreator_settings.value('investigators', type=list)
if not institute:
institute = ""
if not path_indices_file:
path_indices_file = ""
if not path_config_file:
path_config_file = ""
if not path_samplesheets_folder:
path_samplesheets_folder = "";
if not investigators_list:
investigators_list = []
self.lineEdit_institute.setText(institute)
self.lineEdit_indices_file.setText(path_indices_file)
self.lineEdit_config_file.setText(path_config_file)
self.lineEdit_samplesheets_folder.setText(path_samplesheets_folder)
for i in investigators_list:
item = QListWidgetItem(i)
self.listWidget_investigators.addItem(item)
stylesheet = """
QTableWidget {
background-color: rgb(80, 80, 80);
}
QPushButton {
background-color: rgb(90,70,0);
}
QTreeWidget::indicator {
width: 10px;
height: 10px;
margin: 5px;
border-radius: 5px;
border: 3px solid rgb(120,90,0);
}
QTreeWidget::indicator::unchecked {
background-color: transparent rgb(80, 80, 80);
}
QTreeWidget::indicator::checked {
background-color: rgb(150,120,0);
}
QTreeWidget {
background-color: rgb(80, 80, 80);
}
"""
self.setStyleSheet(stylesheet)
self.grip1 = QSizeGrip(self)
self.verticalLayout_3.addWidget(self.grip1, 0, Qt.AlignRight | Qt.AlignBottom)
def ok(self, parent):
SampleSheetCreator_settings = QSettings('vll', 'SampleSheetCreator')
institute = self.lineEdit_institute.text()
path_indices_file = self.lineEdit_indices_file.text()
path_config_file = self.lineEdit_config_file.text()
path_samplesheets_folder = self.lineEdit_samplesheets_folder.text()
SampleSheetCreator_settings.setValue('institute', institute)
SampleSheetCreator_settings.setValue('path_indices_file', path_indices_file)
SampleSheetCreator_settings.setValue('path_config_file', path_config_file)
SampleSheetCreator_settings.setValue('path_samplesheets_folder', path_samplesheets_folder)
parent.repopulate()
self.close()
def cancel(self):
self.close()
def open_indices_file_dialog(self):
options = QFileDialog.Options()
path_tmp, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","Yaml files (*.yaml *.yml);;All filetypes (*)", options=options)
path = str(QDir.toNativeSeparators(path_tmp))
self.lineEdit_indices_file.setText(path)
def open_config_file_dialog(self):
options = QFileDialog.Options()
path_tmp, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","Yaml files (*.yaml *.yml);;All filetypes (*)", options=options)
path = str(QDir.toNativeSeparators(path_tmp))
self.lineEdit_config_file.setText(path)
def open_samplesheets_folder_dialog(self):
path_tmp = str(QFileDialog.getExistingDirectory(self, "Select Directory"))
path = str(QDir.toNativeSeparators(path_tmp))
self.lineEdit_samplesheets_folder.setText(path)
def add_investigator(self):
SampleSheetCreator_settings = QSettings('vll', 'SampleSheetCreator')
investigator = self.lineEdit_add_investigator.text()
if investigator:
investigators_list = SampleSheetCreator_settings.value('investigators', type=list)
investigators_list.append(investigator)
investigators_list = list(set(investigators_list))
SampleSheetCreator_settings.setValue('investigators', investigators_list)
self.listWidget_investigators.clear()
investigators_list = SampleSheetCreator_settings.value('investigators', type=list)
for i in investigators_list:
item = QListWidgetItem(i)
self.listWidget_investigators.addItem(item)
self.lineEdit_add_investigator.setText("")
def remove_investigator(self):
SampleSheetCreator_settings = QSettings('vll', 'SampleSheetCreator')
investigator = ""
try:
investigator = self.listWidget_investigators.currentItem().text()
except:
pass
if investigator:
investigators_list = SampleSheetCreator_settings.value('investigators', type=list)
investigators_list.remove(investigator)
investigators_list = list(set(investigators_list))
SampleSheetCreator_settings.setValue('investigators', investigators_list)
self.listWidget_investigators.clear()
investigators_list = SampleSheetCreator_settings.value('investigators', type=list)
for i in investigators_list:
item = QListWidgetItem(i)
self.listWidget_investigators.addItem(item)