~alisonken1/openlp/pjlink2-i

« back to all changes in this revision

Viewing changes to openlp/core/ui/thememanager.py

  • Committer: Tim Bentley
  • Author(s): Phill
  • Date: 2017-08-11 20:31:09 UTC
  • mfrom: (2754.1.11 pathlib2)
  • Revision ID: tim.bentley@gmail.com-20170811203109-0idjanfltutf8n38
Definitely ready for merging, unless, of course you guys find some more issues!

Part 2

Changed the pathedit widget over to using pathlib
Added a 'patched' file dialog
Added a few utility methods

lp:~phill-ridout/openlp/pathlib2 (revision 2763)
[SUCCESS] https://ci.openlp.io/job/Branch-01-Pull/2125/
[SUCCESS] https://ci.openlp.io/job/Branch-02-Functional-Tests/2033/
[SUCCESS] https://ci.openlp.io/job/Branch-03-Interface-Tests/1938/
[SUCCESS] https://ci.openlp.io/job/Branch-04a-Code_Analysis...

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
"""
23
23
The Theme Manager manages adding, deleteing and modifying of themes.
24
24
"""
25
 
import json
26
25
import os
27
26
import zipfile
28
27
import shutil
32
31
 
33
32
from openlp.core.common import Registry, RegistryProperties, AppLocation, Settings, OpenLPMixin, RegistryMixin, \
34
33
    UiStrings, check_directory_exists, translate, is_win, get_filesystem_encoding, delete_file
35
 
from openlp.core.lib import FileDialog, ImageSource, ValidationError, get_text_file_string, build_icon, \
 
34
from openlp.core.common.path import path_to_str, str_to_path
 
35
from openlp.core.lib import ImageSource, ValidationError, get_text_file_string, build_icon, \
36
36
    check_item_selected, create_thumb, validate_thumb
37
37
from openlp.core.lib.theme import Theme, BackgroundType
38
38
from openlp.core.lib.ui import critical_error_message_box, create_widget_action
39
39
from openlp.core.ui import FileRenameForm, ThemeForm
40
40
from openlp.core.ui.lib import OpenLPToolbar
 
41
from openlp.core.ui.lib.filedialog import FileDialog
41
42
from openlp.core.common.languagemanager import get_locale_key
42
43
 
43
44
 
424
425
        those files. This process will only load version 2 themes.
425
426
        :param field:
426
427
        """
427
 
        files = FileDialog.getOpenFileNames(self,
428
 
                                            translate('OpenLP.ThemeManager', 'Select Theme Import File'),
429
 
                                            Settings().value(self.settings_section + '/last directory import'),
430
 
                                            translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
431
 
        self.log_info('New Themes {name}'.format(name=str(files)))
432
 
        if not files:
 
428
        file_paths, selected_filter = FileDialog.getOpenFileNames(
 
429
            self,
 
430
            translate('OpenLP.ThemeManager', 'Select Theme Import File'),
 
431
            str_to_path(Settings().value(self.settings_section + '/last directory import')),
 
432
            translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
 
433
        self.log_info('New Themes {file_paths}'.format(file_paths=file_paths))
 
434
        if not file_paths:
433
435
            return
434
436
        self.application.set_busy_cursor()
435
 
        for file_name in files:
 
437
        for file_path in file_paths:
 
438
            file_name = path_to_str(file_path)
436
439
            Settings().setValue(self.settings_section + '/last directory import', str(file_name))
437
440
            self.unzip_theme(file_name, self.path)
438
441
        self.load_themes()