class Button_Previous_MM(): """ Concrete class of the "Previous" button from the Main Menu Audio Widget. """ def __init__(self): """ Constructor of the Button_Previous_MM Class. """ self.audioController = AudioController() self.audioObject = self.audioController.getAudioObject() def onClick(self, isLongClick=False): """ OnClick method. Describes the behaviour of the button when is pressed. In this case, it switch to the previous song of the list. """ if (self.audioObject.getStatus() != AudioStatus.NOFILE and self.audioController.getPlayingRadio() == False): self.audioController.previousTrack() if (self.audioObject.getStatus() == AudioStatus.NOFILE and self.audioController.getPlayingRadio() == True): if (self.audioController.getGUICoolDown() == False): self.audioController.startGUICoolDown(1.1) self.audioController.seekDown() def createButton(self, sizeX, sizeY): """ This method is a factory of a PicButton object. Creates a button with the described size. :param sizeX: X size of the button. :param sizeY: Y size of the button. :return: Created button object. """ button = PicButton( QPixmap("themes/default/img/previous_pam.png"), QPixmap("themes/default/img/previous_pam_pressed.png"), sizeX, sizeY, "", self.onClick) return button
def __init__(self, parent=None): """ Constructor of the RadioMenuChannelMemory class. """ super(RadioMenuChannelMemory, self).__init__(parent) self.db = RAM_DB() audioController = AudioController() radioChannels = self.db.getRadioChannels() self.memoryButtons = [] self.labelsMemoryButtons = [] for i in range(0, 9): self.memoryButtons.append( Button_Memory_PRM(i).createButton(60, 60)) if (audioController.getPlayingRadio() == False or audioController.getGUICoolDown() == True): self.memoryButtons[i].setOppacity(0.3) for i in range(0, 9): if (radioChannels[i] == None): memoryButtonLabel = "VacĂo" else: memoryButtonLabel = radioChannels[i][1] self.labelsMemoryButtons.append(CustomLabel().createLabel( memoryButtonLabel, Qt.AlignCenter, 7)) hButtonBarBox = QHBoxLayout() hButtonBarBox.addStretch() for i in range(0, len(self.memoryButtons)): vButtonBox = QVBoxLayout() hMemoryButtonBox = QHBoxLayout() hMemoryButtonBox.addStretch() hMemoryButtonBox.addWidget(self.memoryButtons[i]) hMemoryButtonBox.addStretch() vButtonBox.addLayout(hMemoryButtonBox) hMemoryLabelBox = QHBoxLayout() hMemoryLabelBox.addStretch() hMemoryLabelBox.addWidget(self.labelsMemoryButtons[i]) hMemoryLabelBox.addStretch() vButtonBox.addLayout(hMemoryLabelBox) hButtonBarBox.addLayout(vButtonBox) hButtonBarBox.addStretch() self.setLayout(hButtonBarBox)
def __init__(self, controller, parent=None): """ Constructor of the PlayRadioMenu class. :param controller: GUIController object. """ super(PlayRadioMenu, self).__init__(parent) self.controller = controller audioController = AudioController() self.db = RAM_DB() radioMenuChannelMemoryWidget = RadioMenuChannelMemory() # Observer audioController.register(radioMenuChannelMemoryWidget) self.backButton = Button_Back_PRM(self.controller).createButton(269, 100) self.upFreqButton = Button_Upfreq_PRM(self.controller).createButton(60, 60) self.downFreqButton = Button_Downfreq_PRM(self.controller).createButton(60, 60) self.seekBackButton = Button_SeekBack_PRM(self.controller).createButton(60, 60) self.seekForwardButton = Button_SeekForward_PRM(self.controller).createButton(60, 60) if(audioController.getPlayingRadio() == False or audioController.getGUICoolDown() == True): self.upFreqButton.setOppacity(0.3) self.downFreqButton.setOppacity(0.3) self.seekBackButton.setOppacity(0.3) self.seekForwardButton.setOppacity(0.3) audioController.initRadio() self.freqLabel = CustomLabel().createLabel(str(audioController.getCurrentFMFrequency()) + " FM", Qt.AlignCenter, 30) verticalBoxLayout = QVBoxLayout() verticalBoxLayout.setContentsMargins(0, 0, 0, 0) verticalBoxLayout.addStretch() verticalBoxLayout.addStretch() verticalBoxLayout.addWidget(self.freqLabel) verticalBoxLayout.addStretch() hMenuBox = QHBoxLayout() hMenuBox.addStretch() hMenuBox.addWidget(self.seekBackButton) hMenuBox.addStretch() hMenuBox.addWidget(self.downFreqButton) hMenuBox.addStretch() hMenuBox.addWidget(self.upFreqButton) hMenuBox.addStretch() hMenuBox.addWidget(self.seekForwardButton) hMenuBox.addStretch() verticalBoxLayout.addLayout(hMenuBox) verticalBoxLayout.addStretch() verticalBoxLayout.addWidget(radioMenuChannelMemoryWidget) verticalBoxLayout.addStretch() hbox = QHBoxLayout() hbox.addWidget(self.backButton) hbox.addStretch() verticalBoxLayout.addLayout(hbox) self.setLayout(verticalBoxLayout)