17#include <QCoreApplication>
22#include <QMediaPlayer>
27#include <QStandardPaths>
29#include <QFontDatabase>
35#include <swradiyomainwidget.h>
36#include <ui_swradiyomainwidget.h>
37#include <swshutdowndialog.h>
38#include <swclockcontrol.h>
39#include <swplayercontrol.h>
40#include <swsendercontrol.h>
41#include <swsongscontrol.h>
42#include <swalarmcontrol.h>
43#include <swsetupcontrol.h>
44#include <swusbcontrol.h>
45#include <swbluetoothcontrol.h>
98 _radioButtons.addKeyButton( _buttonSender, SWSENDERCONTROL,
"sender" );
99 _radioButtons.addKeyButton( _buttonSongs, SWSONGSCONTROL,
"songs" );
100 _radioButtons.addKeyButton( _buttonUSB, SWUSBCONTROL,
"usb" );
103 _radioButtons.addKeyButton( _buttonClock, SWCLOCKCONTROL,
"clock" );
104 _radioButtons.addKeyButton( _buttonAlarm, SWALARMCONTROL,
"alarm" );
105 _radioButtons.addKeyButton( _buttonPlay, SWPLAYERCONTROL,
"play" );
106 _radioButtons.addKeyButton( _buttonSetup, SWSETUPCONTROL,
"setup" );
107 _radioButtons.addKeyButton( _buttonShutdown, SWSHUTDOWNCONTROL,
"shutdown" );
118 qDebug() <<
" --- Q_OS_LINUX";
123 qDebug() <<
" --- Q_OS_WIN";
133 _controls.resize( SWCONTROLSSIZE );
136 _controls[SWPLAYERCONTROL] = _playerControl;
137 _controls[SWSENDERCONTROL] = _senderControl;
138 _controls[SWSONGSCONTROL] = _songsControl;
144 _idleTimer.setInterval( raDIYo::IdleTimeOut );
145 _idleTimer.setSingleShot(
true );
149 connect( _volumeControl, SIGNAL(valueChanged(
int)), _playerControl, SLOT(onDialValueChanged(
int)) );
154 _songsControl->getCurrentEntry( _nowPlaying );
155 _currentTitle->setText( _nowPlaying.title );
156 _nowPlaying.volume = 40;
157 _version->setText( raDIYo::Version );
160 _lastControlID = _currentCtrlID = SWCLOCKCONTROL;
161 currentControl().show();
162 _buttonClock->setChecked(
true );
166 if( !_settings.contains( raDIYo::KeySongsDir ) )
167 _settings.setValue( raDIYo::KeySongsDir, QDir::homePath() + raDIYo::SongsDir );
171 if( !_settings.contains( raDIYo::KeySenderList ) )
173 QString senderList = readResource( raDIYo::ResSenderList );
175 _settings.setValue( raDIYo::KeySenderList, senderList );
178 _senderControl->loadEntryList( _settings.value( raDIYo::KeySenderList ).toString() );
179 _songsControl->loadEntryList( _settings.value( raDIYo::KeySongsDir ).toString() );
196 _playerControl->stopPlaying();
229QSettings& SWRaDIYoMainWidget::settings()
238 qDebug() <<
"--- onIdleTimeOut";
240 swapControls( SWCLOCKCONTROL );
244void SWRaDIYoMainWidget::swapControls(
int newID )
247 qDebug() <<
"Fade IN" << newID <<
" Fade OUT: " << _currentCtrlID;
250 currentControl().fadeOut();
251 _radioButtons.button( _currentCtrlID )->setChecked(
false );
254 _lastControlID = _currentCtrlID;
257 _currentCtrlID = newID;
258 _radioButtons.button( newID )->setChecked(
true );
259 currentControl().fadeIn();
272 qDebug() <<
"onIDTriggered( int newID ): " << newID;
277 if( SWPLAYERCONTROL != newID && newID == _currentCtrlID )
285 case SWPLAYERCONTROL :
287 qDebug(
"SW PLAYER CONTROL");
292 case SWSENDERCONTROL :
case SWSONGSCONTROL :
case SWUSBCONTROL :
298 case SWALARMCONTROL :
300 qDebug(
"SW ALARM CONTROL");
303 case SWCLOCKCONTROL :
305 qDebug(
"SW CLOCK CONTROL");
308 case SWSETUPCONTROL :
310 qDebug(
"SW SETUP CONTROL");
313 case SWSHUTDOWNCONTROL :
315 qDebug(
"SW SHUTDOWN CONTROL");
316 currentControl().fadeOut();
321 _radioButtons.button( _currentCtrlID )->setChecked(
true );
326 swapControls( newID );
356 qDebug() <<
"onSenderButtonClicked()";
368 qDebug() <<
"--onSenderValueChanged: " << value <<
" :" << _radioButtons.checkedId();
373 if( currentControl().acceptDial() )
398 qDebug(
"--onVolumeButtonClicked()");
415 dvalue = (double) value / 100;
416 qDebug() <<
"--:onVolumeValueChanged: " << value <<
": " << dvalue;
425 qDebug() <<
"--:onEntryActivated: " << _currentCtrlID <<
":" << item.title <<
": " << item.urlText;
428 if( _nowPlaying.urlText == item.urlText )
434 _playerActive =
false;
451 _playerActive = !_playerActive;
454 qDebug() <<
"\n\n+++ togglePlayMode(): " << _currentCtrlID <<
" :" << _nowPlaying.title <<
" Url: " << _nowPlaying.urlText <<
"\n\n";
459 _currentTitle->setText( _nowPlaying.title );
461 _buttonPlay->setStyleSheet( _playerActive ? _buttonPauseCss : _buttonPlayCss ) ;
467 qDebug() <<
" --- Player OFF";
468 _playerControl->stopPlaying();
469 return swapControls( _lastControlID );
472 qDebug() <<
" --- Player ON";
473 swapControls( SWPLAYERCONTROL );
490 qDebug() <<
"SWRaDIYoMainWidget::loadSettings()";
493 resize( RADIYO_LARGE_X, RADIYO_LARGE_Y );
495 qDebug() << QDir( raDIYo::FontDir ).entryList();
496 QStringList fontList = QDir( raDIYo::FontDir ).entryList();
497 for(
const QString& fontName : fontList )
500 QFontDatabase::addApplicationFont( raDIYo::FontDir + fontName );
510 _buttonPlayCss = readResource( SWPLAYBUTTONNSTYLE );
511 _buttonPauseCss = readResource( SWPAUSEBUTTONNSTYLE );
512 _titleCss = readResource( SWTITLELABELSTYLE );
558 if( QDialog::Rejected == dialog.exec() )
virtual void onDialValueChanged(int value)
Wird aufgerufen, wenn das (externe) Dial gedreht wurde.
void startPlaying(const QString &urlText)
SWPlayerControl::startPlaying: Erwartet eine ordentliche URL als String.
void onIDTriggered(int id)
onIDTriggered
void onShutDown()
onShutDown
void loadSettings()
loadSettings: die Einstellungen laden (fonts etc.)
void onVolumeValueChanged(int value)
onVolumeValueChanged
void onSenderValueChanged(int value)
onSenderValueChanged
void onVolumeButtonClicked()
onVolumeButtonClicked() wechselt zwischen Play- und Standby-Mode
void onSenderButtonClicked()
swapControls
void togglePlayMode()
startPlaying: von aussen und von innen
virtual ~SWRaDIYoMainWidget()
~SWRaDIYoMainWidget Destructor.
void saveSettings()
saveSettings
SWRaDIYoMainWidget(QWidget *parent=nullptr)
SWRaDIYoMainWidget –doku begins here —.