Reformated GUI code
This commit is contained in:
parent
11c53368cb
commit
3ac65efe9c
@ -1,5 +1,5 @@
|
||||
from PySide import QtGui #@UnresolvedImport
|
||||
from PySide.QtCore import Qt, QSettings, QSize, QPoint #@UnresolvedImport
|
||||
from PySide import QtGui # @UnresolvedImport
|
||||
from PySide.QtCore import Qt, QSettings, QSize, QPoint # @UnresolvedImport
|
||||
from syncplay import utils, constants, version
|
||||
from syncplay.messages import getMessage
|
||||
import sys
|
||||
@ -8,6 +8,7 @@ import re
|
||||
import os
|
||||
from syncplay.utils import formatTime, sameFilename, sameFilesize, sameFileduration
|
||||
|
||||
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
def addClient(self, client):
|
||||
self._syncplayClient = client
|
||||
@ -36,9 +37,9 @@ class MainWindow(QtGui.QMainWindow):
|
||||
except ():
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def promptFor(self, prompt=">", message=""):
|
||||
#TODO: Prompt user
|
||||
# TODO: Prompt user
|
||||
return None
|
||||
|
||||
def showMessage(self, message, noTimestamp=False):
|
||||
@ -51,13 +52,14 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.newMessage(message + "<br />")
|
||||
else:
|
||||
self.newMessage(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message + "<br />")
|
||||
|
||||
|
||||
def showUserList(self, currentUser, rooms):
|
||||
self._usertreebuffer = QtGui.QStandardItemModel()
|
||||
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()
|
||||
|
||||
|
||||
for room in rooms:
|
||||
roomitem = QtGui.QStandardItem(room)
|
||||
if room == currentUser.room:
|
||||
@ -65,14 +67,15 @@ class MainWindow(QtGui.QMainWindow):
|
||||
font.setWeight(QtGui.QFont.Bold)
|
||||
roomitem.setFont(font)
|
||||
blankitem = QtGui.QStandardItem("")
|
||||
roomitem.setFlags(roomitem.flags() & ~Qt.ItemIsEditable)
|
||||
roomitem.setFlags(roomitem.flags() & ~Qt.ItemIsEditable)
|
||||
blankitem.setFlags(blankitem.flags() & ~Qt.ItemIsEditable)
|
||||
usertreeRoot.appendRow((roomitem, blankitem))
|
||||
for user in rooms[room]:
|
||||
useritem = QtGui.QStandardItem(user.username)
|
||||
fileitem = QtGui.QStandardItem("")
|
||||
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:
|
||||
sameName = sameFilename(user.file['name'], currentUser.file['name'])
|
||||
sameSize = sameFilesize(user.file['size'], currentUser.file['size'])
|
||||
@ -83,11 +86,17 @@ class MainWindow(QtGui.QMainWindow):
|
||||
differentDuration = not sameDuration
|
||||
if sameName or sameRoom:
|
||||
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:
|
||||
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:
|
||||
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):
|
||||
fileitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR)))
|
||||
else:
|
||||
@ -98,42 +107,42 @@ class MainWindow(QtGui.QMainWindow):
|
||||
font = QtGui.QFont()
|
||||
font.setWeight(QtGui.QFont.Bold)
|
||||
useritem.setFont(font)
|
||||
useritem.setFlags(useritem.flags() & ~Qt.ItemIsEditable)
|
||||
fileitem.setFlags(fileitem.flags() & ~Qt.ItemIsEditable)
|
||||
useritem.setFlags(useritem.flags() & ~Qt.ItemIsEditable)
|
||||
fileitem.setFlags(fileitem.flags() & ~Qt.ItemIsEditable)
|
||||
roomitem.appendRow((useritem, fileitem))
|
||||
|
||||
|
||||
self.listTreeModel = self._usertreebuffer
|
||||
self.listTreeView.setModel(self.listTreeModel)
|
||||
self.listTreeView.setItemsExpandable(False)
|
||||
self.listTreeView.expandAll()
|
||||
self.listTreeView.resizeColumnToContents(0)
|
||||
self.listTreeView.resizeColumnToContents(1)
|
||||
|
||||
|
||||
def roomClicked(self, item):
|
||||
while item.parent().row() != -1:
|
||||
item = item.parent()
|
||||
self.joinRoom(item.sibling(item.row(), 0).data())
|
||||
|
||||
|
||||
def userListChange(self):
|
||||
self._syncplayClient.showUserList()
|
||||
|
||||
|
||||
def showDebugMessage(self, message):
|
||||
print(message)
|
||||
|
||||
def showErrorMessage(self, message, criticalerror = False):
|
||||
|
||||
def showErrorMessage(self, message, criticalerror=False):
|
||||
message = unicode(message)
|
||||
if criticalerror:
|
||||
QtGui.QMessageBox.critical(self,"Syncplay", message)
|
||||
QtGui.QMessageBox.critical(self, "Syncplay", message)
|
||||
message = message.replace("&", "&").replace('"', """).replace("<", "<").replace(">", ">")
|
||||
message = message.replace("\n", "<br />")
|
||||
message = "<span style=\"{}\">".format(constants.STYLE_ERRORNOTIFICATION) + message + "</span>"
|
||||
self.newMessage(time.strftime(constants.UI_TIME_FORMAT, time.localtime()) + message + "<br />")
|
||||
|
||||
def joinRoom(self, room = None):
|
||||
def joinRoom(self, room=None):
|
||||
if room == None:
|
||||
room = self.roomInput.text()
|
||||
if room == "":
|
||||
if self._syncplayClient.userlist.currentUser.file:
|
||||
if self._syncplayClient.userlist.currentUser.file:
|
||||
room = self._syncplayClient.userlist.currentUser.file["name"]
|
||||
else:
|
||||
room = self._syncplayClient.defaultRoom
|
||||
@ -150,45 +159,45 @@ class MainWindow(QtGui.QMainWindow):
|
||||
if t is None:
|
||||
return
|
||||
if sign:
|
||||
t = self._syncplayClient.getGlobalPosition() + sign * t
|
||||
t = self._syncplayClient.getGlobalPosition() + sign * t
|
||||
self._syncplayClient.setPosition(t)
|
||||
|
||||
else:
|
||||
self.showErrorMessage("Invalid seek value")
|
||||
|
||||
|
||||
def undoSeek(self):
|
||||
tmp_pos = self._syncplayClient.getPlayerPosition()
|
||||
self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
|
||||
self._syncplayClient.playerPositionBeforeLastSeek = tmp_pos
|
||||
|
||||
|
||||
def togglePause(self):
|
||||
self._syncplayClient.setPaused(not self._syncplayClient.getPlayerPaused())
|
||||
|
||||
|
||||
def play(self):
|
||||
self._syncplayClient.setPaused(False)
|
||||
|
||||
|
||||
def pause(self):
|
||||
self._syncplayClient.setPaused(True)
|
||||
|
||||
|
||||
def exitSyncplay(self):
|
||||
self._syncplayClient.stop()
|
||||
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.exitSyncplay()
|
||||
self.saveSettings()
|
||||
|
||||
|
||||
def loadMediaBrowseSettings(self):
|
||||
settings = QSettings("Syncplay", "MediaBrowseDialog")
|
||||
settings.beginGroup("MediaBrowseDialog")
|
||||
self.mediadirectory = settings.value("mediadir", "")
|
||||
settings.endGroup()
|
||||
|
||||
|
||||
def saveMediaBrowseSettings(self):
|
||||
settings = QSettings("Syncplay", "MediaBrowseDialog")
|
||||
settings.beginGroup("MediaBrowseDialog")
|
||||
settings.setValue("mediadir", self.mediadirectory)
|
||||
settings.endGroup()
|
||||
|
||||
|
||||
def browseMediapath(self):
|
||||
self.loadMediaBrowseSettings()
|
||||
options = QtGui.QFileDialog.Options()
|
||||
@ -200,12 +209,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
defaultdirectory = QtGui.QDesktopServices.storageLocation(QtGui.QDesktopServices.HomeLocation)
|
||||
else:
|
||||
defaultdirectory = ""
|
||||
browserfilter = "All files (*)"
|
||||
fileName, filtr = QtGui.QFileDialog.getOpenFileName(self,getMessage("browseformedia-label"),defaultdirectory,
|
||||
browserfilter, "", options)
|
||||
browserfilter = "All files (*)"
|
||||
fileName, filtr = QtGui.QFileDialog.getOpenFileName(self, getMessage("browseformedia-label"), defaultdirectory,
|
||||
browserfilter, "", options)
|
||||
if fileName:
|
||||
if sys.platform.startswith('win'):
|
||||
fileName = fileName.replace("/","\\")
|
||||
fileName = fileName.replace("/", "\\")
|
||||
self.mediadirectory = os.path.dirname(fileName)
|
||||
self.saveMediaBrowseSettings()
|
||||
self._syncplayClient._player.openFile(fileName)
|
||||
@ -215,7 +224,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def identifyAsController(self):
|
||||
tooltip = "Enter controller password for this room\r\n(see http://syncplay.pl/guide/ for usage instructions):"
|
||||
name = "Identify as Room Controller"
|
||||
name = "Identify as Room Controller"
|
||||
controlpassword, ok = QtGui.QInputDialog.getText(self, name, tooltip, QtGui.QLineEdit.Normal, "")
|
||||
if ok and controlpassword != '':
|
||||
self._syncplayClient.identifyAsController(controlpassword)
|
||||
@ -228,11 +237,11 @@ class MainWindow(QtGui.QMainWindow):
|
||||
return 1
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def setOffset(self):
|
||||
newoffset, ok = QtGui.QInputDialog.getText(self,getMessage("setoffset-msgbox-label"),
|
||||
getMessage("offsetinfo-msgbox-label"), QtGui.QLineEdit.Normal,
|
||||
"")
|
||||
newoffset, ok = QtGui.QInputDialog.getText(self, getMessage("setoffset-msgbox-label"),
|
||||
getMessage("offsetinfo-msgbox-label"), QtGui.QLineEdit.Normal,
|
||||
"")
|
||||
if ok and newoffset != '':
|
||||
o = re.match(constants.UI_OFFSET_REGEX, "o " + newoffset)
|
||||
if o:
|
||||
@ -241,13 +250,13 @@ class MainWindow(QtGui.QMainWindow):
|
||||
if t is None:
|
||||
return
|
||||
if o.group('sign') == "/":
|
||||
t = self._syncplayClient.getPlayerPosition() - t
|
||||
t = self._syncplayClient.getPlayerPosition() - t
|
||||
elif sign:
|
||||
t = self._syncplayClient.getUserOffset() + sign * t
|
||||
t = self._syncplayClient.getUserOffset() + sign * t
|
||||
self._syncplayClient.setUserOffset(t)
|
||||
else:
|
||||
self.showErrorMessage("Invalid offset value")
|
||||
|
||||
|
||||
def openUserGuide(self):
|
||||
if sys.platform.startswith('linux'):
|
||||
self.QtGui.QDesktopServices.openUrl("http://syncplay.pl/guide/linux/")
|
||||
@ -258,8 +267,8 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def drop(self):
|
||||
self.close()
|
||||
|
||||
def addTopLayout(self, window):
|
||||
|
||||
def addTopLayout(self, window):
|
||||
window.topSplit = QtGui.QSplitter(Qt.Horizontal)
|
||||
|
||||
window.outputLayout = QtGui.QVBoxLayout()
|
||||
@ -269,11 +278,11 @@ class MainWindow(QtGui.QMainWindow):
|
||||
window.outputFrame = QtGui.QFrame()
|
||||
window.outputFrame.setLineWidth(0)
|
||||
window.outputFrame.setMidLineWidth(0)
|
||||
window.outputLayout.setContentsMargins(0,0,0,0)
|
||||
window.outputLayout.setContentsMargins(0, 0, 0, 0)
|
||||
window.outputLayout.addWidget(window.outputlabel)
|
||||
window.outputLayout.addWidget(window.outputbox)
|
||||
window.outputFrame.setLayout(window.outputLayout)
|
||||
|
||||
|
||||
window.listLayout = QtGui.QVBoxLayout()
|
||||
window.listTreeModel = QtGui.QStandardItemModel()
|
||||
window.listTreeView = QtGui.QTreeView()
|
||||
@ -283,7 +292,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
window.listFrame = QtGui.QFrame()
|
||||
window.listFrame.setLineWidth(0)
|
||||
window.listFrame.setMidLineWidth(0)
|
||||
window.listLayout.setContentsMargins(0,0,0,0)
|
||||
window.listLayout.setContentsMargins(0, 0, 0, 0)
|
||||
window.listLayout.addWidget(window.listlabel)
|
||||
window.listLayout.addWidget(window.listTreeView)
|
||||
window.contactLabel = QtGui.QLabel()
|
||||
@ -297,13 +306,13 @@ class MainWindow(QtGui.QMainWindow):
|
||||
window.contactLabel.setOpenExternalLinks(True)
|
||||
window.listLayout.addWidget(window.contactLabel)
|
||||
window.listFrame.setLayout(window.listLayout)
|
||||
|
||||
|
||||
window.topSplit.addWidget(window.outputFrame)
|
||||
window.topSplit.addWidget(window.listFrame)
|
||||
window.topSplit.setStretchFactor(0,4)
|
||||
window.topSplit.setStretchFactor(1,5)
|
||||
window.topSplit.setStretchFactor(0, 4)
|
||||
window.topSplit.setStretchFactor(1, 5)
|
||||
window.mainLayout.addWidget(window.topSplit)
|
||||
window.topSplit.setSizePolicy(QtGui.QSizePolicy.Preferred,QtGui.QSizePolicy.Expanding)
|
||||
window.topSplit.setSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Expanding)
|
||||
|
||||
def addBottomLayout(self, window):
|
||||
window.bottomLayout = QtGui.QHBoxLayout()
|
||||
@ -320,137 +329,149 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def addRoomBox(self, window):
|
||||
window.roomGroup = QtGui.QGroupBox(getMessage("room-heading-label"))
|
||||
|
||||
|
||||
window.roomInput = QtGui.QLineEdit()
|
||||
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.roomLayout = QtGui.QHBoxLayout()
|
||||
window.roomInput.setFixedWidth(150)
|
||||
|
||||
self.roomButton.setToolTip(getMessage("joinroom-tooltip"))
|
||||
|
||||
|
||||
window.roomLayout.addWidget(window.roomInput)
|
||||
window.roomLayout.addWidget(window.roomButton)
|
||||
|
||||
|
||||
window.roomGroup.setLayout(window.roomLayout)
|
||||
window.roomGroup.setFixedSize(window.roomGroup.sizeHint())
|
||||
|
||||
|
||||
def addSeekBox(self, window):
|
||||
window.seekGroup = QtGui.QGroupBox(getMessage("seek-heading-label"))
|
||||
|
||||
|
||||
window.seekInput = QtGui.QLineEdit()
|
||||
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)
|
||||
|
||||
self.seekButton.setToolTip(getMessage("seektime-tooltip"))
|
||||
|
||||
|
||||
window.seekLayout = QtGui.QHBoxLayout()
|
||||
window.seekInput.setText("0:00")
|
||||
window.seekInput.setFixedWidth(60)
|
||||
|
||||
|
||||
window.seekLayout.addWidget(window.seekInput)
|
||||
window.seekLayout.addWidget(window.seekButton)
|
||||
|
||||
|
||||
window.seekGroup.setLayout(window.seekLayout)
|
||||
window.seekGroup.setFixedSize(window.seekGroup.sizeHint())
|
||||
|
||||
|
||||
def addMiscBox(self, window):
|
||||
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)
|
||||
self.unseekButton.setToolTip(getMessage("undoseek-tooltip"))
|
||||
|
||||
window.miscLayout = QtGui.QHBoxLayout()
|
||||
window.miscLayout.addWidget(window.unseekButton)
|
||||
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.miscLayout.addWidget(window.playpauseButton)
|
||||
self.playpauseButton.setToolTip(getMessage("togglepause-tooltip"))
|
||||
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.setMaximumWidth(60)
|
||||
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.setMaximumWidth(60)
|
||||
window.miscLayout.addWidget(window.pauseButton)
|
||||
self.playButton.setToolTip(getMessage("play-tooltip"))
|
||||
self.pauseButton.setToolTip(getMessage("pause-tooltip"))
|
||||
|
||||
|
||||
window.miscGroup.setLayout(window.miscLayout)
|
||||
window.miscGroup.setFixedSize(window.miscGroup.sizeHint())
|
||||
|
||||
|
||||
|
||||
def addMenubar(self, window):
|
||||
window.menuBar = QtGui.QMenuBar()
|
||||
|
||||
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.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.menuBar.addMenu(window.fileMenu)
|
||||
|
||||
|
||||
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.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.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.menuBar.addMenu(window.advancedMenu)
|
||||
|
||||
|
||||
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.menuBar.addMenu(window.helpMenu)
|
||||
window.mainLayout.setMenuBar(window.menuBar)
|
||||
|
||||
|
||||
def addMainFrame(self, window):
|
||||
window.mainFrame = QtGui.QFrame()
|
||||
window.mainFrame.setLineWidth(0)
|
||||
window.mainFrame.setMidLineWidth(0)
|
||||
window.mainFrame.setContentsMargins(0,0,0,0)
|
||||
window.mainFrame.setContentsMargins(0, 0, 0, 0)
|
||||
window.mainFrame.setLayout(window.mainLayout)
|
||||
|
||||
|
||||
window.setCentralWidget(window.mainFrame)
|
||||
|
||||
|
||||
def newMessage(self, message):
|
||||
self.outputbox.moveCursor(QtGui.QTextCursor.End)
|
||||
self.outputbox.insertHtml(message)
|
||||
self.outputbox.moveCursor(QtGui.QTextCursor.End)
|
||||
|
||||
|
||||
def resetList(self):
|
||||
self.listbox.setText("")
|
||||
|
||||
|
||||
def newListItem(self, item):
|
||||
self.listbox.moveCursor(QtGui.QTextCursor.End)
|
||||
self.listbox.insertHtml(item)
|
||||
self.listbox.moveCursor(QtGui.QTextCursor.End)
|
||||
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
data = event.mimeData()
|
||||
urls = data.urls()
|
||||
if urls and urls[0].scheme() == 'file':
|
||||
event.acceptProposedAction()
|
||||
|
||||
|
||||
def dropEvent(self, event):
|
||||
rewindFile = False
|
||||
if QtGui.QDropEvent.proposedAction(event) == Qt.MoveAction:
|
||||
QtGui.QDropEvent.setDropAction(event, Qt.CopyAction) # Avoids file being deleted
|
||||
QtGui.QDropEvent.setDropAction(event, Qt.CopyAction) # Avoids file being deleted
|
||||
rewindFile = True
|
||||
data = event.mimeData()
|
||||
urls = data.urls()
|
||||
if urls and urls[0].scheme() == 'file':
|
||||
if sys.platform.startswith('win'):
|
||||
dropfilepath = unicode(urls[0].path().replace("/", "\\"))[1:] # Removes starting slash
|
||||
dropfilepath = unicode(urls[0].path().replace("/", "\\"))[1:] # Removes starting slash
|
||||
else:
|
||||
dropfilepath = unicode(urls[0].path())
|
||||
if rewindFile == False:
|
||||
@ -459,14 +480,14 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self._syncplayClient.setPosition(0)
|
||||
self._syncplayClient._player.openFile(dropfilepath)
|
||||
self._syncplayClient.setPosition(0)
|
||||
|
||||
|
||||
def saveSettings(self):
|
||||
settings = QSettings("Syncplay", "MainWindow")
|
||||
settings.beginGroup("MainWindow")
|
||||
settings.setValue("size", self.size())
|
||||
settings.setValue("pos", self.pos())
|
||||
settings.endGroup()
|
||||
|
||||
|
||||
def loadSettings(self):
|
||||
settings = QSettings("Syncplay", "MainWindow")
|
||||
settings.beginGroup("MainWindow")
|
||||
@ -489,6 +510,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.addMainFrame(self)
|
||||
self.loadSettings()
|
||||
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.setAcceptDrops(True)
|
||||
Loading…
x
Reference in New Issue
Block a user