raDIYo 0.4
swradiyomainwidget.h
1/***************************************************************************
2
3 source::worx raDIYo
4 Copyright © 2020-2022 c.holzheuer
5 c.holzheuer@sourceworx.org
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12***************************************************************************/
13
14
15#ifndef SWRADIYOMAINCONTROL_H
16#define SWRADIYOMAINCONTROL_H
17
18
19#include <QAudioBuffer>
20#include <QMediaPlayer>
21#include <QTimer>
22#include <QUrl>
23#include <QAudioProbe>
24
25#include <swbuttongroup.h>
26#include <swlistcontrol.h>
27#include <swradiyobasewidget.h>
28
29#include <swdialdialog.h>
30#include <ui_swradiyomainwidget.h>
31
32
33QT_BEGIN_NAMESPACE
34namespace Ui { class SWRaDIYoMainWidget; }
35QT_END_NAMESPACE
36
38class SWPlayerControl;
39class SWSenderControl;
40class SWSongsControl;
41
42
43class SWRaDIYoMainWidget : public SWRaDIYoBaseWidget, private Ui_SWRaDIYoMainWidget
44{
45
46 Q_OBJECT
47
48public:
49
50 enum SWControlType
51 {
52 SWCLOCKCONTROL = 0,
53
54 SWSENDERCONTROL,
55 SWSONGSCONTROL,
56 SWUSBCONTROL,
57 //SWBLUETOOTHCONTROL,
58
59 SWPLAYERCONTROL,
60 SWSETUPCONTROL,
61 SWALARMCONTROL,
62 SWSHUTDOWNCONTROL,
63
64 SWCONTROLSSIZE,
65 };
66
67
68 static constexpr const char* SWPLAYBUTTONNSTYLE = ":/data/radiyo.playbutton.css";
69 static constexpr const char* SWPAUSEBUTTONNSTYLE = ":/data/radiyo.pausebutton.css";
70 static constexpr const char* SWTITLELABELSTYLE = ":/data/radiyo.titlelabel.css";
71
72 typedef QVector<SWAbstractControl*> SWControlVec;
73
74 SWRaDIYoMainWidget( QWidget* parent = nullptr );
75 virtual ~SWRaDIYoMainWidget();
76
77 QSettings& settings();
78 void togglePlayMode();
79
80
81public slots:
82
83
84 void onIdleTimeOut();
85 // buttongroup: kommt von innen
86 void onIDTriggered( int id );
87
88 // die dials: kommt von aussen
90 void onSenderValueChanged( int value );
91
93 void onVolumeValueChanged( int value );
94
95 void onEntryActivated( SWPlayableItem item );
96
97
98protected:
99
100 inline SWAbstractControl& currentControl()
101 {
102 return *( _controls[_currentCtrlID] );
103 }
104
105 void setupDials();
106
107 void onShutDown();
108 //void playUrl( const QString& title, const QString& urltext );
109 void setAlarm();
110
111 void swapControls( int newID );
112
113 void loadSettings();
114 void saveSettings();
115
116 static const int RADIYO_SMALL_X = 480;
117 static const int RADIYO_SMALL_Y = 320;
118 static const int RADIYO_LARGE_X = 800;
119 static const int RADIYO_LARGE_Y = 480;
120
121 QSettings _settings;
122
123 QString _buttonPlayCss, _buttonPauseCss;
124 QString _titleCss;
125 bool _playerActive = false;
126
127 QTimer _idleTimer;
128 SWButtonGroup _radioButtons;
129 SWDialDialog _dialDialog;
130 SWPlayableItem _nowPlaying;
131
132 SWControlVec _controls;
133 int _currentCtrlID;
134 int _lastControlID;
135
136 SWSenderControl* _senderControl = nullptr;
137 SWSongsControl* _songsControl = nullptr;
138 SWPlayerControl* _playerControl = nullptr;
139
140 int _senderDialValue = -1;
141 int _volumeDialValue = -1;
142
143};
144
145
146
147
148
149#endif // SWRADIYOMAINCONTROL_H
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 —.