From c48008443870d54c28f721ce4db373c6030e8720 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 20 Jan 2020 17:43:02 -0500 Subject: Toggleable pause/play button and license --- .gitignore | 2 ++ about.ui | 19 +++++++++++++++++-- player.cpp | 48 ++++++++++++++++++++++++++---------------------- player.h | 4 +--- player.ui | 35 ++--------------------------------- 5 files changed, 48 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index f147edf..c74505c 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,5 @@ compile_commands.json # QtCreator local machine specific files for imported projects *creator.user* + +build diff --git a/about.ui b/about.ui index 76acb4b..baad897 100644 --- a/about.ui +++ b/about.ui @@ -10,9 +10,24 @@ 391 + + + 516 + 391 + + + + + 516 + 391 + + About + + false + @@ -49,7 +64,7 @@ AleePlayer 0.1 by Alee Productions - + 20 @@ -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> diff --git a/player.cpp b/player.cpp index 0b8d451..c1fa2ec 100644 --- a/player.cpp +++ b/player.cpp @@ -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(); + } } diff --git a/player.h b/player.h index 26a8377..d9d6f6a 100644 --- a/player.h +++ b/player.h @@ -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(); diff --git a/player.ui b/player.ui index 902e4a4..8c50a77 100644 --- a/player.ui +++ b/player.ui @@ -24,7 +24,7 @@ - Play Audio + Play/Pause false @@ -33,7 +33,7 @@ false - + 130 @@ -42,41 +42,10 @@ 34 - - Pause - - - - - - 240 - 20 - 88 - 34 - - Set Media - - - - 30 - 70 - 81 - 31 - - - - - 14 - - - - Nothing - - -- cgit v1.2.3