summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--beetplayer.qrc1
-rw-r--r--male_chastity_belt.pngbin0 -> 927 bytes
-rw-r--r--playerwidget.cpp28
-rw-r--r--playerwidget.h1
4 files changed, 30 insertions, 0 deletions
diff --git a/beetplayer.qrc b/beetplayer.qrc
index beb3cd5..83c18e5 100644
--- a/beetplayer.qrc
+++ b/beetplayer.qrc
@@ -30,5 +30,6 @@
<file>sissyd.png</file>
<file>quadd.png</file>
<file>dog_hood.png</file>
+ <file>male_chastity_belt.png</file>
</qresource>
</RCC>
diff --git a/male_chastity_belt.png b/male_chastity_belt.png
new file mode 100644
index 0000000..ca3a859
--- /dev/null
+++ b/male_chastity_belt.png
Binary files differ
diff --git a/playerwidget.cpp b/playerwidget.cpp
index 451b0c8..da91986 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -378,6 +378,8 @@ void PlayerWidget::createActions(){
connect(miscFilterFromPlaylistA, &QAction::triggered, this, &PlayerWidget::filterFromPlaylist);
QAction *addToWebRadioA = new QAction(QIcon(":/dog_hood.png"), tr("Add Webradio"), this);
connect(addToWebRadioA, &QAction::triggered, this, &PlayerWidget::addWebRadio);
+ QAction *addToFavoritesA = new QAction(QIcon(":/male_chastity_belt.png"), tr("Add to Favorites"), this);
+ connect(addToFavoritesA, &QAction::triggered, this, &PlayerWidget::addToFavorites);
mView->addAction(addToPlayListA);
mView->addAction(addToPlayListAndClearA);
mView->addAction(Helper::createSeparator(this));
@@ -403,6 +405,8 @@ void PlayerWidget::createActions(){
mPlayListView->addAction(Helper::createSeparator(this));
mPlayListView->addAction(shufflePlayistA);
mPlayListView->addAction(clearPlayListA);
+ mPlayListView->addAction(Helper::createSeparator(this));
+ mPlayListView->addAction(addToFavoritesA);
QWidget* spacer1 = new QWidget();
spacer1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
mToolBar->addWidget(spacer1);
@@ -1040,6 +1044,7 @@ void PlayerWidget::addSong(const QModelIndex &idx){
item->setData(len, LengthRole);
item->setData(artist, ArtistRole);
item->setData(album, AlbumRole);
+ item->setData(title, TitleRole);
root->appendRow(item);
mPlayListLength += len;
}
@@ -1224,6 +1229,28 @@ void PlayerWidget::removeFromPlayList(){
emit playListLengthChanged(mPlayListLength);
}
+void PlayerWidget::addToFavorites(){
+ QModelIndexList sel = mPlayListView->selectionModel()->selectedRows();
+ QSqlDatabase db = QSqlDatabase::database("beetplayerdb");
+ QSqlQuery favInsertQ(db);
+ favInsertQ.prepare("INSERT INTO persistent_favorites (tartist_name, talbum_name, ttitle) VALUES(:artist, :album, :title)");
+ foreach(QModelIndex i, sel){
+ QString artist = i.data(ArtistRole).toString();
+ QString album = i.data(AlbumRole).toString();
+ QString title = i.data(TitleRole).toString();
+ QString msg;
+ favInsertQ.bindValue(":artist", artist);
+ favInsertQ.bindValue(":album", album);
+ favInsertQ.bindValue(":title", title);
+ if(favInsertQ.exec()){
+ msg = QString(tr("Added %1 to favorites")).arg(title);
+ }else{
+ msg = QString(tr("Oops! Failed to add %1 to favorites")).arg(title);
+ }
+ emit message(msg);
+ }
+}
+
void PlayerWidget::clearPlayList(){
mPlayListModel->clear();
mPlayListModel->setHorizontalHeaderLabels(QStringList() << "Title");
@@ -1266,6 +1293,7 @@ void PlayerWidget::randomPlay(){
item->setData(randomQ.value(6), LengthRole);
item->setData(randomQ.value(4), ArtistRole);
item->setData(randomQ.value(5), AlbumRole);
+ item->setData(randomQ.value(1), TitleRole);
mPlayListLength += randomQ.value(6).toInt();
root->appendRow(item);
}
diff --git a/playerwidget.h b/playerwidget.h
index 52f2785..91f34e0 100644
--- a/playerwidget.h
+++ b/playerwidget.h
@@ -64,6 +64,7 @@ class PlayerWidget : public QWidget {
void addToPlayList();
void addToPlayListAndClear();
void removeFromPlayList();
+ void addToFavorites();
void clearPlayList();
void shufflePlayList();
void randomPlay();