Пример #1
0
class Button_Memory_PRM():

    def __init__(self, buttonId):
        self.buttonId = buttonId
        self.db = RAM_DB()
        self.radioChannels = self.db.getRadioChannels()
        self.audioController = AudioController()

    def onClick(self, isLongClick = False):
        if(self.audioController.getGUICoolDown() == False and isLongClick == False):
            self.audioController.startGUICoolDown(1)
            # If there's an entry in the XML with memorized channel, we assign it to this button/memory bank
            if(self.radioChannels[self.buttonId] != None):
                self.audioController.setCurrentFMFrequency(self.radioChannels[self.buttonId][0])
        elif ((self.audioController.getGUICoolDown() == False and isLongClick == True)):
            # On long click, we memorize the current radio channel to this memory bank :)
            self.db.setRadioChannel(self.buttonId, self.audioController.getCurrentFMFrequency(), self.audioController.getCurrentFMStationName())
            self.radioChannels = self.db.getRadioChannels()
            self.audioController.updateRadioObservers()



    def createButton(self, sizeX, sizeY):
        button = PicButton(QPixmap("themes/default/img/MemoryButton.png"), QPixmap("themes/default/img/MemoryButton_Pressed.png"), sizeX, sizeY, str(self.buttonId), self.onClick)

        return button
Пример #2
0
    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)