#include "UiStateModel.h" #include UiStateModel::UiStateModel(QObject *parent) : QObject(parent) { initProfiles(); showNavigation(); } void UiStateModel::setProfile(UiStateModel::EProfile profile) { mProfile = profile; emit profileChanged(); } bool UiStateModel::isShowQuitAppButton() const { const auto & profileInfo = mProfileInfoMap[mProfile]; return profileInfo.isShowQuitAppButton; } bool UiStateModel::isShowVolumeControls() const { // return true; //comment in as workaround for maya pi const auto & profileInfo = mProfileInfoMap[mProfile]; return profileInfo.isShowVolumeControls; } QUrl UiStateModel::getSource() const { return mSource; } void UiStateModel::showMusicPlayer(){ mSource = QUrl("MusicPlayer.qml"); emit sourceChanged(); } void UiStateModel::showNavigation(){ mSource = QUrl("Navigation.qml"); emit sourceChanged(); } void UiStateModel::initProfiles() { // Profile_RasPiTouch ProfileInfo rasPiTouchProfile; rasPiTouchProfile.profileType = Profile_RasPiTouch; rasPiTouchProfile.isShowQuitAppButton = false; rasPiTouchProfile.isShowVolumeControls = false; mProfileInfoMap.insert(rasPiTouchProfile.profileType, rasPiTouchProfile); // Profile_Desktop ProfileInfo desktopProfile; desktopProfile.profileType = Profile_Desktop; desktopProfile.isShowQuitAppButton = true; desktopProfile.isShowVolumeControls = true; mProfileInfoMap.insert(desktopProfile.profileType, desktopProfile); } UiStateModel::EProfile UiStateModel::getProfileFromString(const QString &profileString) { if(profileString == "Desktop"){ return Profile_Desktop; } else if(profileString != "RasPiTouch"){ std::cout << "WARNING: Unknown profile\t" << profileString.toStdString() << std::endl; } return Profile_RasPiTouch; }