From f516ef9fb568076de8eb12ada6712f6e0f068366 Mon Sep 17 00:00:00 2001 From: kelteseth Date: Tue, 6 Jun 2017 12:51:53 +0200 Subject: [PATCH] laptop --- DefaultProfilePackage.json | 13 ++ ScreenPlay.pro | 12 +- assets/images/Window.svg | 6 +- main.cpp | 16 +++ qml.qrc | 3 +- qml/Components/FileDropper.qml | 12 +- qml/Components/Installed.qml | 3 +- qml/Components/Navigation.qml | 2 +- qml/Components/ScreenPlay.qml | 13 +- qml/Components/ScreenPlayItem.qml | 4 +- qml/Components/ScreenPlayItemImage.qml | 56 ++++++--- qml/Components/Screens/ScreenVideo.qml | 34 +++--- qml/Components/Settings.qml | 4 +- qml/main.qml | 43 ++++++- settings.json | 7 +- src/backend.cpp | 5 + src/backend.h | 2 + src/installedlistmodel.cpp | 22 +++- src/installedlistmodel.h | 21 +--- src/monitorlistmodel.cpp | 24 ++-- src/monitorlistmodel.h | 4 + src/profile.cpp | 6 + src/profile.h | 11 ++ src/profilelistmodel.cpp | 56 +++++++++ src/profilelistmodel.h | 35 ++++++ src/screenplay.cpp | 17 +-- src/screenplay.h | 9 +- src/settings.cpp | 66 ++++++++-- src/settings.h | 56 +++++++-- src/settings.h.CX9396 | 161 ++++++++++++++++++++++++ src/settings.h.mN9396 | 161 ++++++++++++++++++++++++ src/settings.h.pl9396 | 161 ++++++++++++++++++++++++ src/settings.h.vE9396 | 161 ++++++++++++++++++++++++ src/settings.h.yd2772 | 163 +++++++++++++++++++++++++ src/settings.h.yu9396 | 161 ++++++++++++++++++++++++ src/wallpaper.cpp | 27 ++++ src/wallpaper.h | 33 +++++ 37 files changed, 1472 insertions(+), 118 deletions(-) create mode 100644 DefaultProfilePackage.json create mode 100644 src/profile.cpp create mode 100644 src/profile.h create mode 100644 src/profilelistmodel.cpp create mode 100644 src/profilelistmodel.h create mode 100644 src/settings.h.CX9396 create mode 100644 src/settings.h.mN9396 create mode 100644 src/settings.h.pl9396 create mode 100644 src/settings.h.vE9396 create mode 100644 src/settings.h.yd2772 create mode 100644 src/settings.h.yu9396 create mode 100644 src/wallpaper.cpp create mode 100644 src/wallpaper.h diff --git a/DefaultProfilePackage.json b/DefaultProfilePackage.json new file mode 100644 index 00000000..1f81269d --- /dev/null +++ b/DefaultProfilePackage.json @@ -0,0 +1,13 @@ +{ + "Screens": + [ + { "ScreenName1": {"id": "abc", "fillmode": "stretch"} }, + { "ScreenName2": {"id": "xyz"} } + ], + "Widgets": + [ + { "WidgetName1": {"id": "abc"} }, + { "WidgetName2": {"id": "aaa"} } + ], + "Plays": [] +} \ No newline at end of file diff --git a/ScreenPlay.pro b/ScreenPlay.pro index e8ae379c..3ca53877 100644 --- a/ScreenPlay.pro +++ b/ScreenPlay.pro @@ -12,7 +12,10 @@ SOURCES += main.cpp \ src/backend.cpp \ src/monitorlistmodel.cpp \ src/settings.cpp \ - src/packagefilehandler.cpp + src/packagefilehandler.cpp \ + src/wallpaper.cpp \ + src/profilelistmodel.cpp \ + src/profile.cpp RESOURCES += qml.qrc @@ -23,12 +26,17 @@ HEADERS += \ src/backend.h \ src/monitorlistmodel.h \ src/settings.h \ - src/packagefilehandler.h + src/packagefilehandler.h \ + src/wallpaper.h \ + src/profilelistmodel.h \ + src/profile.h INCLUDEPATH += \ $$PWD/ThirdParty/ \ $$PWD/src/\ +INCLUDEPATH += . + CONFIG(debug, debug|release) { install_it.path = $${OUT_PWD}/debug/ } else { diff --git a/assets/images/Window.svg b/assets/images/Window.svg index 4ba15522..c04e9244 100644 --- a/assets/images/Window.svg +++ b/assets/images/Window.svg @@ -1 +1,5 @@ - \ No newline at end of file + + + + + diff --git a/main.cpp b/main.cpp index 28656471..de39ba0c 100644 --- a/main.cpp +++ b/main.cpp @@ -19,11 +19,16 @@ #include "backend.h" #include "installedlistmodel.h" #include "monitorlistmodel.h" +#include "packagefilehandler.h" #include "screenplay.h" #include "settings.h" +#include "profilelistmodel.h" int main(int argc, char* argv[]) { + + Q_INIT_RESOURCE(qml); + QGuiApplication app(argc, argv); QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); @@ -35,12 +40,19 @@ int main(int argc, char* argv[]) InstalledListModel installedListModel; MonitorListModel monitorListModel; + PackageFileHandler packageFileHandler; + ProfileListModel profileListModel; + // Create settings at the end because for now it depends on + // such things as the profile list model to complete Settings settings; + monitorListModel.loadMonitors(); QQmlApplicationEngine mainWindow; mainWindow.rootContext()->setContextProperty("monitorListModel", &monitorListModel); mainWindow.rootContext()->setContextProperty("installedListModel", &installedListModel); mainWindow.rootContext()->setContextProperty("settings", &settings); + mainWindow.rootContext()->setContextProperty("packageFileHandler", &packageFileHandler); + mainWindow.rootContext()->setContextProperty("profileListModel", &profileListModel); mainWindow.load(QUrl(QStringLiteral("qrc:/qml/main.qml"))); ScreenPlay sp(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); @@ -50,6 +62,10 @@ int main(int argc, char* argv[]) sp.loadQQuickView(QUrl(QStringLiteral("qrc:/qml/Components/ScreenPlay.qml"))); sp.showQQuickView(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); + installedListModel.loadScreens(); + QObject::connect(&installedListModel, &InstalledListModel::setScreenVisible, + &sp, &ScreenPlay::setVisible); + int status = app.exec(); //Shutdown diff --git a/qml.qrc b/qml.qrc index 75483ab0..fe0754b9 100644 --- a/qml.qrc +++ b/qml.qrc @@ -8,7 +8,6 @@ qml/Components/ScreenPlay.qml qml/Components/Settings.qml qml/Components/Page.qml - qml/Components/Settings/SettingBool.qml assets/licenses/Apache2.txt assets/licenses/OFL.txt assets/fonts/LibreBaskerville-Italic.ttf @@ -36,6 +35,8 @@ qml/Components/Settings/SettingBool.qml qml/Components/Headline.qml qtquickcontrols2.conf + qml/Components/FileDropper.qml qml/Components/Widgets/Window.qml + settings.json diff --git a/qml/Components/FileDropper.qml b/qml/Components/FileDropper.qml index f9322771..5f438530 100644 --- a/qml/Components/FileDropper.qml +++ b/qml/Components/FileDropper.qml @@ -14,9 +14,14 @@ DropArea { dropper.state = "invisible" } + Connections { + target: packageFileHandler + onCurrentLoaderStatusChanged:print("aaaaa") + } + onDropped: { var a= packageFileHandler.loadPackageFromLocalZip(drop.urls,".") - print(LoaderStatus.AllErrors) + print(packageFileHandler.currentLoaderStatus) if(a === -1) { dropper.state = "badFile" @@ -71,6 +76,11 @@ DropArea { target: fill opacity: 0 } + + PropertyChanges { + target: text1 + opacity: 0 + } }, State { name: "badFile" diff --git a/qml/Components/Installed.qml b/qml/Components/Installed.qml index 5a3e0709..36e28f5b 100644 --- a/qml/Components/Installed.qml +++ b/qml/Components/Installed.qml @@ -41,8 +41,7 @@ Page { } add: Transition { - NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400; } - NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } + NumberAnimation { properties: "x,y"; from: 100; duration: 1000 } } displaced: Transition { diff --git a/qml/Components/Navigation.qml b/qml/Components/Navigation.qml index 3a2a9068..d7dd0de3 100644 --- a/qml/Components/Navigation.qml +++ b/qml/Components/Navigation.qml @@ -100,7 +100,7 @@ Rectangle { Text { id: activeMonitorName - text: qsTr("Monitor Name") + text: qsTr("Monitor Setup") anchors.right: image.right anchors.rightMargin: 20 + image.width horizontalAlignment: Text.AlignRight diff --git a/qml/Components/ScreenPlay.qml b/qml/Components/ScreenPlay.qml index f2c288b9..f5adfc0f 100644 --- a/qml/Components/ScreenPlay.qml +++ b/qml/Components/ScreenPlay.qml @@ -4,13 +4,13 @@ import QtAV 1.07 Item { id:empty - height: parent.height - width: parent.width + anchors.fill: parent -// Loader { -// anchors.fill: parent -// source: "qrc:/qml/Components/Screens/ScreenVideo.qml" -// } + + Loader { + anchors.fill: parent + source: "qrc:/qml/Components/Screens/ScreenVideo.qml" + } Connections { target: installedListModel @@ -19,6 +19,7 @@ Item { video.stop() video.source = absolutePath; video.play(); + print(absolutePath) } } diff --git a/qml/Components/ScreenPlayItem.qml b/qml/Components/ScreenPlayItem.qml index 79a0e64f..1d9c4bab 100644 --- a/qml/Components/ScreenPlayItem.qml +++ b/qml/Components/ScreenPlayItem.qml @@ -32,7 +32,7 @@ Item { Rectangle { id: itemWrapper color: "white" - radius: 5 + radius: 2 anchors { fill: parent margins: 5 @@ -67,8 +67,8 @@ Item { antialiasing: true source: rectangle1 maskSource: mask - } + MouseArea { anchors.fill: parent onClicked: { diff --git a/qml/Components/ScreenPlayItemImage.qml b/qml/Components/ScreenPlayItemImage.qml index f9adf7f0..b6bd4cac 100644 --- a/qml/Components/ScreenPlayItemImage.qml +++ b/qml/Components/ScreenPlayItemImage.qml @@ -1,13 +1,18 @@ import QtQuick 2.7 -Image { - id: image +Item { + id: screenPlayItemImage width: 320 height: 121 + anchors.bottomMargin: 0 state: "loading" property string sourceImage: "" + onSourceImageChanged: { + image.source = screenPlayItemImage.sourceImage + } + states: [ State { name: "loading" @@ -16,6 +21,11 @@ Image { target: image opacity: 0 } + + PropertyChanges { + target: text1 + wrapMode: Text.WrapAnywhere + } }, State { name: "loaded" @@ -24,6 +34,11 @@ Image { target: image opacity: 1 } + + PropertyChanges { + target: text1 + opacity: 0 + } } ] @@ -38,25 +53,36 @@ Image { duration: 300 easing.type: Easing.InOutQuad } + NumberAnimation { + target: text1 + property: "opacity" + duration: 300 + easing.type: Easing.InOutQuad + } } ] + Image { + id:image + anchors.fill: parent + antialiasing: false + asynchronous: true + //sourceSize: Qt.size(320,121) + fillMode: Image.PreserveAspectCrop + source: screenPlayItemImage.sourceImage.trim() - onSourceImageChanged: { - image.source = sourceImage + onStatusChanged: { + + if (image.status === Image.Ready) + screenPlayItemImage.state = "loaded" + } } - opacity: 0 - anchors.bottomMargin: 0 - antialiasing: false - asynchronous: true - fillMode: Image.PreserveAspectCrop - source: sourceImage - anchors.fill: parent - - onStatusChanged: { - if (image.status == Image.Ready) - image.state = "loaded" + Text { + id: text1 + text: "" + anchors.fill: parent + font.pixelSize: 12 } } diff --git a/qml/Components/Screens/ScreenVideo.qml b/qml/Components/Screens/ScreenVideo.qml index cf8f0030..536a16fd 100644 --- a/qml/Components/Screens/ScreenVideo.qml +++ b/qml/Components/Screens/ScreenVideo.qml @@ -1,24 +1,26 @@ import QtQuick 2.0 -import QtAV 1.07 +//import QtAV 1.07 Rectangle { color: "orange" - height: parent.height - width: parent.width - Connections { - target: installedListModel - onSetScreenToVideo:{ - installedListModel.setScreenVisibleFromQml(true) - video.stop() - video.source = absolutePath; - video.play(); - } - } - Video { - id: video - anchors.fill: parent - } +// height: parent.height +// width: parent.width + + +// Connections { +// target: installedListModel +// onSetScreenToVideo:{ +// installedListModel.setScreenVisibleFromQml(true) +// video.stop() +// video.source = absolutePath; +// video.play(); +// } +// } +// Video { +// id: video +// anchors.fill: parent +// } } diff --git a/qml/Components/Settings.qml b/qml/Components/Settings.qml index 8e2125d0..c7550c22 100644 --- a/qml/Components/Settings.qml +++ b/qml/Components/Settings.qml @@ -1,7 +1,7 @@ import QtQuick 2.7 import QtQuick.Controls 1.4 import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.1 + import "Settings/" @@ -17,7 +17,7 @@ Page { SettingBool { name: "Autostart" isChecked: settings.autostart - onCheckboxChanged: settings.setAutostart(checked) + //onCheckboxChanged: settings.setAutostart(checked) } Headline { name: "Misc" diff --git a/qml/main.qml b/qml/main.qml index fee4d89e..c79d6a5f 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -5,7 +5,7 @@ import QtQuick.Layouts 1.3 import "Components" -Window { +ApplicationWindow { id: window color: "#eeeeee" visible: true @@ -13,10 +13,18 @@ Window { minimumHeight: 768 minimumWidth: 1050 + Component.onCompleted: { setX(Screen.width / 2 - width / 2); setY(Screen.height / 2 - height / 2); } + + // Fixme: make ui responsive at startup without timer + Timer{ + running: true; repeat: false + onTriggered: pageLoader.source = "qrc:/qml/Components/Installed.qml" + } + Loader { id: pageLoader anchors { @@ -25,7 +33,33 @@ Window { bottom: parent.bottom left: parent.left } - source: "qrc:/qml/Components/Installed.qml" + onStateChanged: { + if(pageLoader.state === Loader.Loading){ + loaderText.visible = true + } else if(pageLoader.state === Loader.Ready){ + loaderText.visible = false + } + } + + Text { + id: loaderText + visible: true + text: qsTr("Loading...") + anchors.centerIn: parent + font.pixelSize: 32 + + font.family: font_LibreBaskerville_Italic.name + font.pointSize: 32 + font.italic: true + color: "#818181" + FontLoader{ + id: font_LibreBaskerville_Italic + source: "qrc:/assets/fonts/LibreBaskerville-Italic.ttf" + } + } + + + // onSourceChanged: pageLoaderAnim.running = true // SequentialAnimation { @@ -76,6 +110,7 @@ Window { onToggleMonitors: { monitors.state = monitors.state == "active" ? "inactive" : "active" } + } Monitors { @@ -85,5 +120,9 @@ Window { z:98 } + FileDropper { + anchors.fill: parent + z:99 + } } diff --git a/settings.json b/settings.json index 3a25602f..bba5438c 100644 --- a/settings.json +++ b/settings.json @@ -6,5 +6,8 @@ "renderer": { "renderer-value": 0, "renderer-enum" : ["OpenGL","Vulkan", "DirectX11", "DirectX12", "Software"] - } -} \ No newline at end of file + }, + "profiles":[ + { "monitorID": "","profile": "" } + ] +} diff --git a/src/backend.cpp b/src/backend.cpp index e58523c8..ca96a75b 100644 --- a/src/backend.cpp +++ b/src/backend.cpp @@ -9,3 +9,8 @@ void Backend::getTest() { emit setTest(); } + +void Backend::exit() +{ + qDebug() << "EXIOTTT"; +} diff --git a/src/backend.h b/src/backend.h index 0c1c402e..ab142cbb 100644 --- a/src/backend.h +++ b/src/backend.h @@ -2,6 +2,7 @@ #define BACKEND_H #include +#include class Backend : public QObject { @@ -14,6 +15,7 @@ signals: public slots: void getTest(); + void exit(); }; #endif // BACKEND_H diff --git a/src/installedlistmodel.cpp b/src/installedlistmodel.cpp index 9b53202f..d07e28ea 100644 --- a/src/installedlistmodel.cpp +++ b/src/installedlistmodel.cpp @@ -9,13 +9,13 @@ InstalledListModel::InstalledListModel(QObject* parent) if (!QDir(writablePath).exists()) { if (!QDir().mkdir(writablePath)) { qWarning("ERROR: Cloud not create install dir"); + return; } } else { - _screensPath = writablePath + "/Installed/"; + _screensPath = writablePath + "/Wallpaper/"; } - loadScreens(); } int InstalledListModel::rowCount(const QModelIndex& parent) const @@ -77,7 +77,6 @@ void InstalledListModel::loadScreens() for (auto&& item : list) { tmpPath = _screensPath + item.baseName() + "/project.json"; - if (!QFile(tmpPath).exists()) continue; @@ -122,3 +121,20 @@ void InstalledListModel::setScreenToVideoFromQml(QString absolutePath) { emit setScreenToVideo(absolutePath); } + +ScreenPlayFile::ScreenPlayFile(QJsonObject obj, QString folderName) +{ + if (obj.contains("description")) + _description = obj.value("description"); + + if (obj.contains("file")) + _file = obj.value("file"); + + if (obj.contains("preview")) + _preview = obj.value("preview"); + + if (obj.contains("title")) + _title = obj.value("title"); + + _folderId = folderName; +} diff --git a/src/installedlistmodel.h b/src/installedlistmodel.h index 63891a6a..626c6fee 100644 --- a/src/installedlistmodel.h +++ b/src/installedlistmodel.h @@ -26,8 +26,7 @@ public: // Basic functionality: int rowCount(const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex& index, - int role = Qt::DisplayRole) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; void append(const QJsonObject, const QString); QHash roleNames() const override; @@ -37,7 +36,6 @@ public: Q_INVOKABLE void setScreenToVideoFromQml(QString absolutePath); Q_PROPERTY(QString _screensPath READ name CONSTANT) - enum InstalledRole { TitleRole, PreviewRole, @@ -64,22 +62,7 @@ class ScreenPlayFile { public: ScreenPlayFile(); - ScreenPlayFile(QJsonObject obj, QString folderName) - { - if (obj.contains("description")) - _description = obj.value("description"); - - if (obj.contains("file")) - _file = obj.value("file"); - - if (obj.contains("preview")) - _preview = obj.value("preview"); - - if (obj.contains("title")) - _title = obj.value("title"); - - _folderId = folderName; - } + ScreenPlayFile(QJsonObject obj, QString folderName); QVariant _description; QVariant _file; diff --git a/src/monitorlistmodel.cpp b/src/monitorlistmodel.cpp index 6a0a23fa..8bcfe5e1 100644 --- a/src/monitorlistmodel.cpp +++ b/src/monitorlistmodel.cpp @@ -3,15 +3,7 @@ MonitorListModel::MonitorListModel(QObject *parent) : QAbstractListModel(parent) { - for (int i = 0; i < QApplication::screens().count(); i++) { - QScreen* screen = QApplication::screens().at(i); - _monitorList.append(Monitor(screen->manufacturer(), - screen->size(), - screen->availableGeometry(), - // More convenient for the user if the first monitor == 1 - i + 1)); - } } QHash MonitorListModel::roleNames() const @@ -104,6 +96,20 @@ bool MonitorListModel::removeRows(int row, int count, const QModelIndex &parent) endRemoveRows(); } +void MonitorListModel::loadMonitors() +{ + for (int i = 0; i < QApplication::screens().count(); i++) { + QScreen* screen = QApplication::screens().at(i); + + _monitorList.append(Monitor(screen->name(), + screen->size(), + screen->availableGeometry(), + + // More convenient for the user if the first monitor == 1 + i + 1)); + } +} + Monitor::Monitor() { @@ -115,4 +121,6 @@ Monitor::Monitor(QString name, QSize size, QRect availableGeometry, int number) _size = size; _availableGeometry = availableGeometry; _number = number; + // FIXME 5.9: Use device id and manufacturer when 5.9 is available + _id = name + QString::number(size.width()) + QString::number(size.height()) + QString::number(availableGeometry.x()) + QString::number( availableGeometry.y()); } diff --git a/src/monitorlistmodel.h b/src/monitorlistmodel.h index 2eeb3182..db9d9681 100644 --- a/src/monitorlistmodel.h +++ b/src/monitorlistmodel.h @@ -9,12 +9,14 @@ #include #include #include +#include "settings.h" class Monitor; class MonitorListModel : public QAbstractListModel { Q_OBJECT + friend Settings; public: explicit MonitorListModel(QObject *parent = nullptr); @@ -51,6 +53,7 @@ public: // Remove data: bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) override; + void loadMonitors(); private: QVector _monitorList; }; @@ -61,6 +64,7 @@ public: Monitor(); Monitor(QString name, QSize size, QRect availableGeometry, int number); + QString _id; QString _name; QSize _size; QRect _availableGeometry; diff --git a/src/profile.cpp b/src/profile.cpp new file mode 100644 index 00000000..79cdc746 --- /dev/null +++ b/src/profile.cpp @@ -0,0 +1,6 @@ +#include "profile.h" + +Profile::Profile() +{ + +} diff --git a/src/profile.h b/src/profile.h new file mode 100644 index 00000000..42b6a643 --- /dev/null +++ b/src/profile.h @@ -0,0 +1,11 @@ +#ifndef PROFILE_H +#define PROFILE_H + + +class Profile +{ +public: + Profile(); +}; + +#endif // PROFILE_H \ No newline at end of file diff --git a/src/profilelistmodel.cpp b/src/profilelistmodel.cpp new file mode 100644 index 00000000..331c120c --- /dev/null +++ b/src/profilelistmodel.cpp @@ -0,0 +1,56 @@ +#include "profilelistmodel.h" + +ProfileListModel::ProfileListModel(QObject* parent) + : QAbstractListModel(parent) +{ +} + +int ProfileListModel::rowCount(const QModelIndex& parent) const +{ + // For list models only the root node (an invalid parent) should return the list's size. For all + // other (valid) parents, rowCount() should return 0 so that it does not become a tree model. + if (parent.isValid()) + return 0; + + return m_profileList.count(); +} + +QVariant ProfileListModel::data(const QModelIndex& index, int role) const +{ + if (!index.isValid()) + return QVariant(); + + int row = index.row(); + if (row < 0 || row >= m_profileList.count()) { + return QVariant(); + } + + switch (role) { + case NameRole: + return QVariant(); + } + return QVariant(); +} + +QHash ProfileListModel::roleNames() const +{ + return m_roleNames; +} + +void ProfileListModel::loadProfiles() +{ + + QString writablePath = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) ; + if (!QDir(writablePath).exists()) { + if (!QDir().mkdir(writablePath)) { + qWarning("ERROR: Cloud not create install dir"); + + return; + } + } else { + + } + +} + + diff --git a/src/profilelistmodel.h b/src/profilelistmodel.h new file mode 100644 index 00000000..1075eb0e --- /dev/null +++ b/src/profilelistmodel.h @@ -0,0 +1,35 @@ +#ifndef PROFILELISTMODEL_H +#define PROFILELISTMODEL_H + +#include "profile.h" +#include +#include +#include +#include +#include +#include + +class Profile; + +class ProfileListModel : public QAbstractListModel { + Q_OBJECT + +public: + explicit ProfileListModel(QObject* parent = 0); + + enum RoleNames { + NameRole = Qt::UserRole, + NumberRole = Qt::UserRole + 2 + }; + + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; + virtual QHash roleNames() const override; + void loadProfiles(); + +private: + QHash m_roleNames; + QVector m_profileList; +}; + +#endif // PROFILELISTMODEL_H diff --git a/src/screenplay.cpp b/src/screenplay.cpp index 7dec2323..13ba666d 100644 --- a/src/screenplay.cpp +++ b/src/screenplay.cpp @@ -1,17 +1,6 @@ #include "screenplay.h" -BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam) -{ - // 0xXXXXXXX "" WorkerW - // ... - // 0xXXXXXXX "" SHELLDLL_DefView - // 0xXXXXXXXX "FolderView" SysListView32 - // 0xXXXXXXXX "" WorkerW <---- We want this one - // 0xXXXXXXXX "Program Manager" Progman - if (FindWindowExW(hwnd, nullptr, L"SHELLDLL_DefView", nullptr)) - *reinterpret_cast(lparam) = FindWindowExW(nullptr, hwnd, L"WorkerW", nullptr); - return TRUE; -} + ScreenPlay::ScreenPlay(QWindow* parent) : QWindow(parent) @@ -39,7 +28,7 @@ ScreenPlay::ScreenPlay(int width, int height) 1000, nullptr); // Get window handle to the worker window and hide it - +/* EnumWindows(SearchForWorkerWindow, reinterpret_cast(&worker_hwnd)); ShowWindow(worker_hwnd, SW_SHOWDEFAULT); @@ -55,7 +44,7 @@ ScreenPlay::ScreenPlay(int width, int height) this->show(); //ShowWindow(hwnd, SW_SHOWDEFAULT); - +*/ // We do not want to display anything initially setVisible(false); } diff --git a/src/screenplay.h b/src/screenplay.h index 4a975ed3..0206d8f1 100644 --- a/src/screenplay.h +++ b/src/screenplay.h @@ -1,11 +1,11 @@ #ifndef SCREENPLAY_H #define SCREENPLAY_H +#include +#include #include #include -#include #include -#include class ScreenPlay : public QWindow { Q_OBJECT @@ -17,10 +17,7 @@ public: void loadQQuickView(QUrl path); void showQQuickView(int width, int height); - - - - QQmlContext *context() const; + QQmlContext* context() const; signals: diff --git a/src/settings.cpp b/src/settings.cpp index db960d5f..f58d9345 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -4,16 +4,17 @@ Settings::Settings(QObject* parent) : QObject(parent) { QFile configTmp; + QString appConfigLocation = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation); + configTmp.setFileName(appConfigLocation + "/settings.json"); + + // App Settings + if (!configTmp.exists()) + createDefaultConfig(); + QJsonDocument configJsonDocument; QJsonParseError parseError; QJsonObject configObj; - configTmp.setFileName(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/settings.json"); - - if (!configTmp.exists()) { - //If we cannot find the settings json file we will create one - createDefaultConfig(); - } configTmp.open(QIODevice::ReadOnly | QIODevice::Text); QString config = configTmp.readAll(); configJsonDocument = QJsonDocument::fromJson(config.toUtf8(), &parseError); @@ -23,16 +24,54 @@ Settings::Settings(QObject* parent) } configObj = configJsonDocument.object(); - m_version = configObj.value("version").toVariant(); + QString tmp(configObj.value("version").toVariant().toString()); + int major, minor, patch; + major = QString(tmp.at(0)).toInt(); + minor = QString(tmp.at(2)).toInt(); + patch = QString(tmp.at(4)).toInt(); + + //Checks if the settings file has the same version as ScreeenPlay + if (!(major == m_version.major && minor == m_version.minor && patch == m_version.patch)) { + //TODO Display error message + return; + } + m_autostart = configObj.value("autostart").toBool(); m_highPriorityStart = configObj.value("highPriorityStart").toBool(); m_sendStatistics = configObj.value("sendStatistics").toBool(); m_renderer = static_cast(configObj.value("renderer-value").toInt()); + + /* + * LOAD ACTIVE PROFILES + */ + + QJsonArray activeProfilesTmp; + activeProfilesTmp = configObj.value("profiles").toArray(); + int size = activeProfilesTmp.size(); + + // Only load profiles if we have any + if (size > 0) { + for (int i = 0; i < size; i++) { + QString profile = activeProfilesTmp.at(i).toObject().value("profile").toString(); + QString monitorID = activeProfilesTmp.at(i).toObject().value("monitorID").toString(); + m_activeProfiles.append(ActiveProfiles(profile, monitorID)); + constructWallpaper(profile, monitorID); + } + } + +} + +void Settings::createNewProfile(int screenNumber) +{ +} + +void Settings::constructWallpaper(QString profile, QString monitorID) +{ + //m_wallpapers.append(Wallpaper( )); } void Settings::createDefaultConfig() { - Q_INIT_RESOURCE(qml); QFile file(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/settings.json"); QFile defaultSettings(":/settings.json"); @@ -46,4 +85,15 @@ void Settings::createDefaultConfig() out << defaultOut.readAll(); file.close(); + defaultSettings.close(); +} + +ActiveProfiles::ActiveProfiles() +{ +} + +ActiveProfiles::ActiveProfiles(QString name, QString id) +{ + m_name = name; + m_id = id; } diff --git a/src/settings.h b/src/settings.h index b4a9810d..5f2c2733 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,6 +1,7 @@ #ifndef SCREENPLAYSETTINGS_H #define SCREENPLAYSETTINGS_H +#include #include #include #include @@ -10,19 +11,31 @@ #include #include #include +#include #include -#include +#include +#include + +#include "wallpaper.h" +#include "profile.h" + + +class ActiveProfiles; +class Profile; class Settings : public QObject { Q_OBJECT public: explicit Settings(QObject* parent = nullptr); - Q_PROPERTY(QVariant version READ version) Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(Version version READ version) + + Q_INVOKABLE void createNewProfile(int screenNumber); + Q_INVOKABLE void constructWallpaper(QString profile, QString monitorID); enum Renderer { OpenGL, @@ -30,10 +43,11 @@ public: }; Q_ENUM(Renderer) - QVariant version() const - { - return m_version; - } + struct Version { + int major = 0; + int minor = 0; + int patch = 0; + }; bool autostart() const { @@ -55,6 +69,11 @@ public: return m_sendStatistics; } + Version version() const + { + return m_version; + } + signals: void autostartChanged(bool autostart); @@ -115,12 +134,35 @@ public slots: private: void createDefaultConfig(); + void createProfileConfig(); - QVariant m_version = ""; bool m_autostart = true; bool m_highPriorityStart = true; Renderer m_renderer = Renderer::OpenGL; bool m_sendStatistics; + Version m_version; + + QVector m_wallpapers; + QVector m_activeProfiles; + + }; + +class ActiveProfiles { +public: + ActiveProfiles(); + ActiveProfiles(QString name, QString id); + +private: + QString m_name; + QString m_id; + Profile m_profile; +}; + +enum FillMode { + Stretch, + PreserveAspectFit, + PreserveAspectCrop, +}; #endif // SCREENPLAYSETTINGS_H diff --git a/src/settings.h.CX9396 b/src/settings.h.CX9396 new file mode 100644 index 00000000..95e5b267 --- /dev/null +++ b/src/settings.h.CX9396 @@ -0,0 +1,161 @@ +#ifndef SCREENPLAYSETTINGS_H +#define SCREENPLAYSETTINGS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wallpaper.h" + +class ActiveProfiles; +class Profile; + +class Settings : public QObject { + Q_OBJECT +public: + explicit Settings(QObject* parent = nullptr); + + Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) + Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) + Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) + Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(Version version READ version) + + Q_INVOKABLE void createNewProfile(int screenNumber); + Q_INVOKABLE void constructWallpaper(QString profile, QString monitorID); + + enum Renderer { + OpenGL, + Softare, + }; + Q_ENUM(Renderer) + + struct Version { + int major = 0; + int minor = 0; + int patch = 0; + }; + + bool autostart() const + { + return m_autostart; + } + + bool highPriorityStart() const + { + return m_highPriorityStart; + } + + Renderer renderer() const + { + return m_renderer; + } + + bool sendStatistics() const + { + return m_sendStatistics; + } + + Version version() const + { + return m_version; + } + +signals: + + void autostartChanged(bool autostart); + + void highPriorityStartChanged(bool highPriorityStart); + + void rendererChanged(Renderer renderer); + + void sendStatisticsChanged(bool sendStatistics); + +public slots: + + void setAutostart(bool autostart) + { + qDebug() << autostart; + if (m_autostart == autostart) + return; + + m_autostart = autostart; + emit autostartChanged(m_autostart); + } + + void setHighPriorityStart(bool highPriorityStart) + { + if (m_highPriorityStart == highPriorityStart) + return; + + m_highPriorityStart = highPriorityStart; + emit highPriorityStartChanged(m_highPriorityStart); + } + + void setRenderer(Renderer renderer) + { + if (m_renderer == renderer) + return; + + m_renderer = renderer; + emit rendererChanged(m_renderer); + } + + void setsendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + + void setSendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + +private: + void createDefaultConfig(); + void createProfileConfig(); + + bool m_autostart = true; + bool m_highPriorityStart = true; + Renderer m_renderer = Renderer::OpenGL; + bool m_sendStatistics; + Version m_version; + + QVector m_wallpapers; + QVector m_activeProfiles; +}; + +class ActiveProfiles { +public: + ActiveProfiles(); + ActiveProfiles(QString name, QString id); + +private: + QString m_name; + QString m_id; +}; + +enum FillMode { + Stretch, + PreserveAspectFit, + PreserveAspectCrop, +}; +#endif // SCREENPLAYSETTINGS_H diff --git a/src/settings.h.mN9396 b/src/settings.h.mN9396 new file mode 100644 index 00000000..95e5b267 --- /dev/null +++ b/src/settings.h.mN9396 @@ -0,0 +1,161 @@ +#ifndef SCREENPLAYSETTINGS_H +#define SCREENPLAYSETTINGS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wallpaper.h" + +class ActiveProfiles; +class Profile; + +class Settings : public QObject { + Q_OBJECT +public: + explicit Settings(QObject* parent = nullptr); + + Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) + Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) + Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) + Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(Version version READ version) + + Q_INVOKABLE void createNewProfile(int screenNumber); + Q_INVOKABLE void constructWallpaper(QString profile, QString monitorID); + + enum Renderer { + OpenGL, + Softare, + }; + Q_ENUM(Renderer) + + struct Version { + int major = 0; + int minor = 0; + int patch = 0; + }; + + bool autostart() const + { + return m_autostart; + } + + bool highPriorityStart() const + { + return m_highPriorityStart; + } + + Renderer renderer() const + { + return m_renderer; + } + + bool sendStatistics() const + { + return m_sendStatistics; + } + + Version version() const + { + return m_version; + } + +signals: + + void autostartChanged(bool autostart); + + void highPriorityStartChanged(bool highPriorityStart); + + void rendererChanged(Renderer renderer); + + void sendStatisticsChanged(bool sendStatistics); + +public slots: + + void setAutostart(bool autostart) + { + qDebug() << autostart; + if (m_autostart == autostart) + return; + + m_autostart = autostart; + emit autostartChanged(m_autostart); + } + + void setHighPriorityStart(bool highPriorityStart) + { + if (m_highPriorityStart == highPriorityStart) + return; + + m_highPriorityStart = highPriorityStart; + emit highPriorityStartChanged(m_highPriorityStart); + } + + void setRenderer(Renderer renderer) + { + if (m_renderer == renderer) + return; + + m_renderer = renderer; + emit rendererChanged(m_renderer); + } + + void setsendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + + void setSendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + +private: + void createDefaultConfig(); + void createProfileConfig(); + + bool m_autostart = true; + bool m_highPriorityStart = true; + Renderer m_renderer = Renderer::OpenGL; + bool m_sendStatistics; + Version m_version; + + QVector m_wallpapers; + QVector m_activeProfiles; +}; + +class ActiveProfiles { +public: + ActiveProfiles(); + ActiveProfiles(QString name, QString id); + +private: + QString m_name; + QString m_id; +}; + +enum FillMode { + Stretch, + PreserveAspectFit, + PreserveAspectCrop, +}; +#endif // SCREENPLAYSETTINGS_H diff --git a/src/settings.h.pl9396 b/src/settings.h.pl9396 new file mode 100644 index 00000000..95e5b267 --- /dev/null +++ b/src/settings.h.pl9396 @@ -0,0 +1,161 @@ +#ifndef SCREENPLAYSETTINGS_H +#define SCREENPLAYSETTINGS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wallpaper.h" + +class ActiveProfiles; +class Profile; + +class Settings : public QObject { + Q_OBJECT +public: + explicit Settings(QObject* parent = nullptr); + + Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) + Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) + Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) + Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(Version version READ version) + + Q_INVOKABLE void createNewProfile(int screenNumber); + Q_INVOKABLE void constructWallpaper(QString profile, QString monitorID); + + enum Renderer { + OpenGL, + Softare, + }; + Q_ENUM(Renderer) + + struct Version { + int major = 0; + int minor = 0; + int patch = 0; + }; + + bool autostart() const + { + return m_autostart; + } + + bool highPriorityStart() const + { + return m_highPriorityStart; + } + + Renderer renderer() const + { + return m_renderer; + } + + bool sendStatistics() const + { + return m_sendStatistics; + } + + Version version() const + { + return m_version; + } + +signals: + + void autostartChanged(bool autostart); + + void highPriorityStartChanged(bool highPriorityStart); + + void rendererChanged(Renderer renderer); + + void sendStatisticsChanged(bool sendStatistics); + +public slots: + + void setAutostart(bool autostart) + { + qDebug() << autostart; + if (m_autostart == autostart) + return; + + m_autostart = autostart; + emit autostartChanged(m_autostart); + } + + void setHighPriorityStart(bool highPriorityStart) + { + if (m_highPriorityStart == highPriorityStart) + return; + + m_highPriorityStart = highPriorityStart; + emit highPriorityStartChanged(m_highPriorityStart); + } + + void setRenderer(Renderer renderer) + { + if (m_renderer == renderer) + return; + + m_renderer = renderer; + emit rendererChanged(m_renderer); + } + + void setsendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + + void setSendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + +private: + void createDefaultConfig(); + void createProfileConfig(); + + bool m_autostart = true; + bool m_highPriorityStart = true; + Renderer m_renderer = Renderer::OpenGL; + bool m_sendStatistics; + Version m_version; + + QVector m_wallpapers; + QVector m_activeProfiles; +}; + +class ActiveProfiles { +public: + ActiveProfiles(); + ActiveProfiles(QString name, QString id); + +private: + QString m_name; + QString m_id; +}; + +enum FillMode { + Stretch, + PreserveAspectFit, + PreserveAspectCrop, +}; +#endif // SCREENPLAYSETTINGS_H diff --git a/src/settings.h.vE9396 b/src/settings.h.vE9396 new file mode 100644 index 00000000..95e5b267 --- /dev/null +++ b/src/settings.h.vE9396 @@ -0,0 +1,161 @@ +#ifndef SCREENPLAYSETTINGS_H +#define SCREENPLAYSETTINGS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wallpaper.h" + +class ActiveProfiles; +class Profile; + +class Settings : public QObject { + Q_OBJECT +public: + explicit Settings(QObject* parent = nullptr); + + Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) + Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) + Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) + Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(Version version READ version) + + Q_INVOKABLE void createNewProfile(int screenNumber); + Q_INVOKABLE void constructWallpaper(QString profile, QString monitorID); + + enum Renderer { + OpenGL, + Softare, + }; + Q_ENUM(Renderer) + + struct Version { + int major = 0; + int minor = 0; + int patch = 0; + }; + + bool autostart() const + { + return m_autostart; + } + + bool highPriorityStart() const + { + return m_highPriorityStart; + } + + Renderer renderer() const + { + return m_renderer; + } + + bool sendStatistics() const + { + return m_sendStatistics; + } + + Version version() const + { + return m_version; + } + +signals: + + void autostartChanged(bool autostart); + + void highPriorityStartChanged(bool highPriorityStart); + + void rendererChanged(Renderer renderer); + + void sendStatisticsChanged(bool sendStatistics); + +public slots: + + void setAutostart(bool autostart) + { + qDebug() << autostart; + if (m_autostart == autostart) + return; + + m_autostart = autostart; + emit autostartChanged(m_autostart); + } + + void setHighPriorityStart(bool highPriorityStart) + { + if (m_highPriorityStart == highPriorityStart) + return; + + m_highPriorityStart = highPriorityStart; + emit highPriorityStartChanged(m_highPriorityStart); + } + + void setRenderer(Renderer renderer) + { + if (m_renderer == renderer) + return; + + m_renderer = renderer; + emit rendererChanged(m_renderer); + } + + void setsendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + + void setSendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + +private: + void createDefaultConfig(); + void createProfileConfig(); + + bool m_autostart = true; + bool m_highPriorityStart = true; + Renderer m_renderer = Renderer::OpenGL; + bool m_sendStatistics; + Version m_version; + + QVector m_wallpapers; + QVector m_activeProfiles; +}; + +class ActiveProfiles { +public: + ActiveProfiles(); + ActiveProfiles(QString name, QString id); + +private: + QString m_name; + QString m_id; +}; + +enum FillMode { + Stretch, + PreserveAspectFit, + PreserveAspectCrop, +}; +#endif // SCREENPLAYSETTINGS_H diff --git a/src/settings.h.yd2772 b/src/settings.h.yd2772 new file mode 100644 index 00000000..2f2895a5 --- /dev/null +++ b/src/settings.h.yd2772 @@ -0,0 +1,163 @@ +#ifndef SCREENPLAYSETTINGS_H +#define SCREENPLAYSETTINGS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wallpaper.h" + +class ActiveProfiles; + +class Settings : public QObject { + Q_OBJECT +public: + explicit Settings(QObject* parent = nullptr); + + Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) + Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) + Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) + Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(Version version READ version) + + Q_INVOKABLE void createNewProfile(int screenNumber); + + enum Renderer { + OpenGL, + Softare, + }; + Q_ENUM(Renderer) + + struct Version { + int major = 0; + int minor = 0; + int patch = 0; + }; + + bool autostart() const + { + return m_autostart; + } + + bool highPriorityStart() const + { + return m_highPriorityStart; + } + + Renderer renderer() const + { + return m_renderer; + } + + bool sendStatistics() const + { + return m_sendStatistics; + } + + Version version() const + { + return m_version; + } + +signals: + + void autostartChanged(bool autostart); + + void highPriorityStartChanged(bool highPriorityStart); + + void rendererChanged(Renderer renderer); + + void sendStatisticsChanged(bool sendStatistics); + +public slots: + + void setAutostart(bool autostart) + { + qDebug() << autostart; + if (m_autostart == autostart) + return; + + m_autostart = autostart; + emit autostartChanged(m_autostart); + } + + void setHighPriorityStart(bool highPriorityStart) + { + if (m_highPriorityStart == highPriorityStart) + return; + + m_highPriorityStart = highPriorityStart; + emit highPriorityStartChanged(m_highPriorityStart); + } + + void setRenderer(Renderer renderer) + { + if (m_renderer == renderer) + return; + + m_renderer = renderer; + emit rendererChanged(m_renderer); + } + + void setsendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + + void setSendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + +private: + void createDefaultConfig(); + void createProfileConfig(); + + bool m_autostart = true; + bool m_highPriorityStart = true; + Renderer m_renderer = Renderer::OpenGL; + bool m_sendStatistics; + Version m_version; + + QVector m_wallpapers; + QVector m_activeProfiles; +}; + +class ActiveProfiles { + +public: + ActiveProfiles(); + ActiveProfiles(QString name, QString id) + { + m_name = name; + m_id = id; + } + + QString m_name; + QString m_id; +}; + +enum FillMode { + Stretch, + PreserveAspectFit, + PreserveAspectCrop, +}; +#endif // SCREENPLAYSETTINGS_H diff --git a/src/settings.h.yu9396 b/src/settings.h.yu9396 new file mode 100644 index 00000000..95e5b267 --- /dev/null +++ b/src/settings.h.yu9396 @@ -0,0 +1,161 @@ +#ifndef SCREENPLAYSETTINGS_H +#define SCREENPLAYSETTINGS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "wallpaper.h" + +class ActiveProfiles; +class Profile; + +class Settings : public QObject { + Q_OBJECT +public: + explicit Settings(QObject* parent = nullptr); + + Q_PROPERTY(bool autostart READ autostart WRITE setAutostart NOTIFY autostartChanged) + Q_PROPERTY(bool highPriorityStart READ highPriorityStart WRITE setHighPriorityStart NOTIFY highPriorityStartChanged) + Q_PROPERTY(Renderer renderer READ renderer WRITE setRenderer NOTIFY rendererChanged) + Q_PROPERTY(bool sendStatistics READ sendStatistics WRITE setSendStatistics NOTIFY sendStatisticsChanged) + Q_PROPERTY(Version version READ version) + + Q_INVOKABLE void createNewProfile(int screenNumber); + Q_INVOKABLE void constructWallpaper(QString profile, QString monitorID); + + enum Renderer { + OpenGL, + Softare, + }; + Q_ENUM(Renderer) + + struct Version { + int major = 0; + int minor = 0; + int patch = 0; + }; + + bool autostart() const + { + return m_autostart; + } + + bool highPriorityStart() const + { + return m_highPriorityStart; + } + + Renderer renderer() const + { + return m_renderer; + } + + bool sendStatistics() const + { + return m_sendStatistics; + } + + Version version() const + { + return m_version; + } + +signals: + + void autostartChanged(bool autostart); + + void highPriorityStartChanged(bool highPriorityStart); + + void rendererChanged(Renderer renderer); + + void sendStatisticsChanged(bool sendStatistics); + +public slots: + + void setAutostart(bool autostart) + { + qDebug() << autostart; + if (m_autostart == autostart) + return; + + m_autostart = autostart; + emit autostartChanged(m_autostart); + } + + void setHighPriorityStart(bool highPriorityStart) + { + if (m_highPriorityStart == highPriorityStart) + return; + + m_highPriorityStart = highPriorityStart; + emit highPriorityStartChanged(m_highPriorityStart); + } + + void setRenderer(Renderer renderer) + { + if (m_renderer == renderer) + return; + + m_renderer = renderer; + emit rendererChanged(m_renderer); + } + + void setsendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + + void setSendStatistics(bool sendStatistics) + { + if (m_sendStatistics == sendStatistics) + return; + + m_sendStatistics = sendStatistics; + emit sendStatisticsChanged(m_sendStatistics); + } + +private: + void createDefaultConfig(); + void createProfileConfig(); + + bool m_autostart = true; + bool m_highPriorityStart = true; + Renderer m_renderer = Renderer::OpenGL; + bool m_sendStatistics; + Version m_version; + + QVector m_wallpapers; + QVector m_activeProfiles; +}; + +class ActiveProfiles { +public: + ActiveProfiles(); + ActiveProfiles(QString name, QString id); + +private: + QString m_name; + QString m_id; +}; + +enum FillMode { + Stretch, + PreserveAspectFit, + PreserveAspectCrop, +}; +#endif // SCREENPLAYSETTINGS_H diff --git a/src/wallpaper.cpp b/src/wallpaper.cpp new file mode 100644 index 00000000..55b69050 --- /dev/null +++ b/src/wallpaper.cpp @@ -0,0 +1,27 @@ +#include "wallpaper.h" + +BOOL WINAPI SearchForWorkerWindow(HWND hwnd, LPARAM lparam) +{ + // 0xXXXXXXX "" WorkerW + // ... + // 0xXXXXXXX "" SHELLDLL_DefView + // 0xXXXXXXXX "FolderView" SysListView32 + // 0xXXXXXXXX "" WorkerW <---- We want this one + // 0xXXXXXXXX "Program Manager" Progman + if (FindWindowExW(hwnd, nullptr, L"SHELLDLL_DefView", nullptr)) + *reinterpret_cast(lparam) = FindWindowExW(nullptr, hwnd, L"WorkerW", nullptr); + return TRUE; +} + +Wallpaper::Wallpaper(QWindow* parent) + : QWindow(parent) +{ +} + +Wallpaper::Wallpaper(QRect rect, float playback, bool isLooping, int fillmode) +{ + m_rect = rect; + m_playback = playback; + m_isLooping = isLooping; + m_fillmode = fillmode; +} diff --git a/src/wallpaper.h b/src/wallpaper.h new file mode 100644 index 00000000..6e863ebf --- /dev/null +++ b/src/wallpaper.h @@ -0,0 +1,33 @@ +#ifndef WALLPAPER_H +#define WALLPAPER_H + +#include +#include +#include +#include +#include + +#include + +class Wallpaper : public QWindow { + Q_OBJECT +public: + explicit Wallpaper(QWindow* parent = 0); + + Wallpaper(QRect rect, float playback, bool isLooping, int fillmode); + + QQmlContext* context() const; + +private: + HWND hwnd = nullptr; + HWND worker_hwnd = nullptr; + QQuickView* quickRenderer = nullptr; + QQmlContext* _context = nullptr; + + QRect m_rect; + float m_playback; + bool m_isLooping; + int m_fillmode; +}; + +#endif // WALLPAPER_H