Allow user to set media directories via main GUI

This commit is contained in:
Et0h 2016-06-02 16:30:54 +01:00
parent a8d3c3ccc8
commit 53e32e2283
7 changed files with 51 additions and 7 deletions

View File

@ -655,6 +655,7 @@ guiIcons = ['resources/accept.png', 'resources/arrow_undo.png', 'resources/clock
'resources/tick.png', 'resources/lock_open.png', 'resources/empty_checkbox.png', 'resources/tick_checkbox.png',
'resources/world_explore.png', 'resources/application_get.png', 'resources/cog.png', 'resources/arrow_switch.png',
'resources/film_go.png', 'resources/world_go.png', 'resources/arrow_refresh.png', 'resources/bullet_right_grey.png',
'film_folder_edit.png',
'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png', 'resources/spinner.mng'
]
resources = ["resources/icon.ico", "resources/syncplay.png"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1021 B

View File

@ -1591,6 +1591,15 @@ class FileSwitchManager(object):
def setCurrentDirectory(self, curDir):
self.currentDirectory = curDir
def changeMediaDirectories(self, mediaDirs):
if mediaDirs <> self._client._config["mediaSearchDirectories"]:
from syncplay.ui.ConfigurationGetter import ConfigurationGetter
ConfigurationGetter().setConfigOption("mediaSearchDirectories", mediaDirs)
self._client._config["mediaSearchDirectories"] = mediaDirs
self._client.ui.showMessage(getMessage("media-directory-list-updated-notification"))
self.folderSearchEnabled = True
self.setMediaDirectories(mediaDirs)
def setMediaDirectories(self, mediaDirs):
self.mediaDirectories = mediaDirs
self.updateInfo()

View File

@ -28,6 +28,8 @@ de = {
"current-offset-notification" : u"Aktueller Offset: {} Sekunden", # Offset
"media-directory-list-updated-notification" : u"Syncplay media directories have been updated.", # TODO: Translate
"room-join-notification" : u"<{}> hat den Raum '{}' betreten", # User
"left-notification" : u"<{}> ist gegangen", # User
"left-paused-notification" : u"<{}> ist gegangen, <{}> pausierte", # User who left, User who paused
@ -137,8 +139,8 @@ de = {
"invalid-offset-value" : u"Ungültiger Offset-Wert",
"switch-file-not-found-error" : u"Konnte nicht zur Datei '{0}' wechseln. Syncplay looks in the specified media directories.", # File not found, folder it was not found in # TODO: Re-translate "Syncplay sucht im Ordner der aktuellen Datei und angegebenen Medien-Verzeichnissen." to reference to checking in "current media directory"
"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 remove this directory as a media directory (optionally using a sub-directory instead) and re-open Syncplay.", #Folder # TODO: Re-translate using new language
"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 remove this directory as a media directory or resolve the issue (e.g. by changing power saving settings) and re-open Syncplay.", #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
"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.",
@ -255,6 +257,7 @@ de = {
"file-menu-label" : u"&Datei", # & precedes shortcut key
"openmedia-menu-label" : u"&Mediendatei öffnen...",
"openstreamurl-menu-label" : u"&Stream URL öffnen",
"setmediadirectories-menu-label" : u"Set media &directories", # TODO: Translate
"exit-menu-label" : u"&Beenden",
"advanced-menu-label" : u"&Erweitert",
"window-menu-label" : u"&Fenster",

View File

@ -28,6 +28,8 @@ en = {
"current-offset-notification" : "Current offset: {} seconds", # Offset
"media-directory-list-updated-notification" : u"Syncplay media directories have been updated.",
"room-join-notification" : u"<{}> has joined the room: '{}'", # User
"left-notification" : u"<{}> has left", # User
"left-paused-notification" : u"<{}> left, <{}> paused", # User who left, User who paused
@ -137,8 +139,8 @@ en = {
"invalid-offset-value" : u"Invalid offset value",
"switch-file-not-found-error" : u"Could not switch to file '{0}'. Syncplay looks in specified media directories.", # File not found
"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 remove this directory as a media directory (optionally using a sub-directory instead) and re-open Syncplay.", #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 remove this directory as a media directory or resolve the issue (e.g. by changing power saving settings) and re-open Syncplay.", #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
"failed-to-load-server-list-error" : u"Failed to load public server list. Please visit http://www.syncplay.pl/ in your browser.",
@ -257,6 +259,7 @@ en = {
"file-menu-label" : "&File", # & precedes shortcut key
"openmedia-menu-label" : "&Open media file",
"openstreamurl-menu-label" : "Open &media stream URL",
"setmediadirectories-menu-label" : u"Set media &directories",
"exit-menu-label" : "E&xit",
"advanced-menu-label" : "&Advanced",
"window-menu-label" : "&Window",

View File

@ -28,6 +28,8 @@ ru = {
"current-offset-notification" : u"Текущее смещение: {} секунд(ы)", # Offset
"media-directory-list-updated-notification" : u"Syncplay media directories have been updated.", # TODO: Translate
"room-join-notification" : u"<{}> зашел(зашла) в комнату: '{}'", # User
"left-notification" : u"<{}> покинул(а) комнату", # User
"left-paused-notification" : u"<{}> покинул(а) комнату, <{}> приостановил(а) воспроизведение", # User who left, User who paused
@ -137,8 +139,8 @@ ru = {
"invalid-offset-value" : u"Некорректное смещение",
"switch-file-not-found-error" : u"Невозможно переключиться на файл '{0}'. Syncplay looks in the folder specified media directories.", # File not found # TODO: Translate last part into Russian
"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 remove this directory as a media directory (optionally using a sub-directory instead) and re-open Syncplay.", #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 remove this directory as a media directory or resolve the issue (e.g. by changing power saving settings) and re-open Syncplay.", #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
"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
@ -257,6 +259,7 @@ ru = {
"file-menu-label" : u"&Файл", # & precedes shortcut key
"openmedia-menu-label" : u"&Открыть видеофайл",
"openstreamurl-menu-label" : u"Открыть URL &потокового вещания",
"setmediadirectories-menu-label" : u"Set media &directories", # TODO: Translate
"exit-menu-label" : u"&Выход",
"advanced-menu-label" : u"&Дополнительно",
"window-menu-label" : u"&Окна",

View File

@ -776,7 +776,7 @@ class MainWindow(QtGui.QMainWindow):
@needsClient
def OpenAddURIsToPlaylistDialog(self):
URIsDialog = QtGui.QDialog()
URIsDialog.setWindowTitle("Add URLs to playlist (one per line)")
URIsDialog.setWindowTitle(u"Add URLs to playlist (one per line)") # TODO: Move to messages_*.py
URIsLayout = QtGui.QGridLayout()
URIsTextbox = QtGui.QPlainTextEdit()
URIsTextbox.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
@ -797,6 +797,27 @@ class MainWindow(QtGui.QMainWindow):
self.addStreamToPlaylist(URI)
self.updatingPlaylist = False
def openSetMediaDirectoriesDialog(self):
MediaDirectoriesDialog = QtGui.QDialog()
MediaDirectoriesDialog.setWindowTitle(getMessage("syncplay-mediasearchdirectories-title")) # TODO: Move to messages_*.py
MediaDirectoriesLayout = QtGui.QGridLayout()
MediaDirectoriesTextbox = QtGui.QPlainTextEdit()
MediaDirectoriesTextbox.setLineWrapMode(QtGui.QPlainTextEdit.NoWrap)
MediaDirectoriesTextbox.setPlainText(utils.getListAsMultilineString(self.config["mediaSearchDirectories"]))
MediaDirectoriesLayout.addWidget(MediaDirectoriesTextbox, 0, 0, 1, 1)
MediaDirectoriesButtonBox = QtGui.QDialogButtonBox()
MediaDirectoriesButtonBox.setOrientation(Qt.Horizontal)
MediaDirectoriesButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Ok|QtGui.QDialogButtonBox.Cancel)
MediaDirectoriesButtonBox.accepted.connect(MediaDirectoriesDialog.accept)
MediaDirectoriesButtonBox.rejected.connect(MediaDirectoriesDialog.reject)
MediaDirectoriesLayout.addWidget(MediaDirectoriesButtonBox, 1, 0, 1, 1)
MediaDirectoriesDialog.setLayout(MediaDirectoriesLayout)
MediaDirectoriesDialog.show()
result = MediaDirectoriesDialog.exec_()
if result == QtGui.QDialog.Accepted:
newMediaDirectories = utils.convertMultilineStringToList(MediaDirectoriesTextbox.toPlainText())
self._syncplayClient.fileSwitch.changeMediaDirectories(newMediaDirectories)
@needsClient
def promptForStreamURL(self):
streamURL, ok = QtGui.QInputDialog.getText(self, getMessage("promptforstreamurl-msgbox-label"),
@ -1092,6 +1113,10 @@ class MainWindow(QtGui.QMainWindow):
window.openAction = window.fileMenu.addAction(QtGui.QIcon(self.resourcespath + 'world_explore.png'),
getMessage("openstreamurl-menu-label"))
window.openAction.triggered.connect(self.promptForStreamURL)
window.openAction = window.fileMenu.addAction(QtGui.QIcon(self.resourcespath + 'film_folder_edit.png'),
getMessage("setmediadirectories-menu-label"))
window.openAction.triggered.connect(self.openSetMediaDirectoriesDialog)
window.exitAction = window.fileMenu.addAction(QtGui.QIcon(self.resourcespath + 'cross.png'),
getMessage("exit-menu-label"))