diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-01-20 17:43:02 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-01-20 17:43:02 -0500 |
| commit | c48008443870d54c28f721ce4db373c6030e8720 (patch) | |
| tree | f2d8a27e096ddea109132f41f8d0659713a76895 | |
| parent | a8e0d6dea2da5b59d7404a3581a2e96acc747b2a (diff) | |
| download | erable-godot-c48008443870d54c28f721ce4db373c6030e8720.tar.gz erable-godot-c48008443870d54c28f721ce4db373c6030e8720.tar.bz2 erable-godot-c48008443870d54c28f721ce4db373c6030e8720.zip | |
Toggleable pause/play button and license
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | about.ui | 19 | ||||
| -rw-r--r-- | player.cpp | 48 | ||||
| -rw-r--r-- | player.h | 4 | ||||
| -rw-r--r-- | player.ui | 35 |
5 files changed, 48 insertions, 60 deletions
@@ -50,3 +50,5 @@ compile_commands.json # QtCreator local machine specific files for imported projects *creator.user* + +build @@ -10,9 +10,24 @@ <height>391</height> </rect> </property> + <property name="minimumSize"> + <size> + <width>516</width> + <height>391</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>516</width> + <height>391</height> + </size> + </property> <property name="windowTitle"> <string>About</string> </property> + <property name="modal"> + <bool>false</bool> + </property> <widget class="QLabel" name="label_2"> <property name="geometry"> <rect> @@ -49,7 +64,7 @@ <string>AleePlayer 0.1 by Alee Productions</string> </property> </widget> - <widget class="QTextEdit" name="textEdit"> + <widget class="QTextEdit" name="licenseText"> <property name="geometry"> <rect> <x>20</x> @@ -68,7 +83,7 @@ p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;"> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans';"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans';"> AleePlayer: Music player in Qt </span></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans';"> Copyright (C) 2020 Alee Productions</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans';"> Copyright (C) 2020 Alee Productions</span></p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Noto Sans';"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans';"> This program is free software: you can redistribute it and/or modify</span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Noto Sans';"> it under the terms of the GNU General Public License as published by</span></p> @@ -29,37 +29,36 @@ void Player::on_actionQuit_triggered() void Player::on_playButton_pressed() { - QPushButton mPlay; - - qDebug() << "Playing music..."; - - mPlayer->play(); + if (mPlayer->state() == mPlayer->PlayingState) { + qDebug() << "Pausing music..."; + mPlayer->pause(); + } else { + qDebug() << "Playing music..."; + mPlayer->play(); + } } void Player::on_actionAbout_triggered() { qDebug() << "Opening dialog"; About about; - about.setModal(true); about.exec(); } -void Player::on_pauseButton_pressed() -{ - qDebug() << "Pausing music..."; - mPlayer->pause(); -} - - -void Player::on_pushButton_pressed() +void Player::on_mediaButton_pressed() { QString mFile; QMessageBox msgbox; mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3)")); - mPlayer->setMedia(QUrl::fromLocalFile(mFile)); - qDebug() << "Opening" << mFile; - msgbox.setText("This audio file has been loaded."); - msgbox.exec(); + if (mFile == NULL) { + msgbox.setText("File is invalid."); + return; + } else { + mPlayer->setMedia(QUrl::fromLocalFile(mFile)); + qDebug() << "Opening" << mFile; + msgbox.setText("This audio file has been loaded."); + msgbox.exec(); + } } void Player::on_actionOpen_triggered() @@ -67,8 +66,13 @@ void Player::on_actionOpen_triggered() QString mFile; QMessageBox msgbox; mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3)")); - mPlayer->setMedia(QUrl::fromLocalFile(mFile)); - qDebug() << "Opening" << mFile; - msgbox.setText("This audio file has been loaded."); - msgbox.exec(); + if (mFile == NULL) { + msgbox.setText("File is invalid."); + return; + } else { + mPlayer->setMedia(QUrl::fromLocalFile(mFile)); + qDebug() << "Opening" << mFile; + msgbox.setText("This audio file has been loaded."); + msgbox.exec(); + } } @@ -24,9 +24,7 @@ private slots: void on_actionAbout_triggered(); - void on_pauseButton_pressed(); - - void on_pushButton_pressed(); + void on_mediaButton_pressed(); void on_actionOpen_triggered(); @@ -24,7 +24,7 @@ </rect> </property> <property name="text"> - <string>Play Audio</string> + <string>Play/Pause</string> </property> <property name="checkable"> <bool>false</bool> @@ -33,7 +33,7 @@ <bool>false</bool> </property> </widget> - <widget class="QPushButton" name="pauseButton"> + <widget class="QPushButton" name="mediaButton"> <property name="geometry"> <rect> <x>130</x> @@ -43,40 +43,9 @@ </rect> </property> <property name="text"> - <string>Pause</string> - </property> - </widget> - <widget class="QPushButton" name="pushButton"> - <property name="geometry"> - <rect> - <x>240</x> - <y>20</y> - <width>88</width> - <height>34</height> - </rect> - </property> - <property name="text"> <string>Set Media</string> </property> </widget> - <widget class="QLabel" name="titleLabel"> - <property name="geometry"> - <rect> - <x>30</x> - <y>70</y> - <width>81</width> - <height>31</height> - </rect> - </property> - <property name="font"> - <font> - <pointsize>14</pointsize> - </font> - </property> - <property name="text"> - <string>Nothing</string> - </property> - </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> |
