Imported existing sources
This commit is contained in:
BIN
images/web-radio.png
Normal file
BIN
images/web-radio.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.1 KiB |
101
translations/webradioplugin_de.ts
Normal file
101
translations/webradioplugin_de.ts
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="de_DE">
|
||||||
|
<context>
|
||||||
|
<name>WebRadioDialog</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.ui" line="14"/>
|
||||||
|
<source>Radio</source>
|
||||||
|
<translation>Radio</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<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="76"/>
|
||||||
|
<source>Stopped</source>
|
||||||
|
<translation>Gestoppt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="77"/>
|
||||||
|
<source>Playing</source>
|
||||||
|
<translation>Wird abgespielt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="78"/>
|
||||||
|
<source>Paused</source>
|
||||||
|
<translation>Pausiert</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="81"/>
|
||||||
|
<location filename="../webradiodialog.cpp" line="100"/>
|
||||||
|
<source>Unknown</source>
|
||||||
|
<translation>Unbekannt</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="89"/>
|
||||||
|
<source>Unknown media</source>
|
||||||
|
<translation>Unbekanntes Medium</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="90"/>
|
||||||
|
<source>No media</source>
|
||||||
|
<translation>Kein Medium</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="91"/>
|
||||||
|
<source>Loading media...</source>
|
||||||
|
<translation>Lade Medium...</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="92"/>
|
||||||
|
<source>Loaded media</source>
|
||||||
|
<translation>Medium geladen</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="93"/>
|
||||||
|
<source>Stalled media</source>
|
||||||
|
<translation>Medium angehalten</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="94"/>
|
||||||
|
<source>Buffering media</source>
|
||||||
|
<translation>Puffere Medium</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="95"/>
|
||||||
|
<source>Buffered media</source>
|
||||||
|
<translation>Medium gepuffert</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="96"/>
|
||||||
|
<source>End of media</source>
|
||||||
|
<translation>Ende des Mediums</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="97"/>
|
||||||
|
<source>Invalid media</source>
|
||||||
|
<translation>Ungültiges Medium</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>WebRadioPlugin</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradioplugin.cpp" line="38"/>
|
||||||
|
<source>Play webradio</source>
|
||||||
|
<translation>Webradio spielen</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
101
translations/webradioplugin_en.ts
Normal file
101
translations/webradioplugin_en.ts
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>WebRadioDialog</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.ui" line="14"/>
|
||||||
|
<source>Radio</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<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="76"/>
|
||||||
|
<source>Stopped</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="77"/>
|
||||||
|
<source>Playing</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="78"/>
|
||||||
|
<source>Paused</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="81"/>
|
||||||
|
<location filename="../webradiodialog.cpp" line="100"/>
|
||||||
|
<source>Unknown</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="89"/>
|
||||||
|
<source>Unknown media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="90"/>
|
||||||
|
<source>No media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="91"/>
|
||||||
|
<source>Loading media...</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="92"/>
|
||||||
|
<source>Loaded media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="93"/>
|
||||||
|
<source>Stalled media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="94"/>
|
||||||
|
<source>Buffering media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="95"/>
|
||||||
|
<source>Buffered media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="96"/>
|
||||||
|
<source>End of media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradiodialog.cpp" line="97"/>
|
||||||
|
<source>Invalid media</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>WebRadioPlugin</name>
|
||||||
|
<message>
|
||||||
|
<location filename="../webradioplugin.cpp" line="38"/>
|
||||||
|
<source>Play webradio</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
128
webradiodialog.cpp
Normal file
128
webradiodialog.cpp
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
#include "webradiodialog.h"
|
||||||
|
#include "ui_webradiodialog.h"
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
#include "zeiterfassungsettings.h"
|
||||||
|
|
||||||
|
WebRadioDialog::WebRadioDialog(MainWindow &mainWindow) :
|
||||||
|
ZeiterfassungDialog(&mainWindow),
|
||||||
|
ui(new Ui::WebRadioDialog),
|
||||||
|
m_mainWindow(mainWindow),
|
||||||
|
m_settings(m_mainWindow.settings())
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
m_player = new QMediaPlayer(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_settings.urls())
|
||||||
|
ui->comboBox->addItem(url, url);
|
||||||
|
|
||||||
|
ui->comboBox->setCurrentIndex(ui->comboBox->findData(m_settings.lastUrl()));
|
||||||
|
|
||||||
|
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);
|
||||||
|
connect(ui->pushButtonStop, &QAbstractButton::pressed, m_player, &QMediaPlayer::stop);
|
||||||
|
|
||||||
|
m_player->setVolume(m_settings.volume());
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
// To avoid crash on app close
|
||||||
|
disconnect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::stateChanged);
|
||||||
|
disconnect(m_player, &QMediaPlayer::stateChanged, this, &WebRadioDialog::updateWidgets);
|
||||||
|
disconnect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::mediaStatusChanged);
|
||||||
|
disconnect(m_player, &QMediaPlayer::mediaStatusChanged, this, &WebRadioDialog::updateWidgets);
|
||||||
|
disconnect(m_player, static_cast<void(QMediaPlayer::*)(QMediaPlayer::Error)>(&QMediaPlayer::error), this, &WebRadioDialog::error);
|
||||||
|
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebRadioDialog::stateChanged(QMediaPlayer::State 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)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
if(ui->comboBox->currentIndex() == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_settings.setLastUrl(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_settings.setVolume(volume);
|
||||||
|
m_player->setVolume(volume);
|
||||||
|
}
|
38
webradiodialog.h
Normal file
38
webradiodialog.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QMediaPlayer>
|
||||||
|
|
||||||
|
#include "zeiterfassungdialog.h"
|
||||||
|
|
||||||
|
#include "webradiosettings.h"
|
||||||
|
|
||||||
|
class MainWindow;
|
||||||
|
|
||||||
|
namespace Ui { class WebRadioDialog; }
|
||||||
|
|
||||||
|
class WebRadioDialog : public ZeiterfassungDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit WebRadioDialog(MainWindow &mainWindow);
|
||||||
|
~WebRadioDialog();
|
||||||
|
|
||||||
|
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;
|
||||||
|
WebRadioSettings m_settings;
|
||||||
|
|
||||||
|
QMediaPlayer *m_player;
|
||||||
|
};
|
135
webradiodialog.ui
Normal file
135
webradiodialog.ui
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>WebRadioDialog</class>
|
||||||
|
<widget class="QDialog" name="WebRadioDialog">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>494</width>
|
||||||
|
<height>155</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Radio</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="comboBox"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonPlay">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Play</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonPause">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Pause</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButtonStop">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Stop</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="horizontalSlider">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<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">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>WebRadioDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>WebRadioDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
45
webradioplugin.cpp
Normal file
45
webradioplugin.cpp
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
#include "webradioplugin.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QLocale>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
|
|
||||||
|
#include "webradiodialog.h"
|
||||||
|
#include "webradiosettingswidget.h"
|
||||||
|
|
||||||
|
WebRadioPlugin::WebRadioPlugin(QObject *parent) :
|
||||||
|
ZeiterfassungPlugin(parent)
|
||||||
|
{
|
||||||
|
qDebug() << "called";
|
||||||
|
|
||||||
|
static auto dir = QDir(QCoreApplication::applicationDirPath()).absoluteFilePath(QStringLiteral("translations"));
|
||||||
|
|
||||||
|
if(m_translator.load(QLocale(), QStringLiteral("webradioplugin"), QStringLiteral("_"), dir))
|
||||||
|
{
|
||||||
|
if(!QCoreApplication::installTranslator(&m_translator))
|
||||||
|
{
|
||||||
|
qWarning() << "could not install translation webradioplugin";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << "could not load translation webradioplugin";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebRadioPlugin::attachTo(MainWindow &mainWindow)
|
||||||
|
{
|
||||||
|
auto dialog = new WebRadioDialog(mainWindow);
|
||||||
|
mainWindow.menuTools()->addAction(QIcon(QStringLiteral(":/zeiterfassung/plugins/webradioplugin/images/web-radio.png")),
|
||||||
|
tr("Play webradio"), dialog, &QWidget::show);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsWidget *WebRadioPlugin::settingsWidget(ZeiterfassungSettings &settings, QWidget *parent) const
|
||||||
|
{
|
||||||
|
return new WebRadioSettingsWidget(settings, parent);
|
||||||
|
}
|
24
webradioplugin.h
Normal file
24
webradioplugin.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include "zeiterfassungplugin.h"
|
||||||
|
|
||||||
|
class Q_DECL_EXPORT WebRadioPlugin : public ZeiterfassungPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "dbsoftware.zeiterfassung.plugin/1.0" FILE "webradioplugin.json")
|
||||||
|
Q_INTERFACES(ZeiterfassungPlugin)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit WebRadioPlugin(QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
// ZeiterfassungPlugin interface
|
||||||
|
void attachTo(MainWindow &mainWindow) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
SettingsWidget *settingsWidget(ZeiterfassungSettings &settings, QWidget *parent = Q_NULLPTR) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTranslator m_translator;
|
||||||
|
};
|
0
webradioplugin.json
Normal file
0
webradioplugin.json
Normal file
26
webradioplugin.pro
Normal file
26
webradioplugin.pro
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
QT += core network gui widgets multimedia
|
||||||
|
|
||||||
|
DBLIBS += dbgui zeiterfassungcore zeiterfassunggui
|
||||||
|
|
||||||
|
TARGET = webradioplugin
|
||||||
|
|
||||||
|
HEADERS += webradiodialog.h \
|
||||||
|
webradioplugin.h \
|
||||||
|
webradiosettings.h \
|
||||||
|
webradiosettingswidget.h
|
||||||
|
|
||||||
|
SOURCES += webradiodialog.cpp \
|
||||||
|
webradioplugin.cpp \
|
||||||
|
webradiosettings.cpp \
|
||||||
|
webradiosettingswidget.cpp
|
||||||
|
|
||||||
|
FORMS += webradiodialog.ui
|
||||||
|
|
||||||
|
RESOURCES += webradioplugin_resources.qrc
|
||||||
|
|
||||||
|
TRANSLATIONS += translations/webradioplugin_en.ts \
|
||||||
|
translations/webradioplugin_de.ts
|
||||||
|
|
||||||
|
OTHER_FILES += webradioplugin.json
|
||||||
|
|
||||||
|
include(../plugin.pri)
|
5
webradioplugin_resources.qrc
Normal file
5
webradioplugin_resources.qrc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/zeiterfassung/plugins/webradioplugin">
|
||||||
|
<file>images/web-radio.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
114
webradiosettings.cpp
Normal file
114
webradiosettings.cpp
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
#include "webradiosettings.h"
|
||||||
|
|
||||||
|
#include "zeiterfassungsettings.h"
|
||||||
|
|
||||||
|
const QString WebRadioSettings::m_urls("WebRadioPlugin/urls");
|
||||||
|
const QString WebRadioSettings::m_lastUrl("WebRadioPlugin/lastUrl");
|
||||||
|
const QString WebRadioSettings::m_volume("WebRadioPlugin/volume");
|
||||||
|
const QStringList WebRadioSettings::m_defaultUrls {
|
||||||
|
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")
|
||||||
|
};
|
||||||
|
const int WebRadioSettings::m_defaultVolume(100);
|
||||||
|
|
||||||
|
WebRadioSettings::WebRadioSettings(ZeiterfassungSettings &settings, QObject *parent) :
|
||||||
|
QObject(parent),
|
||||||
|
m_settings(settings)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList WebRadioSettings::urls() const
|
||||||
|
{
|
||||||
|
return m_settings.value(m_urls, m_defaultUrls).toStringList();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebRadioSettings::setUrls(const QStringList &urls)
|
||||||
|
{
|
||||||
|
if(this->urls() == urls)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(urls == m_defaultUrls)
|
||||||
|
m_settings.remove(m_urls);
|
||||||
|
else
|
||||||
|
m_settings.setValue(m_urls, urls);
|
||||||
|
|
||||||
|
m_settings.sync();
|
||||||
|
|
||||||
|
const auto success = m_settings.status() == QSettings::NoError;
|
||||||
|
if(success)
|
||||||
|
Q_EMIT urlsChanged(urls);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Q_EMIT m_settings.saveErrorOccured();
|
||||||
|
Q_EMIT saveErrorOccured();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WebRadioSettings::lastUrl() const
|
||||||
|
{
|
||||||
|
return m_settings.value(m_lastUrl).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebRadioSettings::setLastUrl(const QString &lastUrl)
|
||||||
|
{
|
||||||
|
if(this->lastUrl() == lastUrl)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(lastUrl.isNull())
|
||||||
|
m_settings.remove(m_lastUrl);
|
||||||
|
else
|
||||||
|
m_settings.setValue(m_lastUrl, lastUrl);
|
||||||
|
|
||||||
|
m_settings.sync();
|
||||||
|
|
||||||
|
const auto success = m_settings.status() == QSettings::NoError;
|
||||||
|
if(success)
|
||||||
|
Q_EMIT lastUrlChanged(lastUrl);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Q_EMIT m_settings.saveErrorOccured();
|
||||||
|
Q_EMIT saveErrorOccured();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WebRadioSettings::volume() const
|
||||||
|
{
|
||||||
|
return m_settings.value(m_volume, m_defaultVolume).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebRadioSettings::setVolume(int volume)
|
||||||
|
{
|
||||||
|
if(this->volume() == volume)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(volume == m_defaultVolume)
|
||||||
|
m_settings.remove(m_volume);
|
||||||
|
else
|
||||||
|
m_settings.setValue(m_volume, volume);
|
||||||
|
|
||||||
|
m_settings.sync();
|
||||||
|
|
||||||
|
const auto success = m_settings.status() == QSettings::NoError;
|
||||||
|
if(success)
|
||||||
|
Q_EMIT volumeChanged(volume);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Q_EMIT m_settings.saveErrorOccured();
|
||||||
|
Q_EMIT saveErrorOccured();
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
42
webradiosettings.h
Normal file
42
webradiosettings.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
class ZeiterfassungSettings;
|
||||||
|
|
||||||
|
class WebRadioSettings : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(QStringList urls READ urls WRITE setUrls NOTIFY urlsChanged)
|
||||||
|
Q_PROPERTY(QString lastUrl READ lastUrl WRITE setLastUrl NOTIFY lastUrlChanged)
|
||||||
|
Q_PROPERTY(int volume READ volume WRITE setVolume NOTIFY volumeChanged)
|
||||||
|
|
||||||
|
public:
|
||||||
|
WebRadioSettings(ZeiterfassungSettings &settings, QObject *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
QStringList urls() const;
|
||||||
|
bool setUrls(const QStringList &urls);
|
||||||
|
|
||||||
|
QString lastUrl() const;
|
||||||
|
bool setLastUrl(const QString &lastUrl);
|
||||||
|
|
||||||
|
int volume() const;
|
||||||
|
bool setVolume(int volume);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void saveErrorOccured();
|
||||||
|
|
||||||
|
void urlsChanged(const QStringList &urls);
|
||||||
|
void lastUrlChanged(const QString &lastUrl);
|
||||||
|
void volumeChanged(int volume);
|
||||||
|
|
||||||
|
private:
|
||||||
|
ZeiterfassungSettings &m_settings;
|
||||||
|
|
||||||
|
static const QString m_urls;
|
||||||
|
static const QString m_lastUrl;
|
||||||
|
static const QString m_volume;
|
||||||
|
static const QStringList m_defaultUrls;
|
||||||
|
static const int m_defaultVolume;
|
||||||
|
};
|
37
webradiosettingswidget.cpp
Normal file
37
webradiosettingswidget.cpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include "webradiosettingswidget.h"
|
||||||
|
|
||||||
|
#include <QFormLayout>
|
||||||
|
|
||||||
|
#include "stringlistwidget.h"
|
||||||
|
|
||||||
|
WebRadioSettingsWidget::WebRadioSettingsWidget(ZeiterfassungSettings &settings, QWidget *parent) :
|
||||||
|
SettingsWidget(parent),
|
||||||
|
m_settings(settings)
|
||||||
|
{
|
||||||
|
auto layout = new QFormLayout(this);
|
||||||
|
layout->setMargin(0);
|
||||||
|
|
||||||
|
m_urlsWidget = new StringListWidget(m_settings.urls(), this);
|
||||||
|
layout->addRow(tr("URLs:"), m_urlsWidget);
|
||||||
|
|
||||||
|
setLayout(layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebRadioSettingsWidget::isValid(QString &message) const
|
||||||
|
{
|
||||||
|
for(const auto &url : m_urlsWidget->value())
|
||||||
|
{
|
||||||
|
if(!QUrl::fromUserInput(url).isValid())
|
||||||
|
{
|
||||||
|
message = tr("A web radio url is invalid!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebRadioSettingsWidget::apply()
|
||||||
|
{
|
||||||
|
return m_settings.setUrls(m_urlsWidget->value());
|
||||||
|
}
|
29
webradiosettingswidget.h
Normal file
29
webradiosettingswidget.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "settingswidget.h"
|
||||||
|
|
||||||
|
#include "webradiosettings.h"
|
||||||
|
|
||||||
|
class StringListWidget;
|
||||||
|
|
||||||
|
class ZeiterfassungSettings;
|
||||||
|
|
||||||
|
class WebRadioSettingsWidget : public SettingsWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit WebRadioSettingsWidget(ZeiterfassungSettings &settings, QWidget *parent = Q_NULLPTR);
|
||||||
|
|
||||||
|
bool isValid(QString &message) const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
virtual bool apply() Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
WebRadioSettings m_settings;
|
||||||
|
|
||||||
|
StringListWidget *m_urlsWidget;
|
||||||
|
};
|
Reference in New Issue
Block a user