From 4a571bccfa7119eb81f0e634e7527e18a025c043 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 6 Mar 2017 06:15:55 +0100 Subject: Add view: search --- beetplayer.qrc | 1 + gaping_ass.png | Bin 0 -> 884 bytes playerwidget.cpp | 19 ++++++++++++++----- playerwidget.h | 1 + 4 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 gaping_ass.png diff --git a/beetplayer.qrc b/beetplayer.qrc index ab28cba..7688f96 100644 --- a/beetplayer.qrc +++ b/beetplayer.qrc @@ -23,5 +23,6 @@ belly_right_and_clear.png folder.png splash.png + gaping_ass.png diff --git a/gaping_ass.png b/gaping_ass.png new file mode 100644 index 0000000..18feb02 Binary files /dev/null and b/gaping_ass.png differ diff --git a/playerwidget.cpp b/playerwidget.cpp index b9152d1..62ab6e1 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -75,6 +75,11 @@ void PlayerWidget::setupGui(){ viewByFolderA->setCheckable(true); viewAG->addAction(viewByFolderA); connect(viewByFolderA, SIGNAL(triggered()), this, SLOT(doPopulateByFolder())); + viewAG->addAction(Helper::createSeparator(this)); + mSearchA = new QAction(QIcon(":/gaping_ass.png"), tr("View search"), this); + mSearchA->setCheckable(true); + viewAG->addAction(mSearchA); + connect(mSearchA, SIGNAL(triggered()), this, SLOT(doFilter())); viewTB->addActions(viewAG->actions()); //filter @@ -653,15 +658,19 @@ void PlayerWidget::doPopulateBySong(){ void PlayerWidget::doFilter(){ QString filter = mSearch->text(); - if(filter.isEmpty()){ - mView->setModel(mViewModel); - return; - } - qApp->setOverrideCursor(Qt::BusyCursor); mSearchModel->clear(); mSearchModel->setHorizontalHeaderLabels(QStringList() << tr("Name")); mView->setModel(mSearchModel); mCurrentModel = mSearchModel; + emit viewModeChanged(tr("Search")); + mSearchA->setChecked(true); + if(filter.isEmpty()){ + emit message(QString(tr("No search term set! Cowardly refusing to do anything!"))); + return; + } + QString msg = QString(tr("Searching for \"%1\"")).arg(filter); + emit message(msg); + qApp->setOverrideCursor(Qt::BusyCursor); QStandardItem *root = mSearchModel->invisibleRootItem(); populateByArtist(root, filter); populateByAlbum(root, filter, FilterType); diff --git a/playerwidget.h b/playerwidget.h index b2b8c5e..5713cd0 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -92,6 +92,7 @@ class PlayerWidget : public QWidget { QAction *mPlayA; QAction *mStopA; QAction *mPauseA; + QAction *mSearchA; qint64 mDurSecs; quint64 mPlayListLength; }; -- cgit v1.2.3-70-g09d2