diff --git a/main.cpp b/main.cpp index 95bb9c6a..d02f2c8f 100644 --- a/main.cpp +++ b/main.cpp @@ -51,6 +51,7 @@ int main(int argc, char* argv[]) QQmlApplicationEngine mainWindowEngine; + installedListModel.loadScreens(); mainWindowEngine.rootContext()->setContextProperty("monitorListModel", &monitorListModel); mainWindowEngine.rootContext()->setContextProperty("installedListModel", &installedListModel); mainWindowEngine.rootContext()->setContextProperty("settings", &settings); @@ -64,7 +65,7 @@ int main(int argc, char* argv[]) [&](){exit(app.exec()); }); - installedListModel.loadScreens(); + profileListModel.loadProfiles(); int status = app.exec(); //Shutdown diff --git a/qml/Components/Installed.qml b/qml/Components/Installed.qml index 36e28f5b..036e1add 100644 --- a/qml/Components/Installed.qml +++ b/qml/Components/Installed.qml @@ -41,16 +41,8 @@ Page { } add: Transition { - NumberAnimation { properties: "x,y"; from: 100; duration: 1000 } - } - - displaced: Transition { - NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } + NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400 } } - - - - } diff --git a/settings.json b/settings.json index bba5438c..f58a91eb 100644 --- a/settings.json +++ b/settings.json @@ -3,6 +3,7 @@ "autostart" : true, "highPriorityStart" : false, "sendStatistics" : false, + "absoluteStoragePath": "", //we use the Appdata folder if empty AppData\Local\Aimber\ScreenPlay "renderer": { "renderer-value": 0, "renderer-enum" : ["OpenGL","Vulkan", "DirectX11", "DirectX12", "Software"] diff --git a/src/installedlistmodel.cpp b/src/installedlistmodel.cpp index d07e28ea..da580dfe 100644 --- a/src/installedlistmodel.cpp +++ b/src/installedlistmodel.cpp @@ -3,19 +3,6 @@ InstalledListModel::InstalledListModel(QObject* parent) : QAbstractListModel(parent) { - - QString writablePath = QStandardPaths::writableLocation(QStandardPaths::StandardLocation::DataLocation); - - if (!QDir(writablePath).exists()) { - if (!QDir().mkdir(writablePath)) { - qWarning("ERROR: Cloud not create install dir"); - - return; - } - } else { - _screensPath = writablePath + "/Wallpaper/"; - } - } int InstalledListModel::rowCount(const QModelIndex& parent) const diff --git a/src/profile.cpp b/src/profile.cpp index 6049a532..cdb2fe51 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -5,8 +5,9 @@ Profile::Profile() } -Profile::Profile(QString id, QString version, QString wallpaperId, QRect rect, bool isLooping) +Profile::Profile(QUrl absolutePath, QString id, QString version, QString wallpaperId, QRect rect, bool isLooping) { + m_absolutePath = absolutePath; m_id = id; m_version = version; m_wallpaperId = wallpaperId; diff --git a/src/profile.h b/src/profile.h index 7bb1328b..c23dec27 100644 --- a/src/profile.h +++ b/src/profile.h @@ -3,12 +3,14 @@ #include #include +#include class Profile { public: Profile(); - Profile(QString id, QString version, QString wallpaperId, QRect rect, bool isLooping); + Profile(QUrl absolutePath, QString id, QString version, QString wallpaperId, QRect rect, bool isLooping); + QUrl m_absolutePath; QString m_id; QString m_version = ""; QString m_wallpaperId = ""; diff --git a/src/profilelistmodel.h b/src/profilelistmodel.h index 2042b294..c65affd5 100644 --- a/src/profilelistmodel.h +++ b/src/profilelistmodel.h @@ -8,7 +8,7 @@ #include #include #include - +#include #include class Profile; @@ -33,6 +33,8 @@ public: private: QHash m_roleNames; QVector m_profileList; + + QUrl m_absoluteStoragePath; }; #endif // PROFILELISTMODEL_H diff --git a/src/settings.cpp b/src/settings.cpp index 4e546022..85e8e20d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -8,8 +8,17 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo m_mlm = mlm; m_ilm = ilm; + QFile configTmp; QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); + + if (!QDir(appConfigLocation).exists()) { + if (!QDir().mkdir(appConfigLocation)) { + qWarning("ERROR: Cloud not create install dir"); + return; + } + } + configTmp.setFileName(appConfigLocation + "/settings.json"); // App Settings @@ -18,6 +27,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo createDefaultConfig(); } + QJsonDocument configJsonDocument; QJsonParseError parseError; QJsonObject configObj; @@ -45,6 +55,37 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo return; } + + if(QString(configObj.value("absoluteStoragePath").toString()).isEmpty()) + m_absoluteStoragePath = appConfigLocation; + + + //Create default folders + if (!QDir(appConfigLocation + "/ProfilePackages").exists()) { + if (!QDir().mkdir(appConfigLocation + "/ProfilePackages")) { + qWarning("ERROR: Cloud not create ProfilePackages dir"); + return; + } + } + if (!QDir(appConfigLocation + "/Profiles").exists()) { + if (!QDir().mkdir(appConfigLocation + "/Profiles")) { + qWarning("ERROR: Cloud not create Profiles dir"); + return; + } + } + if (!QDir(appConfigLocation + "/Wallpaper").exists()) { + if (!QDir().mkdir(appConfigLocation + "/Wallpaper")) { + qWarning("ERROR: Cloud not create Wallpaper dir"); + return; + } + } + if (!QDir(appConfigLocation + "/Widgets").exists()) { + if (!QDir().mkdir(appConfigLocation + "/Widgets")) { + qWarning("ERROR: Cloud not create Widgets dir"); + return; + } + } + m_autostart = configObj.value("autostart").toBool(); m_highPriorityStart = configObj.value("highPriorityStart").toBool(); m_sendStatistics = configObj.value("sendStatistics").toBool(); @@ -64,6 +105,7 @@ Settings::Settings(ProfileListModel* plm, MonitorListModel* mlm, InstalledListMo QString profileName = activeProfilesTmp.at(i).toObject().value("profile").toString(); QString monitorID = activeProfilesTmp.at(i).toObject().value("monitorID").toString(); Profile profile; + if (!m_plm->getProfileByName(profileName, &profile)) continue; diff --git a/src/settings.h b/src/settings.h index 421da87d..542fc8c1 100644 --- a/src/settings.h +++ b/src/settings.h @@ -140,8 +140,11 @@ private: bool m_autostart = true; bool m_highPriorityStart = true; - Renderer m_renderer = Renderer::OpenGL; bool m_sendStatistics; + + QUrl m_absoluteStoragePath; + + Renderer m_renderer = Renderer::OpenGL; Version m_version; ProfileListModel* m_plm; InstalledListModel* m_ilm;