From 3ded08ff5b68d5a66a0032d85480ede7dd07dcab Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 5 May 2017 21:33:42 +0200 Subject: 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! --- playerwidget.cpp | 19 +++++++++++++++++++ playerwidget.h | 3 +++ 2 files changed, 22 insertions(+) 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(); -- cgit v1.2.3-70-g09d2