diff options
author | Arno <arno@disconnect.de> | 2017-06-18 15:14:25 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-06-18 15:14:25 +0200 |
commit | aa3883a4c39f4422bb3fb795b117266a39d820af (patch) | |
tree | 2cc6b1b460206cb7cfe869f06e6be9dc76e04627 | |
parent | 764c79b88e9ebf9e7e729aeea0f235d55f5ac77b (diff) | |
download | BeetPlayer-aa3883a4c39f4422bb3fb795b117266a39d820af.tar.gz BeetPlayer-aa3883a4c39f4422bb3fb795b117266a39d820af.tar.bz2 BeetPlayer-aa3883a4c39f4422bb3fb795b117266a39d820af.zip |
List files appropriate for musicbrainz
-rw-r--r-- | playerwidget.cpp | 38 | ||||
-rw-r--r-- | playerwidget.h | 2 |
2 files changed, 29 insertions, 11 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp index ba00af0..a078761 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -69,7 +69,6 @@ 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; @@ -201,8 +200,8 @@ void PlayerWidget::setupGui(){ currentInfoL->addWidget(mCurrentTE); currentInfoGB->setLayout(currentInfoL); - //current left info - QString leftInfoGBS = QString(tr("%1 Selected")).arg(QChar(0x26A5)); + //misc info + QString leftInfoGBS = QString(tr("%1 Misc. %1")).arg(QChar(0x26A5)); QGroupBox *leftInfoGB = new QGroupBox(leftInfoGBS); mLeftTE = new QTextEdit; mLeftTE->setFont(QFont("courier")); @@ -353,6 +352,8 @@ void PlayerWidget::createActions(){ connect(aboutQtA, &QAction::triggered, qApp, &QApplication::aboutQt); helpM->addAction(aboutQtA); helpA->setMenu(helpM); + QAction *miscPrintA = new QAction(QIcon(":/clean_tampon.png"), tr("List selected"), this); + connect(miscPrintA, &QAction::triggered, this, &PlayerWidget::printList); mView->addAction(addToPlayListA); mView->addAction(addToPlayListAndClearA); mView->addAction(Helper::createSeparator(this)); @@ -363,6 +364,8 @@ void PlayerWidget::createActions(){ mView->addAction(mDeselectAllA); mView->addAction(mDeleteFilesA); mView->addAction(Helper::createSeparator(this)); + mView->addAction(miscPrintA); + mView->addAction(Helper::createSeparator(this)); mView->addAction(mRefreshA); mView->addAction(Helper::createSeparator(this)); mView->addAction(randomPlayA); @@ -756,13 +759,6 @@ 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()); @@ -1193,6 +1189,28 @@ void PlayerWidget::playCurrent(const QModelIndex &index){ mTrayIcon->setToolTip(mCurToolTip); } +void PlayerWidget::printList(){ + QModelIndexList sel = mView->selectionModel()->selectedRows(); + if(sel.isEmpty()){ + return; + } + QString output; + foreach(QModelIndex i, sel){ + QString fp = i.data(FullPathRole).toString(); + TagLib::FileRef fr(fp.toUtf8()); + if(!fr.isNull()){ + quint16 track = fr.tag()->track(); + QString title = QString::fromStdWString(fr.tag()->title().toWString()); + int length = fr.audioProperties()->lengthInSeconds(); + int minutes = length / 60; + int seconds = length % 60; + QString t = QString("%1 - %2 (%3:%4)\n").arg(track, 2, 10, QChar('0')).arg(title).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0')); + output.append(t); + } + } + mLeftTE->setText(output); +} + void PlayerWidget::play(const QString &fullPath){ mPlayer->setMedia(QUrl::fromLocalFile(fullPath)); TagLib::FileRef file(QString(fullPath).toUtf8()); diff --git a/playerwidget.h b/playerwidget.h index f5b9741..3f41b49 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -41,7 +41,6 @@ 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(); @@ -65,6 +64,7 @@ class PlayerWidget : public QWidget { void shufflePlayList(); void randomPlay(); void playCurrent(const QModelIndex &index); + void printList(); void mute(bool triggered); void volumeChanged(int volume); |