From eb859ccf5e67b4cc55eba00a5917d5a5f8c6b937 Mon Sep 17 00:00:00 2001 From: Et0h Date: Sun, 4 Oct 2015 20:29:02 +0100 Subject: [PATCH] Add initial code for playlist context menu --- buildPy2exe.py | 2 +- resources/delete.png | Bin 0 -> 715 bytes resources/film_add.png | Bin 0 -> 739 bytes resources/world_add.png | Bin 0 -> 940 bytes syncplay/ui/gui.py | 42 +++++++++++++++++++++++++++++++++++++--- 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 resources/delete.png create mode 100644 resources/film_add.png create mode 100644 resources/world_add.png 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 0000000000000000000000000000000000000000..08f249365afd29594b51210c6e21ba253897505d GIT binary patch literal 715 zcmV;+0yO=JP)C4}Mrzlg<+1Y8PEBfUp0jJpx4B>@E+cy3`^(Gw`Mf+2&yxZm<$to~Vpgvg&QKNR z_f#1(r6svZt%iF?s+n<8X?B&!h3g9Dbb8_=MX}!;HiQSAh`bp^WMl~Z-44teO7W_Y zV4thSL{h;rJY7!l3%5J4H1!tIzB`Dv+YxO(haWeausGZYkI8^hWj6mzo=L0{%;yxzh{5!Htr?51 zvG|W62MzC8BZ76hRpCyO2zOn<%e)K>NHge!-~)Ap33OdWw6hsLYbCxGNt0%wk_2z7 zfyYvXheSG)5HRK1VB~%mq7Dmurw#bi@hEcOr3&G1ZiF*$M=&9nB#VNf&Q^r$4G5kp zTURh&s)E0%5&hyVD}sp<72~zmAY`Y(9aqO6CXF%=zFHGzO-A&I(pE}v70YQxCPJ{Y z4L+?5-crdLn3ZRPEs!A4ehEY3ZRpL~w9>@aMN+{F4dI@v&>(QDHQum!mG~E^$OS8l z!7?%Uwib*ROP67Hw`ika)gX-(8Ia`-u_IEhxG7U<13kSsMW+$lbb2dUMm5p6pa}cjgA+U$^mJ^AjD?&bdi)8~y+Q002ovPDHLkV1g8IMc@Dc literal 0 HcmV?d00001 diff --git a/resources/film_add.png b/resources/film_add.png new file mode 100644 index 0000000000000000000000000000000000000000..40d681feba594596c64e0947b8cae5ce9086f919 GIT binary patch literal 739 zcmV<90v!E`P)GL6il?1Z7P2*|7g?{OO9$@TbH1?j^i>BB&)xBSKKI=BdzS+s=YPijNo#8> z*V5AR)9?3h9JknJv&E~ct9MK$)0#*?;BA_wANhPfI2?{62Z2#lRW+c~=~hJo0)xOm zJRVPmX1?&(C%^N7u`S*k-QpKxJ^Z(|9^Pm)X0%%ELPbRdL;|nZyG-C)6h(2$>2CPu zHV}LVG)@CAV;R;g61NZ@w6lP;HQ#_4pj`q>&t7&BZ`>!@b{&p2>% z;uFft%U6_2<&0b|Pl^NtP7rvQyz7!PR)fwp2bz|(sCys8g|R5kjl@7;mcYXji6kKs z)YjH=1P+m;7l+bqc)r<%r<)y!q^=_J`7#F6mmrhL*y7^iP(eWfClc80_O#V%Wl0vt zwop`5#OLSdv$?ssX_0`yoW)`Zk)#&_^V?|u0JO~k^enKn{t&OHI?)`q?>5}4fxY|e zuBk)XbwFS?n-d0uVVESnbhw2(ueuR>LE$YI0sECfc%li8@ENF@PxkK%^m=`=va)i9 zBrR&;%I)(Q{dgav@drZx=%4f;JlQA+e(wti%o3O;Nv|Gm!E!^6DEAou9&c76g5d9W zURG8Hg+eh;lK%B18OT0MwP%M?*Rq2fby;=r6z($h=w)1caPPQFyo1ux(o9K72}LBL z^bM2>7yD0RfN}3VS(t_E0~tuA()Gf^!c1OX-ojCTB3az0XgskiY+KQ=H}?tm{{Txk VbfZtx1EK%`002ovPDHLkV1hC*Sxo={ literal 0 HcmV?d00001 diff --git a/resources/world_add.png b/resources/world_add.png new file mode 100644 index 0000000000000000000000000000000000000000..6d0d7f74c0d89a5d1975eb65c3e048ace0290daf GIT binary patch literal 940 zcmV;d15^BoP)%?%c;Y_xOF9QVIY7fRV}JLEt>l17rXb zC;_)rpe}tj`1Q{K005d&3V@NxVG|ey-h3^0CX$Y2uaOh_TG3L)SA z^5q{Y0Gd*Yk;&l@aHG5N$^I8}&tW+cTs)R7jj)QaYX>Od5yNKFonUrjc24->neX1Z zQqlo{(Nhh_`Ujf3DM$}r*APOdD#F-=DYy}~ofvDS5RWFFraSw1hv)j=0~p1#4+emb z-#PZGF)#Poq)IgqRGb6_H-zOte!Wa-f1gNt7p*Q&Ut=5B7iU_(xixy%=p8=!>AB|K z6PgiYQx~9`I4Bd`-ZH2}_By5ADbi^dQ@DgQMMO6+E7$01>qP33 z&Vy%>nonQ*X>`xY>R-KbdE9gTpT-w&@@z{Nbw&;8L_l3wQX6(ihFpr3Ekas?*N>kE z;DZ;w;BZq1Ku8DhUH{!*^LOU{T=|Q0Z9TN6Ob)~qjYgRU-KJPBvam75g{wmVTo@nX z-u4`Tqba2Tcl#FWG)4l2eAPSU$OVbxOKKviB! 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")