diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2020-02-12 09:01:31 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2020-02-12 09:01:31 -0500 |
| commit | df265f7f4cfb8343197ed86f5c20fb2d14c51b0f (patch) | |
| tree | edbd6f6ac6512776f8c798dfaf5b05750f86bef2 /player.cpp | |
| parent | 21f2659dd4d4267f6385fd5492d6e407d8b183a2 (diff) | |
| download | erable-godot-df265f7f4cfb8343197ed86f5c20fb2d14c51b0f.tar.gz erable-godot-df265f7f4cfb8343197ed86f5c20fb2d14c51b0f.tar.bz2 erable-godot-df265f7f4cfb8343197ed86f5c20fb2d14c51b0f.zip | |
Localization and library system in progress
Diffstat (limited to 'player.cpp')
| -rw-r--r-- | player.cpp | 51 |
1 files changed, 34 insertions, 17 deletions
@@ -1,28 +1,41 @@ -#include <QMediaPlayer> -#include <QDebug> -#include <QFileDialog> -#include <QMessageBox> +/* + AleePlayer: Music player in Qt + Copyright (C) 2020 Alee Productions + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ #include "player.h" #include "ui_player.h" #include "about.h" +#include "library.h" void Player::loadFile() { - QString mFile; QMessageBox msgbox; - mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3 *.wav *.ogg *.flac)")); + mFile = QFileDialog::getOpenFileName(this, tr("Open any audio file"), QDir::homePath(), tr("Audio Files (*.mp3 *.wav *.ogg *.flac *.mp4)")); if (mFile == NULL) { - qDebug() << "File cannot be found"; - msgbox.setWindowTitle("Uh oh! An error has occured!"); - msgbox.setText("File is invalid. Maybe try loading a valid audio file."); + qDebug() << tr("File cannot be found"); + msgbox.setWindowTitle(tr("Uh oh! An error has occured!")); + msgbox.setText(tr("File is invalid. Maybe try loading a valid audio file.")); msgbox.setIcon(QMessageBox::Critical); msgbox.exec(); return; } else { mPlayer->setMedia(QUrl::fromLocalFile(mFile)); - qDebug() << "Opening" << mFile; - msgbox.setWindowTitle("Success!"); - msgbox.setText("This audio file has been loaded."); + qDebug() << tr("Opening") << mFile; + msgbox.setWindowTitle(tr("Success!")); + msgbox.setText(tr("This audio file has been loaded.")); msgbox.setIcon(QMessageBox::Information); msgbox.exec(); ui->volumeSlider->setValue(100); @@ -39,6 +52,8 @@ Player::Player(QWidget *parent) { ui->setupUi(this); + ui->library->setModel(new Library()); + connect(mPlayer, &QMediaPlayer::positionChanged, this, &Player::on_positionChanged); connect(mPlayer, &QMediaPlayer::durationChanged, this, &Player::on_durationChanged); @@ -46,7 +61,7 @@ Player::Player(QWidget *parent) Player::~Player() { - qInfo() << "Closing AleePlayer..."; + qInfo() << tr("Closing AleePlayer..."); mPlayer->deleteLater(); delete ui; } @@ -62,20 +77,22 @@ void Player::on_playButton_pressed() ui->volumeSlider->setEnabled(true); if (mPlayer->state() == mPlayer->PlayingState) { - qDebug() << "Pausing music..."; + qDebug() << tr("Pausing music..."); mPlayer->pause(); ui->playButton->setText(tr("Play")); } else { - qDebug() << "Playing music..."; + qDebug() << tr("Playing music..."); mPlayer->play(); ui->playButton->setText(tr("Pause")); + amount++; + //qDebug() << "You have pressed play for" << amount << "time(s)."; } } void Player::on_stopButton_pressed() { - qInfo() << "Stopping music..."; + qInfo() << tr("Stopping music..."); mPlayer->stop(); ui->volumeSlider->setEnabled(false); ui->volumeSlider->setValue(100); @@ -85,7 +102,7 @@ void Player::on_stopButton_pressed() void Player::on_actionAbout_triggered() { - qDebug() << "Opening dialog"; + qDebug() << tr("Opening about dialog"); About about; about.exec(); } |
