Buttons are now disabled when not available in webradioplugin
This commit is contained in:
@@ -5,13 +5,89 @@
|
|||||||
<name>WebRadioDialog</name>
|
<name>WebRadioDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../webradiodialog.ui" line="14"/>
|
<location filename="../webradiodialog.ui" line="14"/>
|
||||||
<source>Dialog</source>
|
<source>Radio</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation>Radio</translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../webradiodialog.ui" line="42"/>
|
<location filename="../webradiodialog.ui" line="31"/>
|
||||||
<source>PushButton</source>
|
<source>Play</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation>Abspielen</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.ui" line="44"/>
|
||||||
|
<source>Pause</source>
|
||||||
|
<translation>Pause</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.ui" line="57"/>
|
||||||
|
<source>Stop</source>
|
||||||
|
<translation>Stop</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="69"/>
|
||||||
|
<source>Stopped</source>
|
||||||
|
<translation>Gestoppt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="70"/>
|
||||||
|
<source>Playing</source>
|
||||||
|
<translation>Wird abgespielt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="71"/>
|
||||||
|
<source>Paused</source>
|
||||||
|
<translation>Pausiert</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="74"/>
|
||||||
|
<location filename="../webradiodialog.cpp" line="93"/>
|
||||||
|
<source>Unknown</source>
|
||||||
|
<translation>Unbekannt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="82"/>
|
||||||
|
<source>Unknown media</source>
|
||||||
|
<translation>Unbekanntes Medium</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="83"/>
|
||||||
|
<source>No media</source>
|
||||||
|
<translation>Kein Medium</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="84"/>
|
||||||
|
<source>Loading media...</source>
|
||||||
|
<translation>Lade Medium...</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="85"/>
|
||||||
|
<source>Loaded media</source>
|
||||||
|
<translation>Medium geladen</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="86"/>
|
||||||
|
<source>Stalled media</source>
|
||||||
|
<translation>Medium angehalten</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="87"/>
|
||||||
|
<source>Buffering media</source>
|
||||||
|
<translation>Puffere Medium</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="88"/>
|
||||||
|
<source>Buffered media</source>
|
||||||
|
<translation>Medium gepuffert</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="89"/>
|
||||||
|
<source>End of media</source>
|
||||||
|
<translation>Ende des Mediums</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="90"/>
|
||||||
|
<source>Invalid media</source>
|
||||||
|
<translation>Ungültiges Medium</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
@@ -19,7 +95,7 @@
|
|||||||
<message>
|
<message>
|
||||||
<location filename="../webradioplugin.cpp" line="38"/>
|
<location filename="../webradioplugin.cpp" line="38"/>
|
||||||
<source>Play webradio</source>
|
<source>Play webradio</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation>Webradio spielen</translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
@@ -5,12 +5,88 @@
|
|||||||
<name>WebRadioDialog</name>
|
<name>WebRadioDialog</name>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../webradiodialog.ui" line="14"/>
|
<location filename="../webradiodialog.ui" line="14"/>
|
||||||
<source>Dialog</source>
|
<source>Radio</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<location filename="../webradiodialog.ui" line="42"/>
|
<location filename="../webradiodialog.ui" line="31"/>
|
||||||
<source>PushButton</source>
|
<source>Play</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.ui" line="44"/>
|
||||||
|
<source>Pause</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.ui" line="57"/>
|
||||||
|
<source>Stop</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="69"/>
|
||||||
|
<source>Stopped</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="70"/>
|
||||||
|
<source>Playing</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="71"/>
|
||||||
|
<source>Paused</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="74"/>
|
||||||
|
<location filename="../webradiodialog.cpp" line="93"/>
|
||||||
|
<source>Unknown</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="82"/>
|
||||||
|
<source>Unknown media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="83"/>
|
||||||
|
<source>No media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="84"/>
|
||||||
|
<source>Loading media...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="85"/>
|
||||||
|
<source>Loaded media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="86"/>
|
||||||
|
<source>Stalled media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="87"/>
|
||||||
|
<source>Buffering media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="88"/>
|
||||||
|
<source>Buffered media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="89"/>
|
||||||
|
<source>End of media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="90"/>
|
||||||
|
<source>Invalid media</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
</context>
|
</context>
|
||||||
|
@@ -13,7 +13,9 @@ WebRadioDialog::WebRadioDialog(MainWindow &mainWindow) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
connect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::stateChanged);
|
connect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::stateChanged);
|
||||||
|
connect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::updateWidgets);
|
||||||
connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::mediaStatusChanged);
|
connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::mediaStatusChanged);
|
||||||
|
connect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::updateWidgets);
|
||||||
connect(m_player, static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)>(&QMediaPlayer::error), this, &WebRadioDialog::error);
|
connect(m_player, static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)>(&QMediaPlayer::error), this, &WebRadioDialog::error);
|
||||||
|
|
||||||
for(const auto &url : m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/urls"), QStringList {
|
for(const auto &url : m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/urls"), QStringList {
|
||||||
@@ -33,11 +35,13 @@ WebRadioDialog::WebRadioDialog(MainWindow &mainWindow) :
|
|||||||
ui->comboBox->addItem(url, url);
|
ui->comboBox->addItem(url, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto lastUrl = m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/lastUrl")).toString();
|
ui->comboBox->setCurrentIndex(ui->comboBox->findData(m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/lastUrl")).toString()));
|
||||||
qDebug() << lastUrl;
|
|
||||||
auto index = ui->comboBox->findData(lastUrl);
|
connect(ui->comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
qDebug() << index;
|
this, &WebRadioDialog::currentIndexChanged);
|
||||||
ui->comboBox->setCurrentIndex(index);
|
|
||||||
|
connect(ui->comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
|
this, &WebRadioDialog::updateWidgets);
|
||||||
|
|
||||||
connect(ui->pushButtonPlay, &QAbstractButton::pressed, this, &WebRadioDialog::play);
|
connect(ui->pushButtonPlay, &QAbstractButton::pressed, this, &WebRadioDialog::play);
|
||||||
connect(ui->pushButtonPause, &QAbstractButton::pressed, m_player, &QMediaPlayer::pause);
|
connect(ui->pushButtonPause, &QAbstractButton::pressed, m_player, &QMediaPlayer::pause);
|
||||||
@@ -46,6 +50,11 @@ WebRadioDialog::WebRadioDialog(MainWindow &mainWindow) :
|
|||||||
m_player->setVolume(m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/volume"), 100).toInt());
|
m_player->setVolume(m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/volume"), 100).toInt());
|
||||||
ui->horizontalSlider->setValue(m_player->volume());
|
ui->horizontalSlider->setValue(m_player->volume());
|
||||||
connect(ui->horizontalSlider, &QAbstractSlider::valueChanged, this, &WebRadioDialog::volumeChanged);
|
connect(ui->horizontalSlider, &QAbstractSlider::valueChanged, this, &WebRadioDialog::volumeChanged);
|
||||||
|
|
||||||
|
stateChanged(m_player->state());
|
||||||
|
mediaStatusChanged(m_player->mediaStatus());
|
||||||
|
currentIndexChanged(ui->comboBox->currentIndex());
|
||||||
|
updateWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRadioDialog::~WebRadioDialog()
|
WebRadioDialog::~WebRadioDialog()
|
||||||
@@ -55,31 +64,69 @@ WebRadioDialog::~WebRadioDialog()
|
|||||||
|
|
||||||
void WebRadioDialog::stateChanged(QMediaPlayer::State newState)
|
void WebRadioDialog::stateChanged(QMediaPlayer::State newState)
|
||||||
{
|
{
|
||||||
qDebug() << newState;
|
switch(newState)
|
||||||
|
{
|
||||||
|
case QMediaPlayer::StoppedState: ui->labelState->setText(tr("Stopped")); break;
|
||||||
|
case QMediaPlayer::PlayingState: ui->labelState->setText(tr("Playing")); break;
|
||||||
|
case QMediaPlayer::PausedState: ui->labelState->setText(tr("Paused")); break;
|
||||||
|
default:
|
||||||
|
qWarning() << "unknown state" << newState;
|
||||||
|
ui->labelState->setText(tr("Unknown"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRadioDialog::mediaStatusChanged(QMediaPlayer::MediaStatus status)
|
void WebRadioDialog::mediaStatusChanged(QMediaPlayer::MediaStatus status)
|
||||||
{
|
{
|
||||||
qDebug() << status;
|
switch(status)
|
||||||
|
{
|
||||||
|
case QMediaPlayer::UnknownMediaStatus: ui->labelMediaStatus->setText(tr("Unknown media")); break;
|
||||||
|
case QMediaPlayer::NoMedia: ui->labelMediaStatus->setText(tr("No media")); break;
|
||||||
|
case QMediaPlayer::LoadingMedia: ui->labelMediaStatus->setText(tr("Loading media...")); break;
|
||||||
|
case QMediaPlayer::LoadedMedia: ui->labelMediaStatus->setText(tr("Loaded media")); break;
|
||||||
|
case QMediaPlayer::StalledMedia: ui->labelMediaStatus->setText(tr("Stalled media")); break;
|
||||||
|
case QMediaPlayer::BufferingMedia: ui->labelMediaStatus->setText(tr("Buffering media")); break;
|
||||||
|
case QMediaPlayer::BufferedMedia: ui->labelMediaStatus->setText(tr("Buffered media")); break;
|
||||||
|
case QMediaPlayer::EndOfMedia: ui->labelMediaStatus->setText(tr("End of media")); break;
|
||||||
|
case QMediaPlayer::InvalidMedia: ui->labelMediaStatus->setText(tr("Invalid media")); break;
|
||||||
|
default:
|
||||||
|
qWarning() << "unknown mediaStatus" << status;
|
||||||
|
ui->labelMediaStatus->setText(tr("Unknown"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRadioDialog::error(QMediaPlayer::Error error)
|
void WebRadioDialog::error(QMediaPlayer::Error error)
|
||||||
{
|
{
|
||||||
qDebug() << error;
|
qWarning() << error;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebRadioDialog::currentIndexChanged(int index)
|
||||||
|
{
|
||||||
|
if(index == -1)
|
||||||
|
m_player->setMedia(QMediaContent());
|
||||||
|
else
|
||||||
|
m_player->setMedia(QMediaContent(QUrl(ui->comboBox->currentData().toString())));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRadioDialog::play()
|
void WebRadioDialog::play()
|
||||||
{
|
{
|
||||||
qDebug() << "called";
|
|
||||||
if(ui->comboBox->currentIndex() == -1)
|
if(ui->comboBox->currentIndex() == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/lastUrl"), ui->comboBox->currentData().toString());
|
m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/lastUrl"), ui->comboBox->currentData().toString());
|
||||||
|
|
||||||
m_player->setMedia(QMediaContent(QUrl(ui->comboBox->currentData().toString())));
|
|
||||||
m_player->play();
|
m_player->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebRadioDialog::updateWidgets()
|
||||||
|
{
|
||||||
|
ui->comboBox->setEnabled(m_player->state() != QMediaPlayer::PlayingState);
|
||||||
|
ui->pushButtonPlay->setEnabled(ui->comboBox->currentIndex() > -1 &&
|
||||||
|
(m_player->state() == QMediaPlayer::StoppedState || m_player->state() == QMediaPlayer::PausedState) &&
|
||||||
|
(m_player->mediaStatus() == QMediaPlayer::LoadedMedia || m_player->mediaStatus() == QMediaPlayer::BufferedMedia));
|
||||||
|
ui->pushButtonPause->setEnabled(m_player->state() == QMediaPlayer::PlayingState || m_player->state() == QMediaPlayer::PausedState);
|
||||||
|
ui->pushButtonStop->setEnabled(m_player->state() == QMediaPlayer::PlayingState || m_player->state() == QMediaPlayer::PausedState);
|
||||||
|
}
|
||||||
|
|
||||||
void WebRadioDialog::volumeChanged(int volume)
|
void WebRadioDialog::volumeChanged(int volume)
|
||||||
{
|
{
|
||||||
m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/volume"), volume);
|
m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/volume"), volume);
|
||||||
|
@@ -20,11 +20,13 @@ private Q_SLOTS:
|
|||||||
void stateChanged(QMediaPlayer::State newState);
|
void stateChanged(QMediaPlayer::State newState);
|
||||||
void mediaStatusChanged(QMediaPlayer::MediaStatus status);
|
void mediaStatusChanged(QMediaPlayer::MediaStatus status);
|
||||||
void error(QMediaPlayer::Error error);
|
void error(QMediaPlayer::Error error);
|
||||||
|
void currentIndexChanged(int index);
|
||||||
void volumeChanged(int volume);
|
void volumeChanged(int volume);
|
||||||
void play();
|
void play();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void updateWidgets();
|
||||||
|
|
||||||
Ui::WebRadioDialog *ui;
|
Ui::WebRadioDialog *ui;
|
||||||
|
|
||||||
MainWindow &m_mainWindow;
|
MainWindow &m_mainWindow;
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>play()</string>
|
<string>Play</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>pause()</string>
|
<string>Pause</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -54,7 +54,7 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>stop()</string>
|
<string>Stop</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -68,11 +68,22 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="text">
|
<item>
|
||||||
<string>TextLabel</string>
|
<widget class="QLabel" name="labelState">
|
||||||
</property>
|
<property name="text">
|
||||||
</widget>
|
<string notr="true">state</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="labelMediaStatus">
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">mediaStatus</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
Reference in New Issue
Block a user