Increase use of Unicode in strings

This commit is contained in:
Et0h 2016-06-11 13:41:29 +01:00
parent 9ef4cb3b3b
commit 1e9e9609f2
5 changed files with 80 additions and 80 deletions

View File

@ -129,7 +129,7 @@ class SyncplayClient(object):
if constants.DEBUG_MODE and constants.WARN_ABOUT_MISSING_STRINGS: if constants.DEBUG_MODE and constants.WARN_ABOUT_MISSING_STRINGS:
missingStrings = getMissingStrings() missingStrings = getMissingStrings()
if missingStrings is not None and missingStrings is not "": if missingStrings is not None and missingStrings is not "":
self.ui.showDebugMessage("MISSING/UNUSED STRINGS DETECTED:\n{}".format(missingStrings)) self.ui.showDebugMessage(u"MISSING/UNUSED STRINGS DETECTED:\n{}".format(missingStrings))
def initProtocol(self, protocol): def initProtocol(self, protocol):
self._protocol = protocol self._protocol = protocol
@ -953,9 +953,9 @@ class SyncplayUser(object):
def __repr__(self, *args, **kwargs): def __repr__(self, *args, **kwargs):
if self.file: if self.file:
return "{}: {} ({}, {})".format(self.username, self.file['name'], self.file['duration'], self.file['size']) return u"{}: {} ({}, {})".format(self.username, self.file['name'], self.file['duration'], self.file['size'])
else: else:
return "{}".format(self.username) return u"{}".format(self.username)
def setControllerStatus(self, isController): def setControllerStatus(self, isController):
self._controller = isController self._controller = isController
@ -1280,7 +1280,7 @@ class UiManager(object):
def showDebugMessage(self, message): def showDebugMessage(self, message):
if constants.DEBUG_MODE and message.rstrip(): if constants.DEBUG_MODE and message.rstrip():
sys.stderr.write("{}{}\n".format(time.strftime(constants.UI_TIME_FORMAT, time.localtime()),message.rstrip())) sys.stderr.write(u"{}{}\n".format(time.strftime(constants.UI_TIME_FORMAT, time.localtime()),message.rstrip()))
def showMessage(self, message, noPlayer=False, noTimestamp=False, secondaryOSD=False): def showMessage(self, message, noPlayer=False, noTimestamp=False, secondaryOSD=False):
if not noPlayer: self.showOSDMessage(message, duration=constants.OSD_DURATION, secondaryOSD=secondaryOSD) if not noPlayer: self.showOSDMessage(message, duration=constants.OSD_DURATION, secondaryOSD=secondaryOSD)
@ -1353,7 +1353,7 @@ class SyncplayPlaylist():
@wraps(f) @wraps(f)
def wrapper(self, *args, **kwds): def wrapper(self, *args, **kwds):
if not self._client.sharedPlaylistIsEnabled(): if not self._client.sharedPlaylistIsEnabled():
self._ui.showDebugMessage("Tried to use shared playlists when it was disabled!") self._ui.showDebugMessage(u"Tried to use shared playlists when it was disabled!")
return return
return f(self, *args, **kwds) return f(self, *args, **kwds)
return wrapper return wrapper
@ -1640,14 +1640,14 @@ class FileSwitchManager(object):
if dirsToSearch: if dirsToSearch:
# Spin up hard drives to prevent premature timeout # Spin up hard drives to prevent premature timeout
randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+".txt" randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+u".txt"
for directory in dirsToSearch: for directory in dirsToSearch:
if not os.path.isdir(directory): if not os.path.isdir(directory):
self.directorySearchError = getMessage("cannot-find-directory-error").format(directory) self.directorySearchError = getMessage("cannot-find-directory-error").format(directory)
startTime = time.time() startTime = time.time()
if os.path.isfile(os.path.join(directory, randomFilename)): if os.path.isfile(os.path.join(directory, randomFilename)):
randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+".txt" randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+u".txt"
if time.time() - startTime > constants.FOLDER_SEARCH_FIRST_FILE_TIMEOUT: if time.time() - startTime > constants.FOLDER_SEARCH_FIRST_FILE_TIMEOUT:
self.folderSearchEnabled = False self.folderSearchEnabled = False
self.directorySearchError = getMessage("folder-search-first-file-timeout-error").format(directory) self.directorySearchError = getMessage("folder-search-first-file-timeout-error").format(directory)
@ -1688,11 +1688,11 @@ class FileSwitchManager(object):
if highPriority and self.folderSearchEnabled: if highPriority and self.folderSearchEnabled:
directoryList = self.mediaDirectories directoryList = self.mediaDirectories
# Spin up hard drives to prevent premature timeout # Spin up hard drives to prevent premature timeout
randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+".txt" randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+u".txt"
for directory in directoryList: for directory in directoryList:
startTime = time.time() startTime = time.time()
if os.path.isfile(os.path.join(directory, randomFilename)): if os.path.isfile(os.path.join(directory, randomFilename)):
randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+".txt" randomFilename = u"RandomFile"+unicode(random.randrange(10000, 99999))+u".txt"
if not self.folderSearchEnabled: if not self.folderSearchEnabled:
return return
if time.time() - startTime > constants.FOLDER_SEARCH_FIRST_FILE_TIMEOUT: if time.time() - startTime > constants.FOLDER_SEARCH_FIRST_FILE_TIMEOUT:

View File

@ -207,7 +207,7 @@ en = {
"showdifferentroomosd-label" : "Include events in other rooms", "showdifferentroomosd-label" : "Include events in other rooms",
"showslowdownosd-label" :"Include slowing down / reverting notifications", "showslowdownosd-label" :"Include slowing down / reverting notifications",
"language-label" : "Language:", "language-label" : "Language:",
"automatic-language" : "Default ({})", # Default language "automatic-language" : u"Default ({})", # Default language
"showdurationnotification-label" : "Warn about media duration mismatches", "showdurationnotification-label" : "Warn about media duration mismatches",
"basics-label" : "Basics", "basics-label" : "Basics",
"readiness-label" : u"Play/Pause", "readiness-label" : u"Play/Pause",
@ -345,7 +345,7 @@ en = {
"seektime-msgbox-label" : "Jump to specified time (in seconds / min:sec). Use +/- for relative seek.", "seektime-msgbox-label" : "Jump to specified time (in seconds / min:sec). Use +/- for relative seek.",
"ready-tooltip" : "Indicates whether you are ready to watch.", "ready-tooltip" : "Indicates whether you are ready to watch.",
"autoplay-tooltip" : "Auto-play when all users who have readiness indicator are ready and minimum user threshold met.", "autoplay-tooltip" : "Auto-play when all users who have readiness indicator are ready and minimum user threshold met.",
"switch-to-file-tooltip" : "Double click to switch to {}", # Filename "switch-to-file-tooltip" : u"Double click to switch to {}", # Filename
# In-userlist notes (GUI) # In-userlist notes (GUI)
"differentsize-note" : "Different size!", "differentsize-note" : "Different size!",
@ -358,8 +358,8 @@ en = {
# Server notifications # Server notifications
"welcome-server-notification" : "Welcome to Syncplay server, ver. {0}", # version "welcome-server-notification" : "Welcome to Syncplay server, ver. {0}", # version
"client-connected-room-server-notification" : "{0}({2}) connected to room '{1}'", # username, host, room "client-connected-room-server-notification" : u"{0}({2}) connected to room '{1}'", # username, host, room
"client-left-server-notification" : "{0} left server", # name "client-left-server-notification" : u"{0} left server", # name
"no-salt-notification" : "PLEASE NOTE: To allow room operator passwords generated by this server instance to still work when the server is restarted, please add the following command line argument when running the Syncplay server in the future: --salt {}", #Salt "no-salt-notification" : "PLEASE NOTE: To allow room operator passwords generated by this server instance to still work when the server is restarted, please add the following command line argument when running the Syncplay server in the future: --salt {}", #Salt
@ -373,13 +373,13 @@ en = {
"server-disable-ready-argument" : u"disable readiness feature", "server-disable-ready-argument" : u"disable readiness feature",
"server-motd-argument": "path to file from which motd will be fetched", "server-motd-argument": "path to file from which motd will be fetched",
"server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).", "server-messed-up-motd-unescaped-placeholders": "Message of the Day has unescaped placeholders. All $ signs should be doubled ($$).",
"server-messed-up-motd-too-long": "Message of the Day is too long - maximum of {} chars, {} given.", "server-messed-up-motd-too-long": u"Message of the Day is too long - maximum of {} chars, {} given.",
# Server errors # Server errors
"unknown-command-server-error" : "Unknown command {}", # message "unknown-command-server-error" : u"Unknown command {}", # message
"not-json-server-error" : "Not a json encoded string {}", # message "not-json-server-error" : "Not a json encoded string {}", # message
"not-known-server-error" : "You must be known to server before sending this command", "not-known-server-error" : "You must be known to server before sending this command",
"client-drop-server-error" : "Client drop: {} -- {}", # host, error "client-drop-server-error" : u"Client drop: {} -- {}", # host, error
"password-required-server-error" : "Password required", "password-required-server-error" : "Password required",
"wrong-password-server-error" : "Wrong password supplied", "wrong-password-server-error" : "Wrong password supplied",
"hello-server-error" : "Not enough Hello arguments", "hello-server-error" : "Not enough Hello arguments",

View File

@ -76,7 +76,7 @@ class OldMpvPlayer(MpvPlayer):
OSD_QUERY = 'show_text' OSD_QUERY = 'show_text'
def _setProperty(self, property_, value): def _setProperty(self, property_, value):
self._listener.sendLine("no-osd set {} {}".format(property_, value)) self._listener.sendLine(u"no-osd set {} {}".format(property_, value))
def setPaused(self, value): def setPaused(self, value):
if self._paused <> value: if self._paused <> value:

View File

@ -835,27 +835,27 @@ class ConfigDialog(QtGui.QDialog):
self.showSameRoomOSDCheckbox = QCheckBox(getMessage("showsameroomosd-label")) self.showSameRoomOSDCheckbox = QCheckBox(getMessage("showsameroomosd-label"))
self.showSameRoomOSDCheckbox.setObjectName("showSameRoomOSD") self.showSameRoomOSDCheckbox.setObjectName("showSameRoomOSD")
self.showSameRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png")) self.showSameRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + u"chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.showSameRoomOSDCheckbox) self.osdSettingsLayout.addWidget(self.showSameRoomOSDCheckbox)
self.showNonControllerOSDCheckbox = QCheckBox(getMessage("shownoncontrollerosd-label")) self.showNonControllerOSDCheckbox = QCheckBox(getMessage("shownoncontrollerosd-label"))
self.showNonControllerOSDCheckbox.setObjectName("showNonControllerOSD") self.showNonControllerOSDCheckbox.setObjectName("showNonControllerOSD")
self.showNonControllerOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png")) self.showNonControllerOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + u"chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.showNonControllerOSDCheckbox) self.osdSettingsLayout.addWidget(self.showNonControllerOSDCheckbox)
self.showDifferentRoomOSDCheckbox = QCheckBox(getMessage("showdifferentroomosd-label")) self.showDifferentRoomOSDCheckbox = QCheckBox(getMessage("showdifferentroomosd-label"))
self.showDifferentRoomOSDCheckbox.setObjectName("showDifferentRoomOSD") self.showDifferentRoomOSDCheckbox.setObjectName("showDifferentRoomOSD")
self.showDifferentRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png")) self.showDifferentRoomOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + u"chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.showDifferentRoomOSDCheckbox) self.osdSettingsLayout.addWidget(self.showDifferentRoomOSDCheckbox)
self.slowdownOSDCheckbox = QCheckBox(getMessage("showslowdownosd-label")) self.slowdownOSDCheckbox = QCheckBox(getMessage("showslowdownosd-label"))
self.slowdownOSDCheckbox.setObjectName("showSlowdownOSD") self.slowdownOSDCheckbox.setObjectName("showSlowdownOSD")
self.slowdownOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png")) self.slowdownOSDCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + u"chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.slowdownOSDCheckbox) self.osdSettingsLayout.addWidget(self.slowdownOSDCheckbox)
self.showOSDWarningsCheckbox = QCheckBox(getMessage("showosdwarnings-label")) self.showOSDWarningsCheckbox = QCheckBox(getMessage("showosdwarnings-label"))
self.showOSDWarningsCheckbox.setObjectName("showOSDWarnings") self.showOSDWarningsCheckbox.setObjectName("showOSDWarnings")
self.showOSDWarningsCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + "chevrons_right.png")) self.showOSDWarningsCheckbox.setStyleSheet(constants.STYLE_SUBCHECKBOX.format(self.posixresourcespath + u"chevrons_right.png"))
self.osdSettingsLayout.addWidget(self.showOSDWarningsCheckbox) self.osdSettingsLayout.addWidget(self.showOSDWarningsCheckbox)
self.subitems['showOSD'] = ["showSameRoomOSD", "showDifferentRoomOSD", "showSlowdownOSD", "showOSDWarnings", "showNonControllerOSD"] self.subitems['showOSD'] = ["showSameRoomOSD", "showDifferentRoomOSD", "showSlowdownOSD", "showOSDWarnings", "showNonControllerOSD"]
@ -915,20 +915,20 @@ class ConfigDialog(QtGui.QDialog):
self.bottomButtonFrame = QtGui.QFrame() self.bottomButtonFrame = QtGui.QFrame()
self.bottomButtonLayout = QtGui.QHBoxLayout() self.bottomButtonLayout = QtGui.QHBoxLayout()
self.helpButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'help.png'), getMessage("help-label")) self.helpButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + u'help.png'), getMessage("help-label"))
self.helpButton.setObjectName("help") self.helpButton.setObjectName("help")
self.helpButton.setMaximumSize(self.helpButton.sizeHint()) self.helpButton.setMaximumSize(self.helpButton.sizeHint())
self.helpButton.pressed.connect(self.openHelp) self.helpButton.pressed.connect(self.openHelp)
self.resetButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'cog_delete.png'),getMessage("reset-label")) self.resetButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + u'cog_delete.png'),getMessage("reset-label"))
self.resetButton.setMaximumSize(self.resetButton.sizeHint()) self.resetButton.setMaximumSize(self.resetButton.sizeHint())
self.resetButton.setObjectName("reset") self.resetButton.setObjectName("reset")
self.resetButton.pressed.connect(self.resetSettings) self.resetButton.pressed.connect(self.resetSettings)
self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'), getMessage("run-label")) self.runButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + u'accept.png'), getMessage("run-label"))
self.runButton.pressed.connect(self._saveDataAndLeave) self.runButton.pressed.connect(self._saveDataAndLeave)
self.runButton.setToolTip(getMessage("nostore-tooltip")) self.runButton.setToolTip(getMessage("nostore-tooltip"))
self.storeAndRunButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + 'accept.png'), getMessage("storeandrun-label")) self.storeAndRunButton = QtGui.QPushButton(QtGui.QIcon(resourcespath + u'accept.png'), getMessage("storeandrun-label"))
self.storeAndRunButton.pressed.connect(self._runWithoutStoringConfig) self.storeAndRunButton.pressed.connect(self._runWithoutStoringConfig)
self.bottomButtonLayout.addWidget(self.helpButton) self.bottomButtonLayout.addWidget(self.helpButton)
self.bottomButtonLayout.addWidget(self.resetButton) self.bottomButtonLayout.addWidget(self.resetButton)
@ -956,11 +956,11 @@ class ConfigDialog(QtGui.QDialog):
self.tabListLayout = QtGui.QHBoxLayout() self.tabListLayout = QtGui.QHBoxLayout()
self.tabListFrame = QtGui.QFrame() self.tabListFrame = QtGui.QFrame()
self.tabListWidget = QtGui.QListWidget() self.tabListWidget = QtGui.QListWidget()
self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "house.png"),getMessage("basics-label"))) self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + u"house.png"),getMessage("basics-label")))
self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "control_pause_blue.png"),getMessage("readiness-label"))) self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + u"control_pause_blue.png"),getMessage("readiness-label")))
self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "film_link.png"),getMessage("sync-label"))) self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + u"film_link.png"),getMessage("sync-label")))
self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "comments.png"),getMessage("messages-label"))) self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + u"comments.png"),getMessage("messages-label")))
self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + "cog.png"),getMessage("misc-label"))) self.tabListWidget.addItem(QtGui.QListWidgetItem(QtGui.QIcon(self.resourcespath + u"cog.png"),getMessage("misc-label")))
self.tabListLayout.addWidget(self.tabListWidget) self.tabListLayout.addWidget(self.tabListWidget)
self.tabListFrame.setLayout(self.tabListLayout) self.tabListFrame.setLayout(self.tabListLayout)
self.tabListFrame.setFixedWidth(self.tabListFrame.minimumSizeHint().width()) self.tabListFrame.setFixedWidth(self.tabListFrame.minimumSizeHint().width())
@ -1046,15 +1046,15 @@ class ConfigDialog(QtGui.QDialog):
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
resourcespath = utils.findWorkingDir() + "\\resources\\" resourcespath = utils.findWorkingDir() + "\\resources\\"
else: else:
resourcespath = utils.findWorkingDir() + "/resources/" resourcespath = utils.findWorkingDir() + u"/resources/"
self.posixresourcespath = utils.findWorkingDir().replace("\\","/") + "/resources/" self.posixresourcespath = utils.findWorkingDir().replace(u"\\","/") + u"/resources/"
self.resourcespath = resourcespath self.resourcespath = resourcespath
super(ConfigDialog, self).__init__() super(ConfigDialog, self).__init__()
self.setWindowTitle(getMessage("config-window-title")) self.setWindowTitle(getMessage("config-window-title"))
self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & ~Qt.WindowContextHelpButtonHint)
self.setWindowIcon(QtGui.QIcon(resourcespath + "syncplay.png")) self.setWindowIcon(QtGui.QIcon(resourcespath + u"syncplay.png"))
self.stackedLayout = QtGui.QStackedLayout() self.stackedLayout = QtGui.QStackedLayout()
self.stackedFrame = QtGui.QFrame() self.stackedFrame = QtGui.QFrame()

View File

@ -29,12 +29,12 @@ class UserlistItemDelegate(QtGui.QStyledItemDelegate):
currentQAbstractItemModel = indexQModelIndex.model() currentQAbstractItemModel = indexQModelIndex.model()
itemQModelIndex = currentQAbstractItemModel.index(indexQModelIndex.row(), constants.USERLIST_GUI_USERNAME_COLUMN, indexQModelIndex.parent()) itemQModelIndex = currentQAbstractItemModel.index(indexQModelIndex.row(), constants.USERLIST_GUI_USERNAME_COLUMN, indexQModelIndex.parent())
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
resourcespath = utils.findWorkingDir() + "\\resources\\" resourcespath = utils.findWorkingDir() + u"\\resources\\"
else: else:
resourcespath = utils.findWorkingDir() + "/resources/" resourcespath = utils.findWorkingDir() + u"/resources/"
controlIconQPixmap = QtGui.QPixmap(resourcespath + "user_key.png") controlIconQPixmap = QtGui.QPixmap(resourcespath + u"user_key.png")
tickIconQPixmap = QtGui.QPixmap(resourcespath + "tick.png") tickIconQPixmap = QtGui.QPixmap(resourcespath + u"tick.png")
crossIconQPixmap = QtGui.QPixmap(resourcespath + "cross.png") crossIconQPixmap = QtGui.QPixmap(resourcespath + u"cross.png")
roomController = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.USERITEM_CONTROLLER_ROLE) roomController = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.USERITEM_CONTROLLER_ROLE)
userReady = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.USERITEM_READY_ROLE) userReady = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.USERITEM_READY_ROLE)
@ -60,14 +60,14 @@ class UserlistItemDelegate(QtGui.QStyledItemDelegate):
optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+constants.USERLIST_GUI_USERNAME_OFFSET) optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+constants.USERLIST_GUI_USERNAME_OFFSET)
if column == constants.USERLIST_GUI_FILENAME_COLUMN: if column == constants.USERLIST_GUI_FILENAME_COLUMN:
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
resourcespath = utils.findWorkingDir() + "\\resources\\" resourcespath = utils.findWorkingDir() + u"\\resources\\"
else: else:
resourcespath = utils.findWorkingDir() + "/resources/" resourcespath = utils.findWorkingDir() + u"/resources/"
currentQAbstractItemModel = indexQModelIndex.model() currentQAbstractItemModel = indexQModelIndex.model()
itemQModelIndex = currentQAbstractItemModel.index(indexQModelIndex.row(), constants.USERLIST_GUI_FILENAME_COLUMN, indexQModelIndex.parent()) itemQModelIndex = currentQAbstractItemModel.index(indexQModelIndex.row(), constants.USERLIST_GUI_FILENAME_COLUMN, indexQModelIndex.parent())
fileSwitchRole = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.FILEITEM_SWITCH_ROLE) fileSwitchRole = currentQAbstractItemModel.data(itemQModelIndex, Qt.UserRole + constants.FILEITEM_SWITCH_ROLE)
if fileSwitchRole == constants.FILEITEM_SWITCH_FILE_SWITCH: if fileSwitchRole == constants.FILEITEM_SWITCH_FILE_SWITCH:
fileSwitchIconQPixmap = QtGui.QPixmap(resourcespath + "film_go.png") fileSwitchIconQPixmap = QtGui.QPixmap(resourcespath + u"film_go.png")
itemQPainter.drawPixmap ( itemQPainter.drawPixmap (
(optionQStyleOptionViewItem.rect.x()), (optionQStyleOptionViewItem.rect.x()),
optionQStyleOptionViewItem.rect.y(), optionQStyleOptionViewItem.rect.y(),
@ -75,7 +75,7 @@ class UserlistItemDelegate(QtGui.QStyledItemDelegate):
optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+16) optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+16)
elif fileSwitchRole == constants.FILEITEM_SWITCH_STREAM_SWITCH: elif fileSwitchRole == constants.FILEITEM_SWITCH_STREAM_SWITCH:
streamSwitchIconQPixmap = QtGui.QPixmap(resourcespath + "world_go.png") streamSwitchIconQPixmap = QtGui.QPixmap(resourcespath + u"world_go.png")
itemQPainter.drawPixmap ( itemQPainter.drawPixmap (
(optionQStyleOptionViewItem.rect.x()), (optionQStyleOptionViewItem.rect.x()),
optionQStyleOptionViewItem.rect.y(), optionQStyleOptionViewItem.rect.y(),
@ -102,11 +102,11 @@ class MainWindow(QtGui.QMainWindow):
currentQAbstractItemModel = indexQModelIndex.model() currentQAbstractItemModel = indexQModelIndex.model()
currentlyPlayingFile = currentQAbstractItemModel.data(indexQModelIndex, Qt.UserRole + constants.PLAYLISTITEM_CURRENTLYPLAYING_ROLE) currentlyPlayingFile = currentQAbstractItemModel.data(indexQModelIndex, Qt.UserRole + constants.PLAYLISTITEM_CURRENTLYPLAYING_ROLE)
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
resourcespath = utils.findWorkingDir() + "\\resources\\" resourcespath = utils.findWorkingDir() + u"\\resources\\"
else: else:
resourcespath = utils.findWorkingDir() + "/resources/" resourcespath = utils.findWorkingDir() + u"/resources/"
if currentlyPlayingFile: if currentlyPlayingFile:
currentlyplayingIconQPixmap = QtGui.QPixmap(resourcespath + "bullet_right_grey.png") currentlyplayingIconQPixmap = QtGui.QPixmap(resourcespath + u"bullet_right_grey.png")
itemQPainter.drawPixmap ( itemQPainter.drawPixmap (
(optionQStyleOptionViewItem.rect.x()+4), (optionQStyleOptionViewItem.rect.x()+4),
optionQStyleOptionViewItem.rect.y(), optionQStyleOptionViewItem.rect.y(),
@ -324,14 +324,14 @@ class MainWindow(QtGui.QMainWindow):
def showMessage(self, message, noTimestamp=False): def showMessage(self, message, noTimestamp=False):
message = unicode(message) message = unicode(message)
message = message.replace("&", "&amp;").replace('"', "&quot;").replace("<", "&lt;").replace(">", "&gt;") message = message.replace(u"&", u"&amp;").replace(u'"', u"&quot;").replace(u"<", u"&lt;").replace(">", u"&gt;")
message = message.replace("&lt;", "<span style=\"{}\">&lt;".format(constants.STYLE_USERNAME)) message = message.replace(u"&lt;", u"<span style=\"{}\">&lt;".format(constants.STYLE_USERNAME))
message = message.replace("&gt;", "&gt;</span>") message = message.replace(u"&gt;", u"&gt;</span>")
message = message.replace("\n", "<br />") message = message.replace(u"\n", u"<br />")
if noTimestamp: if noTimestamp:
self.newMessage(u"{}<br />".format(message)) self.newMessage(u"{}<br />".format(message))
else: else:
self.newMessage(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message + "<br />") self.newMessage(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message + u"<br />")
@needsClient @needsClient
def getFileSwitchState(self, filename): def getFileSwitchState(self, filename):
@ -404,7 +404,7 @@ class MainWindow(QtGui.QMainWindow):
useritem.setData(isReadyWithFile, Qt.UserRole + constants.USERITEM_READY_ROLE) useritem.setData(isReadyWithFile, Qt.UserRole + constants.USERITEM_READY_ROLE)
if user.file: if user.file:
filesizeitem = QtGui.QStandardItem(formatSize(user.file['size'])) filesizeitem = QtGui.QStandardItem(formatSize(user.file['size']))
filedurationitem = QtGui.QStandardItem("({})".format(formatTime(user.file['duration']))) filedurationitem = QtGui.QStandardItem(u"({})".format(formatTime(user.file['duration'])))
filename = user.file['name'] filename = user.file['name']
if isURL(filename): if isURL(filename):
filename = urllib.unquote(filename) filename = urllib.unquote(filename)
@ -473,9 +473,9 @@ class MainWindow(QtGui.QMainWindow):
def openPlaylistMenu(self, position): def openPlaylistMenu(self, position):
indexes = self.playlist.selectedIndexes() indexes = self.playlist.selectedIndexes()
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
resourcespath = utils.findWorkingDir() + "\\resources\\" resourcespath = utils.findWorkingDir() + u"\\resources\\"
else: else:
resourcespath = utils.findWorkingDir() + "/resources/" resourcespath = utils.findWorkingDir() + u"/resources/"
if len(indexes) > 0: if len(indexes) > 0:
item = self.playlist.selectedIndexes()[0] item = self.playlist.selectedIndexes()[0]
else: else:
@ -486,19 +486,19 @@ class MainWindow(QtGui.QMainWindow):
firstFile = item.sibling(item.row(), 0).data() firstFile = item.sibling(item.row(), 0).data()
if self._syncplayClient.userlist.currentUser.file is None or firstFile <> self._syncplayClient.userlist.currentUser.file["name"]: if self._syncplayClient.userlist.currentUser.file is None or firstFile <> self._syncplayClient.userlist.currentUser.file["name"]:
if isURL(firstFile): if isURL(firstFile):
menu.addAction(QtGui.QPixmap(resourcespath + "world_go.png"), getMessage("openstreamurl-menu-label"), lambda: self.openFile(firstFile)) menu.addAction(QtGui.QPixmap(resourcespath + u"world_go.png"), getMessage("openstreamurl-menu-label"), lambda: self.openFile(firstFile))
else: else:
pathFound = self._syncplayClient.fileSwitch.findFilepath(firstFile) pathFound = self._syncplayClient.fileSwitch.findFilepath(firstFile)
if pathFound: if pathFound:
menu.addAction(QtGui.QPixmap(resourcespath + "film_go.png"), getMessage("openmedia-menu-label"), lambda: self.openFile(pathFound)) menu.addAction(QtGui.QPixmap(resourcespath + u"film_go.png"), getMessage("openmedia-menu-label"), lambda: self.openFile(pathFound))
menu.addAction(QtGui.QPixmap(resourcespath + "delete.png"), getMessage("removefromplaylist-menu-label"), lambda: self.deleteSelectedPlaylistItems()) menu.addAction(QtGui.QPixmap(resourcespath + u"delete.png"), getMessage("removefromplaylist-menu-label"), lambda: self.deleteSelectedPlaylistItems())
menu.addSeparator() menu.addSeparator()
menu.addAction(QtGui.QPixmap(resourcespath + "arrow_switch.png"), getMessage("shuffleplaylist-menuu-label"), lambda: self.shufflePlaylist()) menu.addAction(QtGui.QPixmap(resourcespath + u"arrow_switch.png"), getMessage("shuffleplaylist-menuu-label"), lambda: self.shufflePlaylist())
menu.addAction(QtGui.QPixmap(resourcespath + "arrow_undo.png"), getMessage("undoplaylist-menu-label"), lambda: self.undoPlaylistChange()) menu.addAction(QtGui.QPixmap(resourcespath + u"arrow_undo.png"), getMessage("undoplaylist-menu-label"), lambda: self.undoPlaylistChange())
menu.addAction(QtGui.QPixmap(resourcespath + "film_add.png"),getMessage("addfilestoplaylist-menu-label"), lambda: self.OpenAddFilesToPlaylistDialog()) menu.addAction(QtGui.QPixmap(resourcespath + u"film_add.png"),getMessage("addfilestoplaylist-menu-label"), lambda: self.OpenAddFilesToPlaylistDialog())
menu.addAction(QtGui.QPixmap(resourcespath + "world_add.png"), getMessage("addurlstoplaylist-menu-label"), lambda: self.OpenAddURIsToPlaylistDialog()) menu.addAction(QtGui.QPixmap(resourcespath + u"world_add.png"), getMessage("addurlstoplaylist-menu-label"), lambda: self.OpenAddURIsToPlaylistDialog())
menu.addSeparator() menu.addSeparator()
menu.addAction(QtGui.QPixmap(resourcespath + "film_folder_edit.png"), getMessage("setmediadirectories-menu-label"), lambda: self.openSetMediaDirectoriesDialog()) menu.addAction(QtGui.QPixmap(resourcespath + u"film_folder_edit.png"), getMessage("setmediadirectories-menu-label"), lambda: self.openSetMediaDirectoriesDialog())
menu.exec_(self.playlist.viewport().mapToGlobal(position)) menu.exec_(self.playlist.viewport().mapToGlobal(position))
@ -506,9 +506,9 @@ class MainWindow(QtGui.QMainWindow):
# TODO: Deselect items after right click # TODO: Deselect items after right click
indexes = self.listTreeView.selectedIndexes() indexes = self.listTreeView.selectedIndexes()
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
resourcespath = utils.findWorkingDir() + "\\resources\\" resourcespath = utils.findWorkingDir() + u"\\resources\\"
else: else:
resourcespath = utils.findWorkingDir() + "/resources/" resourcespath = utils.findWorkingDir() + u"/resources/"
if len(indexes) > 0: if len(indexes) > 0:
item = self.listTreeView.selectedIndexes()[0] item = self.listTreeView.selectedIndexes()[0]
else: else:
@ -532,17 +532,17 @@ class MainWindow(QtGui.QMainWindow):
elif username and filename and filename <> getMessage("nofile-note"): elif username and filename and filename <> getMessage("nofile-note"):
if self.config['sharedPlaylistEnabled'] and not self.isItemInPlaylist(filename): if self.config['sharedPlaylistEnabled'] and not self.isItemInPlaylist(filename):
if isURL(filename): if isURL(filename):
menu.addAction(QtGui.QPixmap(resourcespath + "world_add.png"),getMessage("addusersstreamstoplaylist-menu-label").format(shortUsername), lambda: self.addStreamToPlaylist(filename)) menu.addAction(QtGui.QPixmap(resourcespath + u"world_add.png"),getMessage("addusersstreamstoplaylist-menu-label").format(shortUsername), lambda: self.addStreamToPlaylist(filename))
else: else:
menu.addAction(QtGui.QPixmap(resourcespath + "film_add.png"), getMessage("addusersfiletoplaylist-menu-label").format(shortUsername), lambda: self.addStreamToPlaylist(filename)) menu.addAction(QtGui.QPixmap(resourcespath + u"film_add.png"), getMessage("addusersfiletoplaylist-menu-label").format(shortUsername), lambda: self.addStreamToPlaylist(filename))
if self._syncplayClient.userlist.currentUser.file is None or filename <> self._syncplayClient.userlist.currentUser.file["name"]: if self._syncplayClient.userlist.currentUser.file is None or filename <> self._syncplayClient.userlist.currentUser.file["name"]:
if isURL(filename): if isURL(filename):
menu.addAction(QtGui.QPixmap(resourcespath + "world_go.png"), getMessage("openusersstream-menu-label").format(shortUsername), lambda: self.openFile(filename)) menu.addAction(QtGui.QPixmap(resourcespath + u"world_go.png"), getMessage("openusersstream-menu-label").format(shortUsername), lambda: self.openFile(filename))
else: else:
pathFound = self._syncplayClient.fileSwitch.findFilepath(filename) pathFound = self._syncplayClient.fileSwitch.findFilepath(filename)
if pathFound: if pathFound:
menu.addAction(QtGui.QPixmap(resourcespath + "film_go.png"), getMessage("openusersfile-menu-label").format(shortUsername), lambda: self.openFile(pathFound)) menu.addAction(QtGui.QPixmap(resourcespath + u"film_go.png"), getMessage("openusersfile-menu-label").format(shortUsername), lambda: self.openFile(pathFound))
else: else:
return return
menu.exec_(self.listTreeView.viewport().mapToGlobal(position)) menu.exec_(self.listTreeView.viewport().mapToGlobal(position))
@ -627,10 +627,10 @@ class MainWindow(QtGui.QMainWindow):
message = unicode(message) message = unicode(message)
if criticalerror: if criticalerror:
QtGui.QMessageBox.critical(self, "Syncplay", message) QtGui.QMessageBox.critical(self, "Syncplay", message)
message = message.replace("&", "&amp;").replace('"', "&quot;").replace("<", "&lt;").replace(">", "&gt;") message = message.replace(u"&", u"&amp;").replace(u'"', u"&quot;").replace(u"<", u"&lt;").replace(u">", u"&gt;")
message = message.replace("\n", "<br />") message = message.replace(u"\n", u"<br />")
message = "<span style=\"{}\">".format(constants.STYLE_ERRORNOTIFICATION) + message + "</span>" message = u"<span style=\"{}\">".format(constants.STYLE_ERRORNOTIFICATION) + message + u"</span>"
self.newMessage(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message + "<br />") self.newMessage(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message + u"<br />")
@needsClient @needsClient
def joinRoom(self, room=None): def joinRoom(self, room=None):
@ -649,7 +649,7 @@ class MainWindow(QtGui.QMainWindow):
def seekPositionDialog(self): def seekPositionDialog(self):
seekTime, ok = QtGui.QInputDialog.getText(self, getMessage("seektime-menu-label"), seekTime, ok = QtGui.QInputDialog.getText(self, getMessage("seektime-menu-label"),
getMessage("seektime-msgbox-label"), QtGui.QLineEdit.Normal, getMessage("seektime-msgbox-label"), QtGui.QLineEdit.Normal,
"0:00") u"0:00")
if ok and seekTime != '': if ok and seekTime != '':
self.seekPosition(seekTime) self.seekPosition(seekTime)
@ -1103,20 +1103,20 @@ class MainWindow(QtGui.QMainWindow):
window.playbackFrame.setLayout(window.playbackLayout) window.playbackFrame.setLayout(window.playbackLayout)
window.seekInput = QtGui.QLineEdit() window.seekInput = QtGui.QLineEdit()
window.seekInput.returnPressed.connect(self.seekFromButton) window.seekInput.returnPressed.connect(self.seekFromButton)
window.seekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'clock_go.png'), "") window.seekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + u'clock_go.png'), "")
window.seekButton.setToolTip(getMessage("seektime-menu-label")) window.seekButton.setToolTip(getMessage("seektime-menu-label"))
window.seekButton.pressed.connect(self.seekFromButton) window.seekButton.pressed.connect(self.seekFromButton)
window.seekInput.setText("0:00") window.seekInput.setText("0:00")
window.seekInput.setFixedWidth(60) window.seekInput.setFixedWidth(60)
window.playbackLayout.addWidget(window.seekInput) window.playbackLayout.addWidget(window.seekInput)
window.playbackLayout.addWidget(window.seekButton) window.playbackLayout.addWidget(window.seekButton)
window.unseekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'arrow_undo.png'), "") window.unseekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + u'arrow_undo.png'), "")
window.unseekButton.setToolTip(getMessage("undoseek-menu-label")) window.unseekButton.setToolTip(getMessage("undoseek-menu-label"))
window.unseekButton.pressed.connect(self.undoSeek) window.unseekButton.pressed.connect(self.undoSeek)
window.miscLayout = QtGui.QHBoxLayout() window.miscLayout = QtGui.QHBoxLayout()
window.playbackLayout.addWidget(window.unseekButton) window.playbackLayout.addWidget(window.unseekButton)
window.playButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'control_play_blue.png'), "") window.playButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + u'control_play_blue.png'), "")
window.playButton.setToolTip(getMessage("play-menu-label")) window.playButton.setToolTip(getMessage("play-menu-label"))
window.playButton.pressed.connect(self.play) window.playButton.pressed.connect(self.play)
window.playbackLayout.addWidget(window.playButton) window.playbackLayout.addWidget(window.playButton)
@ -1347,7 +1347,7 @@ class MainWindow(QtGui.QMainWindow):
def setPlaylist(self, newPlaylist, newIndexFilename=None): def setPlaylist(self, newPlaylist, newIndexFilename=None):
if self.updatingPlaylist: if self.updatingPlaylist:
self.ui.showDebugMessage("Trying to set playlist while it is already being updated") self.ui.showDebugMessage(u"Trying to set playlist while it is already being updated")
if newPlaylist == self.playlistState: if newPlaylist == self.playlistState:
if newIndexFilename: if newIndexFilename:
self.playlist.setPlaylistIndexFilename(newIndexFilename) self.playlist.setPlaylistIndexFilename(newIndexFilename)
@ -1470,9 +1470,9 @@ class MainWindow(QtGui.QMainWindow):
self.folderSearchEnabled = True self.folderSearchEnabled = True
self.QtGui = QtGui self.QtGui = QtGui
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
self.resourcespath = utils.findWorkingDir() + "\\resources\\" self.resourcespath = utils.findWorkingDir() + u"\\resources\\"
else: else:
self.resourcespath = utils.findWorkingDir() + "/resources/" self.resourcespath = utils.findWorkingDir() + u"/resources/"
self.setWindowFlags(self.windowFlags() & Qt.AA_DontUseNativeMenuBar) self.setWindowFlags(self.windowFlags() & Qt.AA_DontUseNativeMenuBar)
self.setWindowTitle("Syncplay v" + version) self.setWindowTitle("Syncplay v" + version)
self.mainLayout = QtGui.QVBoxLayout() self.mainLayout = QtGui.QVBoxLayout()
@ -1481,7 +1481,7 @@ class MainWindow(QtGui.QMainWindow):
self.addMenubar(self) self.addMenubar(self)
self.addMainFrame(self) self.addMainFrame(self)
self.loadSettings() self.loadSettings()
self.setWindowIcon(QtGui.QIcon(self.resourcespath + "syncplay.png")) self.setWindowIcon(QtGui.QIcon(self.resourcespath + u"syncplay.png"))
self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & Qt.AA_DontUseNativeMenuBar & Qt.WindowMinimizeButtonHint & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & Qt.AA_DontUseNativeMenuBar & Qt.WindowMinimizeButtonHint & ~Qt.WindowContextHelpButtonHint)
self.show() self.show()
self.setAcceptDrops(True) self.setAcceptDrops(True)