Compare commits

2 Commits

Author SHA1 Message Date
Digital Artifex ac65bbb3ab Moving views to content instad of controls 2026-08-18 18:21:45 -04:00
Digital Artifex 45f293a349 Moving views to content instad of controls 2026-08-18 17:49:46 -04:00
28 changed files with 918 additions and 515 deletions
+14 -4
View File
@@ -18,10 +18,20 @@ qt6_add_qml_module(KomplexHubContent
"pages/UserProfilePage.qml" "pages/UserProfilePage.qml"
"pages/WallpaperSettingsPage.qml" "pages/WallpaperSettingsPage.qml"
"pages/VideoSearchPage.qml" "pages/VideoSearchPage.qml"
QML_FILES pages/FeaturedVideosPage.qml "pages/FeaturedVideosPage.qml"
QML_FILES pages/FeaturedPacksPage.qml "pages/FeaturedPacksPage.qml"
QML_FILES pages/FeaturedImagesPage.qml "pages/FeaturedImagesPage.qml"
QML_FILES pages/NewestPacksPage.qml "pages/NewestPacksPage.qml"
"views/CompletedView.qml"
"views/DownloadView.qml"
"views/ErrorView.qml"
"views/ImageView.qml"
"views/PackView.qml"
"views/VideoView.qml"
RESOURCES views/CMakeLists.txt
RESOURCES pages/CMakeLists.txt
) )
add_subdirectory(pages)
add_subdirectory(views)
+7 -7
View File
@@ -81,7 +81,7 @@ Rectangle {
height: 64 height: 64
width: 100 width: 100
text: "Home" text: qsTr("Home")
icon.height: 32 icon.height: 32
icon.width: 32 icon.width: 32
@@ -109,7 +109,7 @@ Rectangle {
height: 64 height: 64
width: 100 width: 100
text: "Images" text: qsTr("Images")
icon.height: 32 icon.height: 32
icon.width: 32 icon.width: 32
@@ -132,7 +132,7 @@ Rectangle {
height: 64 height: 64
width: 100 width: 100
text: "Videos" text: qsTr("Videos")
icon.height: 32 icon.height: 32
icon.width: 32 icon.width: 32
@@ -155,7 +155,7 @@ Rectangle {
height: 64 height: 64
width: 100 width: 100
text: "Live" text: qsTr("Komplex")
icon.height: 32 icon.height: 32
icon.width: 32 icon.width: 32
@@ -178,7 +178,7 @@ Rectangle {
height: 64 height: 64
width: 100 width: 100
text: "Installed" text: qsTr("Installed")
icon.height: 32 icon.height: 32
icon.width: 32 icon.width: 32
@@ -207,7 +207,7 @@ Rectangle {
height: 64 height: 64
width: 100 width: 100
text: "Settings" text: qsTr("Settings")
icon.height: 32 icon.height: 32
icon.width: 32 icon.width: 32
@@ -369,7 +369,7 @@ Rectangle {
function isSearchPage() function isSearchPage()
{ {
return ( return(
pageLoader.item instanceof ImageSearchPage || pageLoader.item instanceof ImageSearchPage ||
pageLoader.item instanceof LiveSearchPage || pageLoader.item instanceof LiveSearchPage ||
pageLoader.item instanceof VideoSearchPage pageLoader.item instanceof VideoSearchPage
+20
View File
@@ -0,0 +1,20 @@
qt_add_library(KomplexHubPages STATIC)
qt6_add_qml_module(KomplexHubPages
URI "KomplexHub.Pages"
VERSION 1.0
RESOURCE_PREFIX "/qt/qml"
QML_FILES
"HomePage.qml"
"ImageSearchPage.qml"
"InstalledWallpaperPage.qml"
"LiveSearchPage.qml"
"LoginPage.qml"
"SettingsPage.qml"
"UserProfilePage.qml"
"WallpaperSettingsPage.qml"
"VideoSearchPage.qml"
"FeaturedVideosPage.qml"
"FeaturedPacksPage.qml"
"FeaturedImagesPage.qml"
"NewestPacksPage.qml"
)
@@ -6,6 +6,8 @@ import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Rectangle Rectangle
{ {
@@ -6,6 +6,8 @@ import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Rectangle Rectangle
{ {
@@ -6,6 +6,8 @@ import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Rectangle Rectangle
{ {
+26 -16
View File
@@ -7,6 +7,7 @@ import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHubContent
Item Item
{ {
@@ -111,7 +112,7 @@ Item
color: palette.text color: palette.text
font.pixelSize: Constants.h2Font.pixelSize font.pixelSize: Constants.h2Font.pixelSize
font.bold: true font.bold: true
text: qsTr("Featured Live Wallpapers") text: qsTr("Featured Komplex Wallpapers")
verticalAlignment: Qt.AlignVCenter verticalAlignment: Qt.AlignVCenter
} }
@@ -198,7 +199,7 @@ Item
SearchResultItem SearchResultItem
{ {
anchors.fill: parent anchors.fill: parent
title: parent.author author: parent.author
description: parent.description description: parent.description
thumbnail: parent.thumbnail thumbnail: parent.thumbnail
uuid: parent.uuid uuid: parent.uuid
@@ -220,13 +221,13 @@ Item
} }
} }
VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin } VerticalSpacer { height: Constants.largeMargin; width: Constants.largeMargin }
} }
} }
} }
} }
VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin } VerticalSpacer { height: Constants.largeMargin; width: Constants.largeMargin }
Rectangle Rectangle
{ {
@@ -257,8 +258,8 @@ Item
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.margins: Constants.largeMargin anchors.margins: Constants.largeMargin
height: childrenRect.height
height: childrenRect.height
color: palette.window color: palette.window
Column Column
@@ -363,7 +364,7 @@ Item
SearchResultItem SearchResultItem
{ {
anchors.fill: parent anchors.fill: parent
title: parent.author author: parent.author
thumbnail: parent.thumbnail thumbnail: parent.thumbnail
uuid: parent.uuid uuid: parent.uuid
pexels: true pexels: true
@@ -388,7 +389,6 @@ Item
VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin } VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin }
} }
} }
Component.onCompleted: () => Component.onCompleted: () =>
@@ -422,7 +422,8 @@ Item
opacity: 0 opacity: 0
visible: opacity > 0.01 visible: opacity > 0.01
Behavior on opacity { Behavior on opacity
{
NumberAnimation NumberAnimation
{ {
duration: 250 duration: 250
@@ -437,7 +438,8 @@ Item
opacity: 0 opacity: 0
visible: opacity > 0.01 visible: opacity > 0.01
Behavior on opacity { Behavior on opacity
{
NumberAnimation NumberAnimation
{ {
duration: 250 duration: 250
@@ -452,7 +454,8 @@ Item
opacity: 0 opacity: 0
visible: opacity > 0.01 visible: opacity > 0.01
Behavior on opacity { Behavior on opacity
{
NumberAnimation NumberAnimation
{ {
duration: 250 duration: 250
@@ -460,7 +463,8 @@ Item
} }
} }
Behavior on opacity { Behavior on opacity
{
NumberAnimation NumberAnimation
{ {
duration: 250 duration: 250
@@ -478,7 +482,8 @@ Item
anchors.fill: parent anchors.fill: parent
opacity: 0 opacity: 0
Behavior on opacity { Behavior on opacity
{
NumberAnimation NumberAnimation
{ {
duration: 250 duration: 250
@@ -548,8 +553,10 @@ Item
} }
} }
states: [ states:
State { [
State
{
name: "loading" name: "loading"
when: homePageRoot.loading when: homePageRoot.loading
@@ -571,7 +578,8 @@ Item
opacity: 0 opacity: 0
} }
}, },
State { State
{
name: "idle" name: "idle"
when: !popup && !loading when: !popup && !loading
@@ -606,7 +614,8 @@ Item
} }
] ]
transitions: [ transitions:
[
Transition Transition
{ {
from: "loading" from: "loading"
@@ -692,6 +701,7 @@ Item
viewMoreWallpaperPopup.authorId = packsModel.data(packsModel.index(index,0), NewestPacksModel.AuthorIdRole) viewMoreWallpaperPopup.authorId = packsModel.data(packsModel.index(index,0), NewestPacksModel.AuthorIdRole)
viewMoreWallpaperPopup.description = packsModel.data(packsModel.index(index,0), NewestPacksModel.DescriptionRole) viewMoreWallpaperPopup.description = packsModel.data(packsModel.index(index,0), NewestPacksModel.DescriptionRole)
viewMoreWallpaperPopup.thumbnail = packsModel.data(packsModel.index(index,0), NewestPacksModel.ThumbnailRole) viewMoreWallpaperPopup.thumbnail = packsModel.data(packsModel.index(index,0), NewestPacksModel.ThumbnailRole)
viewMoreWallpaperPopup.name = packsModel.data(packsModel.index(index,0), NewestPacksModel.NameRole)
viewMoreWallpaperPopup.opacity = 1 viewMoreWallpaperPopup.opacity = 1
popupContainer.opacity = 1 popupContainer.opacity = 1
pageArea.opacity = 0 pageArea.opacity = 0
@@ -6,6 +6,8 @@ import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Item Item
{ {
@@ -2,10 +2,13 @@ import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import QtQuick.Dialogs import QtQuick.Dialogs
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Rectangle { Rectangle {
id: root id: root
@@ -1,9 +1,12 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Item Item
{ {
+5
View File
@@ -1,8 +1,13 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Item { Item {
id: loginFormRoot id: loginFormRoot
@@ -6,6 +6,8 @@ import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Rectangle Rectangle
{ {
+5
View File
@@ -1,8 +1,13 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Item { Item {
readonly property bool searchable: false readonly property bool searchable: false
@@ -1,7 +1,13 @@
import QtQuick import QtQuick
import QtQuick.Controls import QtQuick.Controls
import QtQuick.Layouts import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Item { Item {
id: root id: root
@@ -6,6 +6,8 @@ import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
Item Item
{ {
@@ -31,9 +31,12 @@ import QtQuick.Layouts
//import org.kde.plasma.core as PlasmaCore //import org.kde.plasma.core as PlasmaCore
import QtCore import QtCore
import Qt.labs.folderlistmodel 2.15 import Qt.labs.folderlistmodel 2.15
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Plugin import KomplexHub.Plugin
import KomplexHub.Views
import KomplexHub.Pages
//import com.github.digitalartifex.komplex 1.0 as Komplex //import com.github.digitalartifex.komplex 1.0 as Komplex
+13
View File
@@ -0,0 +1,13 @@
qt_add_library(KomplexHubViews STATIC)
qt6_add_qml_module(KomplexHubViews
URI "KomplexHub.Views"
VERSION 1.0
RESOURCE_PREFIX "/qt/qml"
QML_FILES
"CompletedView.qml"
"DownloadView.qml"
"ErrorView.qml"
"ImageView.qml"
"PackView.qml"
"VideoView.qml"
)
@@ -55,7 +55,7 @@ Item
ImageFrame ImageFrame
{ {
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
Layout.topMargin: Constants.largeMargin Layout.topMargin: Constants.largeMargin
Layout.preferredHeight: width / 1.77777777778 Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800 Layout.maximumWidth: 800
@@ -73,7 +73,7 @@ Item
elide: Text.ElideRight elide: Text.ElideRight
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignLeft Layout.alignment: Qt.AlignTop | Qt.AlignLeft
} }
Text Text
+307
View File
@@ -0,0 +1,307 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Effects
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHub.Plugin
Item
{
property string uuid
property string author
property string authorId
property string description
property string thumbnail
property string name
property int imageHeight
property int imageWidth
id: rootItem
DownloadManager
{
id: downloadManager
}
Rectangle
{
id: pageView
anchors.fill: parent
color: palette.base
BackgroundImage
{
anchors.fill: parent
source: rootItem.thumbnail
}
ColumnLayout
{
anchors.fill: parent
anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin
ImageFrame
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: Constants.largeMargin
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
source: rootItem.thumbnail
}
Text
{
id: titleText
text: rootItem.name
color: palette.text
font.bold: true
font.pixelSize: Constants.h3Font.pixelSize
elide: Text.ElideRight
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignLeft
}
Text
{
id: descriptionText
text: rootItem.description
color: palette.text
font.pointSize: Constants.h4Font.pixelSize
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
Layout.alignment: Qt.AlignTop| Qt.AlignLeft
Layout.fillWidth: true
}
Text
{
id: authorText
text: qsTr("By: ") + rootItem.author
color: palette.text
font.pointSize: Constants.h5Font.pixelSize
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Qt.AlignRight
Layout.alignment: Qt.AlignTop | Qt.AlignRight
Layout.fillWidth: true
}
/** Spacer **/
Item
{
Layout.fillWidth: true
Layout.preferredHeight: 32
}
RowLayout
{
Layout.fillWidth: true
Item { Layout.fillWidth: true }
SquareButton
{
Layout.preferredHeight: 36
Layout.preferredWidth: 128
text: qsTr("Download")
icon.source: "qrc:/images/icons/icons8-download.svg"
onTriggered: () => rootItem.download()
}
}
/** Spacer **/
Item { Layout.fillWidth: true; Layout.fillHeight: true }
RowLayout
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom
Text {
text: qsTr("Shaders Provided Courtesy of ShaderToy, Komplex and Their Respective Authors")
elide: Text.ElideLeft
color: palette.text
font.bold: true
font.pixelSize: Constants.h6Font.pixelSize
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft
}
Image
{
transform: Image.PreserveAspectFit
source: "qrc:/images/icons/pexels-icon-filled-256.svg"
Layout.alignment: Qt.AlignRight
Layout.preferredHeight: 32
Layout.preferredWidth: 32
}
}
}
states:
[
State
{
name: "downloading"
when: downloadManager.state === DownloadManager.Downloading
PropertyChanges
{
target: pageView
opacity: 0
}
PropertyChanges
{
target: downloadView
opacity: 1
}
PropertyChanges
{
target: completedView
opacity: 0
}
PropertyChanges
{
target: errorView
opacity: 0
}
},
State
{
name: "complete"
when: downloadManager.state === DownloadManager.Complete
PropertyChanges
{
target: pageView
opacity: 0
}
PropertyChanges
{
target: downloadView
opacity: 0
}
PropertyChanges
{
target: completedView
opacity: 1
}
PropertyChanges
{
target: errorView
opacity: 0
}
},
State
{
name: "error"
when: downloadManager.state === DownloadManager.Error
PropertyChanges
{
target: pageView
opacity: 0
}
PropertyChanges
{
target: downloadView
opacity: 0
}
PropertyChanges
{
target: completedView
opacity: 0
}
PropertyChanges
{
target: errorView
opacity: 1
}
},
State
{
name: "idle"
when: downloadManager.state === DownloadManager.Idle
PropertyChanges
{
target: pageView
opacity: 1
}
PropertyChanges
{
target: downloadView
opacity: 0
}
PropertyChanges
{
target: completedView
opacity: 0
}
PropertyChanges
{
target: errorView
opacity: 0
}
}
]
}
DownloadView
{
id: downloadView
anchors.fill: parent
manager: downloadManager
thumbnail: rootItem.thumbnail
opacity: 0
visible: opacity > 0.01
}
CompletedView
{
id: completedView
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
manager: downloadManager
}
ErrorView
{
id: errorView
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
manager: downloadManager
}
function download()
{
downloadManager.downloadPack(uuid)
}
}
@@ -21,17 +21,10 @@ Item
property int imageWidth property int imageWidth
visible: opacity > 0.01 visible: opacity > 0.01
onVisibleChanged: () =>
{
if(!visible)
{
model = null
}
}
Connections Connections
{ {
target: model target: model ? model : null
function onRowCountChanged() function onRowCountChanged()
{ {
@@ -39,10 +32,16 @@ Item
} }
} }
DownloadManager
{
id: downloadManager
}
id: rootItem id: rootItem
Rectangle Rectangle
{ {
id: pageView
anchors.fill: parent anchors.fill: parent
color: palette.base color: palette.base
@@ -119,6 +118,8 @@ Item
Layout.preferredWidth: 128 Layout.preferredWidth: 128
text: qsTr("Download") text: qsTr("Download")
icon.source: "qrc:/images/icons/icons8-download.svg" icon.source: "qrc:/images/icons/icons8-download.svg"
onTriggered: () => rootItem.download()
} }
} }
@@ -152,5 +153,161 @@ Item
} }
} }
} }
states:
[
State
{
name: "downloading"
when: downloadManager.state === DownloadManager.Downloading
PropertyChanges
{
target: pageView
opacity: 0
}
PropertyChanges
{
target: downloadView
opacity: 1
}
PropertyChanges
{
target: completedView
opacity: 0
}
PropertyChanges
{
target: errorView
opacity: 0
}
},
State
{
name: "complete"
when: downloadManager.state === DownloadManager.Complete
PropertyChanges
{
target: pageView
opacity: 0
}
PropertyChanges
{
target: downloadView
opacity: 0
}
PropertyChanges
{
target: completedView
opacity: 1
}
PropertyChanges
{
target: errorView
opacity: 0
}
},
State
{
name: "error"
when: downloadManager.state === DownloadManager.Error
PropertyChanges
{
target: pageView
opacity: 0
}
PropertyChanges
{
target: downloadView
opacity: 0
}
PropertyChanges
{
target: completedView
opacity: 0
}
PropertyChanges
{
target: errorView
opacity: 1
}
},
State
{
name: "idle"
when: downloadManager.state === DownloadManager.Idle
PropertyChanges
{
target: pageView
opacity: 1
}
PropertyChanges
{
target: downloadView
opacity: 0
}
PropertyChanges
{
target: completedView
opacity: 0
}
PropertyChanges
{
target: errorView
opacity: 0
}
}
]
}
DownloadView
{
id: downloadView
anchors.fill: parent
manager: downloadManager
thumbnail: rootItem.thumbnail
opacity: 0
visible: opacity > 0.01
}
CompletedView
{
id: completedView
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
manager: downloadManager
}
ErrorView
{
id: errorView
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
manager: downloadManager
}
function download()
{
downloadManager.downloadImage(author, authorUrl, downloadSelector.currentValue)
} }
} }
+6 -13
View File
@@ -14,18 +14,11 @@ qt6_add_qml_module(KomplexHubModule_Controls
"Throbber.qml" "Throbber.qml"
"SearchResultItem.qml" "SearchResultItem.qml"
"SearchResultList.qml" "SearchResultList.qml"
QML_FILES PaginationBox.qml "PaginationBox.qml"
QML_FILES PaginatorGrid.qml "PaginatorGrid.qml"
QML_FILES HorizontalPaginator.qml "HorizontalPaginator.qml"
QML_FILES ImageView.qml "VerticalSpacer.qml"
QML_FILES "ImageFrame.qml"
QML_FILES VideoView.qml "BackgroundImage.qml"
QML_FILES PackView.qml
QML_FILES VerticalSpacer.qml
QML_FILES DownloadView.qml
QML_FILES ImageFrame.qml
QML_FILES BackgroundImage.qml
QML_FILES CompletedView.qml
QML_FILES ErrorView.qml
) )
-130
View File
@@ -1,130 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Effects
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHub.Plugin
Item
{
property string uuid
property string author
property string authorId
property string description
property string thumbnail
property int imageHeight
property int imageWidth
id: rootItem
Rectangle
{
anchors.fill: parent
color: palette.base
BackgroundImage
{
anchors.fill: parent
source: rootItem.thumbnail
}
ColumnLayout
{
anchors.fill: parent
anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin
ImageFrame
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: Constants.largeMargin
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
source: rootItem.thumbnail
}
Text
{
id: titleText
text: rootItem.author
color: palette.text
font.bold: true
font.pixelSize: Constants.h3Font.pixelSize
elide: Text.ElideRight
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignLeft
}
Text
{
id: descriptionText
text: rootItem.description
color: palette.text
font.pointSize: Constants.h4Font.pixelSize
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
Layout.alignment: Qt.AlignTop| Qt.AlignLeft
Layout.fillWidth: true
}
/** Spacer **/
Item
{
Layout.fillWidth: true
Layout.preferredHeight: 32
}
RowLayout
{
Layout.fillWidth: true
Item { Layout.fillWidth: true }
SquareButton
{
Layout.preferredHeight: 36
Layout.preferredWidth: 128
text: qsTr("Download")
icon.source: "qrc:/images/icons/icons8-download.svg"
}
}
/** Spacer **/
Item { Layout.fillWidth: true; Layout.fillHeight: true }
RowLayout
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignBottom
Text {
text: qsTr("Shaders Provided Courtesy of ShaderToy and Their Respective Authors")
elide: Text.ElideLeft
color: palette.text
font.bold: true
font.pixelSize: Constants.h6Font.pixelSize
Layout.fillWidth: true
Layout.alignment: Qt.AlignLeft
}
Image
{
transform: Image.PreserveAspectFit
source: "qrc:/images/icons/pexels-icon-filled-256.svg"
Layout.alignment: Qt.AlignRight
Layout.preferredHeight: 32
Layout.preferredWidth: 32
}
}
}
}
}
+14 -56
View File
@@ -74,7 +74,7 @@ Item {
width: 24 width: 24
height: 24 height: 24
transform: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
opacity: 0.5 opacity: 0.5
source: "qrc:/images/icons/pexels-icon-filled-256.svg" source: "qrc:/images/icons/pexels-icon-filled-256.svg"
@@ -82,49 +82,6 @@ Item {
} }
} }
// Rectangle
// {
// Layout.preferredWidth: 250
// Layout.preferredHeight: 141
// Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
// Layout.topMargin: 3
// border.color: palette.alternateBase.lighter(1.75)
// color: palette.base.lighter(1.25)
// // Throbber
// // {
// // anchors.fill: parent
// // id: loadingThrobber
// // visible: viewImage.status === Image.Loading
// // }
// // Image
// // {
// // property int retries: 0
// // id: viewImage
// // anchors.fill: parent
// // source: rootItem.thumbnail
// // visible: !(status === Image.Loading)
// // fillMode: Image.PreserveAspectCrop
// // onStatusChanged: () =>
// // {
// // // if(status === Image.Error)
// // // {
// // // if(retries <= 3)
// // // {
// // // ++retries
// // // let src = source
// // // source = ""
// // // source = src
// // // }
// // // }
// // }
// // }
// }
Text Text
{ {
color: palette.text color: palette.text
@@ -140,18 +97,6 @@ Item {
Item { Layout.fillHeight: true } Item { Layout.fillHeight: true }
Text
{
color: palette.text
font.pixelSize: 12
text: "By: " + rootItem.author
leftPadding: 12
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
Layout.preferredWidth: 250
visible: !rootItem.pexels
}
Text Text
{ {
id: descriptionText id: descriptionText
@@ -171,6 +116,19 @@ Item {
Layout.bottomMargin: 3 Layout.bottomMargin: 3
} }
Text
{
color: palette.text
font.pixelSize: 12
text: "By: " + rootItem.author
leftPadding: Constants.mediumMargin
rightPadding: Constants.mediumMargin
horizontalAlignment: Qt.AlignRight
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
Layout.fillWidth: true
}
SquareButton SquareButton
{ {
id: viewMoreButton id: viewMoreButton
+307 -278
View File
@@ -79,305 +79,334 @@ DownloadManager::DownloadManager(QObject *parent)
*/ */
auto DownloadManager::downloadImage(const QString &author, const QString &authorId, const QString &description, const QUrl &url) -> void auto DownloadManager::downloadImage(const QString &author, const QString &authorId, const QString &description, const QUrl &url) -> void
{ {
// QFuture future = QtConcurrent::run QNetworkRequest request(url);
// ( QString requestUrl = request.url().toString();
// [this, url, author, authorId, description]() QString id = QUuid::createUuidV7().toString(QUuid::WithoutBraces);
// {
QNetworkRequest request(url);
QString requestUrl = request.url().toString();
QString id = QUuid::createUuidV7().toString(QUuid::WithoutBraces);
setState(Downloading); setState(Downloading);
//QFuture<QUrl> downloadUri = download(request, id, Get); //QFuture<QUrl> downloadUri = download(request, id, Get);
if(m_downloadFuture.isRunning()) if(m_downloadFuture.isRunning())
{
m_downloadFuture.cancelChain();
}
m_downloadFuture = download(request, id, Get);
m_downloadFuture
.then
(
[this, author, description, id](QUrl result) -> QUrl
{ {
m_downloadFuture.cancelChain(); setState(Installing);
}
m_downloadFuture = download(request, id, Get); ShaderPack metadata;
metadata.setAuthor(author);
metadata.setDescription(description);
metadata.setName(QStringLiteral("Pexels Image (%1)").arg(id));
metadata.setSource(QStringLiteral("./images/%1").arg(result.fileName()));
m_downloadFuture QUrl packUri
.then
( (
[this, author, description, id](QUrl result) -> QUrl QStringLiteral("file://%1/%2").arg
{ (
setState(Installing); QStandardPaths::writableLocation(QStandardPaths::TempLocation),
id
ShaderPack metadata; )
metadata.setAuthor(author);
metadata.setDescription(description);
metadata.setName(QStringLiteral("Pexels Image (%1)").arg(id));
metadata.setSource(QStringLiteral("./images/%1").arg(result.fileName()));
QUrl packUri
(
QStringLiteral("file://%1/%2").arg
(
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
id
)
);
QUrl packImageUri
(
QStringLiteral("file://%1/%2/images/%3").arg
(
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
id,
result.fileName()
)
);
QDir packDirectory(packUri.toLocalFile());
if(!packDirectory.mkpath(packUri.toLocalFile()))
{
throw FileException(QStringLiteral("Could not create directory"));
}
packDirectory.mkdir(QStringLiteral("images"));
QFile::rename(result.toLocalFile(), packImageUri.toLocalFile());
QFile packFile
(
packDirectory.absoluteFilePath
(
QStringLiteral("pack.json")
)
);
if(!packFile.open(QFile::ReadWrite))
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
QByteArray data = metadata.json().toJson(QJsonDocument::Indented);
if(packFile.write(data) != data.length())
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
packFile.close();
return packUri;
}
)
.then
(
[this](QUrl result) -> QUrl
{
return install(result);
}
)
.then
(
[this](QUrl result)
{
setLastInstalledFile(result.toLocalFile());
setState(Complete);
}
)
.onCanceled
(
[this]()
{
reset();
}
)
.onFailed
(
[this] (const NetworkException &e)
{
reset();
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] (const FileException &e)
{
reset();
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] ()
{
reset();
setError(QStringLiteral("Unknown Exception"), QString());
}
); );
// downloadUri.waitForFinished(); QUrl packImageUri
// } (
// ); QStringLiteral("file://%1/%2/images/%3").arg
(
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
id,
result.fileName()
)
);
QDir packDirectory(packUri.toLocalFile());
if(!packDirectory.mkpath(packUri.toLocalFile()))
{
throw FileException(QStringLiteral("Could not create directory"));
}
packDirectory.mkdir(QStringLiteral("images"));
QFile::rename(result.toLocalFile(), packImageUri.toLocalFile());
QFile packFile
(
packDirectory.absoluteFilePath
(
QStringLiteral("pack.json")
)
);
if(!packFile.open(QFile::ReadWrite))
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
QByteArray data = metadata.json().toJson(QJsonDocument::Indented);
if(packFile.write(data) != data.length())
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
packFile.close();
return packUri;
}
)
.then
(
[this](QUrl result) -> QUrl
{
return install(result);
}
)
.then
(
[this](QUrl result)
{
setLastInstalledFile(result.toLocalFile());
setState(Complete);
}
)
.onCanceled
(
[this]()
{
reset();
}
)
.onFailed
(
[this] (const NetworkException &e)
{
reset();
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] (const FileException &e)
{
reset();
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] ()
{
reset();
setError(QStringLiteral("Unknown Exception"), QString());
}
);
} }
auto DownloadManager::downloadVideo(const QString &author, const QString &authorId, const QString &description, const QUrl &url) -> void auto DownloadManager::downloadVideo(const QString &author, const QString &authorId, const QUrl &url) -> void
{ {
QFuture future = QtConcurrent::run QNetworkRequest request(url);
( QString id = QUuid::createUuidV7().toString(QUuid::WithoutBraces);
[this, url, author, authorId, description]()
{
QNetworkRequest request(url);
QString id = QUuid::createUuidV7().toString(QUuid::WithoutBraces);
QFuture<QUrl> downloadUri = download(request, id); setState(Downloading);
downloadUri if(m_downloadFuture.isRunning())
.then {
m_downloadFuture.cancelChain();
}
m_downloadFuture = download(request, id, Get);
m_downloadFuture
.then
(
[this, author, id](QUrl result) -> QUrl
{
ShaderPack metadata;
metadata.setAuthor(author);
metadata.setType(ShaderPack::Video);
metadata.setName(QStringLiteral("Pexels Video (%1)").arg(id));
metadata.setSource(QStringLiteral("./videos/%1").arg(result.fileName()));
QUrl packUri
( (
[this, author, description, id](QUrl result) -> QUrl QStringLiteral("%1/%2").arg
{ (
ShaderPack metadata; QStandardPaths::writableLocation(QStandardPaths::TempLocation),
metadata.setAuthor(author); id
metadata.setDescription(description); )
metadata.setName(QStringLiteral("Pexels Video (%1)").arg(id));
metadata.setType(ShaderPack::Video);
QUrl packUri
(
QStringLiteral("%1/%2").arg
(
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
id
)
);
QUrl packImageUri
(
QStringLiteral("%1/%2/images/%3").arg
(
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
id,
result.fileName()
)
);
QDir packDirectory(packUri.toLocalFile());
packDirectory.mkpath(packUri.toLocalFile());
packDirectory.mkdir(QStringLiteral("images"));
QFile::rename(result.toLocalFile(), packImageUri.toLocalFile());
QFile packFile
(
packDirectory.absoluteFilePath
(
QStringLiteral("pack.json")
)
);
if(!packFile.open(QFile::ReadWrite))
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
QByteArray data = metadata.json().toJson(QJsonDocument::Compact);
if(packFile.write(data) != data.length())
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
packFile.close();
return packUri;
}
)
.then
(
[this](QUrl result)
{
install(result);
}
)
.onCanceled
(
[this]()
{
reset();
}
)
.onFailed
(
[this] ()
{
reset();
}
); );
}
); QUrl packVideoUri
(
QStringLiteral("%1/%2/videos/%3").arg
(
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
id,
result.fileName()
)
);
QDir packDirectory(packUri.toLocalFile());
packDirectory.mkpath(packUri.toLocalFile());
packDirectory.mkdir(QStringLiteral("images"));
QFile::rename(result.toLocalFile(), packVideoUri.toLocalFile());
QFile packFile
(
packDirectory.absoluteFilePath
(
QStringLiteral("pack.json")
)
);
if(!packFile.open(QFile::ReadWrite))
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
QByteArray data = metadata.json().toJson(QJsonDocument::Compact);
if(packFile.write(data) != data.length())
{
setError(QStringLiteral("File Error"), packFile.errorString());
throw FileException(packFile.errorString());
}
packFile.close();
return packUri;
}
)
.then
(
[this](QUrl result) -> QUrl
{
return install(result);
}
)
.then
(
[this](QUrl result)
{
setLastInstalledFile(result.toLocalFile());
setState(Complete);
}
)
.onCanceled
(
[this]()
{
reset();
}
)
.onFailed
(
[this] (const NetworkException &e)
{
reset();
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] (const FileException &e)
{
reset();
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] ()
{
reset();
setError(QStringLiteral("Unknown Exception"), QString());
}
);
} }
auto DownloadManager::downloadPack(const QString &id) -> void auto DownloadManager::downloadPack(const QString &id) -> void
{ {
QFuture aether = QtConcurrent::run QUrl downloadUrl = QUrl
( (
[this, id]() QStringLiteral("%1/%2/%3").arg
{ (
QUrl downloadUrl = QUrl KOMPLEX_API_HOST,
( KOMPLEX_API_VERSION,
QStringLiteral("%1/%2/%3").arg KOMPLEX_ENDPOINT_PACKS_ITEM
( )
KOMPLEX_API_HOST,
KOMPLEX_API_VERSION,
KOMPLEX_ENDPOINT_PACKS_ITEM
)
);
QNetworkRequest request(downloadUrl);
request.setRawHeader(QByteArray("uuid"), id.toUtf8());
QFuture<QUrl> downloadUri = download(request, id, Post);
downloadUri
.then
(
[this](QUrl result) -> QUrl
{
return m_compiler->process(result).result();
}
)
.then
(
[this](QUrl result) -> QUrl
{
return install(result);
}
)
.then
(
[this] (QUrl result)
{
setState(Complete);
}
)
.onFailed
(
[this]()
{
reset();
setError(m_compiler->errorTitle(), m_compiler->errorMessage());
}
)
.onCanceled
(
[this]()
{
reset();
}
);
}
); );
QNetworkRequest request(downloadUrl);
request.setRawHeader(QByteArray("uuid"), id.toUtf8());
QFuture<QUrl> downloadUri = download(request, id, Post);
downloadUri
.then
(
[this](QUrl result) -> QUrl
{
return m_compiler->process(result).result();
}
)
.then
(
[this](QUrl result) -> QUrl
{
return install(result);
}
)
.then
(
[this](QUrl result)
{
setLastInstalledFile(result.toLocalFile());
setState(Complete);
}
)
.onCanceled
(
[this]()
{
reset();
}
)
.onFailed
(
[this] (const NetworkException &e)
{
reset();
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] (const FileException &e)
{
reset();
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
}
)
.onFailed
(
[this] ()
{
reset();
setError(QStringLiteral("Unknown Exception"), QString());
}
);
} }
auto DownloadManager::reset() -> void auto DownloadManager::reset() -> void
-1
View File
@@ -89,7 +89,6 @@ public:
( (
const QString &author, const QString &author,
const QString &authorId, const QString &authorId,
const QString &description,
const QUrl &url const QUrl &url
) -> void; ) -> void;