diff --git a/assets/images/Window.svg b/assets/images/Window.svg new file mode 100644 index 00000000..d3e7b474 --- /dev/null +++ b/assets/images/Window.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/main.cpp b/main.cpp index 4745e019..7f4dbaaa 100644 --- a/main.cpp +++ b/main.cpp @@ -38,6 +38,5 @@ int main(int argc, char* argv[]) int status = app.exec(); //Shutdown - return status; } diff --git a/qml.qrc b/qml.qrc index 1325aa41..f563c781 100644 --- a/qml.qrc +++ b/qml.qrc @@ -22,5 +22,6 @@ assets/icons/icon_workshop.svg qml/Components/ScreenPlayItem.qml qml/Components/Sidebar.qml + assets/images/Window.svg diff --git a/qml/Components/Installed.qml b/qml/Components/Installed.qml index 9279c587..b26c5318 100644 --- a/qml/Components/Installed.qml +++ b/qml/Components/Installed.qml @@ -5,36 +5,49 @@ import QtQml.Models 2.2 Page { id:pageInstalled - pageName: "Installed" + pageName: "" - signal toggleSidebar(var screenName) + signal setSidebaractiveItem(var screenId) GridView { id: gridView + boundsBehavior: Flickable.DragOverBounds + cacheBuffer: 1000 + maximumFlickVelocity: 7000 anchors.fill: parent cellWidth: 320 cellHeight: 200 anchors.margins: 30 - - - - - + model: installedListModel delegate: ScreenPlayItem { id:delegate focus: true customTitle: title + screenId: screenFolderId Connections { target: delegate onItemClicked: { - toggleSidebar(screenName) + setSidebaractiveItem(screenId) } } } + Component.onCompleted: { + + } + + add: Transition { + NumberAnimation { property: "opacity"; from: 0; to: 1.0; duration: 400; } + NumberAnimation { property: "scale"; from: 0; to: 1.0; duration: 400 } + } + + displaced: Transition { + NumberAnimation { properties: "x,y"; duration: 400; easing.type: Easing.OutBounce } + } + + - model: installedListModel } diff --git a/qml/Components/ScreenPlayItem.qml b/qml/Components/ScreenPlayItem.qml index 819b97b0..2531d7e7 100644 --- a/qml/Components/ScreenPlayItem.qml +++ b/qml/Components/ScreenPlayItem.qml @@ -1,4 +1,6 @@ import QtQuick 2.0 +import QtGraphicalEffects 1.0 + Item { id:screenPlayItem @@ -6,34 +8,70 @@ Item { height: 180 property string customTitle: "name here" - signal itemClicked(var screenName) + property string screenId: "" + signal itemClicked(var screenId) + + OpacityMask { + anchors.fill: itemWrapper + source: itemWrapper + maskSource: mask + invert: true + } + + Image { + id: mask + source: "qrc:/assets/images/Window.svg" + sourceSize: Qt.size(itemWrapper.width, itemWrapper.height) + smooth: true + visible: false + } Rectangle { - id: rectangle + id: itemWrapper color: "white" radius: 23 + + anchors { fill: parent margins:5 } - Text { - id: text1 - text: customTitle - renderType: Text.QtRendering - wrapMode: Text.WrapAnywhere - anchors.fill: parent - font.pixelSize: 18 - anchors.margins: 10 - + Rectangle { + id: rectangle1 + height: 103 + color: "#8b8b8b" + anchors.right: parent.right + anchors.rightMargin: 0 + anchors.left: parent.left + anchors.leftMargin: 0 + anchors.top: parent.top + anchors.topMargin: 0 + Image { + id: image + asynchronous: true + fillMode: Image.PreserveAspectCrop + anchors.fill: parent + source: Qt.resolvedUrl("file:///" + installedListModel._screensPath + screenFolderId + "/" + screenPreview) + } } + Text { + id: text1 + text: screenTitle + anchors.topMargin: 117 + wrapMode: Text.WrapAnywhere + anchors.fill: parent + font.pixelSize: 12 + anchors.margins: 10 + + } MouseArea { anchors.fill: parent onClicked: { - itemClicked(customTitle) + itemClicked(screenId) } } } diff --git a/qml/Components/Sidebar.qml b/qml/Components/Sidebar.qml index 155c2de3..f0d3e2a2 100644 --- a/qml/Components/Sidebar.qml +++ b/qml/Components/Sidebar.qml @@ -9,6 +9,14 @@ Item { state: "inactive" focus: true + property string activeScreen: "" + + onActiveScreenChanged:{ + print(activeScreen) + + } + + Item { id: sidebarWrapper @@ -53,6 +61,19 @@ Item { } } + Button { + id: button1 + y: 710 + text: qsTr("Set wallpaper") + anchors.left: parent.left + anchors.leftMargin: 148 + anchors.bottom: parent.bottom + anchors.bottomMargin: 18 + onClicked: { + + } + } + } Rectangle { diff --git a/qml/main.qml b/qml/main.qml index 1160801b..620d7149 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -7,14 +7,11 @@ import QtQuick.Layouts 1.3 import "Components" Window { - id: rectangle + id: window color: "#eeeeee" visible: true width: 1366 height: 768 - Component.onCompleted: installedListModel.loadDrives() - - Loader { id: pageLoader @@ -25,14 +22,22 @@ Window { left: parent.left } source: "qrc:/qml/Components/Installed.qml" +// onSourceChanged: pageLoaderAnim.running = true + +// SequentialAnimation { +// id:pageLoaderAnim +// running: true +// NumberAnimation { target: pageLoader.item; property: "opacity"; from:0; to: 1; duration: 500 } +// NumberAnimation { target: pageLoader.item; property: "y"; from: -100; to: 0; duration: 300 } +// } Connections{ target: pageLoader.item ignoreUnknownSignals: true - onToggleSidebar: { - sidebar.state = sidebar.state === "active" ? "inactive" : "active" + onSetSidebaractiveItem: { + sidebar.activeScreen = screenId + sidebar.state = "active" } - } } diff --git a/src/installedlistmodel.cpp b/src/installedlistmodel.cpp index a240b06d..d178f7d8 100644 --- a/src/installedlistmodel.cpp +++ b/src/installedlistmodel.cpp @@ -3,6 +3,19 @@ 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 + "/Installed/"; + } + + loadScreens(); } int InstalledListModel::rowCount(const QModelIndex& parent) const @@ -23,8 +36,10 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const switch (role) { case TitleRole: return _screenPlayFiles.at(index.row())._title; - case ImageRole: - return _screenPlayFiles.at(index.row())._description; + case PreviewRole: + return _screenPlayFiles.at(index.row())._preview; + case FolderIdRole: + return _screenPlayFiles.at(index.row())._folderId; default: return QVariant(); } @@ -34,44 +49,35 @@ QVariant InstalledListModel::data(const QModelIndex& index, int role) const QHash InstalledListModel::roleNames() const { static const QHash roles{ - { TitleRole, "title" }, - { ImageRole, "image" }, + { TitleRole, "screenTitle" }, + { PreviewRole, "screenPreview" }, + { FolderIdRole, "screenFolderId" }, }; return roles; } -void InstalledListModel::append(const QJsonObject obj) +void InstalledListModel::append(const QJsonObject obj, const QString folderName) { int row = 0; beginInsertRows(QModelIndex(), row, row); - ScreenPlayFile tmpFile(obj); + ScreenPlayFile tmpFile(obj, folderName); _screenPlayFiles.append(tmpFile); endInsertRows(); } -void InstalledListModel::loadDrives() +void InstalledListModel::loadScreens() { - QString writablePath = QStandardPaths::writableLocation(QStandardPaths::StandardLocation::DataLocation); - - if (!QDir(writablePath).exists()) { - if (!QDir().mkdir(writablePath)) { - qWarning("ERROR: Cloud not create install dir"); - return; - } - } - - QString tmp(writablePath + "/Installed/"); QJsonDocument jsonProject; QJsonParseError parseError; - QFileInfoList list = QDir(tmp).entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs); + QFileInfoList list = QDir(_screensPath).entryInfoList(QDir::NoDotAndDotDot | QDir::AllDirs); QString tmpPath; for (auto&& item : list) { - tmpPath = tmp + item.baseName() + "/project.json"; + tmpPath = _screensPath + item.baseName() + "/project.json"; if (!QFile(tmpPath).exists()) continue; @@ -85,6 +91,6 @@ void InstalledListModel::loadDrives() if (!(parseError.error == QJsonParseError::NoError)) continue; - append(jsonProject.object()); + append(jsonProject.object(),item.baseName()); } } diff --git a/src/installedlistmodel.h b/src/installedlistmodel.h index fa3a3ed2..477510d0 100644 --- a/src/installedlistmodel.h +++ b/src/installedlistmodel.h @@ -28,27 +28,35 @@ public: int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - void append(const QJsonObject); + void append(const QJsonObject, const QString); QHash roleNames() const; - Q_INVOKABLE void loadDrives(); + Q_INVOKABLE void loadScreens(); + Q_PROPERTY(QString _screensPath READ name CONSTANT) enum InstalledRole { TitleRole, - ImageRole, - + PreviewRole, + FolderIdRole, }; Q_ENUM(InstalledRole) + QString name() const + { + return _screensPath; + } + private: QList _screenPlayFiles; + QString _screensPath; + }; class ScreenPlayFile { public: ScreenPlayFile(); - ScreenPlayFile(QJsonObject obj) + ScreenPlayFile(QJsonObject obj, QString folderName) { if (obj.contains("description")) _description = obj.value("description"); @@ -61,12 +69,15 @@ public: if (obj.contains("title")) _title = obj.value("title"); + + _folderId = folderName; } - QVariant _description = "as"; + QVariant _description; QVariant _file; QVariant _preview; - QVariant _title= "aass"; + QVariant _title; + QString _folderId; QUrl _absolutePath; QVariantList _tags; //TODO: Implement me!