diff options
author | Arno <arno@disconnect.de> | 2017-08-26 07:49:34 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-08-26 07:49:34 +0200 |
commit | 1285456abe4be9a22dc42498a1d0a1a43a0a00be (patch) | |
tree | 1d3475be09492735ab3c30cf043030cc19601ec2 | |
parent | a957512861065d700663ddd522de57925b878eae (diff) | |
download | BeetPlayer-1285456abe4be9a22dc42498a1d0a1a43a0a00be.tar.gz BeetPlayer-1285456abe4be9a22dc42498a1d0a1a43a0a00be.tar.bz2 BeetPlayer-1285456abe4be9a22dc42498a1d0a1a43a0a00be.zip |
Implement dialog for adding WebRadios
Just enter a description and an URL.
-rw-r--r-- | BeetPlayer.pro | 6 | ||||
-rw-r--r-- | playerwidget.cpp | 18 | ||||
-rw-r--r-- | playerwidget.h | 1 | ||||
-rw-r--r-- | webradiodialog.cpp | 29 | ||||
-rw-r--r-- | webradiodialog.h | 20 |
5 files changed, 72 insertions, 2 deletions
diff --git a/BeetPlayer.pro b/BeetPlayer.pro index 0af8894..ef8c662 100644 --- a/BeetPlayer.pro +++ b/BeetPlayer.pro @@ -33,7 +33,8 @@ SOURCES += main.cpp\ beetview.cpp \ indexerdialog.cpp \ helper.cpp \ - webdownloader.cpp + webdownloader.cpp \ + webradiodialog.cpp HEADERS += beetplayer.h \ configurationdialog.h \ @@ -43,7 +44,8 @@ HEADERS += beetplayer.h \ beetview.h \ indexerdialog.h \ helper.h \ - webdownloader.h + webdownloader.h \ + webradiodialog.h LIBS += -ltag diff --git a/playerwidget.cpp b/playerwidget.cpp index 9d41b79..37c6d5c 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -37,6 +37,7 @@ #include "globals.h" #include "helper.h" #include "webdownloader.h" +#include "webradiodialog.h" PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent), mDurSecs(0), mPlayListLength(0){ mStarting = true; @@ -371,6 +372,8 @@ void PlayerWidget::createActions(){ connect(miscMusicBrainzLeftA, &QAction::triggered, this, &PlayerWidget::searchMusicbrainzLeft); QAction *miscFilterFromPlaylistA = new QAction(QIcon(":/chastity_belt.png"), tr("Filter artist"), this); 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); mView->addAction(addToPlayListA); mView->addAction(addToPlayListAndClearA); mView->addAction(Helper::createSeparator(this)); @@ -386,6 +389,8 @@ void PlayerWidget::createActions(){ mView->addAction(Helper::createSeparator(this)); mView->addAction(mRefreshA); mView->addAction(Helper::createSeparator(this)); + mView->addAction(addToWebRadioA); + mView->addAction(Helper::createSeparator(this)); mView->addAction(randomPlayA); mPlayListView->addAction(removeFromPlayListA); mPlayListView->addAction(Helper::createSeparator(this)); @@ -1342,6 +1347,19 @@ void PlayerWidget::filterFromPlaylist(){ doFilter(); } +void PlayerWidget::addWebRadio(){ + WebRadioDialog dlg(this); + dlg.exec(); + QString desc = dlg.description(); + QString url = dlg.url(); + QSqlDatabase db = QSqlDatabase::database("beetplayerdb"); + QSqlQuery wrQ(db); + wrQ.prepare("INSERT INTO webradio (tdescription, turl) VALUES(:d, :u)"); + wrQ.bindValue(":d", desc); + wrQ.bindValue(":u", url); + wrQ.exec(); +} + 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 9489306..2087311 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -72,6 +72,7 @@ class PlayerWidget : public QWidget { void searchMusicbrainzLeft(); void webDlDone(); void filterFromPlaylist(); + void addWebRadio(); void mute(bool triggered); void volumeChanged(int volume); diff --git a/webradiodialog.cpp b/webradiodialog.cpp new file mode 100644 index 0000000..4e08627 --- /dev/null +++ b/webradiodialog.cpp @@ -0,0 +1,29 @@ +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QFormLayout> +#include <QPushButton> +#include <QApplication> + +#include "webradiodialog.h" + +WebRadioDialog::WebRadioDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ + mDescription = new QLineEdit; + mUrl = new QLineEdit; + QFormLayout *topL = new QFormLayout; + topL->addRow(tr("&Description:"), mDescription); + topL->addRow(tr("&Url:"), mUrl); + QPushButton *okB = new QPushButton(tr("OK")); + connect(okB, &QPushButton::clicked, this, &QDialog::accept); + QPushButton *cancelB = new QPushButton(tr("Cancel")); + connect(cancelB, &QPushButton::clicked, this, &QDialog::reject); + QHBoxLayout *buttonL = new QHBoxLayout; + buttonL->addStretch(); + buttonL->addWidget(okB); + buttonL->addWidget(cancelB); + QVBoxLayout *mainL = new QVBoxLayout; + mainL->addLayout(topL); + mainL->addLayout(buttonL); + setLayout(mainL); + setWindowTitle(QString(tr("%1 - Add WebRadio")).arg(qApp->applicationName())); + setMinimumWidth(768); +} diff --git a/webradiodialog.h b/webradiodialog.h new file mode 100644 index 0000000..96262dd --- /dev/null +++ b/webradiodialog.h @@ -0,0 +1,20 @@ +#ifndef WEBRADIODIALOG_H +#define WEBRADIODIALOG_H + +#include <QDialog> +#include <QLineEdit> + +class WebRadioDialog : public QDialog { + Q_OBJECT + public: + explicit WebRadioDialog(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); + const QString description() { return mDescription->text(); } + const QString url() { return mUrl->text(); } + + private: + QLineEdit *mDescription; + QLineEdit *mUrl; + +}; + +#endif // WEBRADIODIALOG_H |