diff --git a/buildPy2exe.py b/buildPy2exe.py index 6cbc095..b7c145b 100644 --- a/buildPy2exe.py +++ b/buildPy2exe.py @@ -655,7 +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/film_go.png', 'resources/world_go.png', 'resources/arrow_refresh.png', - 'resources/world_add.png', 'resources/film_add.png' + 'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png' ] resources = ["resources/icon.ico", "resources/syncplay.png"] resources.extend(guiIcons) diff --git a/resources/delete.png b/resources/delete.png new file mode 100644 index 0000000..08f2493 Binary files /dev/null and b/resources/delete.png differ diff --git a/resources/film_add.png b/resources/film_add.png new file mode 100644 index 0000000..40d681f Binary files /dev/null and b/resources/film_add.png differ diff --git a/resources/world_add.png b/resources/world_add.png new file mode 100644 index 0000000..6d0d7f7 Binary files /dev/null and b/resources/world_add.png differ diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 2beac03..8da9b83 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -164,7 +164,7 @@ class MainWindow(QtGui.QMainWindow): def keyPressEvent(self, event): if event.key() == Qt.Key_Delete: - self._remove_selected_items() + self.remove_selected_items() else: super(MainWindow.PlaylistWidget, self).keyPressEvent(event) @@ -173,7 +173,7 @@ class MainWindow(QtGui.QMainWindow): self.takeItem(0) self.insertItems(0, newPlaylist) - def _remove_selected_items(self): + def remove_selected_items(self): for item in self.selectedItems(): self.takeItem(self.row(item)) @@ -538,6 +538,36 @@ class MainWindow(QtGui.QMainWindow): MainWindow.FileSwitchManager.setFilenameWatchlist(self.newWatchlist) self.checkForDisabledDir() + def undoPlaylistChange(self): + self.showErrorMessage("TODO: Undo playlist change!") + + def openPlaylistMenu(self, position): + indexes = self.playlist.selectedIndexes() + if sys.platform.startswith('win'): + resourcespath = utils.findWorkingDir() + "\\resources\\" + else: + resourcespath = utils.findWorkingDir() + "/resources/" + if len(indexes) > 0: + item = self.playlist.selectedIndexes()[0] + else: + item = None + menu = QtGui.QMenu() + + if item: + firstFile = item.sibling(item.row(), 0).data() + if self._syncplayClient.userlist.currentUser.file is None or firstFile <> self._syncplayClient.userlist.currentUser.file["name"]: + if isURL(firstFile): + menu.addAction(QtGui.QPixmap(resourcespath + "world_go.png"), "Open stream", lambda: self.openFile(firstFile)) + else: + pathFound = MainWindow.FileSwitchManager.findFilepath(firstFile) + if pathFound: + menu.addAction(QtGui.QPixmap(resourcespath + "film_go.png"), "Open file", lambda: self.openFile(pathFound)) + menu.addAction(QtGui.QPixmap(resourcespath + "delete.png"), "Remove from playlist", lambda: self.deleteSelectedPlaylistItems()) + menu.addSeparator() + menu.addAction(QtGui.QPixmap(resourcespath + "arrow_undo.png"), "Undo last change to playlist", lambda: self.undoPlaylistChange()) + menu.exec_(self.playlist.viewport().mapToGlobal(position)) + + def openRoomMenu(self, position): # TODO: Deselect items after right click indexes = self.listTreeView.selectedIndexes() @@ -573,7 +603,7 @@ class MainWindow(QtGui.QMainWindow): if self._syncplayClient.userlist.currentUser.file is None or filename <> self._syncplayClient.userlist.currentUser.file["name"]: if isURL(filename): - menu.addAction(QtGui.QPixmap(resourcespath + "world_go.png"), "Open stream {} stream".format(shortUsername), lambda: self.openFile(filename)) + menu.addAction(QtGui.QPixmap(resourcespath + "world_go.png"), "Open {} stream".format(shortUsername), lambda: self.openFile(filename)) else: pathFound = MainWindow.FileSwitchManager.findFilepath(filename) if pathFound: @@ -959,6 +989,9 @@ class MainWindow(QtGui.QMainWindow): window.playlist.setDefaultDropAction(Qt.MoveAction) window.playlist.setDragDropMode(QtGui.QAbstractItemView.InternalMove) window.playlist.doubleClicked.connect(self.playlistItemClicked) + window.playlist.setContextMenuPolicy(Qt.CustomContextMenu) + window.playlist.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) + window.playlist.customContextMenuRequested.connect(self.openPlaylistMenu) self.playlistUpdateTimer = task.LoopingCall(self.playlistChangeCheck) self.playlistUpdateTimer.start(0.1, True) noteFont = QtGui.QFont() @@ -1295,6 +1328,9 @@ class MainWindow(QtGui.QMainWindow): def addFolderToPlaylist(self, folderPath): self.showErrorMessage("Add Folder {}".format(folderPath)) + + def deleteSelectedPlaylistItems(self): + self.playlist.remove_selected_items() def saveSettings(self): settings = QSettings("Syncplay", "MainWindow")