From df265f7f4cfb8343197ed86f5c20fb2d14c51b0f Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Wed, 12 Feb 2020 09:01:31 -0500 Subject: Localization and library system in progress --- player.cpp | 51 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 17 deletions(-) (limited to 'player.cpp') diff --git a/player.cpp b/player.cpp index 632e9e2..fdc41c7 100644 --- a/player.cpp +++ b/player.cpp @@ -1,28 +1,41 @@ -#include -#include -#include -#include +/* + 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 . +*/ #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(); } -- cgit v1.2.3