Skip to content

Commit 16d7065

Browse files
committed
gui: add menu button instead of browse/dload and add fader start/stop
1 parent e32d6e8 commit 16d7065

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

prodj/gui/gui.py

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import logging
33
import math
44
from threading import Lock
5-
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel, QPushButton, QSizePolicy, QHBoxLayout, QVBoxLayout, QWidget
5+
from PyQt5.QtWidgets import QFrame, QGridLayout, QLabel, QMenu, QPushButton, QSizePolicy, QHBoxLayout, QVBoxLayout, QWidget
66
from PyQt5.QtGui import QColor, QPainter, QPixmap
77
from PyQt5.QtCore import pyqtSignal, Qt, QSize
88

@@ -54,6 +54,7 @@ def __init__(self, player_number, parent):
5454
self.time_mode_remain = False
5555
self.show_color_waveform = parent.show_color_waveform
5656
self.show_color_preview = parent.show_color_preview
57+
self.parent_gui = parent
5758

5859
# metadata and player info
5960
self.labels["title"] = QLabel(self)
@@ -79,27 +80,31 @@ def __init__(self, player_number, parent):
7980
self.pixmap_empty.fill(QColor(40,40,40))
8081
self.labels["artwork"].setPixmap(self.pixmap_empty)
8182

82-
# buttons below time/beat bar
83-
self.browse_button = QPushButton("BROWSE", self)
84-
self.browse_button.setFlat(True)
85-
self.browse_button.setStyleSheet("QPushButton { color: white; font: 10px; background-color: black; padding: 1px; border-style: outset; border-radius: 2px; border-width: 1px; border-color: gray; }")
86-
self.download_button = QPushButton("DLOAD", self)
87-
self.download_button.setFlat(True)
88-
self.download_button.setStyleSheet("QPushButton { color: white; font: 10px; background-color: black; padding: 1px; border-style: outset; border-radius: 2px; border-width: 1px; border-color: gray; }")
83+
# menu button
84+
self.menu_button = QPushButton("MENU", self)
85+
self.menu_button.setFlat(True)
86+
self.menu_button.setStyleSheet("QPushButton { color: white; font: 10px; background-color: black; padding: 1px; border-style: outset; border-radius: 2px; border-width: 1px; border-color: gray; }")
87+
88+
self.menu = QMenu(self.menu_button)
89+
action_browse = self.menu.addAction("Browse Media")
90+
action_browse.triggered.connect(self.openBrowseDialog)
91+
action_download = self.menu.addAction("Download track")
92+
action_download.triggered.connect(self.downloadTrack)
93+
action_start = self.menu.addAction("Start playback")
94+
action_start.triggered.connect(self.playbackStart)
95+
action_stop = self.menu.addAction("Stop playback")
96+
action_stop.triggered.connect(self.playbackStop)
97+
self.menu_button.setMenu(self.menu)
8998

9099
self.labels["play_state"] = QLabel(self)
91100
self.labels["play_state"].setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed)
92101

93102
buttons_layout = QHBoxLayout()
94-
buttons_layout.addWidget(self.browse_button)
95-
buttons_layout.addWidget(self.download_button)
103+
buttons_layout.addWidget(self.menu_button)
96104
buttons_layout.addWidget(self.labels["play_state"])
97-
buttons_layout.setStretch(2, 1)
105+
buttons_layout.setStretch(1, 1)
98106
buttons_layout.setSpacing(3)
99107

100-
self.browse_button.clicked.connect(self.openBrowseDialog)
101-
self.download_button.clicked.connect(self.downloadTrack)
102-
103108
# time and beat bar
104109
self.elapsed_label = ClickableLabel("ELAPSED", self)
105110
self.elapsed_label.setStyleSheet("QLabel { color: white; } QLabel:disabled { color: gray; }")
@@ -288,6 +293,12 @@ def downloadTrack(self):
288293
self.parent().prodj.data.get_mount_info(c.loaded_player_number, c.loaded_slot,
289294
c.track_id, self.parent().prodj.nfs.enqueue_download_from_mount_info)
290295

296+
def playbackStart(self):
297+
self.parent_gui.prodj.vcdj.command_fader_start_single(self.player_number, start=True)
298+
299+
def playbackStop(self):
300+
self.parent_gui.prodj.vcdj.command_fader_start_single(self.player_number, start=False)
301+
291302
# make browser dialog close when player window disappears
292303
def hideEvent(self, event):
293304
if self.browse_dialog is not None:

0 commit comments

Comments
 (0)