示例#1
0
 def on_file_click(self):
     """
     Add a file to the list widget to make it available for showing
     """
     files = FileDialog.getOpenFileNames(self, self.on_new_prompt,
                                         Settings().value(self.settings_section + '/last directory'),
                                         self.on_new_file_masks)
     log.info('New files(s) {files}'.format(files=files))
     if files:
         self.application.set_busy_cursor()
         self.validate_and_load(files)
     self.application.set_normal_cursor()
示例#2
0
 def on_file_click(self):
     """
     Add a file to the list widget to make it available for showing
     """
     files = FileDialog.getOpenFileNames(
         self, self.on_new_prompt,
         Settings().value(self.settings_section + '/last directory'),
         self.on_new_file_masks)
     log.info('New files(s) %s' % files)
     if files:
         self.application.set_busy_cursor()
         self.validate_and_load(files)
     self.application.set_normal_cursor()
示例#3
0
 def on_add_loop(self, field=None):
     """
     Adds a new video background loop and creates the associated thumbnail image for the UI.
     :param field:
     """
     files = FileDialog.getOpenFileNames(self, self.on_new_prompt,
                                         Settings().value(self.settings_section + '/last directory'),
                                         self.on_new_file_masks)
     if files:
         Settings().setValue(self.settings_section + '/last directory', split_filename(files[0])[0])
         for f in files:
             self.application.set_busy_cursor()
             shutil.copy(f, self.path)
             self.create_loop_thumbnail(split_filename(f)[1])
             self.application.set_normal_cursor()
     self.load_loops()
示例#4
0
 def on_add_loop(self, field=None):
     """
     Adds a new video background loop and creates the associated thumbnail image for the UI.
     :param field:
     """
     files = FileDialog.getOpenFileNames(self, self.on_new_prompt,
                                         Settings().value(self.settings_section + '/last directory'),
                                         self.on_new_file_masks)
     if files:
         Settings().setValue(self.settings_section + '/last directory', split_filename(files[0])[0])
         for f in files:
             self.application.set_busy_cursor()
             shutil.copy(f, self.path)
             self.create_loop_thumbnail(split_filename(f)[1])
             self.application.set_normal_cursor()
     self.load_loops()
示例#5
0
 def on_import_theme(self, field=None):
     """
     Opens a file dialog to select the theme file(s) to import before attempting to extract OpenLP themes from
     those files. This process will only load version 2 themes.
     :param field:
     """
     files = FileDialog.getOpenFileNames(self,
                                         translate('OpenLP.ThemeManager', 'Select Theme Import File'),
                                         Settings().value(self.settings_section + '/last directory import'),
                                         translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
     self.log_info('New Themes {name}'.format(name=str(files)))
     if not files:
         return
     self.application.set_busy_cursor()
     for file_name in files:
         Settings().setValue(self.settings_section + '/last directory import', str(file_name))
         self.unzip_theme(file_name, self.path)
     self.load_themes()
     self.application.set_normal_cursor()
示例#6
0
    def get_files(self, title, listbox, filters=''):
        """
        Opens a QFileDialog and writes the filenames to the given listbox.

        :param title: The title of the dialog (str).
        :param listbox: A listbox (QListWidget).
        :param filters: The file extension filters. It should contain the file descriptions as well as the file
            extensions. For example::
                'SongBeamer Files (*.sng)'
        """
        if filters:
            filters += ';;'
        filters += '%s (*)' % UiStrings().AllFiles
        file_names = FileDialog.getOpenFileNames(
            self, title,
            Settings().value(self.plugin.settings_section + '/last directory import'), filters)
        if file_names:
            listbox.addItems(file_names)
            Settings().setValue(self.plugin.settings_section + '/last directory import',
                                os.path.split(str(file_names[0]))[0])
示例#7
0
 def on_import_theme(self, field=None):
     """
     Opens a file dialog to select the theme file(s) to import before attempting to extract OpenLP themes from
     those files. This process will only load version 2 themes.
     :param field:
     """
     files = FileDialog.getOpenFileNames(
         self, translate('OpenLP.ThemeManager', 'Select Theme Import File'),
         Settings().value(self.settings_section + '/last directory import'),
         translate('OpenLP.ThemeManager', 'OpenLP Themes (*.otz)'))
     self.log_info('New Themes %s' % str(files))
     if not files:
         return
     self.application.set_busy_cursor()
     for file_name in files:
         Settings().setValue(
             self.settings_section + '/last directory import',
             str(file_name))
         self.unzip_theme(file_name, self.path)
     self.load_themes()
     self.application.set_normal_cursor()
示例#8
0
    def get_files(self, title, listbox, filters=''):
        """
        Opens a QFileDialog and writes the filenames to the given listbox.

        :param title: The title of the dialog (str).
        :param listbox: A listbox (QListWidget).
        :param filters: The file extension filters. It should contain the file descriptions as well as the file
            extensions. For example::
                'SongBeamer Files (*.sng)'
        """
        if filters:
            filters += ';;'
        filters += '%s (*)' % UiStrings().AllFiles
        file_names = FileDialog.getOpenFileNames(
            self, title,
            Settings().value(self.plugin.settings_section +
                             '/last directory import'), filters)
        if file_names:
            listbox.addItems(file_names)
            Settings().setValue(
                self.plugin.settings_section + '/last directory import',
                os.path.split(str(file_names[0]))[0])