diff options
author | Ken Moore <ken@pcbsd.org> | 2015-01-17 12:06:18 -0500 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-01-17 12:06:18 -0500 |
commit | 9189b75a3f3a8e3cb56b5d6c85bc261d4f058dda (patch) | |
tree | 5eaa3b46f45f39be074e67f9e6f4784e77dc8846 /lumina-desktop/desktop-plugins | |
parent | Commit a couple loose changes to libLuminaXDG (diff) | |
download | lumina-9189b75a3f3a8e3cb56b5d6c85bc261d4f058dda.tar.gz lumina-9189b75a3f3a8e3cb56b5d6c85bc261d4f058dda.tar.bz2 lumina-9189b75a3f3a8e3cb56b5d6c85bc261d4f058dda.zip |
Quick update to the new audioplayer plugin. Now there is a label which displays the current song number in the rotation (<num>/<total>), and a progressbar shows a rough estimate of how much longer the running song has.
Diffstat (limited to 'lumina-desktop/desktop-plugins')
3 files changed, 37 insertions, 14 deletions
diff --git a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp index 9cd16440..9069eabe 100644 --- a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp +++ b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.cpp @@ -17,6 +17,7 @@ PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::Player ui->setupUi(this); //load the designer form PLAYER = new QMediaPlayer(this); PLAYER->setVolume(100); + PLAYER->setNotifyInterval(1000); //1 second interval (just needs to be a rough estimate) PLAYLIST = new QMediaPlaylist(this); PLAYLIST->setPlaybackMode(QMediaPlaylist::Sequential); PLAYER->setPlaylist(PLAYLIST); @@ -26,9 +27,6 @@ PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::Player addMenu = new QMenu(this); ui->tool_add->setMenu(addMenu); - //infoTimer = new QTimer(this); - //infoTimer->setInterval(30000); //every 30 seconds - updatinglists = false; //start off as false LoadIcons(); @@ -36,10 +34,12 @@ PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::Player currentSongChanged(); //Connect all the signals/slots //connect(infoTimer, SIGNAL(timeout()), this, SLOT(rotateTrackInfo()) ); + connect(PLAYER, SIGNAL(positionChanged(qint64)),this, SLOT(updateProgress(qint64)) ); + connect(PLAYER, SIGNAL(durationChanged(qint64)), this, SLOT(updateMaxProgress(qint64)) ); connect(PLAYLIST, SIGNAL(mediaChanged(int, int)), this, SLOT(playlistChanged()) ); connect(PLAYER, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(playerStateChanged()) ); connect(PLAYLIST, SIGNAL(currentMediaChanged(const QMediaContent&)), this, SLOT(currentSongChanged()) ); - connect(ui->combo_playlist, SIGNAL(currentIndexChanged(int)), this, SLOT(userListSelectionChanged()) ); + connect(ui->combo_playlist, SIGNAL(currentIndexChanged(int)), this, SLOT(userlistSelectionChanged()) ); connect(ui->tool_play, SIGNAL(clicked()), this, SLOT(playClicked()) ); connect(ui->tool_pause, SIGNAL(clicked()), this, SLOT(pauseClicked()) ); connect(ui->tool_stop, SIGNAL(clicked()), this, SLOT(stopClicked()) ); @@ -148,19 +148,19 @@ void PlayerWidget::playerStateChanged(){ ui->tool_stop->setVisible(false); ui->tool_play->setVisible(true); ui->tool_pause->setVisible(false); - //infoTimer->stop(); + ui->progressBar->setVisible(false); break; case QMediaPlayer::PausedState: ui->tool_stop->setVisible(true); ui->tool_play->setVisible(true); ui->tool_pause->setVisible(false); - //infoTimer->stop(); + ui->progressBar->setVisible(true); break; case QMediaPlayer::PlayingState: ui->tool_stop->setVisible(true); ui->tool_play->setVisible(false); ui->tool_pause->setVisible(true); - //infoTimer->start(); + ui->progressBar->setVisible(true); break; } @@ -191,13 +191,19 @@ void PlayerWidget::currentSongChanged(){ } ui->tool_next->setEnabled( PLAYLIST->nextIndex() >= 0 ); ui->tool_prev->setEnabled( PLAYLIST->previousIndex() >= 0); - //rotateTrackInfo(); + ui->label_num->setText( QString::number( PLAYLIST->currentIndex()+1)+"/"+QString::number(PLAYLIST->mediaCount()) ); + ui->progressBar->setRange(0, PLAYER->duration() ); + ui->progressBar->setValue(0); +} + +void PlayerWidget::updateProgress(qint64 val){ + //qDebug() << "Update Progress Bar:" << val; + ui->progressBar->setValue(val); } -/*void PlayerWidget::rotateTrackInfo(){ //on a timer to rotate the visible information about the track - //NOTE: QMediaPlayer is a type of QMediaObject - so just pull the current info straight out of the player - ui->label_info->clear(); -}*/ +void PlayerWidget::updateMaxProgress(qint64 val){ + ui->progressBar->setRange(0,val); +} AudioPlayerPlugin::AudioPlayerPlugin(QWidget *parent, QString ID) : LDPlugin(parent, ID){ diff --git a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.h b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.h index d50f8c26..eaa068ff 100644 --- a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.h +++ b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.h @@ -34,7 +34,6 @@ private: Ui::PlayerWidget *ui; QMediaPlaylist *PLAYLIST; QMediaPlayer *PLAYER; - //QTimer *infoTimer; QMenu *configMenu, *addMenu; bool updatinglists; @@ -54,7 +53,8 @@ private slots: void playerStateChanged(); void playlistChanged(); //list of items changed void currentSongChanged(); - //void rotateTrackInfo(); //on a timer to rotate the visible information about the track + void updateProgress(qint64 val); + void updateMaxProgress(qint64 val); }; // Wrapper class to put this into a desktop plugin container diff --git a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.ui b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.ui index 40ad11b5..aa8cbd8b 100644 --- a/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.ui +++ b/lumina-desktop/desktop-plugins/audioplayer/PlayerWidget.ui @@ -85,6 +85,13 @@ QToolButton::menu-indicator{ image: none; }</string> </widget> </item> <item> + <widget class="QLabel" name="label_num"> + <property name="text"> + <string notr="true">1/10</string> + </property> + </widget> + </item> + <item> <widget class="QToolButton" name="tool_next"> <property name="text"> <string notr="true">next</string> @@ -132,6 +139,16 @@ QToolButton::menu-indicator{ image: none; }</string> </property> </spacer> </item> + <item> + <widget class="QProgressBar" name="progressBar"> + <property name="value"> + <number>24</number> + </property> + <property name="textVisible"> + <bool>false</bool> + </property> + </widget> + </item> </layout> </item> </layout> |