Display error if no media directories are set, and reset cache when media directories set to blank, and don't switch to None index in playlist

This commit is contained in:
Et0h 2016-06-02 18:06:39 +01:00
parent 1c9a56e9d5
commit f4ca4c5c00
5 changed files with 17 additions and 5 deletions

View File

@ -1405,6 +1405,9 @@ class SyncplayPlaylist():
return return
try: try:
if index is None:
self._ui.showDebugMessage(u"Cannot switch to None index in playlist")
return
filename = self._playlist[index] filename = self._playlist[index]
# TODO: Handle isse with index being None # TODO: Handle isse with index being None
if utils.isURL(filename): if utils.isURL(filename):
@ -1597,14 +1600,18 @@ class FileSwitchManager(object):
self.currentDirectory = curDir self.currentDirectory = curDir
def changeMediaDirectories(self, mediaDirs): def changeMediaDirectories(self, mediaDirs):
if mediaDirs <> self._client._config["mediaSearchDirectories"]: from syncplay.ui.ConfigurationGetter import ConfigurationGetter
from syncplay.ui.ConfigurationGetter import ConfigurationGetter ConfigurationGetter().setConfigOption("mediaSearchDirectories", mediaDirs)
ConfigurationGetter().setConfigOption("mediaSearchDirectories", mediaDirs) self._client._config["mediaSearchDirectories"] = mediaDirs
self._client._config["mediaSearchDirectories"] = mediaDirs self._client.ui.showMessage(getMessage("media-directory-list-updated-notification"))
self._client.ui.showMessage(getMessage("media-directory-list-updated-notification"))
self.mediaDirectoriesNotFound = [] self.mediaDirectoriesNotFound = []
self.folderSearchEnabled = True self.folderSearchEnabled = True
self.setMediaDirectories(mediaDirs) self.setMediaDirectories(mediaDirs)
if mediaDirs == "":
self._client.ui.showErrorMessage(getMessage("no-media-directories-error"))
self.mediaFilesCache = {}
self.newInfo = True
self.checkForFileSwitchUpdate()
def setMediaDirectories(self, mediaDirs): def setMediaDirectories(self, mediaDirs):
self.mediaDirectories = mediaDirs self.mediaDirectories = mediaDirs

View File

@ -142,6 +142,7 @@ de = {
"folder-search-timeout-error" : u"The search for media in media directories was aborted as it took too long to search through '{}'. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. For automatic file switching to work again please select File->Set Media Directories in the menu bar and remove this directory or replace it with an appropriate sub-folder.", #Folder # TODO: Translate "folder-search-timeout-error" : u"The search for media in media directories was aborted as it took too long to search through '{}'. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. For automatic file switching to work again please select File->Set Media Directories in the menu bar and remove this directory or replace it with an appropriate sub-folder.", #Folder # TODO: Translate
"folder-search-first-file-timeout-error" : u"The search for media in '{}' was aborted as it took too long to access the directory. This could happen if it is a network drive or if you configure your drive to spin down after a period of inactivity. For automatic file switching to work again please go to File->Set Media Directories and either remove the directory or resolve the issue (e.g. by changing power saving settings).", #Folder # TODO: Translate "folder-search-first-file-timeout-error" : u"The search for media in '{}' was aborted as it took too long to access the directory. This could happen if it is a network drive or if you configure your drive to spin down after a period of inactivity. For automatic file switching to work again please go to File->Set Media Directories and either remove the directory or resolve the issue (e.g. by changing power saving settings).", #Folder # TODO: Translate
"added-file-not-in-media-directory-error" : u"You loaded a file in '{}' which is not a known media directory. You can add this as a media directory by selecting File->Set Media Directories in the menu bar.", #Folder # TODO: Translate "added-file-not-in-media-directory-error" : u"You loaded a file in '{}' which is not a known media directory. You can add this as a media directory by selecting File->Set Media Directories in the menu bar.", #Folder # TODO: Translate
"no-media-directories-error" : u"No media directories have been set. For shared playlist and file switching features to work properly please select File->Set Media Directories and specify where Syncplay should look to find media files.", # TODO: Translate
"failed-to-load-server-list-error" : u"Konnte die Liste der öffentlichen Server nicht laden. Bitte besuche http://www.syncplay.pl/ [Englisch] mit deinem Browser.", "failed-to-load-server-list-error" : u"Konnte die Liste der öffentlichen Server nicht laden. Bitte besuche http://www.syncplay.pl/ [Englisch] mit deinem Browser.",

View File

@ -142,6 +142,7 @@ en = {
"folder-search-timeout-error" : u"The search for media in media directories was aborted as it took too long to search through '{}'. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. For automatic file switching to work again please select File->Set Media Directories in the menu bar and remove this directory or replace it with an appropriate sub-folder.", #Folder "folder-search-timeout-error" : u"The search for media in media directories was aborted as it took too long to search through '{}'. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. For automatic file switching to work again please select File->Set Media Directories in the menu bar and remove this directory or replace it with an appropriate sub-folder.", #Folder
"folder-search-first-file-timeout-error" : u"The search for media in '{}' was aborted as it took too long to access the directory. This could happen if it is a network drive or if you configure your drive to spin down after a period of inactivity. For automatic file switching to work again please go to File->Set Media Directories and either remove the directory or resolve the issue (e.g. by changing power saving settings).", #Folder "folder-search-first-file-timeout-error" : u"The search for media in '{}' was aborted as it took too long to access the directory. This could happen if it is a network drive or if you configure your drive to spin down after a period of inactivity. For automatic file switching to work again please go to File->Set Media Directories and either remove the directory or resolve the issue (e.g. by changing power saving settings).", #Folder
"added-file-not-in-media-directory-error" : u"You loaded a file in '{}' which is not a known media directory. You can add this as a media directory by selecting File->Set Media Directories in the menu bar.", #Folder "added-file-not-in-media-directory-error" : u"You loaded a file in '{}' which is not a known media directory. You can add this as a media directory by selecting File->Set Media Directories in the menu bar.", #Folder
"no-media-directories-error" : u"No media directories have been set. For shared playlist and file switching features to work properly please select File->Set Media Directories and specify where Syncplay should look to find media files.",
"failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.", "failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.",

View File

@ -142,6 +142,7 @@ ru = {
"folder-search-timeout-error" : u"The search for media in media directories was aborted as it took too long to search through '{}'. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. For automatic file switching to work again please select File->Set Media Directories in the menu bar and remove this directory or replace it with an appropriate sub-folder.", #Folder # TODO: Translate "folder-search-timeout-error" : u"The search for media in media directories was aborted as it took too long to search through '{}'. This will occur if you select a folder with too many sub-folders in your list of media folders to search through. For automatic file switching to work again please select File->Set Media Directories in the menu bar and remove this directory or replace it with an appropriate sub-folder.", #Folder # TODO: Translate
"folder-search-first-file-timeout-error" : u"The search for media in '{}' was aborted as it took too long to access the directory. This could happen if it is a network drive or if you configure your drive to spin down after a period of inactivity. For automatic file switching to work again please go to File->Set Media Directories and either remove the directory or resolve the issue (e.g. by changing power saving settings).", #Folder # TODO: Translate "folder-search-first-file-timeout-error" : u"The search for media in '{}' was aborted as it took too long to access the directory. This could happen if it is a network drive or if you configure your drive to spin down after a period of inactivity. For automatic file switching to work again please go to File->Set Media Directories and either remove the directory or resolve the issue (e.g. by changing power saving settings).", #Folder # TODO: Translate
"added-file-not-in-media-directory-error" : u"You loaded a file in '{}' which is not a known media directory. You can add this as a media directory by selecting File->Set Media Directories in the menu bar.", #Folder #TODO: Translate "added-file-not-in-media-directory-error" : u"You loaded a file in '{}' which is not a known media directory. You can add this as a media directory by selecting File->Set Media Directories in the menu bar.", #Folder #TODO: Translate
"no-media-directories-error" : u"No media directories have been set. For shared playlist and file switching features to work properly please select File->Set Media Directories and specify where Syncplay should look to find media files.", # TODO: Translate
"failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.", # TODO: Translate into Russian "failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.", # TODO: Translate into Russian

View File

@ -299,6 +299,8 @@ class MainWindow(QtGui.QMainWindow):
self.playlistGroup.setChecked(self.config['sharedPlaylistEnabled']) self.playlistGroup.setChecked(self.config['sharedPlaylistEnabled'])
self.playlistGroup.blockSignals(False) self.playlistGroup.blockSignals(False)
self._syncplayClient.fileSwitch.setMediaDirectories(self.config["mediaSearchDirectories"]) self._syncplayClient.fileSwitch.setMediaDirectories(self.config["mediaSearchDirectories"])
if not self.config["mediaSearchDirectories"]:
self._syncplayClient.ui.showErrorMessage(getMessage("no-media-directories-error"))
self.updateReadyState(self.config['readyAtStart']) self.updateReadyState(self.config['readyAtStart'])
autoplayInitialState = self.config['autoplayInitialState'] autoplayInitialState = self.config['autoplayInitialState']
if autoplayInitialState is not None: if autoplayInitialState is not None: