From 59c877f9fc4707fdb19408ccc794b8606fb11465 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Fri, 22 Dec 2017 19:33:46 +0100 Subject: [PATCH] Added comboBox to choose from webradios --- plugins/webradioplugin/webradiodialog.cpp | 34 ++++++++++- plugins/webradioplugin/webradiodialog.ui | 72 +++++++++++++++++++++-- plugins/webradioplugin/webradioplugin.pro | 11 ++-- 3 files changed, 104 insertions(+), 13 deletions(-) diff --git a/plugins/webradioplugin/webradiodialog.cpp b/plugins/webradioplugin/webradiodialog.cpp index 8625153..39dd264 100644 --- a/plugins/webradioplugin/webradiodialog.cpp +++ b/plugins/webradioplugin/webradiodialog.cpp @@ -10,9 +10,39 @@ WebRadioDialog::WebRadioDialog(QWidget *parent) : { ui->setupUi(this); - m_player->setMedia(QMediaContent(QUrl(QStringLiteral("http://stream.drumandbass.fm:9002")))); + for(const auto &url : QStringList { + QStringLiteral("http://stream.drumandbass.fm:9002"), + QStringLiteral("http://stream.trap.fm:6002"), + QStringLiteral("http://stream.dubbase.fm:7002"), + QStringLiteral("http://lw1.mp3.tb-group.fm/hb.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/tb.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/tt.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/ht.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/trb.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/ct.mp3"), + QStringLiteral("http://lw1.mp3.tb-group.fm/clt.mp3"), + QStringLiteral("https://live.helsinki.at:8088/live160.ogg") + }) + { + ui->comboBox->addItem(url); + } - connect(ui->pushButton, &QAbstractButton::pressed, m_player, &QMediaPlayer::play); + connect(ui->comboBox, &QComboBox::currentTextChanged, this, [=](const QString &url){ m_player->setMedia(QMediaContent(QUrl(url))); }); + + Q_EMIT ui->comboBox->currentTextChanged(ui->comboBox->currentText()); + + connect(ui->pushButtonPlay, &QAbstractButton::pressed, m_player, &QMediaPlayer::play); + connect(ui->pushButtonPause, &QAbstractButton::pressed, m_player, &QMediaPlayer::pause); + connect(ui->pushButtonStop, &QAbstractButton::pressed, m_player, &QMediaPlayer::stop); + connect(ui->horizontalSlider, &QAbstractSlider::valueChanged, m_player, &QMediaPlayer::setVolume); + + connect(m_player, &QMediaPlayer::stateChanged, [](QMediaPlayer::State newState){ qDebug() << newState; }); + connect(m_player, &QMediaPlayer::mediaStatusChanged, [](QMediaPlayer::MediaStatus status){ qDebug() << status; }); + connect(m_player, static_cast(&QMediaPlayer::error), + [](QMediaPlayer::Error error){ qDebug() << error; }); + connect(m_player, SIGNAL(volumeChanged(int)), ui->horizontalSlider, SLOT(setValue(int))); + + Q_EMIT m_player->volumeChanged(m_player->volume()); } WebRadioDialog::~WebRadioDialog() diff --git a/plugins/webradioplugin/webradiodialog.ui b/plugins/webradioplugin/webradiodialog.ui index 90cbbfb..8d7d9eb 100644 --- a/plugins/webradioplugin/webradiodialog.ui +++ b/plugins/webradioplugin/webradiodialog.ui @@ -6,7 +6,7 @@ 0 0 - 433 + 539 300 @@ -29,17 +29,79 @@ QDialogButtonBox::Close - + - 110 + 20 60 - 191 + 131 51 - PushButton + play() + + + + + + 50 + 160 + 351 + 23 + + + + 24 + + + + + + 160 + 60 + 131 + 51 + + + + pause() + + + + + + 300 + 60 + 131 + 51 + + + + stop() + + + + + + 270 + 130 + 160 + 16 + + + + Qt::Horizontal + + + + + + 40 + 20 + 271 + 25 + diff --git a/plugins/webradioplugin/webradioplugin.pro b/plugins/webradioplugin/webradioplugin.pro index b6ae942..28eb042 100644 --- a/plugins/webradioplugin/webradioplugin.pro +++ b/plugins/webradioplugin/webradioplugin.pro @@ -14,14 +14,13 @@ DEPENDPATH += $$PWD/../../zeiterfassungcorelib $$PWD/../../zeiterfassungguilib DEFINES += QT_DEPRECATED_WARNINGS QT_DISABLE_DEPRECATED_BEFORE=0x060000 QT_MESSAGELOGCONTEXT -HEADERS += webradioplugin.h \ - webradiodialog.h +HEADERS += webradiodialog.h \ + webradioplugin.h -SOURCES += webradioplugin.cpp \ - webradiodialog.cpp +SOURCES += webradiodialog.cpp \ + webradioplugin.cpp -FORMS += \ - webradiodialog.ui +FORMS += webradiodialog.ui RESOURCES += webradioplugin_resources.qrc