lena_pi/LenaPi/models/UiStateModel.h
Jan-Martin Raemer 9e7a55fc20 AppSettings for android
added debug output for Navigation as debugger does not work for Android
yet
2022-06-01 20:31:47 +02:00

92 lines
2.6 KiB
C++

#ifndef UISTATEMODEL_H
#define UISTATEMODEL_H
#include <QObject>
#include <QUrl>
#include <QHash>
#include <qstandardpaths.h>
/**
* @brief Handles state of UI by providing the qml source.
*
* Provides the possibility to switch between different
* ui states such as music player or navigation.
*/
class UiStateModel : public QObject
{
Q_OBJECT
Q_PROPERTY(QUrl pSource READ getSource NOTIFY sourceChanged)
Q_PROPERTY(bool pShowQuitAppButton READ isShowQuitAppButton NOTIFY profileChanged)
Q_PROPERTY(bool pShowVolumeControls READ isShowVolumeControls NOTIFY profileChanged)
signals:
void sourceChanged();
void profileChanged();
public:
/**
* @brief Provides the possibility to configure UI according to profile.
*/
enum EProfile : uint{
/**
* @brief Profile designed for running LenaPi as window manager on Raspberry Pi Touch
*
* Start fullscreen and do NOT show close button or volume controls
*/
Profile_RasPiTouch = 0,
/**
* @brief Profiled designed for running LenaPi as a desktop app.
*
* Start fullscreen, show close button and volume controls.
*/
Profile_Desktop
};
explicit UiStateModel(QObject *parent = nullptr);
/**
* @brief setProfile
* @param profileString String identifying profile as read from config.
*
* Known profile strings are "RasPiTouch" and "Desktop".
*/
void setProfile(const QString& profileString){ setProfile(getProfileFromString(profileString)); }
void setProfile(EProfile profile);
bool isShowQuitAppButton() const;
bool isShowVolumeControls() const;
QUrl getSource() const;
void showMusicPlayer();
void showNavigation();
private:
/**
* @brief Container defining ui state inforamtion for a certain profile
*/
struct ProfileInfo{
EProfile profileType = Profile_RasPiTouch;
bool isShowQuitAppButton = false;
bool isShowVolumeControls = false;
};
/**
* @brief Map containing ProfileInfo for each profile
*/
QHash<EProfile, ProfileInfo> mProfileInfoMap;
/**
* @brief Init ProfileInfo for all known profiles and init mProfileInfoMap
*/
void initProfiles();
/**
* @brief Transform given profile string to enum valie
* @param profileString String identifying profile
* @return Matching profile. If given string does not match a known profile, Profile_RasPiTouch is used as default.
*/
static EProfile getProfileFromString(const QString& profileString);
QUrl mSource;
EProfile mProfile = Profile_RasPiTouch;
};
#endif // UISTATEMODEL_H