Devel #56
@@ -5,13 +5,89 @@
|
||||
<name>WebRadioDialog</name>
|
||||
<message>
|
||||
<location filename="../webradiodialog.ui" line="14"/>
|
||||
<source>Dialog</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<source>Radio</source>
|
||||
<translation>Radio</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../webradiodialog.ui" line="42"/>
|
||||
<source>PushButton</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<location filename="../webradiodialog.ui" line="31"/>
|
||||
<source>Play</source>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
@@ -19,7 +95,7 @@
|
||||
<message>
|
||||
<location filename="../webradioplugin.cpp" line="38"/>
|
||||
<source>Play webradio</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Webradio spielen</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
@@ -5,12 +5,88 @@
|
||||
<name>WebRadioDialog</name>
|
||||
<message>
|
||||
<location filename="../webradiodialog.ui" line="14"/>
|
||||
<source>Dialog</source>
|
||||
<source>Radio</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../webradiodialog.ui" line="42"/>
|
||||
<source>PushButton</source>
|
||||
<location filename="../webradiodialog.ui" line="31"/>
|
||||
<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>
|
||||
</message>
|
||||
</context>
|
||||
|
@@ -13,7 +13,9 @@ WebRadioDialog::WebRadioDialog(MainWindow &mainWindow) :
|
||||
ui->setupUi(this);
|
||||
|
||||
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::updateWidgets);
|
||||
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 {
|
||||
@@ -33,11 +35,13 @@ WebRadioDialog::WebRadioDialog(MainWindow &mainWindow) :
|
||||
ui->comboBox->addItem(url, url);
|
||||
}
|
||||
|
||||
auto lastUrl = m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/lastUrl")).toString();
|
||||
qDebug() << lastUrl;
|
||||
auto index = ui->comboBox->findData(lastUrl);
|
||||
qDebug() << index;
|
||||
ui->comboBox->setCurrentIndex(index);
|
||||
ui->comboBox->setCurrentIndex(ui->comboBox->findData(m_mainWindow.settings().value(QStringLiteral("WebRadioPlugin/lastUrl")).toString()));
|
||||
|
||||
connect(ui->comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &WebRadioDialog::currentIndexChanged);
|
||||
|
||||
connect(ui->comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||
this, &WebRadioDialog::updateWidgets);
|
||||
|
||||
connect(ui->pushButtonPlay, &QAbstractButton::pressed, this, &WebRadioDialog::play);
|
||||
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());
|
||||
ui->horizontalSlider->setValue(m_player->volume());
|
||||
connect(ui->horizontalSlider, &QAbstractSlider::valueChanged, this, &WebRadioDialog::volumeChanged);
|
||||
|
||||
stateChanged(m_player->state());
|
||||
mediaStatusChanged(m_player->mediaStatus());
|
||||
currentIndexChanged(ui->comboBox->currentIndex());
|
||||
updateWidgets();
|
||||
}
|
||||
|
||||
WebRadioDialog::~WebRadioDialog()
|
||||
@@ -55,31 +64,69 @@ WebRadioDialog::~WebRadioDialog()
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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()
|
||||
{
|
||||
qDebug() << "called";
|
||||
if(ui->comboBox->currentIndex() == -1)
|
||||
return;
|
||||
|
||||
m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/lastUrl"), ui->comboBox->currentData().toString());
|
||||
|
||||
m_player->setMedia(QMediaContent(QUrl(ui->comboBox->currentData().toString())));
|
||||
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)
|
||||
{
|
||||
m_mainWindow.settings().setValue(QStringLiteral("WebRadioPlugin/volume"), volume);
|
||||
|
@@ -20,11 +20,13 @@ private Q_SLOTS:
|
||||
void stateChanged(QMediaPlayer::State newState);
|
||||
void mediaStatusChanged(QMediaPlayer::MediaStatus status);
|
||||
void error(QMediaPlayer::Error error);
|
||||
|
||||
void currentIndexChanged(int index);
|
||||
void volumeChanged(int volume);
|
||||
void play();
|
||||
|
||||
private:
|
||||
void updateWidgets();
|
||||
|
||||
Ui::WebRadioDialog *ui;
|
||||
|
||||
MainWindow &m_mainWindow;
|
||||
|
@@ -28,7 +28,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>play()</string>
|
||||
<string>Play</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -41,7 +41,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>pause()</string>
|
||||
<string>Pause</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -54,7 +54,7 @@
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>stop()</string>
|
||||
<string>Stop</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -68,11 +68,22 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="labelState">
|
||||
<property name="text">
|
||||
<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>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
|
Reference in New Issue
Block a user