|
37 | 37 | from util_classes import ExistingProjectDialog |
38 | 38 | from util_classes import BackgroundThread, Validator |
39 | 39 | from util_classes import CompleterLineEdit, TagsCompleter |
| 40 | +from util_classes import TreeBrowser |
40 | 41 |
|
41 | 42 | from PySide import QtGui, QtCore |
42 | 43 | from PySide.QtGui import (QApplication, QHBoxLayout, QVBoxLayout) |
@@ -209,18 +210,6 @@ def open_recent_file(self): |
209 | 210 | if action: |
210 | 211 | self.load_project(action.data()) |
211 | 212 |
|
212 | | - def setup_nw_versions(self): |
213 | | - """Loads stored versions that were previously retrieved.""" |
214 | | - nw_version = self.get_setting('nw_version') |
215 | | - try: |
216 | | - f = codecs.open(utils.get_data_file_path(config.VER_FILE), |
217 | | - encoding='utf-8') |
218 | | - for line in f: |
219 | | - nw_version.values.append(line.strip()) |
220 | | - f.close() |
221 | | - except IOError: |
222 | | - nw_version.values.append(nw_version.default_value) |
223 | | - |
224 | 213 | def create_application_layout(self): |
225 | 214 | """Create all widgets and set the central widget.""" |
226 | 215 | self.main_layout = QtGui.QVBoxLayout() |
@@ -989,6 +978,15 @@ def load_project(self, directory, readonly=False): |
989 | 978 |
|
990 | 979 | self.set_window_icon() |
991 | 980 | self.open_export_button.setEnabled(True) |
| 981 | + |
| 982 | + blacklist_setting = self.get_setting('blacklist') |
| 983 | + |
| 984 | + output_blacklist = os.path.basename(self.output_dir()) |
| 985 | + |
| 986 | + self.tree_browser.init(directory, |
| 987 | + blacklist=(blacklist_setting.value.split('\n') + |
| 988 | + ['*'+output_blacklist+'*'])) |
| 989 | + |
992 | 990 | self.update_json = True |
993 | 991 |
|
994 | 992 | def init_main_field(self, directory): |
@@ -1159,23 +1157,116 @@ def create_export_settings(self): |
1159 | 1157 |
|
1160 | 1158 | ex_setting_order = self.settings['order']['export_setting_order'] |
1161 | 1159 |
|
1162 | | - vlayout = self.create_layout(ex_setting_order, cols=4) |
| 1160 | + vlayout = self.create_layout(ex_setting_order, cols=1) |
| 1161 | + vlayout.setContentsMargins(0, 10, 0, 0) |
1163 | 1162 |
|
1164 | 1163 | output_name_layout = self.create_output_name_pattern_line() |
1165 | 1164 |
|
1166 | 1165 | output_layout = self.create_output_directory_line() |
1167 | 1166 |
|
1168 | 1167 | script_layout = self.create_script_layout() |
1169 | 1168 |
|
| 1169 | + hlayout = QtGui.QHBoxLayout() |
| 1170 | + |
| 1171 | + platform_group = QtGui.QGroupBox('Platforms') |
| 1172 | + platform_group.setContentsMargins(0, 10, 0, 0) |
| 1173 | + playout = QtGui.QVBoxLayout() |
| 1174 | + playout.addLayout(vlayout) |
| 1175 | + platform_group.setLayout(playout) |
| 1176 | + |
| 1177 | + hlayout.addWidget(platform_group) |
| 1178 | + |
| 1179 | + tree_layout = self.create_blacklist_layout(hlayout) |
| 1180 | + tree_layout.setContentsMargins(0, 10, 0, 0) |
| 1181 | + |
1170 | 1182 | vbox = QtGui.QVBoxLayout() |
1171 | | - vbox.addLayout(vlayout) |
| 1183 | + vbox.addLayout(hlayout) |
1172 | 1184 | vbox.addLayout(output_name_layout) |
1173 | 1185 | vbox.addLayout(output_layout) |
1174 | 1186 | vbox.addLayout(script_layout) |
1175 | 1187 |
|
1176 | 1188 | group_box.setLayout(vbox) |
1177 | 1189 | return group_box |
1178 | 1190 |
|
| 1191 | + def create_blacklist_layout(self, blacklist_layout): |
| 1192 | + |
| 1193 | + self.tree_browser = TreeBrowser() |
| 1194 | + self.tree_browser.setContentsMargins(0, 0, 0, 0) |
| 1195 | + |
| 1196 | + self.blacklist_text = QtGui.QPlainTextEdit() |
| 1197 | + self.whitelist_text = QtGui.QPlainTextEdit() |
| 1198 | + |
| 1199 | + hlayout = QtGui.QHBoxLayout() |
| 1200 | + |
| 1201 | + blacklayout = QtGui.QVBoxLayout() |
| 1202 | + whitelayout = QtGui.QHBoxLayout() |
| 1203 | + |
| 1204 | + blacklayout.addWidget(self.blacklist_text) |
| 1205 | + whitelayout.addWidget(self.whitelist_text) |
| 1206 | + |
| 1207 | + whitelist_setting = self.get_setting('whitelist') |
| 1208 | + blacklist_setting = self.get_setting('blacklist') |
| 1209 | + |
| 1210 | + self.blacklist_text.setStatusTip(blacklist_setting.description) |
| 1211 | + self.whitelist_text.setStatusTip(whitelist_setting.description) |
| 1212 | + |
| 1213 | + self.blacklist_text.setObjectName(blacklist_setting.name) |
| 1214 | + self.whitelist_text.setObjectName(whitelist_setting.name) |
| 1215 | + |
| 1216 | + blackgroup = QtGui.QGroupBox(blacklist_setting.display_name) |
| 1217 | + whitegroup = QtGui.QGroupBox(whitelist_setting.display_name) |
| 1218 | + |
| 1219 | + blackgroup.setLayout(blacklayout) |
| 1220 | + whitegroup.setLayout(whitelayout) |
| 1221 | + |
| 1222 | + blacklist_layout.addWidget(blackgroup) |
| 1223 | + blacklist_layout.addWidget(whitegroup) |
| 1224 | + blacklist_layout.addWidget(self.tree_browser) |
| 1225 | + |
| 1226 | + self.blacklist_text.textChanged.connect( |
| 1227 | + self.call_with_object('setting_changed', |
| 1228 | + self.blacklist_text, |
| 1229 | + blacklist_setting) |
| 1230 | + ) |
| 1231 | + |
| 1232 | + self.whitelist_text.textChanged.connect( |
| 1233 | + self.call_with_object('setting_changed', |
| 1234 | + self.whitelist_text, |
| 1235 | + whitelist_setting) |
| 1236 | + ) |
| 1237 | + |
| 1238 | + self.blacklist_text.textChanged.connect( |
| 1239 | + self.call_with_object('blacklist_changed', |
| 1240 | + self.blacklist_text, |
| 1241 | + blacklist_setting) |
| 1242 | + ) |
| 1243 | + |
| 1244 | + self.whitelist_text.textChanged.connect( |
| 1245 | + self.call_with_object('whitelist_changed', |
| 1246 | + self.whitelist_text, |
| 1247 | + whitelist_setting) |
| 1248 | + ) |
| 1249 | + |
| 1250 | + return blacklist_layout |
| 1251 | + |
| 1252 | + def blacklist_changed(self, text, blacklist_setting): |
| 1253 | + new_val = text.toPlainText() |
| 1254 | + output_blacklist = os.path.basename(self.output_dir()) |
| 1255 | + self.tree_browser.refresh(blacklist=(new_val.split('\n') + |
| 1256 | + ['*'+output_blacklist+'*'])) |
| 1257 | + |
| 1258 | + def whitelist_changed(self, text, whitelist_setting): |
| 1259 | + new_val = text.toPlainText() |
| 1260 | + self.tree_browser.refresh(whitelist=new_val.split('\n')) |
| 1261 | + |
| 1262 | + @property |
| 1263 | + def used_project_files(self): |
| 1264 | + return self.tree_browser.files |
| 1265 | + |
| 1266 | + @property |
| 1267 | + def used_project_dirs(self): |
| 1268 | + return self.tree_browser.dirs |
| 1269 | + |
1179 | 1270 | def create_output_name_pattern_line(self): |
1180 | 1271 | output_name_layout = QtGui.QHBoxLayout() |
1181 | 1272 |
|
@@ -1415,7 +1506,10 @@ def reset_settings(self): |
1415 | 1506 | old_val = setting.default_value |
1416 | 1507 |
|
1417 | 1508 | setting.value = old_val.replace('\\', '\\\\') |
1418 | | - widget.setText(old_val) |
| 1509 | + if hasattr(widget, 'setText'): |
| 1510 | + widget.setText(old_val) |
| 1511 | + elif hasattr(widget, 'setPlainText'): |
| 1512 | + widget.setPlainText(old_val) |
1419 | 1513 | elif setting.type == 'strings': |
1420 | 1514 | old_val = [] |
1421 | 1515 | if setting.default_value is not None: |
@@ -1477,7 +1571,11 @@ def setting_changed(self, obj, setting, *args): |
1477 | 1571 | setting.type == 'file' or |
1478 | 1572 | setting.type == 'folder' or |
1479 | 1573 | setting.type == 'int'): |
1480 | | - setting.value = args[0] |
| 1574 | + if args: |
| 1575 | + setting.value = args[0] |
| 1576 | + else: |
| 1577 | + setting.value = obj.toPlainText() |
| 1578 | + |
1481 | 1579 | if not setting.value: |
1482 | 1580 | setting.value = setting.default_value |
1483 | 1581 | elif setting.type == 'strings': |
@@ -1629,7 +1727,10 @@ def load_package_json(self, json_path=None): |
1629 | 1727 | setting.type == 'folder' or |
1630 | 1728 | setting.type == 'int'): |
1631 | 1729 | val_str = self.convert_val_to_str(setting.value) |
1632 | | - setting_field.setText(setting.filter_name(val_str)) |
| 1730 | + if hasattr(setting_field, 'setText'): |
| 1731 | + setting_field.setText(setting.filter_name(val_str)) |
| 1732 | + elif hasattr(setting_field, 'setPlainText'): |
| 1733 | + setting_field.setPlainText(setting.filter_name(val_str)) |
1633 | 1734 | if setting.type == 'strings': |
1634 | 1735 | vals = [self.convert_val_to_str(v) for v in setting.value] |
1635 | 1736 | setting_field.setText(','.join(vals)) |
|
0 commit comments