예제 #1
0
class Button_Pause_MM():
    """
    Concrete class of the "Pause" button from the Main Menu Audio Widget.
    """
    def __init__(self):
        """
        Constructor of the Button_Pause_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 pauses the reproduction.
        """

        if (self.audioObject.getStatus() != AudioStatus.NOFILE):
            self.audioController.pause()

    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/pause_pam.png"),
                           QPixmap("themes/default/img/pause_pam_pressed.png"),
                           sizeX, sizeY, "", self.onClick)

        return button
예제 #2
0
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
예제 #3
0
    def __init__(self, controller, parent=None):
        """
        Constructor of the PlayAudioMenu class.

        :param controller: GUIController object.
        """

        super(PlayAudioMenu, self).__init__(parent)

        self.controller = controller
        self.db = RAM_DB()

        backButton = Button_Back_PAM(self.controller).createButton(269, 100)
        self.playButton = Button_Play_PAM(self.controller).createButton(60, 60)
        self.pauseButton = Button_Pause_PAM(self.controller).createButton(
            60, 60)
        nextButton = Button_Next_PAM(self.controller).createButton(60, 60)
        previousButton = Button_Previous_PAM(self.controller).createButton(
            60, 60)

        (self.fileName, self.pathFiles,
         self.metaDataList) = self.db.getAudioDB()
        path = self.pathFiles[self.db.getSelection()]

        audioController = AudioController()
        self.audioObject = audioController.getAudioObject()

        self.textLabel = CustomLabel().createLabel(path, Qt.AlignCenter)
        self.actualTimeLabel = CustomLabel().createLabel(
            "00:00", Qt.AlignCenter)
        self.totalTimeLabel = CustomLabel().createLabel(
            "00:00", Qt.AlignCenter)
        self.timeSlider = TimeSlider(0, 100, 0, self.sliderValueChangedByUser)

        verticalBoxLayout = QVBoxLayout()
        hRepTimeBox = QHBoxLayout()
        hRepButtonsBox = QHBoxLayout()
        hImageBox = QHBoxLayout()
        hButtonsMenuBox = QHBoxLayout()

        verticalBoxLayout.setContentsMargins(0, 0, 0, 0)
        verticalBoxLayout.addStretch()

        verticalBoxLayout.addStretch()
        verticalBoxLayout.addWidget(self.textLabel)
        verticalBoxLayout.addStretch()

        hImageBox.addStretch()
        self.imgQLabel = QLabel()
        self.imgQLabel.setMaximumHeight(150)
        self.imgQLabel.setMaximumWidth(150)

        self.pixmapCover = QPixmap()
        loaded = self.pixmapCover.load(
            getArtworkPath(self.metaDataList[self.db.getSelection()]))

        if (loaded == False):
            self.pixmapCover.load(self.db.getArtworkNotFoundPath())
        self.imgQLabel.setPixmap(self.pixmapCover.scaled(150, 150))

        hImageBox.addWidget(self.imgQLabel)
        hImageBox.addStretch()
        verticalBoxLayout.addLayout(hImageBox)

        verticalBoxLayout.addStretch()

        hRepTimeBox.addWidget(self.actualTimeLabel)
        hRepTimeBox.addStretch()
        hRepTimeBox.addWidget(self.totalTimeLabel)
        verticalBoxLayout.addLayout(hRepTimeBox)
        verticalBoxLayout.addWidget(self.timeSlider)
        verticalBoxLayout.addStretch()

        hRepButtonsBox.addStretch()
        if (self.audioObject.getStatus() == AudioStatus.PAUSED):
            self.pauseButton.hide()
        else:
            self.playButton.hide()
        hRepButtonsBox.addWidget(previousButton)
        hRepButtonsBox.addStretch()
        hRepButtonsBox.addWidget(self.playButton)
        hRepButtonsBox.addWidget(self.pauseButton)
        hRepButtonsBox.addStretch()
        hRepButtonsBox.addWidget(nextButton)
        hRepButtonsBox.addStretch()

        verticalBoxLayout.addLayout(hRepButtonsBox)
        verticalBoxLayout.addStretch()

        hButtonsMenuBox.addWidget(backButton)
        hButtonsMenuBox.addStretch()
        verticalBoxLayout.addLayout(hButtonsMenuBox)

        self.setLayout(verticalBoxLayout)
예제 #4
0
class MainMenuAudioWidget (QWidget):
    """
    This class provides a customized widget for control the music & the radio in the Main Menu.
    """

    __metaclass__ = ABCMeta

    def __init__ (self, parent = None):
        """
        Constructor of the MainMenuAudioWidget class.
        """

        super(MainMenuAudioWidget, self).__init__(parent)
        self.playButton = Button_Play_MM().createButton(60, 60)
        self.pauseButton = Button_Pause_MM().createButton(60, 60)
        self.pauseButton.setOppacity(0.3)

        self.nextButton = Button_Next_MM().createButton(60, 60)
        self.nextButton.setOppacity(0.3)
        self.previousButton = Button_Previous_MM().createButton(60, 60)
        self.previousButton.setOppacity(0.3)
        self.audioController = AudioController()
        self.audioObject = self.audioController.getAudioObject()

        verticalBoxLayout = QVBoxLayout()
        hRepButtonsBox = QHBoxLayout()

        verticalBoxLayout.addStretch()
        self.textLabel = CustomLabel().createLabel("Sin medios de reproducción", Qt.AlignCenter, 13)
        verticalBoxLayout.addWidget(self.textLabel)
        verticalBoxLayout.addStretch()

        hRepButtonsBox.addStretch()
        if (self.audioObject.getStatus() == AudioStatus.PAUSED):
            self.pauseButton.hide()
        else:
            self.playButton.hide()
        hRepButtonsBox.addWidget(self.previousButton)
        hRepButtonsBox.addStretch()
        hRepButtonsBox.addWidget(self.playButton)
        hRepButtonsBox.addWidget(self.pauseButton)
        hRepButtonsBox.addStretch()
        hRepButtonsBox.addWidget(self.nextButton)
        hRepButtonsBox.addStretch()

        verticalBoxLayout.addLayout(hRepButtonsBox)

        self.setLayout(verticalBoxLayout)

    @abstractmethod
    def update(self, *args, **kwargs):
        """
        Update method of the observer pattern.

        :param args: args
        :param kwargs: kwargs
        """

        self.updateView(*args, **kwargs)

    def updateView(self, *args, arg1, arg2):
        """
        Update view method of the observer pattern.

        :param args: Name of the notification.
        :param arg1: Other data.
        :param arg2: Other data.
        """

        if (args[0] == "NewMetaData"):

            if arg2[1] == None:
                titleText = "Artista desconocido" + " - " + arg2[0]
            else:
                titleText = arg2[1] + " - " + arg2[0]

            self.textLabel.setText(titleText)
            self.playButton.hide()
            self.pauseButton.show()
            self.pauseButton.setOppacity(1)
            self.nextButton.setOppacity(1)
            self.previousButton.setOppacity(1)

        elif (args[0] == "AudioPaused"):
            self.playButton.show()
            self.pauseButton.hide()

        elif (args[0] == "AudioResumed"):
            self.playButton.hide()
            self.pauseButton.show()

        elif (args[0] == "UpdateCurrentFMFrequency"):
            self.playButton.hide()
            self.pauseButton.show()
            self.pauseButton.setOppacity(0.3)
            self.textLabel.setText("Radio: " + str(arg1) + " FM")

        elif (args[0] == "CoolDownStarted"):
            self.nextButton.setOppacity(0.3)
            self.previousButton.setOppacity(0.3)


        elif (args[0] == "CoolDownEnded"):
            self.nextButton.setOppacity(1)
            self.previousButton.setOppacity(1)