summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp38
1 files changed, 28 insertions, 10 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());