summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2017-05-05 21:33:42 +0200
committerArno <arno@disconnect.de>2017-05-05 21:33:42 +0200
commit3ded08ff5b68d5a66a0032d85480ede7dd07dcab (patch)
tree6ab7968ef486f7c0f2c0d30a1abecb885d55b197
parentf942c5c9e1fe6d8d1fdddb3f5864251f11dd4818 (diff)
downloadBeetPlayer-3ded08ff5b68d5a66a0032d85480ede7dd07dcab.tar.gz
BeetPlayer-3ded08ff5b68d5a66a0032d85480ede7dd07dcab.tar.bz2
BeetPlayer-3ded08ff5b68d5a66a0032d85480ede7dd07dcab.zip
Display properties of selection
either left or right. Worked immediately. There have to be subtle bugs or something. Cannot believe that it's bug free!
-rw-r--r--playerwidget.cpp19
-rw-r--r--playerwidget.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 78b2531..f34725a 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -69,6 +69,7 @@ void PlayerWidget::setupGui(){
mSearchModel = new QStandardItemModel;
mView->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(mView, &BeetView::doubleClicked, this, &PlayerWidget::viewDoubleClicked);
+ connect(mView->selectionModel(), &QItemSelectionModel::currentChanged, this, &PlayerWidget::leftCurrentChanged);
mFolderModel = new QStandardItemModel;
mCurrentModel = mViewModel;
QToolBar *viewTB = new QToolBar;
@@ -258,6 +259,7 @@ void PlayerWidget::setupGui(){
mPlayListView->setRootIsDecorated(false);
mPlayListView->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(mPlayListView, &BeetView::doubleClicked, this, &PlayerWidget::playCurrent);
+ connect(mPlayListView->selectionModel(), &QItemSelectionModel::currentChanged, this, &PlayerWidget::rightCurrentChanged);
QGroupBox *playListGB = new QGroupBox(tr("Playlist"));
QVBoxLayout *playListL = new QVBoxLayout;
playListL->addWidget(mPlayListView);
@@ -751,6 +753,20 @@ void PlayerWidget::viewDoubleClicked(const QModelIndex &idx){
}
}
+void PlayerWidget::leftCurrentChanged(const QModelIndex &cur, const QModelIndex &prev){
+ Q_UNUSED(prev)
+ QString fullPath(cur.data(FullPathRole).toString());
+ TagLib::FileRef file(QString(fullPath).toUtf8());
+ fillWithText(mLeftTE, file);
+}
+
+void PlayerWidget::rightCurrentChanged(const QModelIndex &cur, const QModelIndex &prev){
+ Q_UNUSED(prev)
+ QString fullPath(cur.data(FullPathRole).toString());
+ TagLib::FileRef file(QString(fullPath).toUtf8());
+ fillWithText(mRightTE, file);
+}
+
void PlayerWidget::doPlay(){
if(mPlayer->state() == QMediaPlayer::PausedState){
mPlayer->play();
@@ -885,6 +901,9 @@ void PlayerWidget::adjustVolume(int by){
}
void PlayerWidget::fillWithText(QTextEdit *te, const TagLib::FileRef &fr){
+ if(fr.isNull()){
+ return;
+ }
QString artist = QString::fromStdWString(fr.tag()->artist().toWString());
QString album = QString::fromStdWString(fr.tag()->album().toWString());
QString title = QString::fromStdWString(fr.tag()->title().toWString());
diff --git a/playerwidget.h b/playerwidget.h
index fb62240..f5b9741 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -41,6 +41,8 @@ class PlayerWidget : public QWidget {
void doPopulateByFolder();
void doModelChanged();
void viewDoubleClicked(const QModelIndex &idx);
+ void leftCurrentChanged(const QModelIndex &cur, const QModelIndex &prev);
+ void rightCurrentChanged(const QModelIndex &cur, const QModelIndex &prev);
void doPlay();
void doStop();
void doPause();
@@ -63,6 +65,7 @@ class PlayerWidget : public QWidget {
void shufflePlayList();
void randomPlay();
void playCurrent(const QModelIndex &index);
+
void mute(bool triggered);
void volumeChanged(int volume);
void next();