Status: | Superseded |
---|---|
Proposed branch: | lp:~phill-ridout/openlp/path_edit |
Merge into: | lp:openlp |
Diff against target: |
1483 lines (+628/-345) 17 files modified
openlp/core/common/__init__.py (+1/-1) openlp/core/lib/theme.py (+1/-1) openlp/core/ui/advancedtab.py (+13/-78) openlp/core/ui/generaltab.py (+11/-41) openlp/core/ui/lib/__init__.py (+8/-6) openlp/core/ui/lib/colorbutton.py (+1/-1) openlp/core/ui/lib/pathedit.py (+197/-0) openlp/core/ui/themeform.py (+18/-39) openlp/core/ui/themewizard.py (+7/-21) openlp/plugins/bibles/forms/bibleimportform.py (+8/-15) openlp/plugins/presentations/lib/presentationtab.py (+12/-51) openlp/plugins/songusage/forms/songusagedetaildialog.py (+5/-10) openlp/plugins/songusage/forms/songusagedetailform.py (+4/-9) tests/functional/openlp_core_ui/test_themeform.py (+17/-56) tests/functional/openlp_core_ui_lib/test_color_button.py (+10/-13) tests/functional/openlp_core_ui_lib/test_path_edit.py (+311/-0) tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py (+4/-3) |
To merge this branch: | bzr merge lp:~phill-ridout/openlp/path_edit |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Bentley | Needs Fixing | ||
Review via email: mp+324018@code.launchpad.net |
This proposal has been superseded by a proposal from 2017-05-14.
Commit message
Description of the change
Add a custom widget for editing and selecting paths. Implemented in OpenLP, with the exception of the import wizards, as I have other plans for refactoring these!
lp:~phill-ridout/openlp/path_edit (revision 2736)
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[FAILURE] https:/
Stopping after failure
Unmerged revisions
Preview Diff
1 | === modified file 'openlp/core/common/__init__.py' | |||
2 | --- openlp/core/common/__init__.py 2016-12-31 11:01:36 +0000 | |||
3 | +++ openlp/core/common/__init__.py 2017-05-14 07:15:51 +0000 | |||
4 | @@ -398,7 +398,7 @@ | |||
5 | 398 | """ | 398 | """ |
6 | 399 | Function that checks whether a binary exists. | 399 | Function that checks whether a binary exists. |
7 | 400 | 400 | ||
9 | 401 | :param program_path:The full path to the binary to check. | 401 | :param program_path: The full path to the binary to check. |
10 | 402 | :return: program output to be parsed | 402 | :return: program output to be parsed |
11 | 403 | """ | 403 | """ |
12 | 404 | log.debug('testing program_path: {text}'.format(text=program_path)) | 404 | log.debug('testing program_path: {text}'.format(text=program_path)) |
13 | 405 | 405 | ||
14 | === modified file 'openlp/core/lib/theme.py' | |||
15 | --- openlp/core/lib/theme.py 2016-12-31 11:01:36 +0000 | |||
16 | +++ openlp/core/lib/theme.py 2017-05-14 07:15:51 +0000 | |||
17 | @@ -164,7 +164,7 @@ | |||
18 | 164 | jsn = get_text_file_string(json_file) | 164 | jsn = get_text_file_string(json_file) |
19 | 165 | jsn = json.loads(jsn) | 165 | jsn = json.loads(jsn) |
20 | 166 | self.expand_json(jsn) | 166 | self.expand_json(jsn) |
22 | 167 | self.background_filename = None | 167 | self.background_filename = '' |
23 | 168 | 168 | ||
24 | 169 | def expand_json(self, var, prev=None): | 169 | def expand_json(self, var, prev=None): |
25 | 170 | """ | 170 | """ |
26 | 171 | 171 | ||
27 | === modified file 'openlp/core/ui/advancedtab.py' | |||
28 | --- openlp/core/ui/advancedtab.py 2016-12-31 11:01:36 +0000 | |||
29 | +++ openlp/core/ui/advancedtab.py 2017-05-14 07:15:51 +0000 | |||
30 | @@ -25,13 +25,13 @@ | |||
31 | 25 | from datetime import datetime, timedelta | 25 | from datetime import datetime, timedelta |
32 | 26 | import logging | 26 | import logging |
33 | 27 | import os | 27 | import os |
34 | 28 | import sys | ||
35 | 29 | 28 | ||
36 | 30 | from PyQt5 import QtCore, QtGui, QtWidgets | 29 | from PyQt5 import QtCore, QtGui, QtWidgets |
37 | 31 | 30 | ||
38 | 32 | from openlp.core.common import AppLocation, Settings, SlideLimits, UiStrings, translate | 31 | from openlp.core.common import AppLocation, Settings, SlideLimits, UiStrings, translate |
39 | 32 | from openlp.core.common.languagemanager import format_time | ||
40 | 33 | from openlp.core.lib import SettingsTab, build_icon | 33 | from openlp.core.lib import SettingsTab, build_icon |
42 | 34 | from openlp.core.common.languagemanager import format_time | 34 | from openlp.core.ui.lib import PathEdit, PathType |
43 | 35 | 35 | ||
44 | 36 | log = logging.getLogger(__name__) | 36 | log = logging.getLogger(__name__) |
45 | 37 | 37 | ||
46 | @@ -153,32 +153,18 @@ | |||
47 | 153 | self.data_directory_group_box.setObjectName('data_directory_group_box') | 153 | self.data_directory_group_box.setObjectName('data_directory_group_box') |
48 | 154 | self.data_directory_layout = QtWidgets.QFormLayout(self.data_directory_group_box) | 154 | self.data_directory_layout = QtWidgets.QFormLayout(self.data_directory_group_box) |
49 | 155 | self.data_directory_layout.setObjectName('data_directory_layout') | 155 | self.data_directory_layout.setObjectName('data_directory_layout') |
50 | 156 | self.data_directory_current_label = QtWidgets.QLabel(self.data_directory_group_box) | ||
51 | 157 | self.data_directory_current_label.setObjectName('data_directory_current_label') | ||
52 | 158 | self.data_directory_label = QtWidgets.QLabel(self.data_directory_group_box) | ||
53 | 159 | self.data_directory_label.setObjectName('data_directory_label') | ||
54 | 160 | self.data_directory_new_label = QtWidgets.QLabel(self.data_directory_group_box) | 156 | self.data_directory_new_label = QtWidgets.QLabel(self.data_directory_group_box) |
55 | 161 | self.data_directory_new_label.setObjectName('data_directory_current_label') | 157 | self.data_directory_new_label.setObjectName('data_directory_current_label') |
59 | 162 | self.new_data_directory_edit = QtWidgets.QLineEdit(self.data_directory_group_box) | 158 | self.data_directory_path_edit = PathEdit(self.data_directory_group_box) |
60 | 163 | self.new_data_directory_edit.setObjectName('new_data_directory_edit') | 159 | self.data_directory_path_edit.path_type = PathType.Directories |
61 | 164 | self.new_data_directory_edit.setReadOnly(True) | 160 | self.data_directory_path_edit.default_path = AppLocation.get_directory(AppLocation.DataDir) |
62 | 161 | self.data_directory_layout.addRow(self.data_directory_new_label, self.data_directory_path_edit) | ||
63 | 165 | self.new_data_directory_has_files_label = QtWidgets.QLabel(self.data_directory_group_box) | 162 | self.new_data_directory_has_files_label = QtWidgets.QLabel(self.data_directory_group_box) |
64 | 166 | self.new_data_directory_has_files_label.setObjectName('new_data_directory_has_files_label') | 163 | self.new_data_directory_has_files_label.setObjectName('new_data_directory_has_files_label') |
65 | 167 | self.new_data_directory_has_files_label.setWordWrap(True) | 164 | self.new_data_directory_has_files_label.setWordWrap(True) |
66 | 168 | self.data_directory_browse_button = QtWidgets.QToolButton(self.data_directory_group_box) | ||
67 | 169 | self.data_directory_browse_button.setObjectName('data_directory_browse_button') | ||
68 | 170 | self.data_directory_browse_button.setIcon(build_icon(':/general/general_open.png')) | ||
69 | 171 | self.data_directory_default_button = QtWidgets.QToolButton(self.data_directory_group_box) | ||
70 | 172 | self.data_directory_default_button.setObjectName('data_directory_default_button') | ||
71 | 173 | self.data_directory_default_button.setIcon(build_icon(':/general/general_revert.png')) | ||
72 | 174 | self.data_directory_cancel_button = QtWidgets.QToolButton(self.data_directory_group_box) | 165 | self.data_directory_cancel_button = QtWidgets.QToolButton(self.data_directory_group_box) |
73 | 175 | self.data_directory_cancel_button.setObjectName('data_directory_cancel_button') | 166 | self.data_directory_cancel_button.setObjectName('data_directory_cancel_button') |
74 | 176 | self.data_directory_cancel_button.setIcon(build_icon(':/general/general_delete.png')) | 167 | self.data_directory_cancel_button.setIcon(build_icon(':/general/general_delete.png')) |
75 | 177 | self.new_data_directory_label_layout = QtWidgets.QHBoxLayout() | ||
76 | 178 | self.new_data_directory_label_layout.setObjectName('new_data_directory_label_layout') | ||
77 | 179 | self.new_data_directory_label_layout.addWidget(self.new_data_directory_edit) | ||
78 | 180 | self.new_data_directory_label_layout.addWidget(self.data_directory_browse_button) | ||
79 | 181 | self.new_data_directory_label_layout.addWidget(self.data_directory_default_button) | ||
80 | 182 | self.data_directory_copy_check_layout = QtWidgets.QHBoxLayout() | 168 | self.data_directory_copy_check_layout = QtWidgets.QHBoxLayout() |
81 | 183 | self.data_directory_copy_check_layout.setObjectName('data_directory_copy_check_layout') | 169 | self.data_directory_copy_check_layout.setObjectName('data_directory_copy_check_layout') |
82 | 184 | self.data_directory_copy_check_box = QtWidgets.QCheckBox(self.data_directory_group_box) | 170 | self.data_directory_copy_check_box = QtWidgets.QCheckBox(self.data_directory_group_box) |
83 | @@ -186,8 +172,6 @@ | |||
84 | 186 | self.data_directory_copy_check_layout.addWidget(self.data_directory_copy_check_box) | 172 | self.data_directory_copy_check_layout.addWidget(self.data_directory_copy_check_box) |
85 | 187 | self.data_directory_copy_check_layout.addStretch() | 173 | self.data_directory_copy_check_layout.addStretch() |
86 | 188 | self.data_directory_copy_check_layout.addWidget(self.data_directory_cancel_button) | 174 | self.data_directory_copy_check_layout.addWidget(self.data_directory_cancel_button) |
87 | 189 | self.data_directory_layout.addRow(self.data_directory_current_label, self.data_directory_label) | ||
88 | 190 | self.data_directory_layout.addRow(self.data_directory_new_label, self.new_data_directory_label_layout) | ||
89 | 191 | self.data_directory_layout.addRow(self.data_directory_copy_check_layout) | 175 | self.data_directory_layout.addRow(self.data_directory_copy_check_layout) |
90 | 192 | self.data_directory_layout.addRow(self.new_data_directory_has_files_label) | 176 | self.data_directory_layout.addRow(self.new_data_directory_has_files_label) |
91 | 193 | self.left_layout.addWidget(self.data_directory_group_box) | 177 | self.left_layout.addWidget(self.data_directory_group_box) |
92 | @@ -239,8 +223,7 @@ | |||
93 | 239 | self.service_name_edit.textChanged.connect(self.update_service_name_example) | 223 | self.service_name_edit.textChanged.connect(self.update_service_name_example) |
94 | 240 | self.service_name_revert_button.clicked.connect(self.on_service_name_revert_button_clicked) | 224 | self.service_name_revert_button.clicked.connect(self.on_service_name_revert_button_clicked) |
95 | 241 | self.alternate_rows_check_box.toggled.connect(self.on_alternate_rows_check_box_toggled) | 225 | self.alternate_rows_check_box.toggled.connect(self.on_alternate_rows_check_box_toggled) |
98 | 242 | self.data_directory_browse_button.clicked.connect(self.on_data_directory_browse_button_clicked) | 226 | self.data_directory_path_edit.pathChanged.connect(self.on_data_directory_path_edit_path_changed) |
97 | 243 | self.data_directory_default_button.clicked.connect(self.on_data_directory_default_button_clicked) | ||
99 | 244 | self.data_directory_cancel_button.clicked.connect(self.on_data_directory_cancel_button_clicked) | 227 | self.data_directory_cancel_button.clicked.connect(self.on_data_directory_cancel_button_clicked) |
100 | 245 | self.data_directory_copy_check_box.toggled.connect(self.on_data_directory_copy_check_box_toggled) | 228 | self.data_directory_copy_check_box.toggled.connect(self.on_data_directory_copy_check_box_toggled) |
101 | 246 | self.end_slide_radio_button.clicked.connect(self.on_end_slide_button_clicked) | 229 | self.end_slide_radio_button.clicked.connect(self.on_end_slide_button_clicked) |
102 | @@ -317,12 +300,7 @@ | |||
103 | 317 | self.service_name_example_label.setText(translate('OpenLP.AdvancedTab', 'Example:')) | 300 | self.service_name_example_label.setText(translate('OpenLP.AdvancedTab', 'Example:')) |
104 | 318 | self.hide_mouse_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) | 301 | self.hide_mouse_group_box.setTitle(translate('OpenLP.AdvancedTab', 'Mouse Cursor')) |
105 | 319 | self.hide_mouse_check_box.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) | 302 | self.hide_mouse_check_box.setText(translate('OpenLP.AdvancedTab', 'Hide mouse cursor when over display window')) |
112 | 320 | self.data_directory_current_label.setText(translate('OpenLP.AdvancedTab', 'Current path:')) | 303 | self.data_directory_new_label.setText(translate('OpenLP.AdvancedTab', 'Path:')) |
107 | 321 | self.data_directory_new_label.setText(translate('OpenLP.AdvancedTab', 'Custom path:')) | ||
108 | 322 | self.data_directory_browse_button.setToolTip(translate('OpenLP.AdvancedTab', | ||
109 | 323 | 'Browse for new data file location.')) | ||
110 | 324 | self.data_directory_default_button.setToolTip( | ||
111 | 325 | translate('OpenLP.AdvancedTab', 'Set the data location to the default.')) | ||
113 | 326 | self.data_directory_cancel_button.setText(translate('OpenLP.AdvancedTab', 'Cancel')) | 304 | self.data_directory_cancel_button.setText(translate('OpenLP.AdvancedTab', 'Cancel')) |
114 | 327 | self.data_directory_cancel_button.setToolTip( | 305 | self.data_directory_cancel_button.setToolTip( |
115 | 328 | translate('OpenLP.AdvancedTab', 'Cancel OpenLP data directory location change.')) | 306 | translate('OpenLP.AdvancedTab', 'Cancel OpenLP data directory location change.')) |
116 | @@ -396,8 +374,7 @@ | |||
117 | 396 | self.new_data_directory_has_files_label.hide() | 374 | self.new_data_directory_has_files_label.hide() |
118 | 397 | self.data_directory_cancel_button.hide() | 375 | self.data_directory_cancel_button.hide() |
119 | 398 | # Since data location can be changed, make sure the path is present. | 376 | # Since data location can be changed, make sure the path is present. |
122 | 399 | self.current_data_path = AppLocation.get_data_path() | 377 | self.data_directory_path_edit.path = AppLocation.get_data_path() |
121 | 400 | self.data_directory_label.setText(os.path.abspath(self.current_data_path)) | ||
123 | 401 | # Don't allow data directory move if running portable. | 378 | # Don't allow data directory move if running portable. |
124 | 402 | if settings.value('advanced/is portable'): | 379 | if settings.value('advanced/is portable'): |
125 | 403 | self.data_directory_group_box.hide() | 380 | self.data_directory_group_box.hide() |
126 | @@ -509,24 +486,10 @@ | |||
127 | 509 | self.service_name_edit.setText(UiStrings().DefaultServiceName) | 486 | self.service_name_edit.setText(UiStrings().DefaultServiceName) |
128 | 510 | self.service_name_edit.setFocus() | 487 | self.service_name_edit.setFocus() |
129 | 511 | 488 | ||
131 | 512 | def on_data_directory_browse_button_clicked(self): | 489 | def on_data_directory_path_edit_path_changed(self, new_data_path): |
132 | 513 | """ | 490 | """ |
133 | 514 | Browse for a new data directory location. | 491 | Browse for a new data directory location. |
134 | 515 | """ | 492 | """ |
135 | 516 | old_root_path = str(self.data_directory_label.text()) | ||
136 | 517 | # Get the new directory location. | ||
137 | 518 | new_data_path = QtWidgets.QFileDialog.getExistingDirectory(self, translate('OpenLP.AdvancedTab', | ||
138 | 519 | 'Select Data Directory Location'), | ||
139 | 520 | old_root_path, | ||
140 | 521 | options=QtWidgets.QFileDialog.ShowDirsOnly) | ||
141 | 522 | # Set the new data path. | ||
142 | 523 | if new_data_path: | ||
143 | 524 | new_data_path = os.path.normpath(new_data_path) | ||
144 | 525 | if self.current_data_path.lower() == new_data_path.lower(): | ||
145 | 526 | self.on_data_directory_cancel_button_clicked() | ||
146 | 527 | return | ||
147 | 528 | else: | ||
148 | 529 | return | ||
149 | 530 | # Make sure they want to change the data. | 493 | # Make sure they want to change the data. |
150 | 531 | answer = QtWidgets.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), | 494 | answer = QtWidgets.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Confirm Data Directory Change'), |
151 | 532 | translate('OpenLP.AdvancedTab', 'Are you sure you want to change the ' | 495 | translate('OpenLP.AdvancedTab', 'Are you sure you want to change the ' |
152 | @@ -537,42 +500,14 @@ | |||
153 | 537 | QtWidgets.QMessageBox.No), | 500 | QtWidgets.QMessageBox.No), |
154 | 538 | QtWidgets.QMessageBox.No) | 501 | QtWidgets.QMessageBox.No) |
155 | 539 | if answer != QtWidgets.QMessageBox.Yes: | 502 | if answer != QtWidgets.QMessageBox.Yes: |
156 | 503 | self.data_directory_path_edit.path = AppLocation.get_data_path() | ||
157 | 540 | return | 504 | return |
158 | 541 | # Check if data already exists here. | 505 | # Check if data already exists here. |
159 | 542 | self.check_data_overwrite(new_data_path) | 506 | self.check_data_overwrite(new_data_path) |
160 | 543 | # Save the new location. | 507 | # Save the new location. |
161 | 544 | self.main_window.set_new_data_path(new_data_path) | 508 | self.main_window.set_new_data_path(new_data_path) |
162 | 545 | self.new_data_directory_edit.setText(new_data_path) | ||
163 | 546 | self.data_directory_cancel_button.show() | 509 | self.data_directory_cancel_button.show() |
164 | 547 | 510 | ||
165 | 548 | def on_data_directory_default_button_clicked(self): | ||
166 | 549 | """ | ||
167 | 550 | Re-set the data directory location to the 'default' location. | ||
168 | 551 | """ | ||
169 | 552 | new_data_path = AppLocation.get_directory(AppLocation.DataDir) | ||
170 | 553 | if self.current_data_path.lower() != new_data_path.lower(): | ||
171 | 554 | # Make sure they want to change the data location back to the | ||
172 | 555 | # default. | ||
173 | 556 | answer = QtWidgets.QMessageBox.question(self, translate('OpenLP.AdvancedTab', 'Reset Data Directory'), | ||
174 | 557 | translate('OpenLP.AdvancedTab', 'Are you sure you want to change ' | ||
175 | 558 | 'the location of the OpenLP data ' | ||
176 | 559 | 'directory to the default location?' | ||
177 | 560 | '\n\nThis location will be used ' | ||
178 | 561 | 'after OpenLP is closed.'), | ||
179 | 562 | QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | | ||
180 | 563 | QtWidgets.QMessageBox.No), | ||
181 | 564 | QtWidgets.QMessageBox.No) | ||
182 | 565 | if answer != QtWidgets.QMessageBox.Yes: | ||
183 | 566 | return | ||
184 | 567 | self.check_data_overwrite(new_data_path) | ||
185 | 568 | # Save the new location. | ||
186 | 569 | self.main_window.set_new_data_path(new_data_path) | ||
187 | 570 | self.new_data_directory_edit.setText(os.path.abspath(new_data_path)) | ||
188 | 571 | self.data_directory_cancel_button.show() | ||
189 | 572 | else: | ||
190 | 573 | # We cancel the change in case user changed their mind. | ||
191 | 574 | self.on_data_directory_cancel_button_clicked() | ||
192 | 575 | |||
193 | 576 | def on_data_directory_copy_check_box_toggled(self): | 511 | def on_data_directory_copy_check_box_toggled(self): |
194 | 577 | """ | 512 | """ |
195 | 578 | Copy existing data when you change your data directory. | 513 | Copy existing data when you change your data directory. |
196 | @@ -589,7 +524,6 @@ | |||
197 | 589 | Check if there's already data in the target directory. | 524 | Check if there's already data in the target directory. |
198 | 590 | """ | 525 | """ |
199 | 591 | test_path = os.path.join(data_path, 'songs') | 526 | test_path = os.path.join(data_path, 'songs') |
200 | 592 | self.data_directory_copy_check_box.show() | ||
201 | 593 | if os.path.exists(test_path): | 527 | if os.path.exists(test_path): |
202 | 594 | self.data_exists = True | 528 | self.data_exists = True |
203 | 595 | # Check is they want to replace existing data. | 529 | # Check is they want to replace existing data. |
204 | @@ -603,6 +537,7 @@ | |||
205 | 603 | QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | | 537 | QtWidgets.QMessageBox.StandardButtons(QtWidgets.QMessageBox.Yes | |
206 | 604 | QtWidgets.QMessageBox.No), | 538 | QtWidgets.QMessageBox.No), |
207 | 605 | QtWidgets.QMessageBox.No) | 539 | QtWidgets.QMessageBox.No) |
208 | 540 | self.data_directory_copy_check_box.show() | ||
209 | 606 | if answer == QtWidgets.QMessageBox.Yes: | 541 | if answer == QtWidgets.QMessageBox.Yes: |
210 | 607 | self.data_directory_copy_check_box.setChecked(True) | 542 | self.data_directory_copy_check_box.setChecked(True) |
211 | 608 | self.new_data_directory_has_files_label.show() | 543 | self.new_data_directory_has_files_label.show() |
212 | @@ -618,7 +553,7 @@ | |||
213 | 618 | """ | 553 | """ |
214 | 619 | Cancel the data directory location change | 554 | Cancel the data directory location change |
215 | 620 | """ | 555 | """ |
217 | 621 | self.new_data_directory_edit.clear() | 556 | self.data_directory_path_edit.path = AppLocation.get_data_path() |
218 | 622 | self.data_directory_copy_check_box.setChecked(False) | 557 | self.data_directory_copy_check_box.setChecked(False) |
219 | 623 | self.main_window.set_new_data_path(None) | 558 | self.main_window.set_new_data_path(None) |
220 | 624 | self.main_window.set_copy_data(False) | 559 | self.main_window.set_copy_data(False) |
221 | 625 | 560 | ||
222 | === modified file 'openlp/core/ui/generaltab.py' | |||
223 | --- openlp/core/ui/generaltab.py 2016-12-31 11:01:36 +0000 | |||
224 | +++ openlp/core/ui/generaltab.py 2017-05-14 07:15:51 +0000 | |||
225 | @@ -27,8 +27,8 @@ | |||
226 | 27 | from PyQt5 import QtCore, QtGui, QtWidgets | 27 | from PyQt5 import QtCore, QtGui, QtWidgets |
227 | 28 | 28 | ||
228 | 29 | from openlp.core.common import Registry, Settings, UiStrings, translate, get_images_filter | 29 | from openlp.core.common import Registry, Settings, UiStrings, translate, get_images_filter |
231 | 30 | from openlp.core.lib import SettingsTab, ScreenList, build_icon | 30 | from openlp.core.lib import SettingsTab, ScreenList |
232 | 31 | from openlp.core.ui.lib.colorbutton import ColorButton | 31 | from openlp.core.ui.lib import ColorButton, PathEdit |
233 | 32 | 32 | ||
234 | 33 | log = logging.getLogger(__name__) | 33 | log = logging.getLogger(__name__) |
235 | 34 | 34 | ||
236 | @@ -172,20 +172,10 @@ | |||
237 | 172 | self.logo_layout.setObjectName('logo_layout') | 172 | self.logo_layout.setObjectName('logo_layout') |
238 | 173 | self.logo_file_label = QtWidgets.QLabel(self.logo_group_box) | 173 | self.logo_file_label = QtWidgets.QLabel(self.logo_group_box) |
239 | 174 | self.logo_file_label.setObjectName('logo_file_label') | 174 | self.logo_file_label.setObjectName('logo_file_label') |
254 | 175 | self.logo_file_edit = QtWidgets.QLineEdit(self.logo_group_box) | 175 | self.logo_file_path_edit = \ |
255 | 176 | self.logo_file_edit.setObjectName('logo_file_edit') | 176 | PathEdit(self.logo_group_box) |
256 | 177 | self.logo_browse_button = QtWidgets.QToolButton(self.logo_group_box) | 177 | self.logo_file_path_edit.default_path = ':/graphics/openlp-splash-screen.png' |
257 | 178 | self.logo_browse_button.setObjectName('logo_browse_button') | 178 | self.logo_layout.addRow(self.logo_file_label, self.logo_file_path_edit) |
244 | 179 | self.logo_browse_button.setIcon(build_icon(':/general/general_open.png')) | ||
245 | 180 | self.logo_revert_button = QtWidgets.QToolButton(self.logo_group_box) | ||
246 | 181 | self.logo_revert_button.setObjectName('logo_revert_button') | ||
247 | 182 | self.logo_revert_button.setIcon(build_icon(':/general/general_revert.png')) | ||
248 | 183 | self.logo_file_layout = QtWidgets.QHBoxLayout() | ||
249 | 184 | self.logo_file_layout.setObjectName('logo_file_layout') | ||
250 | 185 | self.logo_file_layout.addWidget(self.logo_file_edit) | ||
251 | 186 | self.logo_file_layout.addWidget(self.logo_browse_button) | ||
252 | 187 | self.logo_file_layout.addWidget(self.logo_revert_button) | ||
253 | 188 | self.logo_layout.addRow(self.logo_file_label, self.logo_file_layout) | ||
258 | 189 | self.logo_color_label = QtWidgets.QLabel(self.logo_group_box) | 179 | self.logo_color_label = QtWidgets.QLabel(self.logo_group_box) |
259 | 190 | self.logo_color_label.setObjectName('logo_color_label') | 180 | self.logo_color_label.setObjectName('logo_color_label') |
260 | 191 | self.logo_color_button = ColorButton(self.logo_group_box) | 181 | self.logo_color_button = ColorButton(self.logo_group_box) |
261 | @@ -196,8 +186,6 @@ | |||
262 | 196 | self.logo_layout.addRow(self.logo_hide_on_startup_check_box) | 186 | self.logo_layout.addRow(self.logo_hide_on_startup_check_box) |
263 | 197 | self.right_layout.addWidget(self.logo_group_box) | 187 | self.right_layout.addWidget(self.logo_group_box) |
264 | 198 | self.logo_color_button.colorChanged.connect(self.on_logo_background_color_changed) | 188 | self.logo_color_button.colorChanged.connect(self.on_logo_background_color_changed) |
265 | 199 | self.logo_browse_button.clicked.connect(self.on_logo_browse_button_clicked) | ||
266 | 200 | self.logo_revert_button.clicked.connect(self.on_logo_revert_button_clicked) | ||
267 | 201 | # Application Settings | 189 | # Application Settings |
268 | 202 | self.settings_group_box = QtWidgets.QGroupBox(self.right_column) | 190 | self.settings_group_box = QtWidgets.QGroupBox(self.right_column) |
269 | 203 | self.settings_group_box.setObjectName('settings_group_box') | 191 | self.settings_group_box.setObjectName('settings_group_box') |
270 | @@ -254,8 +242,6 @@ | |||
271 | 254 | self.logo_group_box.setTitle(translate('OpenLP.GeneralTab', 'Logo')) | 242 | self.logo_group_box.setTitle(translate('OpenLP.GeneralTab', 'Logo')) |
272 | 255 | self.logo_color_label.setText(UiStrings().BackgroundColorColon) | 243 | self.logo_color_label.setText(UiStrings().BackgroundColorColon) |
273 | 256 | self.logo_file_label.setText(translate('OpenLP.GeneralTab', 'Logo file:')) | 244 | self.logo_file_label.setText(translate('OpenLP.GeneralTab', 'Logo file:')) |
274 | 257 | self.logo_browse_button.setToolTip(translate('OpenLP.GeneralTab', 'Browse for an image file to display.')) | ||
275 | 258 | self.logo_revert_button.setToolTip(translate('OpenLP.GeneralTab', 'Revert to the default OpenLP logo.')) | ||
276 | 259 | self.logo_hide_on_startup_check_box.setText(translate('OpenLP.GeneralTab', 'Don\'t show logo on startup')) | 245 | self.logo_hide_on_startup_check_box.setText(translate('OpenLP.GeneralTab', 'Don\'t show logo on startup')) |
277 | 260 | self.check_for_updates_check_box.setText(translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) | 246 | self.check_for_updates_check_box.setText(translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) |
278 | 261 | self.settings_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Settings')) | 247 | self.settings_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Settings')) |
279 | @@ -282,6 +268,9 @@ | |||
280 | 282 | self.audio_group_box.setTitle(translate('OpenLP.GeneralTab', 'Background Audio')) | 268 | self.audio_group_box.setTitle(translate('OpenLP.GeneralTab', 'Background Audio')) |
281 | 283 | self.start_paused_check_box.setText(translate('OpenLP.GeneralTab', 'Start background audio paused')) | 269 | self.start_paused_check_box.setText(translate('OpenLP.GeneralTab', 'Start background audio paused')) |
282 | 284 | self.repeat_list_check_box.setText(translate('OpenLP.GeneralTab', 'Repeat track list')) | 270 | self.repeat_list_check_box.setText(translate('OpenLP.GeneralTab', 'Repeat track list')) |
283 | 271 | self.logo_file_path_edit.dialog_caption = dialog_caption = translate('OpenLP.AdvancedTab', 'Select Logo File') | ||
284 | 272 | self.logo_file_path_edit.filters = '{text};;{names} (*.*)'.format( | ||
285 | 273 | text=get_images_filter(), names=UiStrings().AllFiles) | ||
286 | 285 | 274 | ||
287 | 286 | def load(self): | 275 | def load(self): |
288 | 287 | """ | 276 | """ |
289 | @@ -304,7 +293,7 @@ | |||
290 | 304 | self.auto_open_check_box.setChecked(settings.value('auto open')) | 293 | self.auto_open_check_box.setChecked(settings.value('auto open')) |
291 | 305 | self.show_splash_check_box.setChecked(settings.value('show splash')) | 294 | self.show_splash_check_box.setChecked(settings.value('show splash')) |
292 | 306 | self.logo_background_color = settings.value('logo background color') | 295 | self.logo_background_color = settings.value('logo background color') |
294 | 307 | self.logo_file_edit.setText(settings.value('logo file')) | 296 | self.logo_file_path_edit.path = settings.value('logo file') |
295 | 308 | self.logo_hide_on_startup_check_box.setChecked(settings.value('logo hide on startup')) | 297 | self.logo_hide_on_startup_check_box.setChecked(settings.value('logo hide on startup')) |
296 | 309 | self.logo_color_button.color = self.logo_background_color | 298 | self.logo_color_button.color = self.logo_background_color |
297 | 310 | self.check_for_updates_check_box.setChecked(settings.value('update check')) | 299 | self.check_for_updates_check_box.setChecked(settings.value('update check')) |
298 | @@ -338,7 +327,7 @@ | |||
299 | 338 | settings.setValue('auto open', self.auto_open_check_box.isChecked()) | 327 | settings.setValue('auto open', self.auto_open_check_box.isChecked()) |
300 | 339 | settings.setValue('show splash', self.show_splash_check_box.isChecked()) | 328 | settings.setValue('show splash', self.show_splash_check_box.isChecked()) |
301 | 340 | settings.setValue('logo background color', self.logo_background_color) | 329 | settings.setValue('logo background color', self.logo_background_color) |
303 | 341 | settings.setValue('logo file', self.logo_file_edit.text()) | 330 | settings.setValue('logo file', self.logo_file_path_edit.path) |
304 | 342 | settings.setValue('logo hide on startup', self.logo_hide_on_startup_check_box.isChecked()) | 331 | settings.setValue('logo hide on startup', self.logo_hide_on_startup_check_box.isChecked()) |
305 | 343 | settings.setValue('update check', self.check_for_updates_check_box.isChecked()) | 332 | settings.setValue('update check', self.check_for_updates_check_box.isChecked()) |
306 | 344 | settings.setValue('save prompt', self.save_check_service_check_box.isChecked()) | 333 | settings.setValue('save prompt', self.save_check_service_check_box.isChecked()) |
307 | @@ -404,25 +393,6 @@ | |||
308 | 404 | """ | 393 | """ |
309 | 405 | self.display_changed = True | 394 | self.display_changed = True |
310 | 406 | 395 | ||
311 | 407 | def on_logo_browse_button_clicked(self): | ||
312 | 408 | """ | ||
313 | 409 | Select the logo file | ||
314 | 410 | """ | ||
315 | 411 | file_filters = '{text};;{names} (*.*)'.format(text=get_images_filter(), names=UiStrings().AllFiles) | ||
316 | 412 | filename, filter_used = QtWidgets.QFileDialog.getOpenFileName(self, | ||
317 | 413 | translate('OpenLP.AdvancedTab', 'Open File'), '', | ||
318 | 414 | file_filters) | ||
319 | 415 | if filename: | ||
320 | 416 | self.logo_file_edit.setText(filename) | ||
321 | 417 | self.logo_file_edit.setFocus() | ||
322 | 418 | |||
323 | 419 | def on_logo_revert_button_clicked(self): | ||
324 | 420 | """ | ||
325 | 421 | Revert the logo file back to the default setting. | ||
326 | 422 | """ | ||
327 | 423 | self.logo_file_edit.setText(':/graphics/openlp-splash-screen.png') | ||
328 | 424 | self.logo_file_edit.setFocus() | ||
329 | 425 | |||
330 | 426 | def on_logo_background_color_changed(self, color): | 396 | def on_logo_background_color_changed(self, color): |
331 | 427 | """ | 397 | """ |
332 | 428 | Select the background color for logo. | 398 | Select the background color for logo. |
333 | 429 | 399 | ||
334 | === modified file 'openlp/core/ui/lib/__init__.py' | |||
335 | --- openlp/core/ui/lib/__init__.py 2016-12-31 11:01:36 +0000 | |||
336 | +++ openlp/core/ui/lib/__init__.py 2017-05-14 07:15:51 +0000 | |||
337 | @@ -21,14 +21,16 @@ | |||
338 | 21 | ############################################################################### | 21 | ############################################################################### |
339 | 22 | 22 | ||
340 | 23 | from .colorbutton import ColorButton | 23 | from .colorbutton import ColorButton |
341 | 24 | from .listpreviewwidget import ListPreviewWidget | ||
342 | 24 | from .listwidgetwithdnd import ListWidgetWithDnD | 25 | from .listwidgetwithdnd import ListWidgetWithDnD |
344 | 25 | from .treewidgetwithdnd import TreeWidgetWithDnD | 26 | from .mediadockmanager import MediaDockManager |
345 | 27 | from .dockwidget import OpenLPDockWidget | ||
346 | 26 | from .toolbar import OpenLPToolbar | 28 | from .toolbar import OpenLPToolbar |
347 | 27 | from .dockwidget import OpenLPDockWidget | ||
348 | 28 | from .wizard import OpenLPWizard, WizardStrings | 29 | from .wizard import OpenLPWizard, WizardStrings |
351 | 29 | from .mediadockmanager import MediaDockManager | 30 | from .pathedit import PathEdit, PathType |
350 | 30 | from .listpreviewwidget import ListPreviewWidget | ||
352 | 31 | from .spelltextedit import SpellTextEdit | 31 | from .spelltextedit import SpellTextEdit |
353 | 32 | from .treewidgetwithdnd import TreeWidgetWithDnD | ||
354 | 32 | 33 | ||
357 | 33 | __all__ = ['ColorButton', 'ListPreviewWidget', 'ListWidgetWithDnD', 'OpenLPToolbar', 'OpenLPDockWidget', | 34 | __all__ = ['ColorButton', 'ListPreviewWidget', 'ListWidgetWithDnD', 'MediaDockManager', 'OpenLPDockWidget', |
358 | 34 | 'OpenLPWizard', 'WizardStrings', 'MediaDockManager', 'ListPreviewWidget', 'SpellTextEdit'] | 35 | 'OpenLPToolbar', 'OpenLPWizard', 'PathEdit', 'PathType', 'SpellTextEdit', 'TreeWidgetWithDnD', |
359 | 36 | 'WizardStrings'] | ||
360 | 35 | 37 | ||
361 | === modified file 'openlp/core/ui/lib/colorbutton.py' | |||
362 | --- openlp/core/ui/lib/colorbutton.py 2016-12-31 11:01:36 +0000 | |||
363 | +++ openlp/core/ui/lib/colorbutton.py 2017-05-14 07:15:51 +0000 | |||
364 | @@ -39,7 +39,7 @@ | |||
365 | 39 | """ | 39 | """ |
366 | 40 | Initialise the ColorButton | 40 | Initialise the ColorButton |
367 | 41 | """ | 41 | """ |
369 | 42 | super(ColorButton, self).__init__() | 42 | super().__init__(parent) |
370 | 43 | self.parent = parent | 43 | self.parent = parent |
371 | 44 | self.change_color('#ffffff') | 44 | self.change_color('#ffffff') |
372 | 45 | self.setToolTip(translate('OpenLP.ColorButton', 'Click to select a color.')) | 45 | self.setToolTip(translate('OpenLP.ColorButton', 'Click to select a color.')) |
373 | 46 | 46 | ||
374 | === added file 'openlp/core/ui/lib/pathedit.py' | |||
375 | --- openlp/core/ui/lib/pathedit.py 1970-01-01 00:00:00 +0000 | |||
376 | +++ openlp/core/ui/lib/pathedit.py 2017-05-14 07:15:51 +0000 | |||
377 | @@ -0,0 +1,197 @@ | |||
378 | 1 | # -*- coding: utf-8 -*- | ||
379 | 2 | # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 | ||
380 | 3 | |||
381 | 4 | ############################################################################### | ||
382 | 5 | # OpenLP - Open Source Lyrics Projection # | ||
383 | 6 | # --------------------------------------------------------------------------- # | ||
384 | 7 | # Copyright (c) 2008-2017 OpenLP Developers # | ||
385 | 8 | # --------------------------------------------------------------------------- # | ||
386 | 9 | # This program is free software; you can redistribute it and/or modify it # | ||
387 | 10 | # under the terms of the GNU General Public License as published by the Free # | ||
388 | 11 | # Software Foundation; version 2 of the License. # | ||
389 | 12 | # # | ||
390 | 13 | # This program is distributed in the hope that it will be useful, but WITHOUT # | ||
391 | 14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # | ||
392 | 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # | ||
393 | 16 | # more details. # | ||
394 | 17 | # # | ||
395 | 18 | # You should have received a copy of the GNU General Public License along # | ||
396 | 19 | # with this program; if not, write to the Free Software Foundation, Inc., 59 # | ||
397 | 20 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA # | ||
398 | 21 | ############################################################################### | ||
399 | 22 | from enum import Enum | ||
400 | 23 | import os.path | ||
401 | 24 | |||
402 | 25 | from PyQt5 import QtCore, QtWidgets | ||
403 | 26 | |||
404 | 27 | from openlp.core.common import UiStrings, translate | ||
405 | 28 | from openlp.core.lib import build_icon | ||
406 | 29 | |||
407 | 30 | |||
408 | 31 | class PathType(Enum): | ||
409 | 32 | Files = 1 | ||
410 | 33 | Directories = 2 | ||
411 | 34 | |||
412 | 35 | |||
413 | 36 | class PathEdit(QtWidgets.QWidget): | ||
414 | 37 | """ | ||
415 | 38 | The :class:`~openlp.core.ui.lib.pathedit.PathEdit` class subclasses QWidget to create a custom widget for use when | ||
416 | 39 | a file or directory needs to be selected. | ||
417 | 40 | """ | ||
418 | 41 | pathChanged = QtCore.pyqtSignal(str) | ||
419 | 42 | |||
420 | 43 | def __init__(self, parent=None, show_revert=True): | ||
421 | 44 | """ | ||
422 | 45 | Initalise the PathEdit widget | ||
423 | 46 | |||
424 | 47 | :param parent: The parent of the widget. This is just passed to the super method. | ||
425 | 48 | :type parent: QWidget or None | ||
426 | 49 | |||
427 | 50 | :param show_revert: Used to determin if the 'revert button' should be visible. | ||
428 | 51 | :type show_revert: bool | ||
429 | 52 | |||
430 | 53 | :ivar default_path: The default path. This is set as the path when the revert button is clicked | ||
431 | 54 | :vartype default_path: str | ||
432 | 55 | |||
433 | 56 | :ivar dialog_caption: Used to customise the caption in the QFileDialog. | ||
434 | 57 | :vartype dialog_caption: str | ||
435 | 58 | """ | ||
436 | 59 | super().__init__(parent) | ||
437 | 60 | self.default_path = '' | ||
438 | 61 | self.dialog_caption = '' | ||
439 | 62 | self._path_type = PathType.Files | ||
440 | 63 | self._path = '' | ||
441 | 64 | self.filters = '{all_files} (*.*)'.format(all_files=UiStrings().AllFiles) | ||
442 | 65 | self._setup(show_revert) | ||
443 | 66 | |||
444 | 67 | def _setup(self, show_revert): | ||
445 | 68 | |||
446 | 69 | widget_layout = QtWidgets.QHBoxLayout() | ||
447 | 70 | widget_layout.setContentsMargins(0, 0, 0, 0) | ||
448 | 71 | self.line_edit = QtWidgets.QLineEdit(self) | ||
449 | 72 | self.line_edit.setText(self._path) | ||
450 | 73 | widget_layout.addWidget(self.line_edit) | ||
451 | 74 | self.browse_button = QtWidgets.QToolButton(self) | ||
452 | 75 | self.browse_button.setIcon(build_icon(':/general/general_open.png')) | ||
453 | 76 | widget_layout.addWidget(self.browse_button) | ||
454 | 77 | self.revert_button = QtWidgets.QToolButton(self) | ||
455 | 78 | self.revert_button.setIcon(build_icon(':/general/general_revert.png')) | ||
456 | 79 | self.revert_button.setVisible(show_revert) | ||
457 | 80 | widget_layout.addWidget(self.revert_button) | ||
458 | 81 | self.setLayout(widget_layout) | ||
459 | 82 | |||
460 | 83 | # Signals and Slots | ||
461 | 84 | self.browse_button.clicked.connect(self.on_browse_button_clicked) | ||
462 | 85 | self.revert_button.clicked.connect(self.on_revert_button_clicked) | ||
463 | 86 | self.line_edit.editingFinished.connect(self.on_line_edit_editing_finished) | ||
464 | 87 | |||
465 | 88 | self.update_button_tool_tips() | ||
466 | 89 | |||
467 | 90 | @property | ||
468 | 91 | def path(self): | ||
469 | 92 | """ | ||
470 | 93 | A property getter method to return the selected path. | ||
471 | 94 | |||
472 | 95 | :return: The selected path | ||
473 | 96 | :rtype: str | ||
474 | 97 | """ | ||
475 | 98 | return self._path | ||
476 | 99 | |||
477 | 100 | @path.setter | ||
478 | 101 | def path(self, path): | ||
479 | 102 | """ | ||
480 | 103 | A Property setter method to set the selected path | ||
481 | 104 | |||
482 | 105 | :param path: The path to set the widget to | ||
483 | 106 | :type path: str | ||
484 | 107 | """ | ||
485 | 108 | self._path = path | ||
486 | 109 | self.line_edit.setText(path) | ||
487 | 110 | self.line_edit.setToolTip(path) | ||
488 | 111 | |||
489 | 112 | @property | ||
490 | 113 | def path_type(self): | ||
491 | 114 | """ | ||
492 | 115 | A property getter method to return the path_type. Path type allows you to sepecify if the user is restricted to | ||
493 | 116 | selecting a file or directory. | ||
494 | 117 | |||
495 | 118 | :return: The type selected | ||
496 | 119 | :rtype: Enum of PathEdit | ||
497 | 120 | """ | ||
498 | 121 | return self._path_type | ||
499 | 122 | |||
500 | 123 | @path_type.setter | ||
501 | 124 | def path_type(self, path_type): | ||
502 | 125 | """ | ||
503 | 126 | A Property setter method to set the path type | ||
504 | 127 | |||
505 | 128 | :param path: The type of path to select | ||
506 | 129 | :type path: Enum of PathEdit | ||
507 | 130 | """ | ||
508 | 131 | self._path_type = path_type | ||
509 | 132 | self.update_button_tool_tips() | ||
510 | 133 | |||
511 | 134 | def update_button_tool_tips(self): | ||
512 | 135 | """ | ||
513 | 136 | Called to update the tooltips on the buttons. This is changing path types, and when the widget is initalised | ||
514 | 137 | :return: None | ||
515 | 138 | """ | ||
516 | 139 | if self._path_type == PathType.Directories: | ||
517 | 140 | self.browse_button.setToolTip(translate('OpenLP.PathEdit', 'Browse for directory.')) | ||
518 | 141 | self.revert_button.setToolTip(translate('OpenLP.PathEdit', 'Revert to default directory.')) | ||
519 | 142 | else: | ||
520 | 143 | self.browse_button.setToolTip(translate('OpenLP.PathEdit', 'Browse for file.')) | ||
521 | 144 | self.revert_button.setToolTip(translate('OpenLP.PathEdit', 'Revert to default file.')) | ||
522 | 145 | |||
523 | 146 | def on_browse_button_clicked(self): | ||
524 | 147 | """ | ||
525 | 148 | A handler to handle a click on the browse button. | ||
526 | 149 | |||
527 | 150 | Show the QFileDialog and process the input from the user | ||
528 | 151 | :return: None | ||
529 | 152 | """ | ||
530 | 153 | caption = self.dialog_caption | ||
531 | 154 | path = '' | ||
532 | 155 | if self._path_type == PathType.Directories: | ||
533 | 156 | if not caption: | ||
534 | 157 | caption = translate('OpenLP.PathEdit', 'Select Directory') | ||
535 | 158 | path = QtWidgets.QFileDialog.getExistingDirectory(self, caption, | ||
536 | 159 | self._path, QtWidgets.QFileDialog.ShowDirsOnly) | ||
537 | 160 | elif self._path_type == PathType.Files: | ||
538 | 161 | if not caption: | ||
539 | 162 | caption = self.dialog_caption = translate('OpenLP.PathEdit', 'Select File') | ||
540 | 163 | path, filter_used = QtWidgets.QFileDialog.getOpenFileName(self, caption, self._path, self.filters) | ||
541 | 164 | if path: | ||
542 | 165 | path = os.path.normpath(path) | ||
543 | 166 | self.on_new_path(path) | ||
544 | 167 | |||
545 | 168 | def on_revert_button_clicked(self): | ||
546 | 169 | """ | ||
547 | 170 | A handler to handle a click on the revert button. | ||
548 | 171 | |||
549 | 172 | Set the new path to the value of the default_path instance variable. | ||
550 | 173 | :return: None | ||
551 | 174 | """ | ||
552 | 175 | self.on_new_path(self.default_path) | ||
553 | 176 | |||
554 | 177 | def on_line_edit_editing_finished(self): | ||
555 | 178 | """ | ||
556 | 179 | A handler to handle when the line edit has finished being edited. | ||
557 | 180 | :return: None | ||
558 | 181 | """ | ||
559 | 182 | self.on_new_path(self.line_edit.text()) | ||
560 | 183 | |||
561 | 184 | def on_new_path(self, path): | ||
562 | 185 | """ | ||
563 | 186 | A method called to validate and set a new path. | ||
564 | 187 | |||
565 | 188 | Emits the pathChanged Signal | ||
566 | 189 | |||
567 | 190 | :param path: The new path | ||
568 | 191 | :type path: str | ||
569 | 192 | |||
570 | 193 | :return: None | ||
571 | 194 | """ | ||
572 | 195 | if self._path != path: | ||
573 | 196 | self.path = path | ||
574 | 197 | self.pathChanged.emit(path) | ||
575 | 0 | 198 | ||
576 | === modified file 'openlp/core/ui/themeform.py' | |||
577 | --- openlp/core/ui/themeform.py 2016-12-31 11:01:36 +0000 | |||
578 | +++ openlp/core/ui/themeform.py 2017-05-14 07:15:51 +0000 | |||
579 | @@ -69,10 +69,16 @@ | |||
580 | 69 | self.video_color_button.colorChanged.connect(self.on_video_color_changed) | 69 | self.video_color_button.colorChanged.connect(self.on_video_color_changed) |
581 | 70 | self.gradient_start_button.colorChanged.connect(self.on_gradient_start_color_changed) | 70 | self.gradient_start_button.colorChanged.connect(self.on_gradient_start_color_changed) |
582 | 71 | self.gradient_end_button.colorChanged.connect(self.on_gradient_end_color_changed) | 71 | self.gradient_end_button.colorChanged.connect(self.on_gradient_end_color_changed) |
587 | 72 | self.image_browse_button.clicked.connect(self.on_image_browse_button_clicked) | 72 | self.image_path_edit.filters = \ |
588 | 73 | self.image_file_edit.editingFinished.connect(self.on_image_file_edit_editing_finished) | 73 | '{name};;{text} (*.*)'.format(name=get_images_filter(), text=UiStrings().AllFiles) |
589 | 74 | self.video_browse_button.clicked.connect(self.on_video_browse_button_clicked) | 74 | self.image_path_edit.pathChanged.connect(self.on_image_path_edit_path_changed) |
590 | 75 | self.video_file_edit.editingFinished.connect(self.on_video_file_edit_editing_finished) | 75 | # TODO: Should work |
591 | 76 | visible_formats = '({name})'.format(name='; '.join(VIDEO_EXT)) | ||
592 | 77 | actual_formats = '({name})'.format(name=' '.join(VIDEO_EXT)) | ||
593 | 78 | video_filter = '{trans} {visible} {actual}'.format(trans=translate('OpenLP', 'Video Files'), | ||
594 | 79 | visible=visible_formats, actual=actual_formats) | ||
595 | 80 | self.video_path_edit.filters = '{video};;{ui} (*.*)'.format(video=video_filter, ui=UiStrings().AllFiles) | ||
596 | 81 | self.video_path_edit.pathChanged.connect(self.on_video_path_edit_path_changed) | ||
597 | 76 | self.main_color_button.colorChanged.connect(self.on_main_color_changed) | 82 | self.main_color_button.colorChanged.connect(self.on_main_color_changed) |
598 | 77 | self.outline_color_button.colorChanged.connect(self.on_outline_color_changed) | 83 | self.outline_color_button.colorChanged.connect(self.on_outline_color_changed) |
599 | 78 | self.shadow_color_button.colorChanged.connect(self.on_shadow_color_changed) | 84 | self.shadow_color_button.colorChanged.connect(self.on_shadow_color_changed) |
600 | @@ -112,7 +118,8 @@ | |||
601 | 112 | self.background_page.registerField('color', self.color_button) | 118 | self.background_page.registerField('color', self.color_button) |
602 | 113 | self.background_page.registerField('gradient_start', self.gradient_start_button) | 119 | self.background_page.registerField('gradient_start', self.gradient_start_button) |
603 | 114 | self.background_page.registerField('gradient_end', self.gradient_end_button) | 120 | self.background_page.registerField('gradient_end', self.gradient_end_button) |
605 | 115 | self.background_page.registerField('background_image', self.image_file_edit) | 121 | self.background_page.registerField('background_image', self.image_path_edit, |
606 | 122 | 'path', self.image_path_edit.pathChanged) | ||
607 | 116 | self.background_page.registerField('gradient', self.gradient_combo_box) | 123 | self.background_page.registerField('gradient', self.gradient_combo_box) |
608 | 117 | self.main_area_page.registerField('main_color_button', self.main_color_button) | 124 | self.main_area_page.registerField('main_color_button', self.main_color_button) |
609 | 118 | self.main_area_page.registerField('main_size_spin_box', self.main_size_spin_box) | 125 | self.main_area_page.registerField('main_size_spin_box', self.main_size_spin_box) |
610 | @@ -309,11 +316,11 @@ | |||
611 | 309 | self.setField('background_type', 1) | 316 | self.setField('background_type', 1) |
612 | 310 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Image): | 317 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Image): |
613 | 311 | self.image_color_button.color = self.theme.background_border_color | 318 | self.image_color_button.color = self.theme.background_border_color |
615 | 312 | self.image_file_edit.setText(self.theme.background_filename) | 319 | self.image_path_edit.path = self.theme.background_filename |
616 | 313 | self.setField('background_type', 2) | 320 | self.setField('background_type', 2) |
617 | 314 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Video): | 321 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Video): |
618 | 315 | self.video_color_button.color = self.theme.background_border_color | 322 | self.video_color_button.color = self.theme.background_border_color |
620 | 316 | self.video_file_edit.setText(self.theme.background_filename) | 323 | self.video_path_edit.path = self.theme.background_filename |
621 | 317 | self.setField('background_type', 4) | 324 | self.setField('background_type', 4) |
622 | 318 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): | 325 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): |
623 | 319 | self.setField('background_type', 3) | 326 | self.setField('background_type', 3) |
624 | @@ -441,48 +448,20 @@ | |||
625 | 441 | """ | 448 | """ |
626 | 442 | self.theme.background_end_color = color | 449 | self.theme.background_end_color = color |
627 | 443 | 450 | ||
629 | 444 | def on_image_browse_button_clicked(self): | 451 | def on_image_path_edit_path_changed(self, filename): |
630 | 445 | """ | 452 | """ |
631 | 446 | Background Image button pushed. | 453 | Background Image button pushed. |
632 | 447 | """ | 454 | """ |
640 | 448 | images_filter = get_images_filter() | 455 | self.theme.background_filename = filename |
634 | 449 | images_filter = '{name};;{text} (*.*)'.format(name=images_filter, text=UiStrings().AllFiles) | ||
635 | 450 | filename, filter_used = QtWidgets.QFileDialog.getOpenFileName( | ||
636 | 451 | self, translate('OpenLP.ThemeWizard', 'Select Image'), | ||
637 | 452 | self.image_file_edit.text(), images_filter) | ||
638 | 453 | if filename: | ||
639 | 454 | self.theme.background_filename = filename | ||
641 | 455 | self.set_background_page_values() | 456 | self.set_background_page_values() |
642 | 456 | 457 | ||
650 | 457 | def on_image_file_edit_editing_finished(self): | 458 | def on_video_path_edit_path_changed(self, filename): |
644 | 458 | """ | ||
645 | 459 | Background image path edited | ||
646 | 460 | """ | ||
647 | 461 | self.theme.background_filename = str(self.image_file_edit.text()) | ||
648 | 462 | |||
649 | 463 | def on_video_browse_button_clicked(self): | ||
651 | 464 | """ | 459 | """ |
652 | 465 | Background video button pushed. | 460 | Background video button pushed. |
653 | 466 | """ | 461 | """ |
665 | 467 | # TODO: Should work | 462 | self.theme.background_filename = filename |
655 | 468 | visible_formats = '({name})'.format(name='; '.join(VIDEO_EXT)) | ||
656 | 469 | actual_formats = '({name})'.format(name=' '.join(VIDEO_EXT)) | ||
657 | 470 | video_filter = '{trans} {visible} {actual}'.format(trans=translate('OpenLP', 'Video Files'), | ||
658 | 471 | visible=visible_formats, actual=actual_formats) | ||
659 | 472 | video_filter = '{video};;{ui} (*.*)'.format(video=video_filter, ui=UiStrings().AllFiles) | ||
660 | 473 | filename, filter_used = QtWidgets.QFileDialog.getOpenFileName( | ||
661 | 474 | self, translate('OpenLP.ThemeWizard', 'Select Video'), | ||
662 | 475 | self.video_file_edit.text(), video_filter) | ||
663 | 476 | if filename: | ||
664 | 477 | self.theme.background_filename = filename | ||
666 | 478 | self.set_background_page_values() | 463 | self.set_background_page_values() |
667 | 479 | 464 | ||
668 | 480 | def on_video_file_edit_editing_finished(self): | ||
669 | 481 | """ | ||
670 | 482 | Background video path edited | ||
671 | 483 | """ | ||
672 | 484 | self.theme.background_filename = str(self.image_file_edit.text()) | ||
673 | 485 | |||
674 | 486 | def on_main_color_changed(self, color): | 465 | def on_main_color_changed(self, color): |
675 | 487 | """ | 466 | """ |
676 | 488 | Set the main colour value | 467 | Set the main colour value |
677 | 489 | 468 | ||
678 | === modified file 'openlp/core/ui/themewizard.py' | |||
679 | --- openlp/core/ui/themewizard.py 2016-12-31 11:01:36 +0000 | |||
680 | +++ openlp/core/ui/themewizard.py 2017-05-14 07:15:51 +0000 | |||
681 | @@ -28,7 +28,7 @@ | |||
682 | 28 | from openlp.core.lib import build_icon | 28 | from openlp.core.lib import build_icon |
683 | 29 | from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType | 29 | from openlp.core.lib.theme import HorizontalType, BackgroundType, BackgroundGradientType |
684 | 30 | from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets | 30 | from openlp.core.lib.ui import add_welcome_page, create_valign_selection_widgets |
686 | 31 | from openlp.core.ui.lib.colorbutton import ColorButton | 31 | from openlp.core.ui.lib import ColorButton, PathEdit |
687 | 32 | 32 | ||
688 | 33 | 33 | ||
689 | 34 | class Ui_ThemeWizard(object): | 34 | class Ui_ThemeWizard(object): |
690 | @@ -116,16 +116,9 @@ | |||
691 | 116 | self.image_layout.addRow(self.image_color_label, self.image_color_button) | 116 | self.image_layout.addRow(self.image_color_label, self.image_color_button) |
692 | 117 | self.image_label = QtWidgets.QLabel(self.image_widget) | 117 | self.image_label = QtWidgets.QLabel(self.image_widget) |
693 | 118 | self.image_label.setObjectName('image_label') | 118 | self.image_label.setObjectName('image_label') |
704 | 119 | self.image_file_layout = QtWidgets.QHBoxLayout() | 119 | self.image_path_edit = PathEdit(self.image_widget, show_revert=False) |
705 | 120 | self.image_file_layout.setObjectName('image_file_layout') | 120 | self.image_path_edit.dialog_caption = translate('OpenLP.ThemeWizard', 'Select Image') |
706 | 121 | self.image_file_edit = QtWidgets.QLineEdit(self.image_widget) | 121 | self.image_layout.addRow(self.image_label, self.image_path_edit) |
697 | 122 | self.image_file_edit.setObjectName('image_file_edit') | ||
698 | 123 | self.image_file_layout.addWidget(self.image_file_edit) | ||
699 | 124 | self.image_browse_button = QtWidgets.QToolButton(self.image_widget) | ||
700 | 125 | self.image_browse_button.setObjectName('image_browse_button') | ||
701 | 126 | self.image_browse_button.setIcon(build_icon(':/general/general_open.png')) | ||
702 | 127 | self.image_file_layout.addWidget(self.image_browse_button) | ||
703 | 128 | self.image_layout.addRow(self.image_label, self.image_file_layout) | ||
707 | 129 | self.image_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacer) | 122 | self.image_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacer) |
708 | 130 | self.background_stack.addWidget(self.image_widget) | 123 | self.background_stack.addWidget(self.image_widget) |
709 | 131 | self.transparent_widget = QtWidgets.QWidget(self.background_page) | 124 | self.transparent_widget = QtWidgets.QWidget(self.background_page) |
710 | @@ -147,16 +140,9 @@ | |||
711 | 147 | self.video_layout.addRow(self.video_color_label, self.video_color_button) | 140 | self.video_layout.addRow(self.video_color_label, self.video_color_button) |
712 | 148 | self.video_label = QtWidgets.QLabel(self.video_widget) | 141 | self.video_label = QtWidgets.QLabel(self.video_widget) |
713 | 149 | self.video_label.setObjectName('video_label') | 142 | self.video_label.setObjectName('video_label') |
724 | 150 | self.video_file_layout = QtWidgets.QHBoxLayout() | 143 | self.video_path_edit = PathEdit(self.video_widget, show_revert=False) |
725 | 151 | self.video_file_layout.setObjectName('video_file_layout') | 144 | self.video_path_edit.dialog_caption = translate('OpenLP.ThemeWizard', 'Select Video') |
726 | 152 | self.video_file_edit = QtWidgets.QLineEdit(self.video_widget) | 145 | self.video_layout.addRow(self.video_label, self.video_path_edit) |
717 | 153 | self.video_file_edit.setObjectName('video_file_edit') | ||
718 | 154 | self.video_file_layout.addWidget(self.video_file_edit) | ||
719 | 155 | self.video_browse_button = QtWidgets.QToolButton(self.video_widget) | ||
720 | 156 | self.video_browse_button.setObjectName('video_browse_button') | ||
721 | 157 | self.video_browse_button.setIcon(build_icon(':/general/general_open.png')) | ||
722 | 158 | self.video_file_layout.addWidget(self.video_browse_button) | ||
723 | 159 | self.video_layout.addRow(self.video_label, self.video_file_layout) | ||
727 | 160 | self.video_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacer) | 146 | self.video_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacer) |
728 | 161 | self.background_stack.addWidget(self.video_widget) | 147 | self.background_stack.addWidget(self.video_widget) |
729 | 162 | theme_wizard.addPage(self.background_page) | 148 | theme_wizard.addPage(self.background_page) |
730 | 163 | 149 | ||
731 | === modified file 'openlp/plugins/bibles/forms/bibleimportform.py' | |||
732 | --- openlp/plugins/bibles/forms/bibleimportform.py 2017-05-06 09:22:34 +0000 | |||
733 | +++ openlp/plugins/bibles/forms/bibleimportform.py 2017-05-14 07:15:51 +0000 | |||
734 | @@ -135,7 +135,6 @@ | |||
735 | 135 | Add the bible import specific wizard pages. | 135 | Add the bible import specific wizard pages. |
736 | 136 | """ | 136 | """ |
737 | 137 | # Select Page | 137 | # Select Page |
738 | 138 | self.spacers = [] | ||
739 | 139 | self.select_page = QtWidgets.QWizardPage() | 138 | self.select_page = QtWidgets.QWizardPage() |
740 | 140 | self.select_page.setObjectName('SelectPage') | 139 | self.select_page.setObjectName('SelectPage') |
741 | 141 | self.select_page_layout = QtWidgets.QVBoxLayout(self.select_page) | 140 | self.select_page_layout = QtWidgets.QVBoxLayout(self.select_page) |
742 | @@ -148,8 +147,8 @@ | |||
743 | 148 | self.format_combo_box.addItems(['', '', '', '', '', '', '']) | 147 | self.format_combo_box.addItems(['', '', '', '', '', '', '']) |
744 | 149 | self.format_combo_box.setObjectName('FormatComboBox') | 148 | self.format_combo_box.setObjectName('FormatComboBox') |
745 | 150 | self.format_layout.addRow(self.format_label, self.format_combo_box) | 149 | self.format_layout.addRow(self.format_label, self.format_combo_box) |
748 | 151 | self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) | 150 | self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) |
749 | 152 | self.format_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) | 151 | self.format_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) |
750 | 153 | self.select_page_layout.addLayout(self.format_layout) | 152 | self.select_page_layout.addLayout(self.format_layout) |
751 | 154 | self.select_stack = QtWidgets.QStackedLayout() | 153 | self.select_stack = QtWidgets.QStackedLayout() |
752 | 155 | self.select_stack.setObjectName('SelectStack') | 154 | self.select_stack.setObjectName('SelectStack') |
753 | @@ -171,8 +170,7 @@ | |||
754 | 171 | self.osis_browse_button.setObjectName('OsisBrowseButton') | 170 | self.osis_browse_button.setObjectName('OsisBrowseButton') |
755 | 172 | self.osis_file_layout.addWidget(self.osis_browse_button) | 171 | self.osis_file_layout.addWidget(self.osis_browse_button) |
756 | 173 | self.osis_layout.addRow(self.osis_file_label, self.osis_file_layout) | 172 | self.osis_layout.addRow(self.osis_file_label, self.osis_file_layout) |
759 | 174 | self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) | 173 | self.osis_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) |
758 | 175 | self.osis_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) | ||
760 | 176 | self.select_stack.addWidget(self.osis_widget) | 174 | self.select_stack.addWidget(self.osis_widget) |
761 | 177 | self.csv_widget = QtWidgets.QWidget(self.select_page) | 175 | self.csv_widget = QtWidgets.QWidget(self.select_page) |
762 | 178 | self.csv_widget.setObjectName('CsvWidget') | 176 | self.csv_widget.setObjectName('CsvWidget') |
763 | @@ -205,8 +203,7 @@ | |||
764 | 205 | self.csv_verses_button.setObjectName('CsvVersesButton') | 203 | self.csv_verses_button.setObjectName('CsvVersesButton') |
765 | 206 | self.csv_verses_layout.addWidget(self.csv_verses_button) | 204 | self.csv_verses_layout.addWidget(self.csv_verses_button) |
766 | 207 | self.csv_layout.addRow(self.csv_verses_label, self.csv_verses_layout) | 205 | self.csv_layout.addRow(self.csv_verses_label, self.csv_verses_layout) |
769 | 208 | self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) | 206 | self.csv_layout.setItem(3, QtWidgets.QFormLayout.LabelRole, self.spacer) |
768 | 209 | self.csv_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) | ||
770 | 210 | self.select_stack.addWidget(self.csv_widget) | 207 | self.select_stack.addWidget(self.csv_widget) |
771 | 211 | self.open_song_widget = QtWidgets.QWidget(self.select_page) | 208 | self.open_song_widget = QtWidgets.QWidget(self.select_page) |
772 | 212 | self.open_song_widget.setObjectName('OpenSongWidget') | 209 | self.open_song_widget.setObjectName('OpenSongWidget') |
773 | @@ -226,8 +223,7 @@ | |||
774 | 226 | self.open_song_browse_button.setObjectName('OpenSongBrowseButton') | 223 | self.open_song_browse_button.setObjectName('OpenSongBrowseButton') |
775 | 227 | self.open_song_file_layout.addWidget(self.open_song_browse_button) | 224 | self.open_song_file_layout.addWidget(self.open_song_browse_button) |
776 | 228 | self.open_song_layout.addRow(self.open_song_file_label, self.open_song_file_layout) | 225 | self.open_song_layout.addRow(self.open_song_file_label, self.open_song_file_layout) |
779 | 229 | self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) | 226 | self.open_song_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) |
778 | 230 | self.open_song_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) | ||
780 | 231 | self.select_stack.addWidget(self.open_song_widget) | 227 | self.select_stack.addWidget(self.open_song_widget) |
781 | 232 | self.web_tab_widget = QtWidgets.QTabWidget(self.select_page) | 228 | self.web_tab_widget = QtWidgets.QTabWidget(self.select_page) |
782 | 233 | self.web_tab_widget.setObjectName('WebTabWidget') | 229 | self.web_tab_widget.setObjectName('WebTabWidget') |
783 | @@ -304,8 +300,7 @@ | |||
784 | 304 | self.zefania_browse_button.setObjectName('ZefaniaBrowseButton') | 300 | self.zefania_browse_button.setObjectName('ZefaniaBrowseButton') |
785 | 305 | self.zefania_file_layout.addWidget(self.zefania_browse_button) | 301 | self.zefania_file_layout.addWidget(self.zefania_browse_button) |
786 | 306 | self.zefania_layout.addRow(self.zefania_file_label, self.zefania_file_layout) | 302 | self.zefania_layout.addRow(self.zefania_file_label, self.zefania_file_layout) |
789 | 307 | self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) | 303 | self.zefania_layout.setItem(5, QtWidgets.QFormLayout.LabelRole, self.spacer) |
788 | 308 | self.zefania_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) | ||
790 | 309 | self.select_stack.addWidget(self.zefania_widget) | 304 | self.select_stack.addWidget(self.zefania_widget) |
791 | 310 | self.sword_widget = QtWidgets.QWidget(self.select_page) | 305 | self.sword_widget = QtWidgets.QWidget(self.select_page) |
792 | 311 | self.sword_widget.setObjectName('SwordWidget') | 306 | self.sword_widget.setObjectName('SwordWidget') |
793 | @@ -386,8 +381,7 @@ | |||
794 | 386 | self.wordproject_browse_button.setObjectName('WordProjectBrowseButton') | 381 | self.wordproject_browse_button.setObjectName('WordProjectBrowseButton') |
795 | 387 | self.wordproject_file_layout.addWidget(self.wordproject_browse_button) | 382 | self.wordproject_file_layout.addWidget(self.wordproject_browse_button) |
796 | 388 | self.wordproject_layout.addRow(self.wordproject_file_label, self.wordproject_file_layout) | 383 | self.wordproject_layout.addRow(self.wordproject_file_label, self.wordproject_file_layout) |
799 | 389 | self.spacers.append(QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)) | 384 | self.wordproject_layout.setItem(5, QtWidgets.QFormLayout.LabelRole, self.spacer) |
798 | 390 | self.wordproject_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacers[-1]) | ||
800 | 391 | self.select_stack.addWidget(self.wordproject_widget) | 385 | self.select_stack.addWidget(self.wordproject_widget) |
801 | 392 | self.select_page_layout.addLayout(self.select_stack) | 386 | self.select_page_layout.addLayout(self.select_stack) |
802 | 393 | self.addPage(self.select_page) | 387 | self.addPage(self.select_page) |
803 | @@ -505,8 +499,7 @@ | |||
804 | 505 | self.csv_verses_label.minimumSizeHint().width(), | 499 | self.csv_verses_label.minimumSizeHint().width(), |
805 | 506 | self.open_song_file_label.minimumSizeHint().width(), | 500 | self.open_song_file_label.minimumSizeHint().width(), |
806 | 507 | self.zefania_file_label.minimumSizeHint().width()) | 501 | self.zefania_file_label.minimumSizeHint().width()) |
809 | 508 | for spacer in self.spacers: | 502 | self.spacer.changeSize(label_width, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) |
808 | 509 | spacer.changeSize(label_width, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) | ||
810 | 510 | 503 | ||
811 | 511 | def validateCurrentPage(self): | 504 | def validateCurrentPage(self): |
812 | 512 | """ | 505 | """ |
813 | 513 | 506 | ||
814 | === modified file 'openlp/plugins/presentations/lib/presentationtab.py' | |||
815 | --- openlp/plugins/presentations/lib/presentationtab.py 2016-12-31 11:01:36 +0000 | |||
816 | +++ openlp/plugins/presentations/lib/presentationtab.py 2017-05-14 07:15:51 +0000 | |||
817 | @@ -25,6 +25,7 @@ | |||
818 | 25 | from openlp.core.common import Settings, UiStrings, translate | 25 | from openlp.core.common import Settings, UiStrings, translate |
819 | 26 | from openlp.core.lib import SettingsTab, build_icon | 26 | from openlp.core.lib import SettingsTab, build_icon |
820 | 27 | from openlp.core.lib.ui import critical_error_message_box | 27 | from openlp.core.lib.ui import critical_error_message_box |
821 | 28 | from openlp.core.ui.lib import PathEdit | ||
822 | 28 | from .pdfcontroller import PdfController | 29 | from .pdfcontroller import PdfController |
823 | 29 | 30 | ||
824 | 30 | 31 | ||
825 | @@ -88,26 +89,15 @@ | |||
826 | 88 | self.pdf_program_check_box = QtWidgets.QCheckBox(self.pdf_group_box) | 89 | self.pdf_program_check_box = QtWidgets.QCheckBox(self.pdf_group_box) |
827 | 89 | self.pdf_program_check_box.setObjectName('pdf_program_check_box') | 90 | self.pdf_program_check_box.setObjectName('pdf_program_check_box') |
828 | 90 | self.pdf_layout.addRow(self.pdf_program_check_box) | 91 | self.pdf_layout.addRow(self.pdf_program_check_box) |
842 | 91 | self.pdf_program_path_layout = QtWidgets.QHBoxLayout() | 92 | self.program_path_edit = PathEdit(self.pdf_group_box) |
843 | 92 | self.pdf_program_path_layout.setObjectName('pdf_program_path_layout') | 93 | self.pdf_layout.addRow(self.program_path_edit) |
831 | 93 | self.pdf_program_path = QtWidgets.QLineEdit(self.pdf_group_box) | ||
832 | 94 | self.pdf_program_path.setObjectName('pdf_program_path') | ||
833 | 95 | self.pdf_program_path.setReadOnly(True) | ||
834 | 96 | self.pdf_program_path.setPalette(self.get_grey_text_palette(True)) | ||
835 | 97 | self.pdf_program_path_layout.addWidget(self.pdf_program_path) | ||
836 | 98 | self.pdf_program_browse_button = QtWidgets.QToolButton(self.pdf_group_box) | ||
837 | 99 | self.pdf_program_browse_button.setObjectName('pdf_program_browse_button') | ||
838 | 100 | self.pdf_program_browse_button.setIcon(build_icon(':/general/general_open.png')) | ||
839 | 101 | self.pdf_program_browse_button.setEnabled(False) | ||
840 | 102 | self.pdf_program_path_layout.addWidget(self.pdf_program_browse_button) | ||
841 | 103 | self.pdf_layout.addRow(self.pdf_program_path_layout) | ||
844 | 104 | self.left_layout.addWidget(self.pdf_group_box) | 94 | self.left_layout.addWidget(self.pdf_group_box) |
845 | 105 | self.left_layout.addStretch() | 95 | self.left_layout.addStretch() |
846 | 106 | self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) | 96 | self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) |
847 | 107 | self.right_layout.addStretch() | 97 | self.right_layout.addStretch() |
848 | 108 | # Signals and slots | 98 | # Signals and slots |
851 | 109 | self.pdf_program_browse_button.clicked.connect(self.on_pdf_program_browse_button_clicked) | 99 | self.program_path_edit.pathChanged.connect(self.on_program_path_edit_path_changed) |
852 | 110 | self.pdf_program_check_box.clicked.connect(self.on_pdf_program_check_box_clicked) | 100 | self.pdf_program_check_box.clicked.connect(self.program_path_edit.setEnabled) |
853 | 111 | 101 | ||
854 | 112 | def retranslateUi(self): | 102 | def retranslateUi(self): |
855 | 113 | """ | 103 | """ |
856 | @@ -132,6 +122,8 @@ | |||
857 | 132 | '(This may fix PowerPoint scaling issues in Windows 8 and 10)')) | 122 | '(This may fix PowerPoint scaling issues in Windows 8 and 10)')) |
858 | 133 | self.pdf_program_check_box.setText( | 123 | self.pdf_program_check_box.setText( |
859 | 134 | translate('PresentationPlugin.PresentationTab', 'Use given full path for mudraw or ghostscript binary:')) | 124 | translate('PresentationPlugin.PresentationTab', 'Use given full path for mudraw or ghostscript binary:')) |
860 | 125 | self.program_path_edit.dialog_caption = translate('PresentationPlugin.PresentationTab', | ||
861 | 126 | 'Select mudraw or ghostscript binary') | ||
862 | 135 | 127 | ||
863 | 136 | def set_controller_text(self, checkbox, controller): | 128 | def set_controller_text(self, checkbox, controller): |
864 | 137 | if checkbox.isEnabled(): | 129 | if checkbox.isEnabled(): |
865 | @@ -161,11 +153,10 @@ | |||
866 | 161 | # load pdf-program settings | 153 | # load pdf-program settings |
867 | 162 | enable_pdf_program = Settings().value(self.settings_section + '/enable_pdf_program') | 154 | enable_pdf_program = Settings().value(self.settings_section + '/enable_pdf_program') |
868 | 163 | self.pdf_program_check_box.setChecked(enable_pdf_program) | 155 | self.pdf_program_check_box.setChecked(enable_pdf_program) |
871 | 164 | self.pdf_program_path.setPalette(self.get_grey_text_palette(not enable_pdf_program)) | 156 | self.program_path_edit.setEnabled(enable_pdf_program) |
870 | 165 | self.pdf_program_browse_button.setEnabled(enable_pdf_program) | ||
872 | 166 | pdf_program = Settings().value(self.settings_section + '/pdf_program') | 157 | pdf_program = Settings().value(self.settings_section + '/pdf_program') |
873 | 167 | if pdf_program: | 158 | if pdf_program: |
875 | 168 | self.pdf_program_path.setText(pdf_program) | 159 | self.program_path_edit.path = pdf_program |
876 | 169 | 160 | ||
877 | 170 | def save(self): | 161 | def save(self): |
878 | 171 | """ | 162 | """ |
879 | @@ -201,7 +192,7 @@ | |||
880 | 201 | Settings().setValue(setting_key, self.ppt_window_check_box.checkState()) | 192 | Settings().setValue(setting_key, self.ppt_window_check_box.checkState()) |
881 | 202 | changed = True | 193 | changed = True |
882 | 203 | # Save pdf-settings | 194 | # Save pdf-settings |
884 | 204 | pdf_program = self.pdf_program_path.text() | 195 | pdf_program = self.program_path_edit.path |
885 | 205 | enable_pdf_program = self.pdf_program_check_box.checkState() | 196 | enable_pdf_program = self.pdf_program_check_box.checkState() |
886 | 206 | # If the given program is blank disable using the program | 197 | # If the given program is blank disable using the program |
887 | 207 | if pdf_program == '': | 198 | if pdf_program == '': |
888 | @@ -228,42 +219,12 @@ | |||
889 | 228 | checkbox.setEnabled(controller.is_available()) | 219 | checkbox.setEnabled(controller.is_available()) |
890 | 229 | self.set_controller_text(checkbox, controller) | 220 | self.set_controller_text(checkbox, controller) |
891 | 230 | 221 | ||
893 | 231 | def on_pdf_program_browse_button_clicked(self): | 222 | def on_program_path_edit_path_changed(self, filename): |
894 | 232 | """ | 223 | """ |
895 | 233 | Select the mudraw or ghostscript binary that should be used. | 224 | Select the mudraw or ghostscript binary that should be used. |
896 | 234 | """ | 225 | """ |
897 | 235 | filename, filter_used = QtWidgets.QFileDialog.getOpenFileName( | ||
898 | 236 | self, translate('PresentationPlugin.PresentationTab', 'Select mudraw or ghostscript binary.'), | ||
899 | 237 | self.pdf_program_path.text()) | ||
900 | 238 | if filename: | 226 | if filename: |
903 | 239 | program_type = PdfController.process_check_binary(filename) | 227 | if not PdfController.process_check_binary(filename): |
902 | 240 | if not program_type: | ||
904 | 241 | critical_error_message_box(UiStrings().Error, | 228 | critical_error_message_box(UiStrings().Error, |
905 | 242 | translate('PresentationPlugin.PresentationTab', | 229 | translate('PresentationPlugin.PresentationTab', |
906 | 243 | 'The program is not ghostscript or mudraw which is required.')) | 230 | 'The program is not ghostscript or mudraw which is required.')) |
907 | 244 | else: | ||
908 | 245 | self.pdf_program_path.setText(filename) | ||
909 | 246 | |||
910 | 247 | def on_pdf_program_check_box_clicked(self, checked): | ||
911 | 248 | """ | ||
912 | 249 | When checkbox for manual entering pdf-program is clicked, | ||
913 | 250 | enable or disable the textbox for the programpath and the browse-button. | ||
914 | 251 | |||
915 | 252 | :param checked: If the box is checked or not. | ||
916 | 253 | """ | ||
917 | 254 | self.pdf_program_path.setPalette(self.get_grey_text_palette(not checked)) | ||
918 | 255 | self.pdf_program_browse_button.setEnabled(checked) | ||
919 | 256 | |||
920 | 257 | def get_grey_text_palette(self, greyed): | ||
921 | 258 | """ | ||
922 | 259 | Returns a QPalette with greyed out text as used for placeholderText. | ||
923 | 260 | |||
924 | 261 | :param greyed: Determines whether the palette should be grayed. | ||
925 | 262 | :return: The created palette. | ||
926 | 263 | """ | ||
927 | 264 | palette = QtGui.QPalette() | ||
928 | 265 | color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Text) | ||
929 | 266 | if greyed: | ||
930 | 267 | color.setAlpha(128) | ||
931 | 268 | palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color) | ||
932 | 269 | return palette | ||
933 | 270 | 231 | ||
934 | === modified file 'openlp/plugins/songusage/forms/songusagedetaildialog.py' | |||
935 | --- openlp/plugins/songusage/forms/songusagedetaildialog.py 2016-12-31 11:01:36 +0000 | |||
936 | +++ openlp/plugins/songusage/forms/songusagedetaildialog.py 2017-05-14 07:15:51 +0000 | |||
937 | @@ -25,6 +25,7 @@ | |||
938 | 25 | from openlp.core.common import translate | 25 | from openlp.core.common import translate |
939 | 26 | from openlp.core.lib import build_icon | 26 | from openlp.core.lib import build_icon |
940 | 27 | from openlp.core.lib.ui import create_button_box | 27 | from openlp.core.lib.ui import create_button_box |
941 | 28 | from openlp.core.ui.lib import PathEdit, PathType | ||
942 | 28 | 29 | ||
943 | 29 | 30 | ||
944 | 30 | class Ui_SongUsageDetailDialog(object): | 31 | class Ui_SongUsageDetailDialog(object): |
945 | @@ -68,20 +69,14 @@ | |||
946 | 68 | self.file_horizontal_layout.setSpacing(8) | 69 | self.file_horizontal_layout.setSpacing(8) |
947 | 69 | self.file_horizontal_layout.setContentsMargins(8, 8, 8, 8) | 70 | self.file_horizontal_layout.setContentsMargins(8, 8, 8, 8) |
948 | 70 | self.file_horizontal_layout.setObjectName('file_horizontal_layout') | 71 | self.file_horizontal_layout.setObjectName('file_horizontal_layout') |
958 | 71 | self.file_line_edit = QtWidgets.QLineEdit(self.file_group_box) | 72 | self.report_path_edit = PathEdit(self.file_group_box, show_revert=False) |
959 | 72 | self.file_line_edit.setObjectName('file_line_edit') | 73 | self.report_path_edit.path_type = PathType.Directories |
960 | 73 | self.file_line_edit.setReadOnly(True) | 74 | self.file_horizontal_layout.addWidget(self.report_path_edit) |
952 | 74 | self.file_horizontal_layout.addWidget(self.file_line_edit) | ||
953 | 75 | self.save_file_push_button = QtWidgets.QPushButton(self.file_group_box) | ||
954 | 76 | self.save_file_push_button.setMaximumWidth(self.save_file_push_button.size().height()) | ||
955 | 77 | self.save_file_push_button.setIcon(build_icon(':/general/general_open.png')) | ||
956 | 78 | self.save_file_push_button.setObjectName('save_file_push_button') | ||
957 | 79 | self.file_horizontal_layout.addWidget(self.save_file_push_button) | ||
961 | 80 | self.vertical_layout.addWidget(self.file_group_box) | 75 | self.vertical_layout.addWidget(self.file_group_box) |
962 | 81 | self.button_box = create_button_box(song_usage_detail_dialog, 'button_box', ['cancel', 'ok']) | 76 | self.button_box = create_button_box(song_usage_detail_dialog, 'button_box', ['cancel', 'ok']) |
963 | 82 | self.vertical_layout.addWidget(self.button_box) | 77 | self.vertical_layout.addWidget(self.button_box) |
964 | 83 | self.retranslateUi(song_usage_detail_dialog) | 78 | self.retranslateUi(song_usage_detail_dialog) |
966 | 84 | self.save_file_push_button.clicked.connect(song_usage_detail_dialog.define_output_location) | 79 | self.report_path_edit.pathChanged.connect(song_usage_detail_dialog.on_report_path_edit_path_changed) |
967 | 85 | 80 | ||
968 | 86 | def retranslateUi(self, song_usage_detail_dialog): | 81 | def retranslateUi(self, song_usage_detail_dialog): |
969 | 87 | """ | 82 | """ |
970 | 88 | 83 | ||
971 | === modified file 'openlp/plugins/songusage/forms/songusagedetailform.py' | |||
972 | --- openlp/plugins/songusage/forms/songusagedetailform.py 2016-12-31 11:01:36 +0000 | |||
973 | +++ openlp/plugins/songusage/forms/songusagedetailform.py 2017-05-14 07:15:51 +0000 | |||
974 | @@ -54,25 +54,20 @@ | |||
975 | 54 | """ | 54 | """ |
976 | 55 | self.from_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + '/from date')) | 55 | self.from_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + '/from date')) |
977 | 56 | self.to_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + '/to date')) | 56 | self.to_date_calendar.setSelectedDate(Settings().value(self.plugin.settings_section + '/to date')) |
979 | 57 | self.file_line_edit.setText(Settings().value(self.plugin.settings_section + '/last directory export')) | 57 | self.report_path_edit.path = Settings().value(self.plugin.settings_section + '/last directory export') |
980 | 58 | 58 | ||
982 | 59 | def define_output_location(self): | 59 | def on_report_path_edit_path_changed(self, file_path): |
983 | 60 | """ | 60 | """ |
984 | 61 | Triggered when the Directory selection button is clicked | 61 | Triggered when the Directory selection button is clicked |
985 | 62 | """ | 62 | """ |
992 | 63 | path = QtWidgets.QFileDialog.getExistingDirectory( | 63 | Settings().setValue(self.plugin.settings_section + '/last directory export', file_path) |
987 | 64 | self, translate('SongUsagePlugin.SongUsageDetailForm', 'Output File Location'), | ||
988 | 65 | Settings().value(self.plugin.settings_section + '/last directory export')) | ||
989 | 66 | if path: | ||
990 | 67 | Settings().setValue(self.plugin.settings_section + '/last directory export', path) | ||
991 | 68 | self.file_line_edit.setText(path) | ||
993 | 69 | 64 | ||
994 | 70 | def accept(self): | 65 | def accept(self): |
995 | 71 | """ | 66 | """ |
996 | 72 | Ok was triggered so lets save the data and run the report | 67 | Ok was triggered so lets save the data and run the report |
997 | 73 | """ | 68 | """ |
998 | 74 | log.debug('accept') | 69 | log.debug('accept') |
1000 | 75 | path = self.file_line_edit.text() | 70 | path = self.report_path_edit.path |
1001 | 76 | if not path: | 71 | if not path: |
1002 | 77 | self.main_window.error_message( | 72 | self.main_window.error_message( |
1003 | 78 | translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'), | 73 | translate('SongUsagePlugin.SongUsageDetailForm', 'Output Path Not Selected'), |
1004 | 79 | 74 | ||
1005 | === modified file 'tests/functional/openlp_core_ui/test_themeform.py' | |||
1006 | --- tests/functional/openlp_core_ui/test_themeform.py 2017-04-24 05:17:55 +0000 | |||
1007 | +++ tests/functional/openlp_core_ui/test_themeform.py 2017-05-14 07:15:51 +0000 | |||
1008 | @@ -32,60 +32,21 @@ | |||
1009 | 32 | """ | 32 | """ |
1010 | 33 | Test the functions in the ThemeManager Class | 33 | Test the functions in the ThemeManager Class |
1011 | 34 | """ | 34 | """ |
1038 | 35 | def test_select_image_file_dialog_cancelled(self): | 35 | def setUp(self): |
1039 | 36 | """ | 36 | with patch('openlp.core.ui.ThemeForm._setup'): |
1040 | 37 | Test the select image file dialog when the user presses cancel | 37 | self.instance = ThemeForm(None) |
1041 | 38 | """ | 38 | |
1042 | 39 | # GIVEN: An instance of Theme Form and mocked QFileDialog which returns an empty string (similating a user | 39 | def test_on_image_path_edit_path_changed(self): |
1043 | 40 | # pressing cancel) | 40 | """ |
1044 | 41 | with patch('openlp.core.ui.ThemeForm._setup'),\ | 41 | Test the `image_path_edit.pathChanged` handler |
1045 | 42 | patch('openlp.core.ui.themeform.get_images_filter', | 42 | """ |
1046 | 43 | **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\ | 43 | # GIVEN: An instance of Theme Form |
1047 | 44 | patch('openlp.core.ui.themeform.QtWidgets.QFileDialog.getOpenFileName', | 44 | with patch.object(self.instance, 'set_background_page_values') as mocked_set_background_page_values: |
1048 | 45 | **{'return_value': ('', '')}) as mocked_get_open_file_name,\ | 45 | self.instance.theme = MagicMock() |
1049 | 46 | patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\ | 46 | |
1050 | 47 | patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_set_background_page_values: | 47 | # WHEN: `on_image_path_edit_path_changed` is clicked |
1051 | 48 | instance = ThemeForm(None) | 48 | self.instance.on_image_path_edit_path_changed('/new/pat.h') |
1052 | 49 | mocked_image_file_edit = MagicMock() | 49 | |
1053 | 50 | mocked_image_file_edit.text.return_value = '/original_path/file.ext' | 50 | # THEN: The theme background file should be set and `set_background_page_values` should have been called |
1054 | 51 | instance.image_file_edit = mocked_image_file_edit | 51 | self.assertEqual(self.instance.theme.background_filename, '/new/pat.h') |
1029 | 52 | |||
1030 | 53 | # WHEN: on_image_browse_button is clicked | ||
1031 | 54 | instance.on_image_browse_button_clicked() | ||
1032 | 55 | |||
1033 | 56 | # THEN: The QFileDialog getOpenFileName and set_background_page_values moethods should have been called | ||
1034 | 57 | # with known arguments | ||
1035 | 58 | mocked_get_open_file_name.assert_called_once_with(instance, 'Translated String', '/original_path/file.ext', | ||
1036 | 59 | 'Image Files (*.bmp; *.gif)(*.bmp *.gif);;' | ||
1037 | 60 | 'All Files (*.*)') | ||
1055 | 61 | mocked_set_background_page_values.assert_called_once_with() | 52 | mocked_set_background_page_values.assert_called_once_with() |
1056 | 62 | |||
1057 | 63 | def test_select_image_file_dialog_new_file(self): | ||
1058 | 64 | """ | ||
1059 | 65 | Test the select image file dialog when the user presses ok | ||
1060 | 66 | """ | ||
1061 | 67 | # GIVEN: An instance of Theme Form and mocked QFileDialog which returns a file path | ||
1062 | 68 | with patch('openlp.core.ui.ThemeForm._setup'),\ | ||
1063 | 69 | patch('openlp.core.ui.themeform.get_images_filter', | ||
1064 | 70 | **{'return_value': 'Image Files (*.bmp; *.gif)(*.bmp *.gif)'}),\ | ||
1065 | 71 | patch('openlp.core.ui.themeform.QtWidgets.QFileDialog.getOpenFileName', | ||
1066 | 72 | **{'return_value': ('/new_path/file.ext', '')}) as mocked_get_open_file_name,\ | ||
1067 | 73 | patch('openlp.core.ui.themeform.translate', **{'return_value': 'Translated String'}),\ | ||
1068 | 74 | patch('openlp.core.ui.ThemeForm.set_background_page_values') as mocked_background_page_values: | ||
1069 | 75 | instance = ThemeForm(None) | ||
1070 | 76 | mocked_image_file_edit = MagicMock() | ||
1071 | 77 | mocked_image_file_edit.text.return_value = '/original_path/file.ext' | ||
1072 | 78 | instance.image_file_edit = mocked_image_file_edit | ||
1073 | 79 | instance.theme = MagicMock() | ||
1074 | 80 | |||
1075 | 81 | # WHEN: on_image_browse_button is clicked | ||
1076 | 82 | instance.on_image_browse_button_clicked() | ||
1077 | 83 | |||
1078 | 84 | # THEN: The QFileDialog getOpenFileName and set_background_page_values moethods should have been called | ||
1079 | 85 | # with known arguments and theme.background_filename should be set | ||
1080 | 86 | mocked_get_open_file_name.assert_called_once_with(instance, 'Translated String', '/original_path/file.ext', | ||
1081 | 87 | 'Image Files (*.bmp; *.gif)(*.bmp *.gif);;' | ||
1082 | 88 | 'All Files (*.*)') | ||
1083 | 89 | self.assertEqual(instance.theme.background_filename, '/new_path/file.ext', | ||
1084 | 90 | 'theme.background_filename should be set to the path that the file dialog returns') | ||
1085 | 91 | mocked_background_page_values.assert_called_once_with() | ||
1086 | 92 | 53 | ||
1087 | === modified file 'tests/functional/openlp_core_ui_lib/test_color_button.py' | |||
1088 | --- tests/functional/openlp_core_ui_lib/test_color_button.py 2017-04-24 05:17:55 +0000 | |||
1089 | +++ tests/functional/openlp_core_ui_lib/test_color_button.py 2017-05-14 07:15:51 +0000 | |||
1090 | @@ -20,12 +20,12 @@ | |||
1091 | 20 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA # | 20 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA # |
1092 | 21 | ############################################################################### | 21 | ############################################################################### |
1093 | 22 | """ | 22 | """ |
1095 | 23 | This module contains tests for the openlp.core.lib.filedialog module | 23 | This module contains tests for the openlp.core.ui.lib.colorbutton module |
1096 | 24 | """ | 24 | """ |
1097 | 25 | from unittest import TestCase | 25 | from unittest import TestCase |
1098 | 26 | from unittest.mock import MagicMock, call, patch | 26 | from unittest.mock import MagicMock, call, patch |
1099 | 27 | 27 | ||
1101 | 28 | from openlp.core.ui.lib.colorbutton import ColorButton | 28 | from openlp.core.ui.lib import ColorButton |
1102 | 29 | 29 | ||
1103 | 30 | 30 | ||
1104 | 31 | class TestColorDialog(TestCase): | 31 | class TestColorDialog(TestCase): |
1105 | @@ -148,11 +148,10 @@ | |||
1106 | 148 | widget.on_clicked() | 148 | widget.on_clicked() |
1107 | 149 | 149 | ||
1108 | 150 | # THEN: change_color should not have been called and the colorChanged signal should not have been emitted | 150 | # THEN: change_color should not have been called and the colorChanged signal should not have been emitted |
1114 | 151 | self.assertEqual( | 151 | self.assertFalse(self.mocked_change_color.called, |
1115 | 152 | self.mocked_change_color.call_count, 0, 'change_color should not have been called with an invalid color') | 152 | 'change_color should not have been called with an invalid color') |
1116 | 153 | self.assertEqual( | 153 | self.assertFalse(self.mocked_color_changed.emit.called, |
1117 | 154 | self.mocked_color_changed.emit.call_count, 0, | 154 | 'colorChange signal should not have been emitted with an invalid color') |
1113 | 155 | 'colorChange signal should not have been emitted with an invalid color') | ||
1118 | 156 | 155 | ||
1119 | 157 | def test_on_clicked_same_color(self): | 156 | def test_on_clicked_same_color(self): |
1120 | 158 | """ | 157 | """ |
1121 | @@ -171,12 +170,10 @@ | |||
1122 | 171 | widget.on_clicked() | 170 | widget.on_clicked() |
1123 | 172 | 171 | ||
1124 | 173 | # THEN: change_color should not have been called and the colorChanged signal should not have been emitted | 172 | # THEN: change_color should not have been called and the colorChanged signal should not have been emitted |
1131 | 174 | self.assertEqual( | 173 | self.assertFalse(self.mocked_change_color.called, |
1132 | 175 | self.mocked_change_color.call_count, 0, | 174 | 'change_color should not have been called when the color has not changed') |
1133 | 176 | 'change_color should not have been called when the color has not changed') | 175 | self.assertFalse(self.mocked_color_changed.emit.called, |
1134 | 177 | self.assertEqual( | 176 | 'colorChange signal should not have been emitted when the color has not changed') |
1129 | 178 | self.mocked_color_changed.emit.call_count, 0, | ||
1130 | 179 | 'colorChange signal should not have been emitted when the color has not changed') | ||
1135 | 180 | 177 | ||
1136 | 181 | def test_on_clicked_new_color(self): | 178 | def test_on_clicked_new_color(self): |
1137 | 182 | """ | 179 | """ |
1138 | 183 | 180 | ||
1139 | === added file 'tests/functional/openlp_core_ui_lib/test_path_edit.py' | |||
1140 | --- tests/functional/openlp_core_ui_lib/test_path_edit.py 1970-01-01 00:00:00 +0000 | |||
1141 | +++ tests/functional/openlp_core_ui_lib/test_path_edit.py 2017-05-14 07:15:51 +0000 | |||
1142 | @@ -0,0 +1,311 @@ | |||
1143 | 1 | # -*- coding: utf-8 -*- | ||
1144 | 2 | # vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 | ||
1145 | 3 | |||
1146 | 4 | ############################################################################### | ||
1147 | 5 | # OpenLP - Open Source Lyrics Projection # | ||
1148 | 6 | # --------------------------------------------------------------------------- # | ||
1149 | 7 | # Copyright (c) 2008-2017 OpenLP Developers # | ||
1150 | 8 | # --------------------------------------------------------------------------- # | ||
1151 | 9 | # This program is free software; you can redistribute it and/or modify it # | ||
1152 | 10 | # under the terms of the GNU General Public License as published by the Free # | ||
1153 | 11 | # Software Foundation; version 2 of the License. # | ||
1154 | 12 | # # | ||
1155 | 13 | # This program is distributed in the hope that it will be useful, but WITHOUT # | ||
1156 | 14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # | ||
1157 | 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # | ||
1158 | 16 | # more details. # | ||
1159 | 17 | # # | ||
1160 | 18 | # You should have received a copy of the GNU General Public License along # | ||
1161 | 19 | # with this program; if not, write to the Free Software Foundation, Inc., 59 # | ||
1162 | 20 | # Temple Place, Suite 330, Boston, MA 02111-1307 USA # | ||
1163 | 21 | ############################################################################### | ||
1164 | 22 | """ | ||
1165 | 23 | This module contains tests for the openlp.core.ui.lib.pathedit module | ||
1166 | 24 | """ | ||
1167 | 25 | from unittest import TestCase | ||
1168 | 26 | |||
1169 | 27 | from PyQt5 import QtWidgets | ||
1170 | 28 | |||
1171 | 29 | from openlp.core.ui.lib import PathEdit, PathType | ||
1172 | 30 | from unittest.mock import MagicMock, PropertyMock, patch | ||
1173 | 31 | |||
1174 | 32 | |||
1175 | 33 | class TestPathEdit(TestCase): | ||
1176 | 34 | """ | ||
1177 | 35 | Test the :class:`~openlp.core.lib.pathedit.PathEdit` class | ||
1178 | 36 | """ | ||
1179 | 37 | def setUp(self): | ||
1180 | 38 | with patch('openlp.core.ui.lib.pathedit.PathEdit._setup'): | ||
1181 | 39 | self.widget = PathEdit() | ||
1182 | 40 | |||
1183 | 41 | def test_path_getter(self): | ||
1184 | 42 | """ | ||
1185 | 43 | Test the `path` property getter. | ||
1186 | 44 | """ | ||
1187 | 45 | # GIVEN: An instance of PathEdit with the `_path` instance variable set | ||
1188 | 46 | self.widget._path = 'getter/test/pat.h' | ||
1189 | 47 | |||
1190 | 48 | # WHEN: Reading the `path` property | ||
1191 | 49 | # THEN: The value that we set should be returned | ||
1192 | 50 | self.assertEqual(self.widget.path, 'getter/test/pat.h') | ||
1193 | 51 | |||
1194 | 52 | def test_path_setter(self): | ||
1195 | 53 | """ | ||
1196 | 54 | Test the `path` property setter. | ||
1197 | 55 | """ | ||
1198 | 56 | # GIVEN: An instance of the PathEdit object and a mocked `line_edit` | ||
1199 | 57 | self.widget.line_edit = MagicMock() | ||
1200 | 58 | |||
1201 | 59 | # WHEN: Writing to the `path` property | ||
1202 | 60 | self.widget.path = 'setter/test/pat.h' | ||
1203 | 61 | |||
1204 | 62 | # THEN: The `_path` instance variable should be set with the test data. The `line_edit` text and tooltip | ||
1205 | 63 | # should have also been set. | ||
1206 | 64 | self.assertEqual(self.widget._path, 'setter/test/pat.h') | ||
1207 | 65 | self.widget.line_edit.setToolTip.assert_called_once_with('setter/test/pat.h') | ||
1208 | 66 | self.widget.line_edit.setText.assert_called_once_with('setter/test/pat.h') | ||
1209 | 67 | |||
1210 | 68 | def test_path_type_getter(self): | ||
1211 | 69 | """ | ||
1212 | 70 | Test the `path_type` property getter. | ||
1213 | 71 | """ | ||
1214 | 72 | # GIVEN: An instance of PathEdit | ||
1215 | 73 | # WHEN: Reading the `path` property | ||
1216 | 74 | # THEN: The default value should be returned | ||
1217 | 75 | self.assertEqual(self.widget.path_type, PathType.Files) | ||
1218 | 76 | |||
1219 | 77 | def test_path_type_setter(self): | ||
1220 | 78 | """ | ||
1221 | 79 | Test the `path_type` property setter. | ||
1222 | 80 | """ | ||
1223 | 81 | # GIVEN: An instance of the PathEdit object and a mocked `update_button_tool_tips` method. | ||
1224 | 82 | with patch.object(self.widget, 'update_button_tool_tips') as mocked_update_button_tool_tips: | ||
1225 | 83 | |||
1226 | 84 | # WHEN: Writing to a different value than default to the `path_type` property | ||
1227 | 85 | self.widget.path_type = PathType.Directories | ||
1228 | 86 | |||
1229 | 87 | # THEN: The `_path_type` instance variable should be set with the test data and not the default. The | ||
1230 | 88 | # update_button_tool_tips should have been called. | ||
1231 | 89 | self.assertEqual(self.widget._path_type, PathType.Directories) | ||
1232 | 90 | mocked_update_button_tool_tips.assert_called_once_with() | ||
1233 | 91 | |||
1234 | 92 | def test_update_button_tool_tips_directories(self): | ||
1235 | 93 | """ | ||
1236 | 94 | Test the `update_button_tool_tips` method. | ||
1237 | 95 | """ | ||
1238 | 96 | # GIVEN: An instance of PathEdit with the `path_type` set to `Directories` | ||
1239 | 97 | self.widget.browse_button = MagicMock() | ||
1240 | 98 | self.widget.revert_button = MagicMock() | ||
1241 | 99 | self.widget._path_type = PathType.Directories | ||
1242 | 100 | |||
1243 | 101 | # WHEN: Calling update_button_tool_tips | ||
1244 | 102 | self.widget.update_button_tool_tips() | ||
1245 | 103 | |||
1246 | 104 | self.widget.browse_button.setToolTip.assert_called_once_with('Browse for directory.') | ||
1247 | 105 | self.widget.revert_button.setToolTip.assert_called_once_with('Revert to default directory.') | ||
1248 | 106 | |||
1249 | 107 | def test_update_button_tool_tips_files(self): | ||
1250 | 108 | """ | ||
1251 | 109 | Test the `update_button_tool_tips` method. | ||
1252 | 110 | """ | ||
1253 | 111 | # GIVEN: An instance of PathEdit with the `path_type` set to `Files` | ||
1254 | 112 | self.widget.browse_button = MagicMock() | ||
1255 | 113 | self.widget.revert_button = MagicMock() | ||
1256 | 114 | self.widget._path_type = PathType.Files | ||
1257 | 115 | |||
1258 | 116 | # WHEN: Calling update_button_tool_tips | ||
1259 | 117 | self.widget.update_button_tool_tips() | ||
1260 | 118 | |||
1261 | 119 | self.widget.browse_button.setToolTip.assert_called_once_with('Browse for file.') | ||
1262 | 120 | self.widget.revert_button.setToolTip.assert_called_once_with('Revert to default file.') | ||
1263 | 121 | |||
1264 | 122 | def test_on_browse_button_clicked_directory(self): | ||
1265 | 123 | """ | ||
1266 | 124 | Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Directories. | ||
1267 | 125 | """ | ||
1268 | 126 | # GIVEN: An instance of PathEdit with the `path_type` set to `Directories` and a mocked | ||
1269 | 127 | # QFileDialog.getExistingDirectory | ||
1270 | 128 | with patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getExistingDirectory', return_value='') as \ | ||
1271 | 129 | mocked_get_existing_directory, \ | ||
1272 | 130 | patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getOpenFileName') as \ | ||
1273 | 131 | mocked_get_open_file_name, \ | ||
1274 | 132 | patch('openlp.core.ui.lib.pathedit.os.path.normpath') as mocked_normpath: | ||
1275 | 133 | self.widget._path_type = PathType.Directories | ||
1276 | 134 | self.widget._path = 'test/path/' | ||
1277 | 135 | |||
1278 | 136 | # WHEN: Calling on_browse_button_clicked | ||
1279 | 137 | self.widget.on_browse_button_clicked() | ||
1280 | 138 | |||
1281 | 139 | # THEN: The FileDialog.getExistingDirectory should have been called with the default caption | ||
1282 | 140 | mocked_get_existing_directory.assert_called_once_with(self.widget, 'Select Directory', 'test/path/', | ||
1283 | 141 | QtWidgets.QFileDialog.ShowDirsOnly) | ||
1284 | 142 | self.assertFalse(mocked_get_open_file_name.called) | ||
1285 | 143 | self.assertFalse(mocked_normpath.called) | ||
1286 | 144 | |||
1287 | 145 | def test_on_browse_button_clicked_directory_custom_caption(self): | ||
1288 | 146 | """ | ||
1289 | 147 | Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Directories, | ||
1290 | 148 | and `dialog_caption` is set. | ||
1291 | 149 | """ | ||
1292 | 150 | # GIVEN: An instance of PathEdit with the `path_type` set to `Directories` and a mocked | ||
1293 | 151 | # QFileDialog.getExistingDirectory with `default_caption` set. | ||
1294 | 152 | with patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getExistingDirectory', return_value='') as \ | ||
1295 | 153 | mocked_get_existing_directory, \ | ||
1296 | 154 | patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getOpenFileName') as \ | ||
1297 | 155 | mocked_get_open_file_name, \ | ||
1298 | 156 | patch('openlp.core.ui.lib.pathedit.os.path.normpath') as mocked_normpath: | ||
1299 | 157 | self.widget._path_type = PathType.Directories | ||
1300 | 158 | self.widget._path = 'test/path/' | ||
1301 | 159 | self.widget.dialog_caption = 'Directory Caption' | ||
1302 | 160 | |||
1303 | 161 | # WHEN: Calling on_browse_button_clicked | ||
1304 | 162 | self.widget.on_browse_button_clicked() | ||
1305 | 163 | |||
1306 | 164 | # THEN: The FileDialog.getExistingDirectory should have been called with the custom caption | ||
1307 | 165 | mocked_get_existing_directory.assert_called_once_with(self.widget, 'Directory Caption', 'test/path/', | ||
1308 | 166 | QtWidgets.QFileDialog.ShowDirsOnly) | ||
1309 | 167 | self.assertFalse(mocked_get_open_file_name.called) | ||
1310 | 168 | self.assertFalse(mocked_normpath.called) | ||
1311 | 169 | |||
1312 | 170 | def test_on_browse_button_clicked_file(self): | ||
1313 | 171 | """ | ||
1314 | 172 | Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Files. | ||
1315 | 173 | """ | ||
1316 | 174 | # GIVEN: An instance of PathEdit with the `path_type` set to `Files` and a mocked QFileDialog.getOpenFileName | ||
1317 | 175 | with patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getExistingDirectory') as \ | ||
1318 | 176 | mocked_get_existing_directory, \ | ||
1319 | 177 | patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getOpenFileName', return_value=('', '')) as \ | ||
1320 | 178 | mocked_get_open_file_name, \ | ||
1321 | 179 | patch('openlp.core.ui.lib.pathedit.os.path.normpath') as mocked_normpath: | ||
1322 | 180 | self.widget._path_type = PathType.Files | ||
1323 | 181 | self.widget._path = 'test/pat.h' | ||
1324 | 182 | |||
1325 | 183 | # WHEN: Calling on_browse_button_clicked | ||
1326 | 184 | self.widget.on_browse_button_clicked() | ||
1327 | 185 | |||
1328 | 186 | # THEN: The FileDialog.getOpenFileName should have been called with the default caption | ||
1329 | 187 | mocked_get_open_file_name.assert_called_once_with(self.widget, 'Select File', 'test/pat.h', | ||
1330 | 188 | self.widget.filters) | ||
1331 | 189 | self.assertFalse(mocked_get_existing_directory.called) | ||
1332 | 190 | self.assertFalse(mocked_normpath.called) | ||
1333 | 191 | |||
1334 | 192 | def test_on_browse_button_clicked_file_custom_caption(self): | ||
1335 | 193 | """ | ||
1336 | 194 | Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Files and | ||
1337 | 195 | `dialog_caption` is set. | ||
1338 | 196 | """ | ||
1339 | 197 | # GIVEN: An instance of PathEdit with the `path_type` set to `Files` and a mocked QFileDialog.getOpenFileName | ||
1340 | 198 | # with `default_caption` set. | ||
1341 | 199 | with patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getExistingDirectory') as \ | ||
1342 | 200 | mocked_get_existing_directory, \ | ||
1343 | 201 | patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getOpenFileName', return_value=('', '')) as \ | ||
1344 | 202 | mocked_get_open_file_name, \ | ||
1345 | 203 | patch('openlp.core.ui.lib.pathedit.os.path.normpath') as mocked_normpath: | ||
1346 | 204 | self.widget._path_type = PathType.Files | ||
1347 | 205 | self.widget._path = 'test/pat.h' | ||
1348 | 206 | self.widget.dialog_caption = 'File Caption' | ||
1349 | 207 | |||
1350 | 208 | # WHEN: Calling on_browse_button_clicked | ||
1351 | 209 | self.widget.on_browse_button_clicked() | ||
1352 | 210 | |||
1353 | 211 | # THEN: The FileDialog.getOpenFileName should have been called with the custom caption | ||
1354 | 212 | mocked_get_open_file_name.assert_called_once_with(self.widget, 'File Caption', 'test/pat.h', | ||
1355 | 213 | self.widget.filters) | ||
1356 | 214 | self.assertFalse(mocked_get_existing_directory.called) | ||
1357 | 215 | self.assertFalse(mocked_normpath.called) | ||
1358 | 216 | |||
1359 | 217 | def test_on_browse_button_clicked_user_cancels(self): | ||
1360 | 218 | """ | ||
1361 | 219 | Test the `browse_button` `clicked` handler on_browse_button_clicked when the user cancels the FileDialog (an | ||
1362 | 220 | empty str is returned) | ||
1363 | 221 | """ | ||
1364 | 222 | # GIVEN: An instance of PathEdit with a mocked QFileDialog.getOpenFileName which returns an empty str for the | ||
1365 | 223 | # file path. | ||
1366 | 224 | with patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getOpenFileName', return_value=('', '')) as \ | ||
1367 | 225 | mocked_get_open_file_name, \ | ||
1368 | 226 | patch('openlp.core.ui.lib.pathedit.os.path.normpath') as mocked_normpath: | ||
1369 | 227 | |||
1370 | 228 | # WHEN: Calling on_browse_button_clicked | ||
1371 | 229 | self.widget.on_browse_button_clicked() | ||
1372 | 230 | |||
1373 | 231 | # THEN: normpath should not have been called | ||
1374 | 232 | self.assertTrue(mocked_get_open_file_name.called) | ||
1375 | 233 | self.assertFalse(mocked_normpath.called) | ||
1376 | 234 | |||
1377 | 235 | def test_on_browse_button_clicked_user_accepts(self): | ||
1378 | 236 | """ | ||
1379 | 237 | Test the `browse_button` `clicked` handler on_browse_button_clicked when the user accepts the FileDialog (a path | ||
1380 | 238 | is returned) | ||
1381 | 239 | """ | ||
1382 | 240 | # GIVEN: An instance of PathEdit with a mocked QFileDialog.getOpenFileName which returns a str for the file | ||
1383 | 241 | # path. | ||
1384 | 242 | with patch('openlp.core.ui.lib.pathedit.QtWidgets.QFileDialog.getOpenFileName', | ||
1385 | 243 | return_value=('/test/pat.h', '')) as mocked_get_open_file_name, \ | ||
1386 | 244 | patch('openlp.core.ui.lib.pathedit.os.path.normpath') as mocked_normpath, \ | ||
1387 | 245 | patch.object(self.widget, 'on_new_path'): | ||
1388 | 246 | |||
1389 | 247 | # WHEN: Calling on_browse_button_clicked | ||
1390 | 248 | self.widget.on_browse_button_clicked() | ||
1391 | 249 | |||
1392 | 250 | # THEN: normpath and `on_new_path` should have been called | ||
1393 | 251 | self.assertTrue(mocked_get_open_file_name.called) | ||
1394 | 252 | mocked_normpath.assert_called_once_with('/test/pat.h') | ||
1395 | 253 | self.assertTrue(self.widget.on_new_path.called) | ||
1396 | 254 | |||
1397 | 255 | def test_on_revert_button_clicked(self): | ||
1398 | 256 | """ | ||
1399 | 257 | Test that the default path is set as the path when the `revert_button.clicked` handler is called. | ||
1400 | 258 | """ | ||
1401 | 259 | # GIVEN: An instance of PathEdit with a mocked `on_new_path`, and the `default_path` set. | ||
1402 | 260 | with patch.object(self.widget, 'on_new_path') as mocked_on_new_path: | ||
1403 | 261 | self.widget.default_path = '/default/pat.h' | ||
1404 | 262 | |||
1405 | 263 | # WHEN: Calling `on_revert_button_clicked` | ||
1406 | 264 | self.widget.on_revert_button_clicked() | ||
1407 | 265 | |||
1408 | 266 | # THEN: on_new_path should have been called with the default path | ||
1409 | 267 | mocked_on_new_path.assert_called_once_with('/default/pat.h') | ||
1410 | 268 | |||
1411 | 269 | def test_on_line_edit_editing_finished(self): | ||
1412 | 270 | """ | ||
1413 | 271 | Test that the new path is set as the path when the `line_edit.editingFinished` handler is called. | ||
1414 | 272 | """ | ||
1415 | 273 | # GIVEN: An instance of PathEdit with a mocked `line_edit` and `on_new_path`. | ||
1416 | 274 | with patch.object(self.widget, 'on_new_path') as mocked_on_new_path: | ||
1417 | 275 | self.widget.line_edit = MagicMock(**{'text.return_value': '/test/pat.h'}) | ||
1418 | 276 | |||
1419 | 277 | # WHEN: Calling `on_line_edit_editing_finished` | ||
1420 | 278 | self.widget.on_line_edit_editing_finished() | ||
1421 | 279 | |||
1422 | 280 | # THEN: on_new_path should have been called with the path enetered in `line_edit` | ||
1423 | 281 | mocked_on_new_path.assert_called_once_with('/test/pat.h') | ||
1424 | 282 | |||
1425 | 283 | def test_on_new_path_no_change(self): | ||
1426 | 284 | """ | ||
1427 | 285 | Test `on_new_path` when called with a path that is the same as the existing path. | ||
1428 | 286 | """ | ||
1429 | 287 | # GIVEN: An instance of PathEdit with a test path and mocked `pathChanged` signal | ||
1430 | 288 | with patch('openlp.core.ui.lib.pathedit.PathEdit.path', new_callable=PropertyMock): | ||
1431 | 289 | self.widget._path = '/old/test/pat.h' | ||
1432 | 290 | self.widget.pathChanged = MagicMock() | ||
1433 | 291 | |||
1434 | 292 | # WHEN: Calling `on_new_path` with the same path as the existing path | ||
1435 | 293 | self.widget.on_new_path('/old/test/pat.h') | ||
1436 | 294 | |||
1437 | 295 | # THEN: The `pathChanged` signal should not be emitted | ||
1438 | 296 | self.assertFalse(self.widget.pathChanged.emit.called) | ||
1439 | 297 | |||
1440 | 298 | def test_on_new_path_change(self): | ||
1441 | 299 | """ | ||
1442 | 300 | Test `on_new_path` when called with a path that is the different to the existing path. | ||
1443 | 301 | """ | ||
1444 | 302 | # GIVEN: An instance of PathEdit with a test path and mocked `pathChanged` signal | ||
1445 | 303 | with patch('openlp.core.ui.lib.pathedit.PathEdit.path', new_callable=PropertyMock): | ||
1446 | 304 | self.widget._path = '/old/test/pat.h' | ||
1447 | 305 | self.widget.pathChanged = MagicMock() | ||
1448 | 306 | |||
1449 | 307 | # WHEN: Calling `on_new_path` with the a new path | ||
1450 | 308 | self.widget.on_new_path('/new/test/pat.h') | ||
1451 | 309 | |||
1452 | 310 | # THEN: The `pathChanged` signal should be emitted | ||
1453 | 311 | self.widget.pathChanged.emit.assert_called_once_with('/new/test/pat.h') | ||
1454 | 0 | 312 | ||
1455 | === modified file 'tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py' | |||
1456 | --- tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py 2017-05-06 09:22:34 +0000 | |||
1457 | +++ tests/interfaces/openlp_plugins/bibles/forms/test_bibleimportform.py 2017-05-14 07:15:51 +0000 | |||
1458 | @@ -28,11 +28,12 @@ | |||
1459 | 28 | from PyQt5 import QtWidgets | 28 | from PyQt5 import QtWidgets |
1460 | 29 | 29 | ||
1461 | 30 | from openlp.core.common import Registry | 30 | from openlp.core.common import Registry |
1463 | 31 | from openlp.plugins.bibles.forms import bibleimportform | 31 | from openlp.plugins.bibles.forms.bibleimportform import BibleImportForm, PYSWORD_AVAILABLE |
1464 | 32 | 32 | ||
1465 | 33 | from tests.helpers.testmixin import TestMixin | 33 | from tests.helpers.testmixin import TestMixin |
1466 | 34 | 34 | ||
1467 | 35 | 35 | ||
1468 | 36 | @skip('One of the QFormLayouts in the BibleImportForm is causing a segfault') | ||
1469 | 36 | class TestBibleImportForm(TestCase, TestMixin): | 37 | class TestBibleImportForm(TestCase, TestMixin): |
1470 | 37 | """ | 38 | """ |
1471 | 38 | Test the BibleImportForm class | 39 | Test the BibleImportForm class |
1472 | @@ -46,9 +47,9 @@ | |||
1473 | 46 | self.setup_application() | 47 | self.setup_application() |
1474 | 47 | self.main_window = QtWidgets.QMainWindow() | 48 | self.main_window = QtWidgets.QMainWindow() |
1475 | 48 | Registry().register('main_window', self.main_window) | 49 | Registry().register('main_window', self.main_window) |
1477 | 49 | bibleimportform.PYSWORD_AVAILABLE = False | 50 | PYSWORD_AVAILABLE = False |
1478 | 50 | self.mocked_manager = MagicMock() | 51 | self.mocked_manager = MagicMock() |
1480 | 51 | self.form = bibleimportform.BibleImportForm(self.main_window, self.mocked_manager, MagicMock()) | 52 | self.form = BibleImportForm(self.main_window, self.mocked_manager, MagicMock()) |
1481 | 52 | 53 | ||
1482 | 53 | def tearDown(self): | 54 | def tearDown(self): |
1483 | 54 | """ | 55 | """ |
You tracking head as you have conflicts!