Example #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
class Button_SeekBack_PRM():
    def __init__(self, controller):
        self.controller = controller
        self.audioController = AudioController()

    def onClick(self, isLongClick=False):
        if (self.audioController.getGUICoolDown() == False):
            self.audioController.startGUICoolDown(1.1)
            self.audioController.seekDown()

    def createButton(self, sizeX, sizeY):
        button = PicButton(
            QPixmap("themes/default/img/seekback_prm.png"),
            QPixmap("themes/default/img/seekback_prm_pressed.png"), sizeX,
            sizeY, "", self.onClick)

        return button
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