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
    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)
Example #3
0
class Button_Downfreq_PRM():

    def __init__(self, controller):
        self.controller = controller
        self.audioController = AudioController()

    def onClick(self, isLongClick = False):
        if (self.audioController.getGUICoolDown() == False):
            self.audioController.previousFrequency()
            self.audioController.startChangeFrequencyThread()

    def createButton(self, sizeX, sizeY):
        button = PicButton(QPixmap("themes/default/img/downfreq_prm.png"), QPixmap("themes/default/img/downfreq_prm_pressed.png"), sizeX, sizeY, "", 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
Example #6
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)