Reformated GUI code

This commit is contained in:
Uriziel 2014-09-07 11:08:00 +02:00
parent 11c53368cb
commit 3ac65efe9c

View File

@ -8,6 +8,7 @@ import re
import os import os
from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration
class MainWindow(QtGui.QMainWindow): class MainWindow(QtGui.QMainWindow):
def addClient(self, client): def addClient(self, client):
self._syncplayClient = client self._syncplayClient = client
@ -55,7 +56,8 @@ class MainWindow(QtGui.QMainWindow):
def showUserList(self, currentUser, rooms): def showUserList(self, currentUser, rooms):
self._usertreebuffer = QtGui.QStandardItemModel() self._usertreebuffer = QtGui.QStandardItemModel()
self._usertreebuffer.setColumnCount(2) self._usertreebuffer.setColumnCount(2)
self._usertreebuffer.setHorizontalHeaderLabels((getMessage("roomuser-heading-label"),getMessage("fileplayed-heading-label"))) self._usertreebuffer.setHorizontalHeaderLabels(
(getMessage("roomuser-heading-label"), getMessage("fileplayed-heading-label")))
usertreeRoot = self._usertreebuffer.invisibleRootItem() usertreeRoot = self._usertreebuffer.invisibleRootItem()
for room in rooms: for room in rooms:
@ -72,7 +74,8 @@ class MainWindow(QtGui.QMainWindow):
useritem = QtGui.QStandardItem(user.username) useritem = QtGui.QStandardItem(user.username)
fileitem = QtGui.QStandardItem("") fileitem = QtGui.QStandardItem("")
if user.file: if user.file:
fileitem = QtGui.QStandardItem(u"{} ({})".format(user.file['name'], formatTime(user.file['duration']))) fileitem = QtGui.QStandardItem(
u"{} ({})".format(user.file['name'], formatTime(user.file['duration'])))
if currentUser.file: if currentUser.file:
sameName = sameFilename(user.file['name'], currentUser.file['name']) sameName = sameFilename(user.file['name'], currentUser.file['name'])
sameSize = sameFilesize(user.file['size'], currentUser.file['size']) sameSize = sameFilesize(user.file['size'], currentUser.file['size'])
@ -83,11 +86,17 @@ class MainWindow(QtGui.QMainWindow):
differentDuration = not sameDuration differentDuration = not sameDuration
if sameName or sameRoom: if sameName or sameRoom:
if differentSize and sameDuration: if differentSize and sameDuration:
fileitem = QtGui.QStandardItem(u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']), getMessage("differentsize-note"))) fileitem = QtGui.QStandardItem(
u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']),
getMessage("differentsize-note")))
elif differentSize and differentDuration: elif differentSize and differentDuration:
fileitem = QtGui.QStandardItem(u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']), getMessage("differentsizeandduration-note"))) fileitem = QtGui.QStandardItem(
u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']),
getMessage("differentsizeandduration-note")))
elif differentDuration: elif differentDuration:
fileitem = QtGui.QStandardItem(u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']), getMessage("differentduration-note"))) fileitem = QtGui.QStandardItem(
u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']),
getMessage("differentduration-note")))
if sameRoom and (differentName or differentSize or differentDuration): if sameRoom and (differentName or differentSize or differentDuration):
fileitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR))) fileitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR)))
else: else:
@ -323,7 +332,8 @@ class MainWindow(QtGui.QMainWindow):
window.roomInput = QtGui.QLineEdit() window.roomInput = QtGui.QLineEdit()
window.roomInput.returnPressed.connect(self.joinRoom) window.roomInput.returnPressed.connect(self.joinRoom)
window.roomButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'door_in.png'), getMessage("joinroom-guibuttonlabel")) window.roomButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'door_in.png'),
getMessage("joinroom-guibuttonlabel"))
window.roomButton.pressed.connect(self.joinRoom) window.roomButton.pressed.connect(self.joinRoom)
window.roomLayout = QtGui.QHBoxLayout() window.roomLayout = QtGui.QHBoxLayout()
window.roomInput.setFixedWidth(150) window.roomInput.setFixedWidth(150)
@ -341,7 +351,8 @@ class MainWindow(QtGui.QMainWindow):
window.seekInput = QtGui.QLineEdit() window.seekInput = QtGui.QLineEdit()
window.seekInput.returnPressed.connect(self.seekPosition) window.seekInput.returnPressed.connect(self.seekPosition)
window.seekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'clock_go.png'),getMessage("seektime-guibuttonlabel")) window.seekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'clock_go.png'),
getMessage("seektime-guibuttonlabel"))
window.seekButton.pressed.connect(self.seekPosition) window.seekButton.pressed.connect(self.seekPosition)
self.seekButton.setToolTip(getMessage("seektime-tooltip")) self.seekButton.setToolTip(getMessage("seektime-tooltip"))
@ -359,23 +370,27 @@ class MainWindow(QtGui.QMainWindow):
def addMiscBox(self, window): def addMiscBox(self, window):
window.miscGroup = QtGui.QGroupBox(getMessage("othercommands-heading-label")) window.miscGroup = QtGui.QGroupBox(getMessage("othercommands-heading-label"))
window.unseekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'arrow_undo.png'),getMessage("undoseek-guibuttonlabel")) window.unseekButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'arrow_undo.png'),
getMessage("undoseek-guibuttonlabel"))
window.unseekButton.pressed.connect(self.undoSeek) window.unseekButton.pressed.connect(self.undoSeek)
self.unseekButton.setToolTip(getMessage("undoseek-tooltip")) self.unseekButton.setToolTip(getMessage("undoseek-tooltip"))
window.miscLayout = QtGui.QHBoxLayout() window.miscLayout = QtGui.QHBoxLayout()
window.miscLayout.addWidget(window.unseekButton) window.miscLayout.addWidget(window.unseekButton)
if constants.MERGE_PLAYPAUSE_BUTTONS == True: if constants.MERGE_PLAYPAUSE_BUTTONS == True:
window.playpauseButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'control_pause_blue.png'),getMessage("togglepause-guibuttonlabel")) window.playpauseButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'control_pause_blue.png'),
getMessage("togglepause-guibuttonlabel"))
window.playpauseButton.pressed.connect(self.togglePause) window.playpauseButton.pressed.connect(self.togglePause)
window.miscLayout.addWidget(window.playpauseButton) window.miscLayout.addWidget(window.playpauseButton)
self.playpauseButton.setToolTip(getMessage("togglepause-tooltip")) self.playpauseButton.setToolTip(getMessage("togglepause-tooltip"))
else: else:
window.playButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'control_play_blue.png'),getMessage("play-guibuttonlabel")) window.playButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'control_play_blue.png'),
getMessage("play-guibuttonlabel"))
window.playButton.pressed.connect(self.play) window.playButton.pressed.connect(self.play)
window.playButton.setMaximumWidth(60) window.playButton.setMaximumWidth(60)
window.miscLayout.addWidget(window.playButton) window.miscLayout.addWidget(window.playButton)
window.pauseButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'control_pause_blue.png'),getMessage("pause-guibuttonlabel")) window.pauseButton = QtGui.QPushButton(QtGui.QIcon(self.resourcespath + 'control_pause_blue.png'),
getMessage("pause-guibuttonlabel"))
window.pauseButton.pressed.connect(self.pause) window.pauseButton.pressed.connect(self.pause)
window.pauseButton.setMaximumWidth(60) window.pauseButton.setMaximumWidth(60)
window.miscLayout.addWidget(window.pauseButton) window.miscLayout.addWidget(window.pauseButton)
@ -390,24 +405,30 @@ class MainWindow(QtGui.QMainWindow):
window.menuBar = QtGui.QMenuBar() window.menuBar = QtGui.QMenuBar()
window.fileMenu = QtGui.QMenu(getMessage("file-menu-label"), self) window.fileMenu = QtGui.QMenu(getMessage("file-menu-label"), self)
window.openAction = window.fileMenu.addAction(QtGui.QIcon(self.resourcespath + 'folder_explore.png'), getMessage("openmedia-menu-label")) window.openAction = window.fileMenu.addAction(QtGui.QIcon(self.resourcespath + 'folder_explore.png'),
getMessage("openmedia-menu-label"))
window.openAction.triggered.connect(self.browseMediapath) window.openAction.triggered.connect(self.browseMediapath)
window.exitAction = window.fileMenu.addAction(QtGui.QIcon(self.resourcespath + 'cross.png'), getMessage("file-menu-label")) window.exitAction = window.fileMenu.addAction(QtGui.QIcon(self.resourcespath + 'cross.png'),
getMessage("file-menu-label"))
window.exitAction.triggered.connect(self.exitSyncplay) window.exitAction.triggered.connect(self.exitSyncplay)
window.menuBar.addMenu(window.fileMenu) window.menuBar.addMenu(window.fileMenu)
window.advancedMenu = QtGui.QMenu(getMessage("advanced-menu-label"), self) window.advancedMenu = QtGui.QMenu(getMessage("advanced-menu-label"), self)
window.setoffsetAction = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'timeline_marker.png'),getMessage("setoffset-menu-label")) window.setoffsetAction = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'timeline_marker.png'),
getMessage("setoffset-menu-label"))
window.setoffsetAction.triggered.connect(self.setOffset) window.setoffsetAction.triggered.connect(self.setOffset)
window.createcontrolledroomAction = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'page_white_key.png'), "&Create controlled room suffix") window.createcontrolledroomAction = window.advancedMenu.addAction(
QtGui.QIcon(self.resourcespath + 'page_white_key.png'), "&Create controlled room suffix")
window.createcontrolledroomAction.triggered.connect(self.createControlledRoom) window.createcontrolledroomAction.triggered.connect(self.createControlledRoom)
window.identifyascontroller = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'key_go.png'), "&Identify as room controller") window.identifyascontroller = window.advancedMenu.addAction(QtGui.QIcon(self.resourcespath + 'key_go.png'),
"&Identify as room controller")
window.identifyascontroller.triggered.connect(self.identifyAsController) window.identifyascontroller.triggered.connect(self.identifyAsController)
window.menuBar.addMenu(window.advancedMenu) window.menuBar.addMenu(window.advancedMenu)
window.helpMenu = QtGui.QMenu(getMessage("help-menu-label"), self) window.helpMenu = QtGui.QMenu(getMessage("help-menu-label"), self)
window.userguideAction = window.helpMenu.addAction(QtGui.QIcon(self.resourcespath + 'help.png'), getMessage("userguide-menu-label")) window.userguideAction = window.helpMenu.addAction(QtGui.QIcon(self.resourcespath + 'help.png'),
getMessage("userguide-menu-label"))
window.userguideAction.triggered.connect(self.openUserGuide) window.userguideAction.triggered.connect(self.openUserGuide)
window.menuBar.addMenu(window.helpMenu) window.menuBar.addMenu(window.helpMenu)
@ -489,6 +510,7 @@ class MainWindow(QtGui.QMainWindow):
self.addMainFrame(self) self.addMainFrame(self)
self.loadSettings() self.loadSettings()
self.setWindowIcon(QtGui.QIcon(self.resourcespath + "syncplay.png")) self.setWindowIcon(QtGui.QIcon(self.resourcespath + "syncplay.png"))
self.setWindowFlags(self.windowFlags() & Qt.WindowCloseButtonHint & Qt.WindowMinimizeButtonHint & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(
self.windowFlags() & Qt.WindowCloseButtonHint & Qt.WindowMinimizeButtonHint & ~Qt.WindowContextHelpButtonHint)
self.show() self.show()
self.setAcceptDrops(True) self.setAcceptDrops(True)