added config

This commit is contained in:
Anika Raemer 2021-09-26 21:49:21 +02:00
parent 893a2990af
commit f02f439790
7 changed files with 168 additions and 17 deletions

View file

@ -3,6 +3,7 @@
#include <QObject>
#include <QUrl>
#include <QHash>
/**
* @brief Handles state of UI by providing the qml source.
@ -15,9 +16,12 @@ 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:
/**
@ -37,15 +41,51 @@ public:
*/
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