summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--playerwidget.cpp27
-rw-r--r--playerwidget.h1
2 files changed, 25 insertions, 3 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 7e70125..800c142 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -16,6 +16,8 @@
#include <QToolBar>
#include <algorithm>
+#include <taglib/fileref.h>
+#include <taglib/tag.h>
#include "playerwidget.h"
#include "beetview.h"
@@ -84,7 +86,7 @@ void PlayerWidget::setupGui(){
//current info
QGroupBox *currentInfoGB = new QGroupBox(tr("Current"));
mCurrentTE = new QTextEdit;
- mCurrentTE->setReadOnly(true);
+ mCurrentTE->setFont(QFont("courier"));
QVBoxLayout *currentInfoL = new QVBoxLayout;
currentInfoL->addWidget(mCurrentTE);
currentInfoGB->setLayout(currentInfoL);
@@ -466,6 +468,24 @@ void PlayerWidget::playCurrent(const QModelIndex &index){
void PlayerWidget::play(const QString &fullPath){
mPlayer->setMedia(QUrl::fromLocalFile(fullPath));
+ mCurrentTE->clear();
+ TagLib::FileRef file(QString(fullPath).toUtf8());
+ QString artist = QString::fromStdWString(file.tag()->artist().toWString());
+ QString album = QString::fromStdWString(file.tag()->album().toWString());
+ QString title = QString::fromStdWString(file.tag()->title().toWString());
+ QString genre = QString::fromStdWString(file.tag()->genre().toWString());
+ quint16 track = file.tag()->track();
+ quint16 year = file.tag()->year();
+ mNowPlayingL->setText(title);
+ mCurrentTE->append(QString("%1 %2").arg(tr("Artist:"), -20).arg(artist));
+ mCurrentTE->append(QString("%1 %2").arg(tr("Album:"), -20).arg(album));
+ mCurrentTE->append(QString("%1 %2").arg(tr("Title:"), -20).arg(title));
+ mCurrentTE->append(QString("%1 %2").arg(tr("Genre:"), -20).arg(genre));
+ mCurrentTE->append(QString("%1 %2").arg(tr("Track:"), -20).arg(track, 3, 10, QChar('0')));
+ mCurrentTE->append(QString("%1 %2").arg(tr("Year:"), -20).arg(year, 4, 10));
+ int minutes = mDurSecs / 60;
+ int seconds = mDurSecs % 60;
+ mCurrentTE->append(QString("%1 %2:%3").arg(tr("Length:"), -20).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0')));
mPlayA->trigger();
}
@@ -487,6 +507,7 @@ void PlayerWidget::previous(){
}
void PlayerWidget::advance(int numSongs){
+ mStopA->trigger();
QModelIndexList sel = mPlayListView->selectionModel()->selectedRows();
if(sel.isEmpty()){
QStandardItem *root = mPlayListModel->invisibleRootItem();
@@ -524,9 +545,9 @@ void PlayerWidget::setPosition(qint64 pos){
}
void PlayerWidget::setDuration(qint64 dur){
- qint64 durSecs = dur / 1000;
+ mDurSecs = dur / 1000;
mSongSlider->setMinimum(0);
- mSongSlider->setMaximum(durSecs);
+ mSongSlider->setMaximum(mDurSecs);
}
void PlayerWidget::continuePlaying(QMediaPlayer::State state){
diff --git a/playerwidget.h b/playerwidget.h
index 668e965..103f219 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -70,6 +70,7 @@ class PlayerWidget : public QWidget {
QToolBar *mToolBar;
QAction *mPlayA;
QAction *mStopA;
+ qint64 mDurSecs;
};
#endif // PLAYERWIDGET_H