Files
raDIYo/raDIYo.h
2025-08-05 22:36:00 +02:00

195 lines
4.7 KiB
C++

/***************************************************************************
source::worx raDIYo
Copyright © 2020-2022 c.holzheuer
chris@sourceworx.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
***************************************************************************/
#ifndef RADIYO_H
#define RADIYO_H
#include <QWidget>
#include <QSettings>
#include <QTimer>
#include <QMap>
#include <QMediaPlayer>
#include <QStack>
#include <swurl.h>
#include <swbuttongroup.h>
#include <raDIYoglobals.h>
#include <swcontrol.h>
#include <swdummydialdialog.h>
#include <swdialwidget.h>
//#include <swplayercontrol.h>
#include <raDIYo.h>
#include <ui_raDIYo.h>
#include <swbuttongroup.h>
/**
@mainpage raDIYo
@section sec1 raDIYo
Eine Mediaplayer-Software für den RaspberryPi, zugleich ein
Hardware-Updgrade eines Nora 'Rienzi' Radios, Bj. ca. 1935
@section sec3 Ideen & TODO:
@subsection sec3_1 TODO 1.0.xx RC
@remarks
Für 1.0x
- lib vlc player nehmen!
- videos einbauen, fürs geschmäckle
- artist anzeigen
- progressbar anzeigen
- volume % einblenden
- Qt 6.x upgrade
- Gestensteuerung via Ultraschall Sensor
- Dazu Arduino Bindings
- Config per App
- Röhrenoszi als Pegel Anzeige ??
- mp3 taglib einsetzen
- peak level halten im SpectroViewer
- Player verbessern: Loop / Shuffle
- Player verbessern: Lieblinslautstärke pro song speichern
- Player verbessern: Liste weiterspielen
@bug
- Bluetooth-Einbindung läuft nur über Systemeinstellungen
*/
namespace raDIYo
{
// misc
//#define raDIYo:Version "Version 0.0.01 / 19.12.2020"
[[maybe_unused]] constexpr static const char* Version = "raDIYo 0.5.45 / 01.12.2022 © 2020-22 chris@sourceworx.org";
[[maybe_unused]] constexpr static const char* OrgName = "source::worx";
[[maybe_unused]] constexpr static const char* DomainName = "sourceworx.org";
[[maybe_unused]] constexpr static const char* AppName = "raDIYo";
}
class SWDialHandler;
class PiGRotaryDial;
class SWControl;
class SWPlayerControl;
class SWSenderControl;
class SWSongsControl;
class SWAlarmControl;
class SWUSBControl;
/**
* @brief The RaDIYo class: Erbt alles von RaDIYoWidget,
* Dort wird das GUI implementiert, hier werden die
* Zustandssteuerungen behandelt
*/
class RaDIYo : public QWidget, private Ui_RaDIYoWidget
{
Q_OBJECT
public:
constexpr static const int SWScreenSmallX = 480;
constexpr static const int SWScreenSmallY = 320;
constexpr static const int SWScreenLargeX = 800;
constexpr static const int SWScreenLargeY = 480 - 40;
typedef enum
{
Play = 0,
Pause,
Stop,
Clock,
Alarm,
Sender,
Songs,
USB,
Back,
Shutdown,
ControlsSize
} ControlType;
RaDIYo();
virtual ~RaDIYo();
public slots:
void onChangeState( int id );
// dial handling: kommt von aussen
void onLeftButtonClicked();
void onLeftDeltaChanged(int);
void onRightButtonClicked();
void onRightDeltaChanged(int);
public slots:
void onPlayingChanged( QMediaPlayer::State state );
void onPlayCurrentUrl();
void onPlayUrl( SWUrl item );
protected:
using SWControlMap = QMap<int, SWControl*>;
void onIdleTimeOut();
QString stateName( int state );
void showTitleText( bool pauseClicked );
void addControl( int id, SWControl* control );
void setupFonts();
void setupControls();
void setupConnections();
void setupDefaults();
SWDialHandler* _activeReceiver = nullptr; // das aktive Control, bzw. die Buttongroup
int _curCtrlIdx = RaDIYo::Songs; // index des aktiven Controls
bool _upMode = false;
QMediaPlayer::State _playerState = QMediaPlayer::StoppedState;
SWPlayerControl* _playerControl = nullptr;
SWSenderControl* _senderControl = nullptr;
SWSongsControl* _songsControl = nullptr;
SWAlarmControl* _alarmControl = nullptr;
SWUSBControl* _usbControl = nullptr;
SWUrl _nowPlaying;
QString _titleCss;
QTimer _idleTimer;
SWDummyDialDialog _dialDialog; // fake dials für windows
PiGRotaryDial* _dialLeft = nullptr; // raspi rotary dials
PiGRotaryDial* _dialRight = nullptr;
QSettings _mainSettings;
SWDialButtonGroup _raDIYoButtons;
SWControlMap _controls; // alle Controls
};
#endif // RADIYO_H