def add_directory(self): """Add directory to the tagger.""" current_directory = find_starting_directory() dir_list = [] if not config.setting["toolbar_multiselect"]: directory = QtWidgets.QFileDialog.getExistingDirectory( self, "", current_directory) if directory: dir_list.append(directory) else: file_dialog = MultiDirsSelectDialog(self, "", current_directory) if file_dialog.exec_() == QtWidgets.QDialog.Accepted: dir_list = file_dialog.selectedFiles() dir_count = len(dir_list) if dir_count: parent = os.path.dirname( dir_list[0]) if dir_count > 1 else dir_list[0] config.persist["current_directory"] = parent if dir_count > 1: self.set_statusbar_message( N_("Adding multiple directories from '%(directory)s' ..."), {'directory': parent}) else: self.set_statusbar_message( N_("Adding directory: '%(directory)s' ..."), {'directory': dir_list[0]}) for directory in dir_list: self.tagger.add_directory(directory)
def add_directory(self): """Add directory to the tagger.""" current_directory = find_starting_directory() dir_list = [] if not config.setting["toolbar_multiselect"]: directory = QtWidgets.QFileDialog.getExistingDirectory(self, "", current_directory) if directory: dir_list.append(directory) else: file_dialog = MultiDirsSelectDialog(self, "", current_directory) if file_dialog.exec_() == QtWidgets.QDialog.Accepted: dir_list = file_dialog.selectedFiles() dir_count = len(dir_list) if dir_count: parent = os.path.dirname(dir_list[0]) if dir_count > 1 else dir_list[0] config.persist["current_directory"] = parent if dir_count > 1: self.set_statusbar_message( N_("Adding multiple directories from '%(directory)s' ..."), {'directory': parent} ) else: self.set_statusbar_message( N_("Adding directory: '%(directory)s' ..."), {'directory': dir_list[0]} ) for directory in dir_list: self.tagger.add_directory(directory)
def add_directory(self): """Add directory to the tagger.""" current_directory = find_starting_directory() dir_list = [] if not config.setting["toolbar_multiselect"]: directory = QtGui.QFileDialog.getExistingDirectory(self, "", current_directory) if directory: dir_list.append(directory) else: # Use a custom file selection dialog to allow the selection of multiple directories file_dialog = QtGui.QFileDialog(self, "", current_directory) file_dialog.setFileMode(QtGui.QFileDialog.DirectoryOnly) if sys.platform == "darwin": # The native dialog doesn't allow selecting >1 directory file_dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog) tree_view = file_dialog.findChild(QtGui.QTreeView) tree_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) list_view = file_dialog.findChild(QtGui.QListView, "listView") list_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) if file_dialog.exec_() == QtGui.QDialog.Accepted: dir_list = file_dialog.selectedFiles() if len(dir_list) == 1: config.persist["current_directory"] = dir_list[0] elif len(dir_list) > 1: (parent, dir) = os.path.split(str(dir_list[0])) config.persist["current_directory"] = parent for directory in dir_list: directory = unicode(directory) self.tagger.add_directory(directory)
def add_files(self): """Add files to the tagger.""" current_directory = find_starting_directory() formats = [] extensions = [] for exts, name in supported_formats(): exts = ["*" + e for e in exts] formats.append("%s (%s)" % (name, " ".join(exts))) extensions.extend(exts) formats.sort() extensions.sort() formats.insert(0, _("All Supported Formats") + " (%s)" % " ".join(extensions)) files, _filter = QtWidgets.QFileDialog.getOpenFileNames(self, "", current_directory, ";;".join(formats)) if files: config.persist["current_directory"] = os.path.dirname(files[0]) self.tagger.add_files(files)
def add_directory(self): """Add directory to the tagger.""" current_directory = find_starting_directory() dir_list = [] if not config.setting["toolbar_multiselect"]: directory = QtGui.QFileDialog.getExistingDirectory( self, "", current_directory) if directory: dir_list.append(directory) else: # Use a custom file selection dialog to allow the selection of multiple directories file_dialog = QtGui.QFileDialog(self, "", current_directory) file_dialog.setFileMode(QtGui.QFileDialog.DirectoryOnly) if sys.platform == "darwin": # The native dialog doesn't allow selecting >1 directory file_dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog) tree_view = file_dialog.findChild(QtGui.QTreeView) tree_view.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) list_view = file_dialog.findChild(QtGui.QListView, "listView") list_view.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) if file_dialog.exec_() == QtGui.QDialog.Accepted: dir_list = file_dialog.selectedFiles() if len(dir_list) == 1: config.persist["current_directory"] = dir_list[0] self.set_statusbar_message( N_("Adding directory: '%(directory)s' ..."), {'directory': dir_list[0]}) elif len(dir_list) > 1: (parent, dir) = os.path.split(str(dir_list[0])) config.persist["current_directory"] = parent self.set_statusbar_message( N_("Adding multiple directories from '%(directory)s' ..."), {'directory': parent}) for directory in dir_list: directory = unicode(directory) self.tagger.add_directory(directory)
def add_directory(self): """Add directory to the tagger.""" current_directory = find_starting_directory() dir_list = [] if not config.setting["toolbar_multiselect"]: directory = QtGui.QFileDialog.getExistingDirectory(self, "", current_directory) if directory: dir_list.append(directory) else: # Use a custom file selection dialog to allow the selection of multiple directories file_dialog = QtGui.QFileDialog(self, "", current_directory) file_dialog.setFileMode(QtGui.QFileDialog.DirectoryOnly) if sys.platform == "darwin": # The native dialog doesn't allow selecting >1 directory file_dialog.setOption(QtGui.QFileDialog.DontUseNativeDialog) tree_view = file_dialog.findChild(QtGui.QTreeView) tree_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) list_view = file_dialog.findChild(QtGui.QListView, "listView") list_view.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) if file_dialog.exec_() == QtGui.QDialog.Accepted: dir_list = file_dialog.selectedFiles() dir_count = len(dir_list) if dir_count: parent = os.path.dirname(dir_list[0]) config.persist["current_directory"] = parent if dir_count > 1: self.set_statusbar_message( N_("Adding multiple directories from '%(directory)s' ..."), {'directory': parent} ) else: self.set_statusbar_message( N_("Adding directory: '%(directory)s' ..."), {'directory': dir_list[0]} ) for directory in dir_list: self.tagger.add_directory(directory)