66 Commits

Author SHA1 Message Date
Digital Artifex f7b5b78bd9 Fixed sliding cache issue. fixes: #1 closes: #1 2026-08-12 07:45:01 -04:00
Digital Artifex 896bb0d965 Minor changes 2026-08-12 03:01:23 -04:00
Digital Artifex d80c1ccd18 Renamed ShaderPackMetadata to ShaderPack 2026-08-11 22:28:30 -04:00
Digital Artifex 836a77c11f Added ShaderPack file save functionality 2026-08-11 16:12:07 -04:00
Digital Artifex 7ae2ac34e8 Added PackCompiler 2026-08-11 06:26:23 -04:00
Digital Artifex 6a59a48a35 Fixed clearing search term between pages 2026-08-09 03:37:26 -04:00
Digital Artifex 2f41ad19dd Reformatted code a bit 2026-08-09 03:25:46 -04:00
Digital Artifex a8c0b981e9 Added IBeam cursor to line edit 2026-08-09 02:40:20 -04:00
Digital Artifex 68acb2a914 Added new screenshots 2026-08-05 20:11:08 -04:00
Digital Artifex 236b4b6b0d Updated README 2026-08-05 20:05:29 -04:00
Digital Artifex e5627742d2 Large update. Added Video, Image and Live item views. Added Live search 2026-08-05 19:58:24 -04:00
Digital Artifex 5b2500c841 Added view more to image search 2026-06-25 03:46:38 -04:00
Digital Artifex c08b654f5b Added popup functionality 2026-06-25 03:13:02 -04:00
Digital Artifex 90f65a8a54 Added popup functionality 2026-06-25 03:12:42 -04:00
Digital Artifex d2821b30c3 Added size properties 2026-06-25 03:12:08 -04:00
Digital Artifex 541b57e5a7 Added hovered property 2026-06-25 03:11:39 -04:00
Digital Artifex ad4119ec6c Added Image Item View 2026-06-25 03:10:00 -04:00
Digital Artifex 01716fcccf Added View More Button 2026-06-25 03:09:00 -04:00
Digital Artifex 5dbf9a8383 Added easing 2026-06-25 03:07:41 -04:00
Digital Artifex 549bf794b6 Added icons 2026-06-25 03:06:22 -04:00
Digital Artifex 6d32ed6bce Simplified view code 2026-06-23 21:02:17 -04:00
Digital Artifex 5a150c29f9 General update 2026-06-22 01:59:33 -04:00
Digital Artifex 7854a3f440 Added .gitignore 2026-06-19 15:39:25 -04:00
Digital Artifex 827168b4a8 Added .gitignore 2026-06-19 15:38:19 -04:00
Digital Artifex 96ddc611e5 Removed build dir 2026-06-19 15:36:28 -04:00
Digital Artifex 0b8e6c1704 Updated README 2026-06-19 15:29:07 -04:00
Digital Artifex c978f4ffc7 Updated README 2026-06-19 15:22:32 -04:00
Digital Artifex 69e5fb6594 Updated README 2026-06-19 14:31:21 -04:00
Digital Artifex dc18e6e9b2 Updated README 2026-06-19 14:05:13 -04:00
Digital Artifex e9f6ad537e Updated README 2026-06-19 02:21:08 -04:00
Digital Artifex dde16907bc Updated README 2026-06-19 02:18:59 -04:00
Digital Artifex 5dd894f384 Added screenshots 2026-06-19 02:15:57 -04:00
Digital Artifex fb47b92353 Added video search page and model 2026-06-19 02:06:05 -04:00
Digital Artifex 49db588226 Renamed SearchVideosPaginator 2026-06-19 02:04:31 -04:00
Digital Artifex f2596aaa40 Added Video icon 2026-06-19 02:03:19 -04:00
Digital Artifex 98687febb9 Various visual improvements 2026-06-18 17:54:19 -04:00
Digital Artifex fcceb77987 Fixed bug in assigning home location 2026-06-18 17:52:21 -04:00
Digital Artifex 5354103844 Fixed bug in chunk indexing 2026-06-18 17:51:29 -04:00
Digital Artifex bf1903ddcd Added ImageSearch model and QML page 2026-06-18 01:11:16 -04:00
Digital Artifex 25a51257c1 Added missing trigger for button press 2026-06-18 01:10:08 -04:00
Digital Artifex 6a4dbced85 Fixed bug in reset logic 2026-06-18 01:05:10 -04:00
Digital Artifex 32085a6a52 Renamed SearchImagePaginator 2026-06-17 20:08:28 -04:00
Digital Artifex 7871f3a8cc Added missing calls to setState 2026-06-17 19:51:10 -04:00
Digital Artifex 0062043427 Added KeroLoadingAnimation 2026-06-17 19:50:18 -04:00
Digital Artifex 0a98f83a9b Added featured videos model, paginator and cache 2026-06-17 16:07:11 -04:00
Digital Artifex d8b091d7b8 Removed useless copy of source map 2026-06-17 15:43:03 -04:00
Digital Artifex 8a9417a5e5 Added featured images model, paginator and cache 2026-06-17 14:52:15 -04:00
Digital Artifex ac71b74ed0 Added thumbnail image 2026-06-17 14:50:55 -04:00
Digital Artifex 3f9b33c74d Updated models and display text 2026-06-16 23:54:24 -04:00
Digital Artifex eb061e9034 Added featured endpoint models and paginators 2026-06-16 23:53:03 -04:00
Digital Artifex 576f9e0f29 Fixed feature endpoint defines 2026-06-16 23:52:10 -04:00
Digital Artifex 5f5c2db53f Added featured videos endpoint definition 2026-06-16 22:50:18 -04:00
Digital Artifex 3137318976 Fixed typo in function name 2026-06-16 21:55:43 -04:00
Digital Artifex 8b497d9496 Fixed key name for wallpaper title 2026-06-16 20:25:31 -04:00
Digital Artifex e0540e5089 Fixed data model issues 2026-06-16 16:58:55 -04:00
Digital Artifex 856797e0f0 Added local dev variable 2026-06-16 16:57:58 -04:00
Digital Artifex 473defcd44 Fixed key names and date format 2026-06-16 16:56:56 -04:00
Digital Artifex bbaefdfe88 General bugfixes and improvements 2026-06-16 16:53:37 -04:00
Digital Artifex d01f880338 Changed constness of some functions 2026-06-16 16:52:06 -04:00
Digital Artifex b3f6e55198 Added copy operator 2026-06-16 16:48:12 -04:00
Digital Artifex b53048bebc Added parent to constructor 2026-06-10 15:35:09 -04:00
Digital Artifex e95606be63 Added parent to constructor 2026-06-10 15:32:32 -04:00
Digital Artifex b1270ec0f2 Uri should have been uuid 2026-06-10 15:10:49 -04:00
Digital Artifex 67a7d9cc8f Updated setUri to use defintions 2026-06-10 14:53:08 -04:00
Digital Artifex 2cb14c7f8a Added endpoint path definitions 2026-06-10 14:51:16 -04:00
Digital Artifex 03295cd579 Moved URI building to WallpaperPaginator 2026-06-10 14:50:41 -04:00
2715 changed files with 14472 additions and 634745 deletions
+2
View File
@@ -0,0 +1,2 @@
build/*
*/CMakeLists.txt.user
+2 -1
View File
@@ -8,7 +8,8 @@ target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Quick
Qt${QT_VERSION_MAJOR}::Qml)
Qt${QT_VERSION_MAJOR}::Qml
)
if(ENABLE_ASAN)
message(STATUS "Building with AddressSanitizer")
+34
View File
@@ -3,6 +3,9 @@
#include <QApplication>
#include <QQmlApplicationEngine>
#include <QQmlNetworkAccessManagerFactory>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <qobject.h>
#include <qqml.h>
#include <QPalette>
@@ -15,7 +18,34 @@
#include <QQuickWindow>
#include <QSurfaceFormat>
#include <QSGRendererInterface>
#include <QScreen>
#include "autogen/environment.h"
#include "KomplexHubPlugin/common/komplex_global.h"
#ifdef KOMPLEX_LOCAL_DEV
class DebugNetworkAccessManagerFactory : public QQmlNetworkAccessManagerFactory
{
public:
QNetworkAccessManager *create(QObject *parent) override;
};
QNetworkAccessManager *DebugNetworkAccessManagerFactory::create(QObject *parent)
{
QNetworkAccessManager *nam = new QNetworkAccessManager(parent);
QObject::connect
(
nam,
&QNetworkAccessManager::sslErrors,
nam,
[] (QNetworkReply *reply, const QList<QSslError> &errors)
{
reply->ignoreSslErrors();
}
);
return nam;
}
#endif
int main(int argc, char *argv[])
{
@@ -35,6 +65,10 @@ int main(int argc, char *argv[])
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
#ifdef KOMPLEX_LOCAL_DEV
engine.setNetworkAccessManagerFactory(new DebugNetworkAccessManagerFactory);
#endif
engine.addImportPath(QCoreApplication::applicationDirPath() + "/qml");
engine.addImportPath(":/");
engine.load(url);
+24 -5
View File
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.21.1)
option(LINK_INSIGHT "Link Qt Insight Tracker library" ON)
option(BUILD_QDS_COMPONENTS "Build design studio components" ON)
project(KomplexHub LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
@@ -20,12 +20,13 @@ set(QML_IMPORT_PATH ${QT_QML_OUTPUT_DIRECTORY}
FORCE
)
find_package(Qt6 6.8 REQUIRED COMPONENTS Core Gui Widgets Qml Quick QuickControls2 QuickTimeline ShaderTools)
find_package(Qt6 6.8 REQUIRED COMPONENTS Core Gui Widgets Qml Quick QuickControls2 QuickTimeline ShaderTools Concurrent)
qt_standard_project_setup()
qt_add_executable(${CMAKE_PROJECT_NAME}
README.md
LICENSE)
LICENSE
)
qt_add_resources(${CMAKE_PROJECT_NAME} "configuration"
PREFIX "/"
FILES
@@ -56,6 +57,19 @@ qt_add_resources(${CMAKE_PROJECT_NAME} "app_images"
"images/icons/icons8-store.svg"
"images/icons/icons8-user-account.svg"
"images/icons/icons8-view-more.svg"
"images/icons/icons8-video.svg"
"images/icons/pexels-icon-filled-256.svg"
"images/icons/icons8-trash.svg"
"images/icons/icons8-download.svg"
"images/icons/icons8-play.svg"
"images/icons/icons8-stop.svg"
"images/icons/icons8-codepen.svg"
"images/icons/icons8-cube.svg"
"images/icons/icons8-camera.svg"
"images/icons/icons8-audio.svg"
"images/icons/icons8-3d-model.svg"
"images/icons/icons8-3d-glasses.svg"
"images/icons/kofi.gif"
"images/kero/kero_build_1.png"
"images/kero/kero_build_2.png"
"images/kero/kero_build_3.png"
@@ -72,9 +86,14 @@ qt_add_resources(${CMAKE_PROJECT_NAME} "app_images"
"images/kero/kero_run_4.png"
"images/kero/kero_success.png"
"images/kero/kero_warning.png"
"images/icons/icons8-trash.svg"
)
target_compile_definitions(
${CMAKE_PROJECT_NAME}
PUBLIC
KOMPLEX_LOCAL_DEV
)
include(qds)
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
@@ -125,4 +144,4 @@ install(TARGETS ${CMAKE_PROJECT_NAME}
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
)
+1
View File
@@ -17,6 +17,7 @@ qt6_add_qml_module(KomplexHubContent
"pages/SettingsPage.qml"
"pages/UserProfilePage.qml"
"pages/WallpaperSettingsPage.qml"
"pages/VideoSearchPage.qml"
)
+179 -27
View File
@@ -10,9 +10,11 @@ import QtQuick.Layouts
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubContent
Rectangle {
property MenuButton currentMenuButton
property bool popup: false
id: windowRoot
@@ -34,8 +36,43 @@ Rectangle {
color: palette.base.lighter()
ColumnLayout {
ColumnLayout
{
height: popup ? 64 : 0
opacity: popup ? 1 : 0
MenuButton
{
Layout.alignment: Qt.AlignTop
height: 64
width: 100
text: qsTr("Back")
icon.height: 32
icon.width: 32
icon.url: "qrc:/images/icons/icons8-reply-arrow.svg"
onTriggered: () => {
pageLoader.item.closePopup()
selected = false
}
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
}
ColumnLayout
{
opacity: popup ? 0 : 1
visible: opacity > 0.01
id: windowMenuLayout
Layout.fillHeight: true
anchors.fill: parent
MenuButton {
@@ -50,17 +87,24 @@ Rectangle {
icon.width: 32
icon.url: "qrc:/images/icons/icons8-famous.svg"
onTriggered: () => {
onTriggered: () =>
{
pageLoader.page = "pages/HomePage.qml"
currentMenuButton.selected = false
if(currentMenuButton !== null)
{
currentMenuButton.selected = false
}
currentMenuButton = this
searchContainer.preferredHeight = 0
searchContainer.reset()
}
}
MenuButton {
MenuButton
{
Layout.alignment: Qt.AlignTop
height: 64
@@ -78,10 +122,35 @@ Rectangle {
currentMenuButton = this
searchContainer.preferredHeight = 50
searchContainer.reset()
}
}
MenuButton {
MenuButton
{
Layout.alignment: Qt.AlignTop
height: 64
width: 100
text: "Videos"
icon.height: 32
icon.width: 32
icon.url: "qrc:/images/icons/icons8-video.svg"
onTriggered: () => {
pageLoader.page = "pages/VideoSearchPage.qml"
currentMenuButton.selected = false
currentMenuButton = this
searchContainer.preferredHeight = 50
searchContainer.reset()
}
}
MenuButton
{
Layout.alignment: Qt.AlignTop
height: 64
@@ -99,10 +168,12 @@ Rectangle {
currentMenuButton = this
searchContainer.preferredHeight = 50
searchContainer.reset()
}
}
MenuButton {
MenuButton
{
Layout.alignment: Qt.AlignTop
height: 64
@@ -120,14 +191,18 @@ Rectangle {
currentMenuButton = this
searchContainer.preferredHeight = 0
searchContainer.reset()
}
}
Item {
Item
{
Layout.fillHeight: true
Layout.minimumHeight: 100
}
MenuButton {
MenuButton
{
Layout.alignment: Qt.AlignBottom
height: 64
@@ -145,14 +220,22 @@ Rectangle {
currentMenuButton = this
searchContainer.preferredHeight = 0
searchContainer.reset()
}
}
Behavior on opacity
{
NumberAnimation
{
duration: 250
}
}
}
}
Rectangle {
//Kirigami.Theme.colorSet: Kirigami.Theme.View
Rectangle
{
id: windowContainer
Layout.fillHeight: true
@@ -160,12 +243,14 @@ Rectangle {
color: "transparent"
ColumnLayout {
ColumnLayout
{
id: windowContainerLayout
anchors.fill: parent
spacing: 0
SearchBar {
SearchBar
{
property int preferredHeight: 50
id: searchContainer
color: palette.base.lighter()
@@ -176,12 +261,18 @@ Rectangle {
icon: "qrc:/images/icons/icons8-search.svg"
onSearchTermChanged: () =>
{
pageLoader.setSearchTerm()
}
Behavior on preferredHeight {
NumberAnimation { duration: Constants.normalAnimationDuration }
}
}
Rectangle {
Rectangle
{
id: windowContent
Layout.fillHeight: true
@@ -191,20 +282,23 @@ Rectangle {
color: palette.base.darker()
Loader {
Loader
{
property bool loading: false
property string page
anchors.fill: parent
onPageChanged: () => {
onPageChanged: () =>
{
loading = true
fadeOutPage()
}
id: pageLoader
OpacityAnimator on opacity {
OpacityAnimator on opacity
{
id: pageLoaderAnimation
target: pageLoader
@@ -212,34 +306,74 @@ Rectangle {
onFinished: () => {
if(pageLoader.loading && pageLoader.opacity === 0)
{
pageLoader.loadPage()
}
else if(pageLoader.loading && pageLoader.opacity === 1)
{
pageLoader.loading = false
pageLoader.updateSearchTerm();
popupConnection.target = pageLoader.item
}
}
}
function fadeOutPage() {
function fadeOutPage()
{
pageLoaderAnimation.from = 1
pageLoaderAnimation.to = 0
pageLoaderAnimation.start()
}
function fadeInPage() {
function fadeInPage()
{
if(pageLoader.sourceComponent.status != Component.Ready)
{
return
}
pageLoaderAnimation.from = 0
pageLoaderAnimation.to = 1
pageLoaderAnimation.start()
}
function loadPage() {
function loadPage()
{
sourceComponent = Qt.createComponent(page)
if(pageLoader.sourceComponent.status == Component.Ready)
if(sourceComponent.status == Component.Ready)
{
fadeInPage()
}
else
{
statusChanged.connect(fadeInPage)
}
}
function updateSearchTerm()
{
if(isSearchPage())
{
searchContainer.searchTerm = pageLoader.item.query
}
}
function setSearchTerm()
{
if(isSearchPage())
{
pageLoader.item.query = searchContainer.searchTerm
}
}
function isSearchPage()
{
return (
pageLoader.item instanceof ImageSearchPage ||
pageLoader.item instanceof LiveSearchPage ||
pageLoader.item instanceof VideoSearchPage
);
}
}
}
@@ -247,25 +381,34 @@ Rectangle {
}
}
KeroBuildingAnimation {
KeroBuildingAnimation
{
id: buildingOverlay
anchors.fill: parent
visible: false
}
KeroLoadingAnimation {
KeroLoadingAnimation
{
id: loadingAnimation
anchors.fill: parent
// OpacityAnimator on opacity {
// duration: 150
// }
visible: opacity > 0
opacity: 0
}
Connections
{
id: popupConnection
target: pageLoader.item
function onPopupChanged()
{
windowRoot.popup = pageLoader.item.popup
}
}
Component.onCompleted: () => {
homeMenubutton.selected = true
currentMenuButton = homeMenubutton
@@ -291,6 +434,15 @@ Rectangle {
},
State {
name: "build_complete"
},
State
{
name: "popup"
when: popup
PropertyChanges {
target: searchContainer
preferredHeight: 0
}
}
]
+393 -109
View File
@@ -1,141 +1,425 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Effects
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item {
Item
{
readonly property bool searchable: false
property int resultsPerRow: (homePageRoot.width - (64 + Constants.largeMargin)) / (256 + Constants.largeMargin)
property int resultsPerRow: (homePageRoot.width - (64 + Constants.largeMargin)) / (resultWidth + Constants.largeMargin) + 1
property int resultWidth: 256
property int resultHeight: 245
property bool popup: false
property bool loading: packsModel.state === NewestPacksModel.Loading ||
imagesModel.state === FeaturedImagesModel.Loading ||
videosModel.state === FeaturedVideosModel.Loading;
onWidthChanged:() => {
packsModel.resultsPerPage = resultsPerRow
imagesModel.resultsPerPage = resultsPerRow
videosModel.resultsPerPage = resultsPerRow
}
clip: true
id: homePageRoot
Rectangle {
NewestPacksModel
{
id: packsModel
resultsPerPage: 0
}
FeaturedImagesModel
{
id: imagesModel
resultsPerPage: 0
}
FeaturedVideosModel
{
id: videosModel
resultsPerPage: 0
}
Rectangle
{
anchors.fill: parent
color: palette.base
ScrollView {
ColumnLayout
{
id: resultsLayout
visible: opacity > 0.01
anchors.fill: parent
anchors.margins: Constants.largeMargin
anchors.margins: Constants.mediumMargin
ColumnLayout {
width: homePageRoot.width
Text
{
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: 50
// Featured Results
ColumnLayout {
width: parent.width
height: 420
color: palette.text
font.pixelSize: Constants.h2Font.pixelSize
font.bold: true
text: qsTr("Newest Wallpaper Packs")
verticalAlignment: Qt.AlignVCenter
}
Text {
color: palette.text
font.pixelSize: Constants.largeFont.pixelSize
text: "Featured"
}
HorizontalPaginator
{
id: packsPaginator
Layout.fillWidth: true
Layout.preferredHeight: 245
Layout.alignment: Qt.AlignTop
RowLayout {
model: packsModel
delegate: ItemDelegate
{
width: resultWidth
height: resultHeight
Layout.fillWidth: true
Layout.preferredHeight: 256
Layout.alignment: Qt.AlignHCenter
required property string name
required property string author
required property string description
required property string uuid
required property string thumbnail
required property string authorId
required property int index
Repeater {
model: resultsPerRow
SearchResultItem
{
anchors.fill: parent
title: parent.name
author: parent.author
description: parent.description
thumbnail: parent.thumbnail
uuid: parent.uuid
delegate: SearchResultItem {
selected: packsPaginator.currentIndex === parent.index
}
onTriggered: () => packsPaginator.currentIndex = parent.index
onViewMoreTriggered: () =>
{
showWallpaperPopup(parent.index)
}
SquareButton {
Layout.fillHeight: true
Layout.preferredWidth: 64
icon.source: "qrc:/images/icons/icons8-forward.svg"
icon.height: 24
icon.width: 24
}
}
}
Item {
height: Constants.largeMargin
}
ColumnLayout {
width: parent.width
height: 420
Text {
color: palette.text
font.pixelSize: Constants.largeFont.pixelSize
text: "Newest"
}
RowLayout {
Layout.fillWidth: true
Layout.preferredHeight: 256
Layout.alignment: Qt.AlignHCenter
Repeater {
model: resultsPerRow
delegate: SearchResultItem {
}
}
SquareButton {
Layout.fillHeight: true
Layout.preferredWidth: 64
icon.source: "qrc:/images/icons/icons8-forward.svg"
icon.height: 24
icon.width: 24
}
}
}
Item {
height: Constants.largeMargin
}
ColumnLayout {
width: parent.width
height: 420
Text {
color: palette.text
font.pixelSize: Constants.largeFont.pixelSize
text: "Popular"
}
RowLayout {
Layout.fillWidth: true
Layout.preferredHeight: 256
Layout.alignment: Qt.AlignHCenter
Repeater {
model: resultsPerRow
delegate: SearchResultItem {
}
}
SquareButton {
Layout.fillHeight: true
Layout.preferredWidth: 64
icon.source: "qrc:/images/icons/icons8-forward.svg"
icon.height: 24
icon.width: 24
onThumbnailChanged: () =>
{
console.log(index + " " + thumbnail + " " + parent.thumbnail)
}
}
}
}
Text
{
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: 50
color: palette.text
font.pixelSize: Constants.h2Font.pixelSize
font.bold: true
text: qsTr("Featured Images")
verticalAlignment: Qt.AlignVCenter
}
HorizontalPaginator
{
id: imagesPaginator
Layout.fillWidth: true
Layout.preferredHeight: 245
Layout.alignment: Qt.AlignTop
model: imagesModel
delegate: ItemDelegate
{
width: resultWidth
height: resultHeight
required property string author
required property string description
required property string uuid
required property string thumbnail
required property string authorId
required property int index
SearchResultItem
{
anchors.fill: parent
title: parent.author
description: parent.description
thumbnail: parent.thumbnail
uuid: parent.uuid
pexels: true
selected: imagesPaginator.currentIndex === parent.index
onTriggered: () => imagesPaginator.currentIndex = parent.index
onViewMoreTriggered: () =>
{
showImagePopup(parent.index)
}
}
}
}
Text
{
Layout.alignment: Qt.AlignTop
Layout.preferredHeight: 50
color: palette.text
font.pixelSize: Constants.h2Font.pixelSize
font.bold: true
text: qsTr("Popular Videos")
verticalAlignment: Qt.AlignVCenter
}
HorizontalPaginator
{
id: videosPaginator
Layout.fillWidth: true
Layout.preferredHeight: 245
Layout.alignment: Qt.AlignTop
model: videosModel
delegate: ItemDelegate
{
width: resultWidth
height: resultHeight
required property string uuid
required property string author
required property string authorId
required property string authorUrl
required property string thumbnail
required property int index
SearchResultItem
{
anchors.fill: parent
title: parent.author
thumbnail: parent.thumbnail
uuid: parent.uuid
pexels: true
selected: videosPaginator.currentIndex === parent.index
onTriggered: () => videosPaginator.currentIndex = parent.index
onViewMoreTriggered:() => showVideoPopup(parent.index)
}
}
}
/* spacer */
Item { Layout.fillHeight: true }
}
}
Component.onCompleted: () =>
{
imagesModel.nextPage()
videosModel.nextPage()
packsModel.nextPage()
}
KeroLoadingAnimation
{
id: loadingAnimation
anchors.fill: parent
visible: opacity > 0
opacity: 1
}
Rectangle
{
id: popupContainer
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
color: palette.base
ImageView
{
id: viewMoreImagePopup
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
VideoView
{
id: viewMoreVideoPopup
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
//model: videosModel.itemModel
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
PackView
{
id: viewMoreWallpaperPopup
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
//model: videosModel.itemModel
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
states: [
State {
name: "loading"
when: homePageRoot.loading
PropertyChanges
{
target: loadingAnimation
opacity: 1
}
PropertyChanges
{
target: resultsLayout
opacity: 0
}
PropertyChanges
{
target: popupContainer
opacity: 0
}
},
State {
name: "idle"
when: packsModel.state !== NewestPacksModel.Loading &&
imagesModel.state !== FeaturedImagesModel.Loading &&
videosModel.state !== FeaturedVideosModel.Loading;
PropertyChanges
{
target: loadingAnimation
opacity: 0
}
PropertyChanges
{
target: resultsLayout
opacity: 1
}
}
]
transitions: [
Transition
{
from: "loading"
to: "idle"
NumberAnimation
{
target: loadingAnimation
duration: 250
property: "opacity";
}
NumberAnimation
{
target: resultsLayout
duration: 250
property: "opacity";
}
}
]
function showImagePopup(index)
{
viewMoreImagePopup.author = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.AuthorRole)
viewMoreImagePopup.authorUrl = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.AuthorUrlRole)
viewMoreImagePopup.description = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.DescriptionRole)
viewMoreImagePopup.uuid = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.UuidRole)
viewMoreImagePopup.thumbnail = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LargeThumbnailRole)
viewMoreImagePopup.original = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.OriginalUrlRole)
viewMoreImagePopup.portrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.PortraitUrlRole)
viewMoreImagePopup.landscape = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LandscapeUrlRole)
viewMoreImagePopup.backgroundPortrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.BackgroundPortraitRole)
viewMoreImagePopup.backgroundLandscape = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.BackgroundLandscapeRole)
viewMoreImagePopup.fullScreen = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.ScreenUrlRole)
viewMoreImagePopup.portraitSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.PortraitSizeRole)
viewMoreImagePopup.landscapeSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LandscapeSizeRole)
viewMoreImagePopup.fullScreenSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.ScreenSizeRole)
viewMoreImagePopup.opacity = 1
popupContainer.opacity = 1
resultsLayout.opacity = 0
homePageRoot.popup = true
}
function showVideoPopup(index)
{
videosModel.setItem(index)
viewMoreVideoPopup.author = videosModel.data(videosModel.index(index,0), FeaturedVideosModel.AuthorRole)
viewMoreVideoPopup.authorUrl = videosModel.data(videosModel.index(index,0), FeaturedVideosModel.AuthorUrlRole)
viewMoreVideoPopup.uuid = videosModel.data(videosModel.index(index,0), FeaturedVideosModel.UuidRole)
viewMoreVideoPopup.thumbnail = videosModel.data(videosModel.index(index,0), FeaturedVideosModel.ThumbnailRole)
viewMoreVideoPopup.modelIndex = index
viewMoreVideoPopup.model = videosModel.itemModel
viewMoreVideoPopup.opacity = 1
resultsLayout.opacity = 0
popupContainer.opacity = 1
homePageRoot.popup = true
}
function showWallpaperPopup(index)
{
viewMoreWallpaperPopup.author = packsModel.data(packsModel.index(index,0), NewestPacksModel.AuthorRole)
viewMoreWallpaperPopup.authorId = packsModel.data(packsModel.index(index,0), NewestPacksModel.AuthorIdRole)
viewMoreWallpaperPopup.description = packsModel.data(packsModel.index(index,0), NewestPacksModel.DescriptionRole)
viewMoreWallpaperPopup.thumbnail = packsModel.data(packsModel.index(index,0), NewestPacksModel.ThumbnailRole)
viewMoreWallpaperPopup.opacity = 1
popupContainer.opacity = 1
resultsLayout.opacity = 0
homePageRoot.popup = true
}
function closePopup()
{
viewMoreImagePopup.opacity = 0
viewMoreVideoPopup.opacity = 0
viewMoreWallpaperPopup.opacity = 0
popupContainer.opacity = 0
resultsLayout.opacity = 1
homePageRoot.popup = false
}
}
+107 -59
View File
@@ -1,78 +1,126 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item {
id: imageSearchPageRoot
Item
{
id: rootItem
SearchResultList {
id: searchResultList
anchors.fill: parent
color: palette.base
property string query
readonly property bool searchable: paginator.searchable
property bool popup: false
property int resultWidth: 256
property int resultHeight: 245
ImageSearchModel
{
id: searchModel
query: rootItem.query
resultsPerPage: paginator.resultsPerPage
}
KeroErrorAvatar {
id: errorOverlay
PaginatorGrid
{
id: paginator
anchors.fill: parent
opacity: 0
}
model: searchModel
loading: model.state === ImageSearchModel.Loading
KeroNoResultsAvatar {
id: noResultsOverlay
delegate: ItemDelegate
{
id: resultDelegate
anchors.fill: parent
opacity: 0
}
width: resultWidth
height: resultHeight
KeroLoadingAnimation {
id: loadingOverlay
required property string author
required property string description
required property string uuid
required property string thumbnail
required property string authorId
required property int index
anchors.fill: parent
opacity: 0
}
SearchResultItem
{
anchors.fill: parent
title: parent.author
description: parent.description
thumbnail: parent.thumbnail
uuid: parent.uuid
pexels: true
selected: paginator.currentIndex === parent.index
states: [
State {
name: "loading"
when: searchResultList.state === "loading"
onTriggered: () => paginator.currentIndex = parent.index
PropertyChanges {
target: loadingOverlay
opacity: 1
}
PropertyChanges {
target: resultsView
opacity: 0
}
},
State {
name: "empty"
when: searchResultList.state === "empty"
PropertyChanges {
target: noResultsOverlay
opacity: 1
}
PropertyChanges {
target: resultsView
opacity: 0
}
},
State {
name: "error"
when: searchResultList.state === "error"
PropertyChanges {
target: errorOverlay
opacity: 1
}
PropertyChanges {
target: resultsView
opacity: 0
onViewMoreTriggered: () =>
{
showImagePopup(parent.index)
}
}
}
]
}
Rectangle
{
id: popupContainer
anchors.fill: parent
opacity: 0
color: palette.base
ImageView
{
id: viewMoreImagePopup
anchors.fill: parent
opacity: 0
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
function showImagePopup(index)
{
viewMoreImagePopup.author = searchModel.data(searchModel.index(index,0), ImageSearchModel.AuthorRole)
viewMoreImagePopup.authorUrl = searchModel.data(searchModel.index(index,0), ImageSearchModel.AuthorUrlRole)
viewMoreImagePopup.description = searchModel.data(searchModel.index(index,0), ImageSearchModel.DescriptionRole)
viewMoreImagePopup.uuid = searchModel.data(searchModel.index(index,0), ImageSearchModel.UuidRole)
viewMoreImagePopup.thumbnail = searchModel.data(searchModel.index(index,0), ImageSearchModel.LargeThumbnailRole)
viewMoreImagePopup.original = searchModel.data(searchModel.index(index,0), ImageSearchModel.OriginalUrlRole)
viewMoreImagePopup.portrait = searchModel.data(searchModel.index(index,0), ImageSearchModel.PortraitUrlRole)
viewMoreImagePopup.landscape = searchModel.data(searchModel.index(index,0), ImageSearchModel.LandscapeUrlRole)
viewMoreImagePopup.backgroundPortrait = searchModel.data(searchModel.index(index,0), ImageSearchModel.BackgroundPortraitRole)
viewMoreImagePopup.backgroundLandscape = searchModel.data(searchModel.index(index,0), ImageSearchModel.BackgroundLandscapeRole)
viewMoreImagePopup.fullScreen = searchModel.data(searchModel.index(index,0), ImageSearchModel.ScreenUrlRole)
viewMoreImagePopup.portraitSize = searchModel.data(searchModel.index(index,0), ImageSearchModel.PortraitSizeRole)
viewMoreImagePopup.landscapeSize = searchModel.data(searchModel.index(index,0), ImageSearchModel.LandscapeSizeRole)
viewMoreImagePopup.fullScreenSize = searchModel.data(searchModel.index(index,0), ImageSearchModel.ScreenSizeRole)
viewMoreImagePopup.opacity = 1
popupContainer.opacity = 1
paginator.opacity = 0
rootItem.popup = true
}
function closePopup()
{
viewMoreImagePopup.opacity = 0
popupContainer.opacity = 0
paginator.opacity = 1
rootItem.popup = false
}
}
+97 -59
View File
@@ -3,76 +3,114 @@ import QtQuick.Controls
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item {
id: imageSearchPageRoot
Item
{
id: rootItem
SearchResultList {
id: searchResultList
anchors.fill: parent
color: palette.base
property string query
readonly property bool searchable: paginator.searchable
property bool popup: false
property int resultWidth: 256
property int resultHeight: 245
PackSearchModel
{
id: searchModel
query: rootItem.query
resultsPerPage: paginator.resultsPerPage
}
KeroErrorAvatar {
id: errorOverlay
PaginatorGrid
{
id: paginator
anchors.fill: parent
opacity: 0
}
model: searchModel
loading: model.state === PackSearchModel.Loading
KeroNoResultsAvatar {
id: noResultsOverlay
delegate: ItemDelegate
{
id: resultDelegate
anchors.fill: parent
opacity: 0
}
width: 256
height: 245
KeroLoadingAnimation {
id: loadingOverlay
required property string name
required property string author
required property string description
required property string uuid
required property string thumbnail
required property string authorId
required property int index
anchors.fill: parent
opacity: 0
}
SearchResultItem
{
anchors.fill: parent
title: parent.author
description: parent.description
thumbnail: parent.thumbnail
uuid: parent.uuid
selected: paginator.currentIndex === parent.index
states: [
State {
name: "loading"
when: searchResultList.state === "loading"
onTriggered: () => paginator.currentIndex = parent.index
PropertyChanges {
target: loadingOverlay
opacity: 1
}
PropertyChanges {
target: resultsView
opacity: 0
}
},
State {
name: "empty"
when: searchResultList.state === "empty"
PropertyChanges {
target: noResultsOverlay
opacity: 1
}
PropertyChanges {
target: resultsView
opacity: 0
}
},
State {
name: "error"
when: searchResultList.state === "error"
PropertyChanges {
target: errorOverlay
opacity: 1
}
PropertyChanges {
target: resultsView
opacity: 0
onViewMoreTriggered: () =>
{
showWallpaperPopup(parent.index)
}
}
}
]
}
Rectangle
{
id: popupContainer
anchors.fill: parent
opacity: 0
color: palette.base
PackView
{
id: viewMoreWallpaperPopup
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
//model: videosModel.itemModel
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
Behavior on opacity {
NumberAnimation
{
duration: 250
}
}
}
function closePopup()
{
viewMoreWallpaperPopup.opacity = 0
popupContainer.opacity = 0
paginator.opacity = 1
rootItem.popup = false
}
function showWallpaperPopup(index)
{
viewMoreWallpaperPopup.author = searchModel.data(searchModel.index(index,0), PackSearchModel.AuthorRole)
viewMoreWallpaperPopup.authorId = searchModel.data(searchModel.index(index,0), PackSearchModel.AuthorIdRole)
viewMoreWallpaperPopup.description = searchModel.data(searchModel.index(index,0), PackSearchModel.DescriptionRole)
viewMoreWallpaperPopup.thumbnail = searchModel.data(searchModel.index(index,0), PackSearchModel.ThumbnailRole)
viewMoreWallpaperPopup.opacity = 1
popupContainer.opacity = 1
paginator.opacity = 0
rootItem.popup = true
}
}
+123
View File
@@ -0,0 +1,123 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item
{
id: rootItem
property string query
readonly property bool searchable: paginator.searchable
property bool popup: false
property int resultWidth: 256
property int resultHeight: 245
VideoSearchModel
{
id: searchModel
query: rootItem.query
resultsPerPage: paginator.resultsPerPage
}
PaginatorGrid
{
id: paginator
anchors.fill: parent
model: searchModel
loading: model.state === VideoSearchModel.Loading
visible: opacity > 0.01
delegate: ItemDelegate
{
id: resultDelegate
width: resultWidth
height: resultHeight
required property string uuid
required property string author
required property string authorId
required property string authorUrl
required property string thumbnail
required property int index
SearchResultItem
{
anchors.fill: parent
author: parent.author
description: qsTr("No description available")
thumbnail: parent.thumbnail
uuid: parent.uuid
pexels: true
selected: paginator.currentIndex === parent.index
onTriggered: () => paginator.currentIndex = parent.index
onViewMoreTriggered: () =>
{
showVideoPopup(parent.index)
}
}
}
}
Rectangle
{
id: popupContainer
anchors.fill: parent
opacity: 0
visible: opacity > 0.01
color: palette.base
VideoView
{
id: viewMoreVideoPopup
anchors.fill: parent
opacity: 0
Behavior on opacity
{
NumberAnimation
{
duration: 250
}
}
}
Behavior on opacity
{
NumberAnimation
{
duration: 250
}
}
}
function showVideoPopup(index)
{
searchModel.setItem(index)
viewMoreVideoPopup.author = searchModel.data(searchModel.index(index,0), VideoSearchModel.AuthorRole)
viewMoreVideoPopup.authorUrl = searchModel.data(searchModel.index(index,0), VideoSearchModel.AuthorUrlRole)
viewMoreVideoPopup.uuid = searchModel.data(searchModel.index(index,0), VideoSearchModel.UuidRole)
viewMoreVideoPopup.thumbnail = searchModel.data(searchModel.index(index,0), VideoSearchModel.ThumbnailRole)
viewMoreVideoPopup.modelIndex = index
viewMoreVideoPopup.model = searchModel.itemModel
viewMoreVideoPopup.opacity = 1
paginator.opacity = 0
popupContainer.opacity = 1
rootItem.popup = true
}
function closePopup()
{
viewMoreVideoPopup.opacity = 0
popupContainer.opacity = 0
paginator.opacity = 1
rootItem.popup = false
}
}
+7
View File
@@ -14,5 +14,12 @@ qt6_add_qml_module(KomplexHubModule_Controls
"Throbber.qml"
"SearchResultItem.qml"
"SearchResultList.qml"
QML_FILES PaginationBox.qml
QML_FILES PaginatorGrid.qml
QML_FILES HorizontalPaginator.qml
QML_FILES ImageView.qml
QML_FILES
QML_FILES VideoView.qml
QML_FILES PackView.qml
)
@@ -0,0 +1,169 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item
{
readonly property bool searchable: false
property int resultsPerRow: (resultsContainer.width - (Constants.largeMargin * 2)) / (resultWidth + Constants.mediumMargin)
property int rows: ((resultsContainer.height - (Constants.largeMargin * 2)) / (resultHeight + Constants.mediumMargin))
property int resultsPerPage: resultsPerRow * rows
property int emptyWidth: (resultsContainer.width - (Constants.largeMargin * 2)) - (resultsPerRow * (resultWidth + Constants.mediumMargin))
property int resultWidth: 256
property int resultHeight: 245
property bool loading: false
property alias currentItem: resultsView.currentItem
property alias currentIndex: resultsView.currentIndex
property var model
property Component delegate
id: rootItem
Item
{
id: resultsContainer
anchors.fill: parent
RowLayout
{
anchors.fill: parent
Component
{
id: highlight
Rectangle
{
width: 256
height: 245
color: palette.accent
radius: 5
// x: resultsView.currentItem.x
// y: resultsView.currentItem.y
Behavior on x { SpringAnimation { spring: 3; damping: 0.2 } }
Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } }
}
}
ListView
{
id: resultsView
Layout.fillHeight: true
Layout.fillWidth: true
spacing: Constants.mediumMargin
orientation: ListView.Horizontal
model: rootItem.model
delegate: rootItem.delegate
highlight: Rectangle { color: palette.accent; radius: 5 }
highlightFollowsCurrentItem: true
focus: true
add: Transition
{
NumberAnimation
{
properties: "x"
from: resultsContainer.width
duration: 250
}
NumberAnimation
{
properties: "opacity,scale"
to: 1.0
duration: 500
}
}
move: Transition
{
NumberAnimation
{
properties: "x,y"
duration: 250
}
}
displaced: Transition
{
NumberAnimation
{
properties: "x,y"
duration: 250
}
}
populate: Transition
{
NumberAnimation
{
properties: "opacity,scale"
to: 1.0
duration: 500
}
}
remove: Transition
{
NumberAnimation
{
properties: "x"
to: 0
duration: 250
}
NumberAnimation
{
properties: "opacity"
to: 0
duration: 250
}
}
}
Item
{
Layout.fillHeight: true
Layout.preferredWidth: 128
Rectangle
{
id: gradientMap
anchors.top: parent.top
anchors.right: moreButton.left
height: resultHeight
width: resultWidth / 4
gradient: Gradient
{
orientation: Gradient.Horizontal
GradientStop { position: 0.0; color: "transparent" }
GradientStop { position: 1.0; color: palette.light }
}
opacity: 0.5
}
SquareButton
{
id: moreButton
anchors.top: parent.top
anchors.right: parent.right
height: resultHeight
width: 64
icon.source: "qrc:/images/icons/icons8-forward.svg"
icon.height: 24
icon.width: 24
}
}
}
}
}
+195
View File
@@ -0,0 +1,195 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Effects
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item
{
property string uuid
property string author
property string authorUrl
property string description
property string thumbnail
property string portrait
property string landscape
property string original
property string fullScreen
property string portraitSize
property string landscapeSize
property string fullScreenSize
property string backgroundPortrait
property string backgroundLandscape
property int imageHeight
property int imageWidth
id: rootItem
Rectangle
{
anchors.fill: parent
color: palette.base
Image
{
id: backgroundImage
source: width > height ? backgroundLandscape : backgroundPortrait
transform: Image.PreserveAspectCrop
anchors.fill: parent
visible: false
}
MultiEffect
{
anchors.fill: backgroundImage
source: backgroundImage
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
}
ColumnLayout
{
anchors.fill: parent
anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin
RowLayout
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: 32
Rectangle
{
Layout.fillWidth: true
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Layout.alignment: Qt.AlignHCenter
color: palette.base.darker()
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
transform: Image.PreserveAspectCrop
source: rootItem.thumbnail
visible: !(status === Image.Loading)
}
}
}
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
}
Text
{
text: qsTr("Available Downloads")
color: palette.text
font.bold: true
font.pixelSize: Constants.h3Font.pixelSize
elide: Text.ElideRight
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignLeft
}
RowLayout
{
Layout.fillWidth: true
ComboBox
{
id: downloadSelector
model:[
"Screen (" + fullScreenSize + ")",
"Portrait (" + portraitSize + ")",
"Landscape (" + landscapeSize + ")"
]
Layout.fillWidth: true
Layout.preferredHeight: 36
}
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("Images Provided Courtesy of Pexels")
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 -3
View File
@@ -62,10 +62,12 @@ Item {
id: lineEditRoot
ColumnLayout {
ColumnLayout
{
anchors.fill: parent
Rectangle {
Rectangle
{
id: lineEditBackground
border.color: lineEditRoot.border.color
@@ -87,7 +89,8 @@ Item {
topLeftRadius: lineEditRoot.radius.topLeft
topRightRadius: lineEditRoot.radius.topRight
TextInput {
TextInput
{
id: lineEditInput
anchors.fill: parent
color: lineEditRoot.color
@@ -101,6 +104,14 @@ Item {
onAccepted: () => lineEditRoot.accepted()
onTextChanged: () => lineEditRoot.text = lineEditInput.text
onEditingFinished: () => lineEditRoot.editingFinished()
MouseArea
{
anchors.fill: parent
cursorShape: Qt.IBeamCursor
onClicked: () => lineEditInput.focus = true
}
}
states: [
+177
View File
@@ -0,0 +1,177 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Effects
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
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
Image
{
id: backgroundImage
source: thumbnail
transform: Image.PreserveAspectCrop
anchors.fill: parent
visible: false
}
MultiEffect
{
anchors.fill: backgroundImage
source: backgroundImage
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
}
ColumnLayout
{
anchors.fill: parent
anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin
RowLayout
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: 32
Rectangle
{
Layout.fillWidth: true
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Layout.alignment: Qt.AlignHCenter
color: palette.base.darker()
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
transform: Image.PreserveAspectCrop
source: rootItem.thumbnail
visible: !(status === Image.Loading)
}
}
}
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
}
// Text
// {
// text: qsTr("Available Downloads")
// color: palette.text
// font.bold: true
// font.pixelSize: Constants.h3Font.pixelSize
// elide: Text.ElideRight
// Layout.fillWidth: true
// Layout.alignment: Qt.AlignTop| Qt.AlignLeft
// }
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
}
}
}
}
}
@@ -0,0 +1,55 @@
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import KomplexHub
Item
{
id: itemRoot
property int page: 0
property int totalPages: 0
property bool enablePrevious: false
property bool enableNext: false
signal next
signal previous
RowLayout
{
id: buttonBoxLayout
anchors.fill: parent
SquareButton
{
Layout.fillHeight: true
Layout.preferredWidth: 128
icon.source: "qrc:/images/icons/icons8-back.svg"
icon.height: 16
icon.width: 16
text: qsTr("Previous")
enabled: itemRoot.enablePrevious
onTriggered: () => itemRoot.previous()
}
Item { Layout.fillWidth: true }
SquareButton
{
Layout.fillHeight: true
Layout.preferredWidth: 128
icon.source: "qrc:/images/icons/icons8-next.svg"
icon.height: 16
icon.width: 16
text: qsTr("Next")
enabled: itemRoot.enableNext
onTriggered: () => itemRoot.next()
}
}
}
+425
View File
@@ -0,0 +1,425 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item
{
property string query
readonly property bool searchable: true
property int resultsPerRow: (resultsContainer.width - (Constants.largeMargin * 2)) / (resultWidth + Constants.mediumMargin)
property int rows: ((resultsContainer.height - (Constants.largeMargin * 2)) / (resultHeight + Constants.mediumMargin))
property int resultsPerPage: resultsPerRow * rows
property int emptyWidth: (resultsContainer.width - (Constants.largeMargin * 2)) - (resultsPerRow * (resultWidth + Constants.mediumMargin))
property int resultWidth: 256
property int resultHeight: 245
property bool loading: false
property alias currentItem: resultsView.currentItem
property alias currentIndex: resultsView.currentIndex
property var model
property Component delegate
id: rootItem
KeroErrorAvatar
{
id: errorOverlay
anchors.fill: parent
opacity: 0
}
KeroNoResultsAvatar
{
id: noResultsOverlay
anchors.fill: parent
opacity: 0
}
KeroChoiceAvatar
{
id: noSearchOverlay
title: qsTr("No Search Term")
description: qsTr("Kero needs a subject or term to search for wallpapers")
anchors.fill: parent
opacity: 0
}
KeroLoadingAnimation
{
id: loadingOverlay
anchors.fill: parent
opacity: 0
}
Rectangle
{
id: resultsContainer
anchors.fill: parent
color: palette.base
RowLayout
{
anchors.fill: parent
anchors.margins: Constants.largeMargin
Item
{
Layout.fillHeight: true
Layout.preferredWidth: emptyWidth / 2
Layout.maximumWidth: emptyWidth / 2
}
Component
{
id: highlight
Rectangle
{
width: view.cellWidth
height: view.cellHeight
color: palette.accent
radius: 5
x: view.currentItem.x
y: view.currentItem.y
Behavior on x { SpringAnimation { spring: 3; damping: 0.2 } }
Behavior on y { SpringAnimation { spring: 3; damping: 0.2 } }
}
}
GridView
{
id: resultsView
Layout.fillHeight: true
Layout.fillWidth: true
cellWidth: 256 + Constants.mediumMargin
cellHeight: 245 + Constants.mediumMargin
model: rootItem.model
delegate: rootItem.delegate
highlight: Rectangle { color: palette.accent; radius: 5 }
highlightFollowsCurrentItem: true
focus: true
add: Transition
{
NumberAnimation
{
properties: "x"
from: resultsContainer.width
duration: 250
}
NumberAnimation
{
properties: "opacity,scale"
to: 1.0
duration: 500
}
}
move: Transition
{
NumberAnimation
{
properties: "x,y"
duration: 250
}
}
displaced: Transition
{
NumberAnimation
{
properties: "x,y"
duration: 250
}
}
populate: Transition
{
NumberAnimation
{
properties: "opacity,scale"
to: 1.0
duration: 500
}
}
remove: Transition
{
NumberAnimation
{
properties: "x"
to: 0
duration: 250
}
NumberAnimation
{
properties: "opacity"
to: 0
duration: 250
}
}
}
}
PaginationBox
{
id: buttonBoxLayout
height: 35
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: Constants.largeMargin
onNext: () => model.nextPage()
onPrevious: () => model.previousPage()
enablePrevious: model.hasPreviousPage
enableNext: model.hasNextPage
}
}
states: [
State
{
name: "loading"
when: loading
PropertyChanges
{
target: loadingOverlay
opacity: 1
}
PropertyChanges
{
target: resultsContainer
opacity: 0
}
PropertyChanges
{
target: noSearchOverlay
opacity: 0
}
PropertyChanges
{
target: errorOverlay
opacity: 0
}
PropertyChanges
{
target: buttonBoxLayout
visible: false
}
},
State
{
name: "empty"
when: model.totalResults === 0 && model.query.length > 0
PropertyChanges
{
target: noResultsOverlay
opacity: 1
}
PropertyChanges
{
target: noSearchOverlay
opacity: 0
}
PropertyChanges
{
target: resultsContainer
opacity: 0
}
PropertyChanges
{
target: buttonBoxLayout
visible: false
}
},
State
{
name: "nosearch"
when: model.query.length === 0
PropertyChanges
{
target: noResultsOverlay
opacity: 0
}
PropertyChanges
{
target: noSearchOverlay
opacity: 1
}
PropertyChanges
{
target: resultsContainer
opacity: 0
}
PropertyChanges
{
target: buttonBoxLayout
visible: false
}
},
State
{
name: "idle"
when: model.totalResults !== 0 && !loading
PropertyChanges
{
target: loadingOverlay
opacity: 0.0
}
PropertyChanges
{
target: resultsContainer
opacity: 1.0
}
PropertyChanges
{
target: buttonBoxLayout
visible: true
}
},
State
{
name: "error"
when: model.errorString.length > 0
PropertyChanges
{
target: errorOverlay
opacity: 1.0
}
PropertyChanges
{
target: resultsContainer
opacity: 0.0
}
PropertyChanges
{
target: noSearchOverlay
opacity: 0.0
}
PropertyChanges
{
target: noResultsOverlay
opacity: 0.0
}
}
]
transitions: [
Transition
{
from: "empty"
to: "loading"
NumberAnimation
{
target: noResultsOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
NumberAnimation
{
target: loadingOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
},
Transition
{
from: "nosearch"
to: "loading"
NumberAnimation
{
target: noSearchOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
NumberAnimation
{
target: loadingOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
},
Transition
{
from: "loading"
to: "nosearch"
NumberAnimation
{
target: noSearchOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
NumberAnimation
{
target: loadingOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
},
Transition
{
from: "loading"
to: "empty"
NumberAnimation
{
target: noResultsOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
NumberAnimation
{
target: loadingOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
},
Transition
{
from: "loading"
to: "idle"
NumberAnimation
{
target: loadingOverlay
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
NumberAnimation
{
target: resultsView
duration: 250
property: "opacity";
easing.type: Easing.InOutQuad
}
}
]
}
+17 -5
View File
@@ -9,7 +9,8 @@ import QtQuick.Controls
import QtQuick.Layouts
import KomplexHub
Item {
Item
{
property string searchTerm: ""
property string icon: ""
property color color: "transparent"
@@ -17,15 +18,18 @@ Item {
id: searchBarRootItem
clip: true
Rectangle {
Rectangle
{
color: searchBarRootItem.color
anchors.fill: parent
RowLayout {
RowLayout
{
id: searchContainerLayout
anchors.fill: parent
LineEdit {
LineEdit
{
id: searchEdit
Layout.fillHeight: true
Layout.fillWidth: true
@@ -40,7 +44,8 @@ Item {
onAccepted: () => searchBarRootItem.searchTerm = text
}
SquareButton {
SquareButton
{
id: searchButton
Layout.fillHeight: searchEdit.height
@@ -52,6 +57,8 @@ Item {
icon.source: searchBarRootItem.icon
icon.width: 16
icon.height: 16
onTriggered: () => searchBarRootItem.searchTerm = searchEdit.text
}
}
}
@@ -65,4 +72,9 @@ Item {
}
}
]
function reset()
{
searchEdit.text = ""
}
}
+264 -60
View File
@@ -2,34 +2,63 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import KomplexHub
Item {
property string author: "Author"
property string description: "This is a description of the search result item"
property string title: "Wallpaper Title"
property string author: ""
property string description: ""
property string title: ""
property string thumbnail: ""
property string url: ""
property string uuid: ""
property bool selected: false
property bool pexels: false
signal triggered
signal viewMoreTriggered
id: searchResultItemRoot
id: mainItem
width: 256
height: 256
clip: true
Rectangle {
Rectangle
{
id: searchResultItemContainer
anchors.fill: parent
border.color: palette.alternateBase.lighter(1.75)
color: palette.alternateBase.lighter(1.25)
ColumnLayout {
MouseArea
{
property string lastState
id: mouseArea
anchors.fill: parent
hoverEnabled: true
onEntered: () => {
states.hovered = true
}
onExited: () => {
if(!viewMoreButton.hovered)
states.hovered = false
}
onReleased: () => {
if(!states.selected)
{
mainItem.triggered()
}
}
}
ColumnLayout
{
anchors.fill: parent
Rectangle {
Rectangle
{
Layout.preferredWidth: 250
Layout.preferredHeight: 141
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
@@ -38,11 +67,59 @@ Item {
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: mainItem.thumbnail
visible: !(status === Image.Loading)
fillMode: Image.PreserveAspectCrop
onStatusChanged: () =>
{
// if(status === Image.Error)
// {
// if(retries <= 3)
// {
// ++retries
// let src = source
// source = ""
// source = src
// }
// }
}
}
Image
{
antialiasing: true
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: Constants.mediumMargin
width: 24
height: 24
transform: Image.PreserveAspectFit
opacity: 0.5
source: "qrc:/images/icons/pexels-icon-filled-256.svg"
visible: mainItem.pexels
}
}
Text {
Text
{
color: palette.text
text: searchResultItemRoot.title
text: mainItem.title
font.pixelSize: 16
font.bold: true
@@ -52,83 +129,84 @@ Item {
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
}
Text {
Item { Layout.fillHeight: true }
Text
{
color: palette.text
font.pixelSize: 12
text: "By: " + searchResultItemRoot.author
text: "By: " + mainItem.author
leftPadding: 12
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
Layout.preferredWidth: 250
visible: !mainItem.pexels
}
Text {
Text
{
id: descriptionText
clip: true
color: palette.text
font.pixelSize: 12
text: searchResultItemRoot.description
text: mainItem.description
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
textFormat: Text.PlainText
elide: Text.ElideRight
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Layout.maximumHeight: 32
Layout.preferredHeight: 32
Layout.preferredWidth: 236
Layout.maximumWidth: 236
Layout.bottomMargin: 3
}
}
Behavior on color {
ColorAnimation { duration: 200 }
}
}
SquareButton
{
id: viewMoreButton
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
Layout.maximumHeight: 50
Layout.preferredHeight: 32
Layout.preferredWidth: 236
Layout.maximumWidth: 236
Layout.bottomMargin: 3
MouseArea {
property string lastState
id: mouseArea
text: qsTr("View More")
opacity: 0
anchors.fill: parent
hoverEnabled: true
onEntered: () => {
if(!selected)
searchResultItemRoot.state = "hovered"
}
onExited: () => {
lastState = ""
if(selected)
searchResultItemRoot.state = "selected"
else
searchResultItemRoot.state = ""
}
onPressed: () => {
if(!selected) {
lastState = searchResultItemRoot.state
searchResultItemRoot.state = "clicked"
onTriggered: () => {
mainItem.viewMoreTriggered()
}
}
}
onReleased: () => {
if(!mouseArea.containsMouse)
return;
selected = !selected
Item { Layout.fillHeight: true }
}
}
onSelectedChanged: () => {
if(selected) {
searchResultItemRoot.triggered()
searchResultItemRoot.state = "selected"
}
else {
searchResultItemRoot.state = ""
QtObject
{
id: states
property bool clicked: false
property bool hovered: false
property alias selected: mainItem.selected
property bool idle: true
onIdleChanged: () =>
{
if(idle)
{
clicked = false
hovered = false
selected = false
}
}
}
states: [
State {
name: "hovered"
when: states.hovered && !states.selected
PropertyChanges {
target: searchResultItemContainer
@@ -138,14 +216,140 @@ Item {
0.5, // Set custom lightness
1.0)
}
PropertyChanges
{
target: viewMoreButton
opacity: 0
Layout.preferredHeight: 0
}
PropertyChanges
{
target: descriptionText
opacity: 1
Layout.preferredHeight: 32
}
},
State {
name: "selected"
when: states.selected && !states.hovered
PropertyChanges {
PropertyChanges
{
target: searchResultItemContainer
color: palette.accent
}
},
State
{
name: "view_more"
when: states.selected && states.hovered
PropertyChanges
{
target: viewMoreButton
opacity: 1
Layout.preferredHeight: 32
}
PropertyChanges
{
target: descriptionText
opacity: 0
Layout.preferredHeight: 0
}
},
State
{
name: "default"
when: states.idle
PropertyChanges
{
target: viewMoreButton
opacity: 0
Layout.preferredHeight: 0
}
PropertyChanges
{
target: descriptionText
opacity: 1
Layout.preferredHeight: 32
}
}
]
transitions:
[
Transition
{
to: "selected"
ColorAnimation
{
target: searchResultItemContainer
duration: 250
}
},
Transition
{
from: "selected"
to: "view_more"
NumberAnimation
{
target: viewMoreButton
property: "opacity"
duration: 250
easing.type: Easing.InOutQuad
}
},
Transition
{
from: "view_more"
to: "selected"
NumberAnimation
{
target: descriptionText
property: "opacity"
duration: 250
easing.type: Easing.InOutQuad
}
},
Transition
{
to: "default"
ColorAnimation
{
target: searchResultItemContainer
duration: 250
}
},
Transition
{
to: "hovered"
ColorAnimation
{
target: searchResultItemContainer
duration: 250
}
}
]
}
+2 -7
View File
@@ -12,6 +12,7 @@ Item {
property color color: palette.button
property Gradient gradient: defaultGradient
property BorderSettings border: BorderSettings {}
readonly property bool hovered: state === "hovered"
signal triggered
@@ -24,7 +25,7 @@ Item {
component IconSettings: QtObject {
property int width: 16
property int height: 16
property string source: "images/icons/icons8-next.svg"
property string source: "qrc:/images/icons/icons8-next.svg"
}
component BorderSettings: QtObject {
@@ -106,10 +107,6 @@ Item {
Behavior on color {
ColorAnimation { duration: 250 }
}
// Behavior on gradient {
// PropertyAnimation { duration: 250 }
// }
}
MouseArea {
@@ -216,7 +213,5 @@ Item {
color: palette.text.darker()
}
}
]
}
+146 -113
View File
@@ -1,126 +1,159 @@
import QtQuick
import QtQuick.Shapes
import QtQuick.Effects
import QtQuick.Layouts
Item {
id: throbberRoot
Rectangle {
anchors.fill: parent
color: "transparent"
Item
onHeightChanged: () => {
if(height > width)
{
id: outerRing
anchors.fill: parent
Shape
{
anchors.fill: parent
asynchronous: true
ShapePath
{
property double progress: 0
property int dashSpaceLength: 15
property int dashLength: 1
id: outerRingPath
strokeColor: palette.accent.darker(1 + (progress - 0.25))
fillColor: "transparent"
strokeWidth: 3
strokeStyle: ShapePath.DashLine
startX: 0
startY: outerRing.height * 0.5
dashPattern: [
dashSpaceLength - (dashSpaceLength * progress),
dashSpaceLength * progress
]
PathArc
{
x: outerRing.width
y: outerRing.height * 0.5
radiusX: outerRing.width / 2
radiusY: outerRing.height / 2
useLargeArc: false
}
PathArc
{
x: 0
y: outerRing.height * 0.5
radiusX: outerRing.width / 2
radiusY: outerRing.height / 2
useLargeArc: false
}
}
}
transform: Rotation {
id: outerRingRotation
origin.x: outerRing.width / 2
origin.y: outerRing.height / 2
}
NumberAnimation {
property bool reverse: false
target: outerRingPath
property: "progress"
duration: 1600
//easing.type: Easing.InOutQuad
from: 0
to: 1
loops: 1
running: true
onFinished: () => {
if(reverse)
{
from = 0
to = 1
start()
}
else
{
from = 1
to = 0
start()
}
reverse = !reverse
}
}
NumberAnimation {
target: outerRingRotation
property: "angle"
duration: 16000
easing.type: Easing.InOutQuad
from: 0
to: (360 * 4)
loops: NumberAnimation.Infinite
running: true
}
layout.throbberSize = width - 24
}
else
{
layout.throbberSize = height - 24
}
}
MultiEffect {
source: outerRing
anchors.fill: outerRing
brightness: 0.4
saturation: 0.2
blurEnabled: true
blurMax: 64
blur: 1.0
onWidthChanged: () => {
if(height > width)
{
layout.throbberSize = width - 24
}
else
{
layout.throbberSize = height - 24
}
}
RowLayout
{
property int throbberSize
id: layout
anchors.fill: parent
Rectangle
{
Layout.alignment: Qt.AlignHCenter
Layout.preferredHeight: parent.throbberSize
Layout.preferredWidth: parent.throbberSize
color: "transparent"
Item
{
id: outerRing
anchors.fill: parent
Shape
{
anchors.fill: parent
asynchronous: true
ShapePath
{
property double progress: 0
property int dashSpaceLength: 15
property int dashLength: 1
id: outerRingPath
strokeColor: palette.accent.darker(1 + (progress - 0.25))
fillColor: "transparent"
strokeWidth: 3
strokeStyle: ShapePath.DashLine
startX: 0
startY: outerRing.height * 0.5
dashPattern: [
dashSpaceLength - (dashSpaceLength * progress),
dashSpaceLength * progress
]
PathArc
{
x: outerRing.width
y: outerRing.height * 0.5
radiusX: outerRing.width / 2
radiusY: outerRing.height / 2
useLargeArc: false
}
PathArc
{
x: 0
y: outerRing.height * 0.5
radiusX: outerRing.width / 2
radiusY: outerRing.height / 2
useLargeArc: false
}
}
}
transform: Rotation {
id: outerRingRotation
origin.x: outerRing.width / 2
origin.y: outerRing.height / 2
}
NumberAnimation {
property bool reverse: false
target: outerRingPath
property: "progress"
duration: 1600
//easing.type: Easing.InOutQuad
from: 0
to: 1
loops: 1
running: true
onFinished: () => {
if(reverse)
{
from = 0
to = 1
start()
}
else
{
from = 1
to = 0
start()
}
reverse = !reverse
}
}
NumberAnimation {
target: outerRingRotation
property: "angle"
duration: 16000
easing.type: Easing.InOutQuad
from: 0
to: (360 * 4)
loops: NumberAnimation.Infinite
running: true
}
}
MultiEffect {
source: outerRing
anchors.fill: outerRing
brightness: 0.4
saturation: 0.2
blurEnabled: true
blurMax: 64
blur: 1.0
}
}
}
}
+191
View File
@@ -0,0 +1,191 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Effects
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
Item
{
property string uuid
property string author
property string authorUrl
property string thumbnail
property alias model: downloadSelector.model
property int modelIndex
property int imageHeight
property int imageWidth
visible: opacity > 0.01
onVisibleChanged: () =>
{
if(!visible)
{
model = null
}
}
Connections
{
target: model
function onRowCountChanged()
{
downloadSelector.currentIndex = 0
}
}
id: rootItem
Rectangle
{
anchors.fill: parent
color: palette.base
Image
{
id: backgroundImage
source: thumbnail
anchors.fill: parent
visible: false
fillMode: Image.PreserveAspectFit
}
MultiEffect
{
anchors.fill: backgroundImage
source: backgroundImage
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
}
ColumnLayout
{
anchors.fill: parent
anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin
RowLayout
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: 32
Rectangle
{
Layout.fillWidth: true
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Layout.alignment: Qt.AlignHCenter
color: palette.base.darker()
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
source: rootItem.thumbnail
visible: !(status === Image.Loading)
fillMode: Image.PreserveAspectCrop
}
}
}
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
}
/** Spacer **/
Item
{
Layout.fillWidth: true
Layout.preferredHeight: 32
}
Text
{
text: qsTr("Available Downloads")
color: palette.text
font.bold: true
font.pixelSize: Constants.h3Font.pixelSize
elide: Text.ElideRight
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignLeft
}
RowLayout
{
Layout.fillWidth: true
ComboBox
{
id: downloadSelector
textRole: "text"
valueRole: "url"
Layout.fillWidth: true
Layout.preferredHeight: 36
}
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("Videos Provided Courtesy of Pexels 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
}
}
}
}
}
+41 -15
View File
@@ -19,27 +19,48 @@ qt_add_qml_module(
newestpacksmodel.cpp
common/komplex_global.h
common/slidingcachecontroller.h
common/paginator.h
common/coreservices.h
common/coreservices.cpp
common/logging.h
common/fetchresult.h
paginators/newestpackspaginator.h
SOURCES paginators/featuredpackspaginator.h
SOURCES paginators/featuredimagespaginator.h
SOURCES paginators/wallpaperpaginator.h
SOURCES paginators/searchpackspaginator.h
SOURCES paginators/searchimagespaginator.h
SOURCES paginators/newestshaderspaginator.h
SOURCES paginators/newestcubemapspaginator.h
SOURCES paginators/featuredshaderspaginator.h
SOURCES paginators/featuredcubemapspaginator.h
SOURCES paginators/searchshaderspaginator.h
SOURCES paginators/searchcubemapspaginator.h
SOURCES paginators/searchvideospaginator.h
paginators/featuredpackspaginator.h
paginators/featuredimagespaginator.h
paginators/wallpaperpaginator.h
paginators/packsearchpaginator.h
paginators/imagesearchpaginator.h
paginators/newestshaderspaginator.h
paginators/newestcubemapspaginator.h
paginators/featuredshaderspaginator.h
paginators/featuredcubemapspaginator.h
paginators/searchshaderspaginator.h
paginators/searchcubemapspaginator.h
paginators/videosearchpaginator.h
featuredpacksmodel.h
featuredpacksmodel.cpp
featuredimagesmodel.h
featuredimagesmodel.cpp
featuredvideosmodel.h
featuredvideosmodel.cpp
paginators/featuredvideospaginator.h
common/imagecache.h
paginators/imagepaginator.h
common/videocache.h
paginators/videopaginator.h
imagesearchmodel.cpp
imagesearchmodel.h
videosearchmodel.h
videosearchmodel.cpp
packsearchmodel.cpp
packsearchmodel.h
videoitemmodel.h
videoitemmodel.cpp
downloadmanager.h downloadmanager.cpp
common/exceptions.h
common/shadertoymetadata.h
common/shaderpack.h
SOURCES packcompiler.h packcompiler.cpp
)
target_compile_definitions(
@@ -48,6 +69,11 @@ target_compile_definitions(
KOMPLEX_PLUGIN
)
target_link_libraries(KomplexHubPlugin PRIVATE
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
)
if(ENABLE_ASAN)
message(STATUS "Building with AddressSanitizer")
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
+13
View File
@@ -12,6 +12,7 @@ auto CoreServices::networkAccessManager() -> QWeakPointer<QNetworkAccessManager>
if(!s_networkAccessPointer)
{
s_networkAccessManager = new QNetworkAccessManager;
s_networkAccessManager->setAutoDeleteReplies(true);
QObject::connect(
s_networkAccessManager,
@@ -50,3 +51,15 @@ auto CoreServices::sessionToken() -> QByteArray
{}
);
}
auto CoreServices::screenSize() -> QSize
{
QScreen *screen = QGuiApplication::primaryScreen();
if(screen == nullptr)
{
return QSize(0,0);
}
return screen->size();
}
+3
View File
@@ -24,6 +24,7 @@
#include <QNetworkReply>
#include <QSharedPointer>
#include <QWeakPointer>
#include <QScreen>
#include <QMutex>
#include <QMutexLocker>
@@ -45,6 +46,8 @@ public:
*/
static auto sessionToken() -> QByteArray;
static auto screenSize() -> QSize;
private:
CoreServices() = default;
File diff suppressed because it is too large Load Diff
+34
View File
@@ -0,0 +1,34 @@
#ifndef EXCEPTIONS_H
#define EXCEPTIONS_H
#include <QString>
#include <exception>
#include "komplex_global.h"
struct KOMPLEX_EXPORT Exception : std::exception
{
explicit Exception(const QString &message, quint16 errorCode = 0)
: std::exception(), message(message), errorCode(errorCode){}
const QString message;
const quint16 errorCode;
};
struct NetworkException : Exception
{
NetworkException(const QString &message, qsizetype errorCode = 0) : Exception(message, errorCode) {}
};
struct FileException : Exception
{
FileException(const QString &message, qsizetype errorCode = 0) : Exception(message, errorCode) {}
};
struct SqlException : Exception
{
SqlException(const QString &message, qsizetype errorCode = 0) : Exception(message, errorCode) {}
};
struct KOMPLEX_EXPORT ShaderCompilerException : Exception
{
ShaderCompilerException(const QString &message, qsizetype errorCode = 0) : Exception(message, errorCode) {}
};
#endif // EXCEPTIONS_H
+7
View File
@@ -41,6 +41,13 @@ struct FetchResult
* Results list
*/
QList<T> data;
auto operator=(const FetchResult<T> &other) -> FetchResult<T>
{
total = other.total;
count = other.count;
data = other.data;
}
};
#endif // FETCHRESULT_H
+50
View File
@@ -0,0 +1,50 @@
#ifndef IMAGECACHE_H
#define IMAGECACHE_H
#include "komplex_global.h"
#include <QObject>
#include <QMap>
#include <QString>
struct KOMPLEX_EXPORT ImageCache
{
QString altText;
QByteArray averageColor;
qsizetype height;
qsizetype width;
qint64 id;
bool liked; //probably not needed
QString photographer;
QString photographerUrl;
qint64 photographerId;
QMap<QString, QString> sources;
QMap<QString, QString> sourceSizes;
QString url;
auto operator == (const ImageCache &other) const -> bool
{
return (
other.altText == altText &&
other.averageColor == averageColor &&
other.height == height &&
other.width == width &&
other.id == id &&
other.liked == liked &&
other.photographer == photographer &&
other.photographerUrl == photographerUrl &&
other.photographerId == photographerId &&
other.sources == sources &&
other.sourceSizes == sourceSizes &&
other.url == url
);
}
auto operator != (const ImageCache &other) const -> bool
{
return !(other == *this);
}
};
Q_DECLARE_METATYPE(ImageCache)
#endif // IMAGECACHE_H
+33 -2
View File
@@ -18,6 +18,8 @@
*/
#ifndef KOMPLEX_GLOBAL_H
#define KOMPLEX_GLOBAL_H
#include <QtTypes>
#include <chrono>
#ifdef KOMPLEX_PLUGIN
#define KOMPLEX_EXPORT Q_DECL_EXPORT
@@ -29,11 +31,40 @@
#define SLIDING_CACHE_PREFETCH_THRESHOLD 20
#define NETWORK_TIMEOUT 10000
#define NETWORK_RETRY_LIMIT 3
#ifdef KOMPLEX_LOCAL_DEV
#define KOMPLEX_API_HOST "https://komplex.net.hlab"
#define KOMPLEX_API_HOST "https://komplexapi.hlab"
#else
#define KOMPLEX_API_HOST "https://digitalartifex.dev"
#define KOMPLEX_API_HOST "https://api.komplex.dev"
#endif
#define KOMPLEX_API_VERSION "v2"
#define KOMPLEX_ENDPOINT_IMAGES_SEARCH "images/search"
#define KOMPLEX_ENDPOINT_IMAGES_FEATURED "featured/images"
#define KOMPLEX_ENDPOINT_IMAGES_ITEM "images/item"
#define KOMPLEX_ENDPOINT_VIDEOS_SEARCH "videos/search"
#define KOMPLEX_ENDPOINT_VIDEOS_FEATURED "featured/videos"
#define KOMPLEX_ENDPOINT_VIDEOS_ITEM "videos/item"
#define KOMPLEX_ENDPOINT_SHADERS_SEARCH "shaders/search"
#define KOMPLEX_ENDPOINT_SHADERS_FEATURED "shaders/featured"
#define KOMPLEX_ENDPOINT_SHADERS_ITEM "shaders/item"
#define KOMPLEX_ENDPOINT_SHADERS_NEWEST "shaders/newest"
#define KOMPLEX_ENDPOINT_CUBEMAPS_SEARCH "cubemaps/search"
#define KOMPLEX_ENDPOINT_CUBEMAPS_FEATURED "cubemaps/featured"
#define KOMPLEX_ENDPOINT_CUBEMAPS_ITEM "cubemaps/item"
#define KOMPLEX_ENDPOINT_CUBEMAPS_NEWEST "cubemaps/newest"
#define KOMPLEX_ENDPOINT_PACKS_SEARCH "packs/search"
#define KOMPLEX_ENDPOINT_PACKS_FEATURED "packs/featured"
#define KOMPLEX_ENDPOINT_PACKS_ITEM "packs/item"
#define KOMPLEX_ENDPOINT_PACKS_NEWEST "packs/newest"
inline static qsizetype nullsize = std::numeric_limits<qsizetype>::min();
inline static std::chrono::milliseconds KOMPLEX_RATE_LIMIT(500);
#endif // KOMPLEX_GLOBAL_H
+199 -56
View File
@@ -22,6 +22,10 @@
#include <QObject>
#include <QMutex>
#include <QMutexLocker>
#include <qdebug.h>
#include <QNetworkReply>
#include <QJsonDocument>
#include <QJsonParseError>
#include "komplex_global.h"
#include "slidingcachecontroller.h"
@@ -38,12 +42,15 @@ class KOMPLEX_EXPORT PaginationNotifier : public QObject
protected:
explicit PaginationNotifier(QObject *parent = nullptr) : QObject(parent) {}
signals:
auto dataChanged() -> void;
auto fetchComplete() -> void;
auto fetching() -> void;
auto resultsPerPageChanged() -> void;
auto totalResultsChanged() -> void;
auto totalPagesChanged() -> void;
auto pageChanged() -> void;
auto countChanged() -> void;
auto queryChanged() -> void;
auto uriChanged() -> void;
};
/**
@@ -56,7 +63,21 @@ class KOMPLEX_EXPORT Paginator : public PaginationNotifier
public:
explicit Paginator(QObject *parent = nullptr) : PaginationNotifier(parent)
{
QObject::connect
(
&m_cacheController,
&SlidingCacheNotifier::fetchComplete,
this,
&PaginationNotifier::fetchComplete
);
QObject::connect
(
&m_cacheController,
&SlidingCacheNotifier::fetching,
this,
&PaginationNotifier::fetching
);
}
/**
@@ -64,9 +85,17 @@ public:
*
* Attempts to get the next page and notifies pageChanged
*/
auto next() const -> void
auto next() -> void
{
setOffset(m_offset + m_resultsPerPage);
if(m_offset != nullsize)
{
setOffset(m_offset + m_resultsPerPage);
}
else
{
controller()->init();
setOffset(0);
}
}
/**
@@ -74,9 +103,17 @@ public:
*
* Attempts to get the previous page and notifies pageChanged
*/
auto previous() const -> void
auto previous() -> void
{
setOffset(m_offset - m_resultsPerPage);
if(m_offset != nullsize && m_offset > m_resultsPerPage)
{
setOffset(m_offset - m_resultsPerPage);
}
else
{
controller()->init();
setOffset(0);
}
}
/**
@@ -94,8 +131,6 @@ public:
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void
{
QMutexLocker dataLocker(&m_dataMutex);
if(resultsPerPage == m_resultsPerPage)
{
return;
@@ -103,18 +138,81 @@ public:
m_resultsPerPage = resultsPerPage;
Q_EMIT static_cast<PaginationNotifier*>(this)->resultsPerPageChanged();
}
m_data = m_cacheController.chunk(m_offset, m_resultsPerPage);
Q_EMIT static_cast<PaginationNotifier*>(this)->dataChanged();
/**
* @brief query
* Current query string, if the API Endpoint supports queries
* @return
*/
[[nodiscard]]
auto query() const -> QString
{
return m_query;
}
/**
* @brief setQuery
* Sets the new query string and updates the controller
* @param query
*/
auto setQuery(const QString &query) -> void
{
if(query == m_query)
{
return;
}
reset();
m_query = query;
Q_EMIT queryChanged();
controller()->init();
setOffset(0);
}
/**
* @brief uri
* URI of the API Endpoint. This is set by the child class
* @return
*/
[[nodiscard]]
auto uri() const -> QString
{
return m_uri;
}
/**
* @brief setUri
* Sets the API Endpoint URI to fetch from
* @param uri
*/
auto setUri(const QString &uri) -> void
{
if(uri == m_uri)
{
return;
}
m_uri = uri;
Q_EMIT uriChanged();
}
/**
* @brief data
* @return
*/
auto data() const -> QList<T>
auto data() const -> const QList<T>
{
return m_data;
if(boundaryCheck(m_resultsPerPage))
{
return m_cacheController.chunk(m_offset, m_resultsPerPage);
}
qsizetype count = (m_cacheController.totalCount() - m_offset);
return m_cacheController.chunk(m_offset, count);
}
/**
@@ -123,7 +221,18 @@ public:
*/
auto count() const -> qsizetype
{
return m_data.count();
if(m_offset == nullsize)
{
return 0;
}
if(boundaryCheck(m_resultsPerPage))
{
return m_resultsPerPage;
}
qsizetype count = (m_cacheController.totalCount() - m_offset);
return count;
}
/**
@@ -131,16 +240,9 @@ public:
* @param index
* @return
*/
auto at(qsizetype index) const -> T
auto at(qsizetype index) const -> const T&
{
QMutexLocker dataLocker(&m_dataMutex);
if(index < 0 || index >= m_data.count())
{
return {};
}
return m_data.at(index);
return m_cacheController.at(m_offset + index);
}
/**
@@ -149,7 +251,7 @@ public:
* The total number of results as reported by the controller
* @return
*/
auto totalResults() -> qsizetype
auto totalResults() const -> qsizetype
{
return m_cacheController.totalCount();
}
@@ -180,6 +282,16 @@ public:
protected:
auto queryable() const -> bool
{
return m_queryable;
}
auto setQueryable(bool queryable) -> void
{
m_queryable = queryable;
}
/**
* @brief controller
* Reference to the underlying cache controller
@@ -214,26 +326,11 @@ protected:
m_offset = 0;
}
QList<T> data = m_cacheController.chunk(m_offset, m_resultsPerPage);
setData(data);
m_cacheController.focus(offset, m_resultsPerPage);
Q_EMIT this->pageChanged();
}
/**
* @brief setData
* @param data
*/
auto setData(const QList<T> &data)
{
m_dataMutex.lock();
m_data.clear();
m_data.append(std::move(data));
m_dataMutex.unlock();
Q_EMIT this->countChanged();
Q_EMIT this->dataChanged();
Q_EMIT totalResultsChanged();
Q_EMIT totalPagesChanged();
Q_EMIT pageChanged();
}
/**
@@ -251,25 +348,59 @@ protected:
*/
auto reset() -> void
{
m_dataMutex.lock();
m_offset = std::numeric_limits<qsizetype>::infinity();
m_data.clear();
m_query.clear();
m_offset = nullsize;
controller()->reset();
m_dataMutex.unlock();
}
Q_EMIT totalPagesChanged();
Q_EMIT dataChanged();
Q_EMIT pageChanged();
/**
* @brief getDocument
* Extracts the JSON document from the server reply and deletes the reply
* object.
* @param reply
* @return
*/
[[nodiscard]]
auto getDocument(QNetworkReply *reply) const -> QJsonDocument
{
QByteArray data = reply->readAll();
QJsonParseError documentError;
QJsonDocument document = QJsonDocument::fromJson(data, &documentError);
reply->deleteLater();
LOG_ERROR_X(documentError.error != QJsonParseError::NoError,
"NewestPacksPaginator::getDocument",
documentError.errorString().toStdString().c_str(),
{}
);
return document;
}
private:
/**
* @brief boundaryCheck
* Checks if the index is within the bounds of the dataset
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || (m_offset + index) >= m_cacheController.totalCount())
{
return false;
}
return true;
}
/**
* @brief m_offset
* Current absolute offset. Used in fetch operations
*/
qsizetype m_offset = std::numeric_limits<qsizetype>::infinity();
mutable qsizetype m_offset = nullsize;
/**
* @brief m_resultsPerPage
@@ -287,16 +418,28 @@ private:
*/
SlidingCacheController<T> m_cacheController;
/**
* @brief m_data
* Internal data copy
*/
QList<T> m_data;
/**
* @brief m_dataMutex
*/
mutable QMutex m_dataMutex;
/**
* @brief m_query
* The query string used in fetch operations
*/
QString m_query;
/**
* @brief m_queryable
* Controls the queryable state of the paginator
*/
bool m_queryable = false;
/**
* @brief m_uri
* API Endpoint URI
*/
QString m_uri;
};
#endif // PAGINATOR_H
+612
View File
@@ -0,0 +1,612 @@
#ifndef SHADERPACK_H
#define SHADERPACK_H
#include <QObject>
#include <QString>
#include <QFile>
#include <QFileInfo>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonParseError>
#include <QStandardPaths>
#include <QDir>
#include <QMap>
#include <QProcess>
#include <QEventLoop>
#include <QtQml/qqmlregistration.h>
#include "komplex_global.h"
class KOMPLEX_EXPORT ShaderChannel : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
enum Type
{
Image,
Video,
Shader,
Cubemap,
Audio,
Scene,
Model
};
Q_ENUM(Type)
enum MirrorMode
{
MirrorVertical,
MirrorHorizontal,
NoMirror
};
Q_ENUM(MirrorMode)
enum Format
{
RGB8A,
RGB16F,
RGB32F
};
Q_ENUM(Format)
enum TextureRepeat
{
ClampToEdge,
RepeatVertically,
RepeatHorizontally,
Repeat
};
Q_ENUM(TextureRepeat)
inline auto source() const -> QString { return m_source; }
inline auto setSource(const QString &source) -> void
{
if(source == this->source())
{
return;
}
m_source = source;
Q_EMIT sourceChanged();
}
inline auto type() const -> Type { return m_type; }
inline auto setType(Type type) -> void
{
if(type == this->type())
{
return;
}
m_type = type;
Q_EMIT typeChanged();
}
inline auto mirrorMode() const -> MirrorMode { return m_mirrorMode; }
inline auto setMirrorMode(MirrorMode mode)
{
if(mirrorMode() == mode)
{
return;
}
m_mirrorMode = mode;
Q_EMIT mirrorModeChanged();
}
inline auto textureRepeat() const -> TextureRepeat { return m_textureRepeat; }
inline auto setTextureRepeat(TextureRepeat mode) -> void
{
if(textureRepeat() == mode)
{
return;
}
m_textureRepeat = mode;
Q_EMIT textureRepeatChanged();
}
inline auto resolutionY() const -> qsizetype { return m_resolutionY; }
inline auto setResolutionY(qsizetype resolution)
{
if(resolutionY() == resolution)
{
return;
}
m_resolutionY = resolution;
Q_EMIT resolutionYChanged();
}
inline auto resolutionX() const -> qsizetype { return m_resolutionX; }
inline auto setResolutionX(qsizetype resolution)
{
if(resolutionX() == resolution)
{
return;
}
m_resolutionX = resolution;
Q_EMIT resolutionXChanged();
}
inline auto resolutionScale() const -> qreal { return m_resolutionScale; }
inline auto setResolutionScale(qreal scale)
{
if(qFuzzyCompare(resolutionScale(), scale))
{
return;
}
m_resolutionScale = scale;
Q_EMIT resolutionScaledChanged();
}
inline auto speed() const -> qreal { return m_speed; }
inline auto setSpeed(qreal speed)
{
if(qFuzzyCompare(this->speed(), speed))
{
return;
}
m_speed = speed;
Q_EMIT speedChanged();
}
inline auto mouseSpeedBias() const -> qreal { return m_mouseSpeedBias; }
inline auto setMouseSpeedBias(qreal bias)
{
if(qFuzzyCompare(mouseSpeedBias(), bias))
{
return;
}
m_mouseSpeedBias = bias;
Q_EMIT mouseSpeedBiasChanged();
}
inline auto bufferA() const -> ShaderChannel* { return m_bufferA; }
inline auto setBufferA(ShaderChannel *buffer) -> void
{
if (m_bufferA == buffer)
{
return;
}
m_bufferA = buffer;
Q_EMIT bufferAChanged();
}
inline auto bufferB() const -> ShaderChannel* { return m_bufferB; }
inline auto setBufferB(ShaderChannel *buffer) -> void
{
if (m_bufferB == buffer)
{
return;
}
m_bufferB = buffer;
Q_EMIT bufferBChanged();
}
inline auto bufferC() const -> ShaderChannel* { return m_bufferC; }
inline auto setBufferC(ShaderChannel *buffer) -> void
{
if (m_bufferC == buffer)
{
return;
}
m_bufferC = buffer;
Q_EMIT bufferCChanged();
}
inline auto bufferD() const -> ShaderChannel* { return m_bufferD; }
inline auto setBufferD(ShaderChannel *buffer) -> void
{
if (m_bufferD == buffer)
{
return;
}
m_bufferD = buffer;
Q_EMIT bufferDChanged();
}
inline auto channel0() const -> ShaderChannel* { return m_channel0; }
inline auto setChannel0(ShaderChannel *channel) -> void
{
if (m_channel0 == channel)
{
return;
}
m_channel0 = channel;
Q_EMIT channel0Changed();
}
inline auto channel1() const -> ShaderChannel* { return m_channel1; }
inline auto setChannel1(ShaderChannel *channel) -> void
{
if (m_channel1 == channel)
{
return;
}
m_channel1 = channel;
Q_EMIT channel1Changed();
}
inline auto channel2() const -> ShaderChannel* { return m_channel2; }
inline auto setChannel2(ShaderChannel *channel) -> void
{
if (m_channel2 == channel)
{
return;
}
m_channel2 = channel;
Q_EMIT channel2Changed();
}
inline auto channel3() const -> ShaderChannel* { return m_channel3; }
inline auto setChannel3(ShaderChannel *channel) -> void
{
if (m_channel3 == channel)
{
return;
}
m_channel3 = channel;
Q_EMIT channel3Changed();
}
inline auto frameBufferChannel() const -> qint8 { return m_frameBufferChannel; };
inline auto setFrameBufferChannel(qint8 frameBufferChannel) -> void
{
if (m_frameBufferChannel == frameBufferChannel)
{
return;
}
m_frameBufferChannel = frameBufferChannel;
Q_EMIT frameBufferChannelChanged();
}
inline auto invert() const -> bool { return m_invert; }
inline auto setInvert(bool invert) -> void
{
if (m_invert == invert)
{
return;
}
m_invert = invert;
emit invertChanged();
}
inline auto mipmap() const -> bool { return m_mipmap; }
inline auto setMipmap(bool on)
{
if(on == mipmap())
{
return;
}
m_mipmap = on;
Q_EMIT mipmapChanged();
}
inline auto format() const -> Format { return m_format; }
inline auto setFormat(Format format)
{
if(this->format() == format)
{
return;
}
m_format = format;
Q_EMIT formatChanged();
}
Q_SIGNALS:
auto sourceChanged() -> void;
auto typeChanged() -> void;
auto mirrorModeChanged() -> void;
auto textureRepeatChanged() -> void;
auto resolutionXChanged() -> void;
auto resolutionYChanged() -> void;
auto resolutionScaledChanged() -> void;
auto speedChanged() -> void;
auto mouseSpeedBiasChanged() -> void;
auto bufferAChanged() -> void;
auto bufferBChanged() -> void;
auto bufferCChanged() -> void;
auto bufferDChanged() -> void;
auto channel0Changed() -> void;
auto channel1Changed() -> void;
auto channel2Changed() -> void;
auto channel3Changed() -> void;
auto resolutionScaleChanged() -> void;
auto frameBufferChannelChanged() -> void;
auto invertChanged() -> void;
auto mipmapChanged() -> void;
auto formatChanged() -> void;
private:
ShaderChannel *m_bufferA = nullptr;
ShaderChannel *m_bufferB = nullptr;
ShaderChannel *m_bufferC = nullptr;
ShaderChannel *m_bufferD = nullptr;
ShaderChannel *m_channel0 = nullptr;
ShaderChannel *m_channel1 = nullptr;
ShaderChannel *m_channel2 = nullptr;
ShaderChannel *m_channel3 = nullptr;
QString m_source;
Type m_type = Image;
MirrorMode m_mirrorMode = MirrorVertical;
TextureRepeat m_textureRepeat = ClampToEdge;
Format m_format = RGB8A;
qsizetype m_resolutionX = 0;
qsizetype m_resolutionY = 0;
qreal m_resolutionScale = 1.0;
qreal m_speed = 1.0;
qreal m_mouseSpeedBias = 1.0;
qint8 m_frameBufferChannel = -1;
bool m_invert = false;
bool m_mipmap = false;
Q_PROPERTY(ShaderChannel *bufferA READ bufferA WRITE setBufferA NOTIFY bufferAChanged FINAL)
Q_PROPERTY(ShaderChannel *bufferB READ bufferB WRITE setBufferB NOTIFY bufferBChanged FINAL)
Q_PROPERTY(ShaderChannel *bufferC READ bufferC WRITE setBufferC NOTIFY bufferCChanged FINAL)
Q_PROPERTY(ShaderChannel *bufferD READ bufferD WRITE setBufferD NOTIFY bufferDChanged FINAL)
Q_PROPERTY(ShaderChannel *channel0 READ channel0 WRITE setChannel0 NOTIFY channel0Changed FINAL)
Q_PROPERTY(ShaderChannel *channel1 READ channel1 WRITE setChannel1 NOTIFY channel1Changed FINAL)
Q_PROPERTY(ShaderChannel *channel2 READ channel2 WRITE setChannel2 NOTIFY channel2Changed FINAL)
Q_PROPERTY(ShaderChannel *channel3 READ channel3 WRITE setChannel3 NOTIFY channel3Changed FINAL)
Q_PROPERTY(QString source READ source WRITE setSource NOTIFY sourceChanged FINAL)
Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged FINAL)
Q_PROPERTY(MirrorMode mirrorMode READ mirrorMode WRITE setMirrorMode NOTIFY mirrorModeChanged FINAL)
Q_PROPERTY(TextureRepeat textureRepeat READ textureRepeat WRITE setTextureRepeat NOTIFY textureRepeatChanged FINAL)
Q_PROPERTY(qsizetype resolutionX READ resolutionX WRITE setResolutionX NOTIFY resolutionXChanged FINAL)
Q_PROPERTY(qsizetype resolutionY READ resolutionY WRITE setResolutionY NOTIFY resolutionYChanged FINAL)
Q_PROPERTY(qreal resolutionScale READ resolutionScale WRITE setResolutionScale NOTIFY resolutionScaleChanged FINAL)
Q_PROPERTY(qreal speed READ speed WRITE setSpeed NOTIFY speedChanged FINAL)
Q_PROPERTY(qreal mouseSpeedBias READ mouseSpeedBias WRITE setMouseSpeedBias NOTIFY mouseSpeedBiasChanged FINAL)
Q_PROPERTY(qint8 frameBufferChannel READ frameBufferChannel WRITE setFrameBufferChannel NOTIFY frameBufferChannelChanged FINAL)
Q_PROPERTY(bool invert READ invert WRITE setInvert NOTIFY invertChanged FINAL)
Q_PROPERTY(bool mipmap READ mipmap WRITE setMipmap NOTIFY mipmapChanged FINAL)
Q_PROPERTY(Format format READ format WRITE setFormat NOTIFY formatChanged FINAL)
};
Q_DECLARE_METATYPE(ShaderChannel)
class KOMPLEX_EXPORT ShaderPack : public ShaderChannel
{
Q_OBJECT
QML_ELEMENT
QString m_author;
QString m_description;
QString m_engine;
QString m_file;
QString m_id;
QString m_license;
QString m_name;
QString m_version;
Q_PROPERTY(QString author READ author WRITE setAuthor NOTIFY authorChanged)
Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged)
Q_PROPERTY(QString engine READ engine WRITE setEngine NOTIFY engineChanged)
Q_PROPERTY(QString file READ file WRITE setFile NOTIFY fileChanged)
Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
Q_PROPERTY(QString license READ license WRITE setLicense NOTIFY licenseChanged)
Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
Q_PROPERTY(QString version READ version WRITE setVersion NOTIFY versionChanged)
Q_SIGNALS:
void authorChanged();
void descriptionChanged();
void engineChanged();
void idChanged();
void licenseChanged();
void nameChanged();
void versionChanged();
void fileChanged();
public:
QString author() const { return m_author; }
void setAuthor(const QString& author)
{
if(author != m_author)
{
m_author = author;
Q_EMIT authorChanged();
}
}
QString description() const { return m_description; }
void setDescription(const QString& description)
{
if(description != m_description)
{
m_description = description;
Q_EMIT descriptionChanged();
}
}
QString engine() const { return m_engine; }
void setEngine(const QString& engine)
{
if(engine != m_engine)
{
m_engine = engine;
Q_EMIT engineChanged();
}
}
QString file() const { return m_file; }
void setFile(const QString& file)
{
if(file != m_file)
{
m_file = file;
Q_EMIT fileChanged();
}
}
QString id() const { return m_id; }
void setId(const QString& id)
{
if(id != m_id)
{
m_id = id;
Q_EMIT idChanged();
}
}
QString license() const { return m_license; }
void setLicense(const QString& license)
{
if(license != m_license)
{
m_license = license;
Q_EMIT licenseChanged();
}
}
QString name() const { return m_name; }
void setName(const QString& name)
{
if(name != m_name)
{
m_name = name;
Q_EMIT nameChanged();
}
}
QString version() const { return m_version; }
void setVersion(const QString& version)
{
if(version != m_version)
{
m_version = version;
Q_EMIT versionChanged();
}
}
auto json() -> QJsonDocument
{
QJsonObject rootObject;
rootObject[QStringLiteral("author")] = author();
rootObject[QStringLiteral("version")] = version();
rootObject[QStringLiteral("name")] = name();
rootObject[QStringLiteral("id")] = id();
rootObject[QStringLiteral("engine")] = engine();
rootObject[QStringLiteral("license")] = license();
QJsonObject bufferObject = bufferJson(this);
const QStringList bufferKeys = bufferObject.keys();
for(const QString &key : bufferKeys)
{
rootObject[key] = bufferObject[key];
}
QJsonObject channelObject = channelJson(this);
const QStringList channelKeys = channelObject.keys();
for(const QString &key : channelKeys)
{
rootObject[key] = channelObject[key];
}
return QJsonDocument
{
rootObject
};
}
private:
auto bufferJson(ShaderChannel *channel) -> QJsonObject
{
QJsonObject channelObject;
if(channel->bufferA())
{
channelObject[QStringLiteral("bufferA")] = channelJson(channel->bufferA());
}
if(channel->bufferB())
{
channelObject[QStringLiteral("bufferB")] = channelJson(channel->bufferB());
}
if(channel->bufferC())
{
channelObject[QStringLiteral("bufferC")] = channelJson(channel->bufferC());
}
if(channel->bufferD())
{
channelObject[QStringLiteral("bufferD")] = channelJson(channel->bufferD());
}
return channelObject;
}
auto channelJson(ShaderChannel *channel) -> QJsonObject
{
if(channel == nullptr)
{
return {};
}
QJsonObject channelObject;
if(channel->channel0() != nullptr)
{
channelObject[QStringLiteral("channel0")] = channelJson(channel->channel0());
}
if(channel->channel1() != nullptr)
{
channelObject[QStringLiteral("channel1")] = channelJson(channel->channel1());
}
if(channel->channel2() != nullptr)
{
channelObject[QStringLiteral("channel2")] = channelJson(channel->channel2());
}
if(channel->channel3() != nullptr)
{
channelObject[QStringLiteral("channel3")] = channelJson(channel->channel3());
}
channelObject[QStringLiteral("source")] = channel->source();
channelObject[QStringLiteral("type")] = channel->type();
channelObject[QStringLiteral("texture_mirroring")] = channel->mirrorMode();
channelObject[QStringLiteral("wrap_mode")] = channel->textureRepeat();
channelObject[QStringLiteral("invert")] = channel->invert();
channelObject[QStringLiteral("time_scale")] = channel->speed();
channelObject[QStringLiteral("resolution_scale")] = channel->resolutionScale();
channelObject[QStringLiteral("mouse_scale")] = channel->mouseSpeedBias();
channelObject[QStringLiteral("resolution_x")] = channel->resolutionX();
channelObject[QStringLiteral("resolution_y")] = channel->resolutionY();
channelObject[QStringLiteral("frame_buffer_channel")] = channel->frameBufferChannel();
channelObject[QStringLiteral("format")] = channel->format();
channelObject[QStringLiteral("mipmap")] = channel->mipmap();
return channelObject;
}
};
Q_DECLARE_METATYPE(ShaderPack)
#endif
+108
View File
@@ -0,0 +1,108 @@
#ifndef SHADERTOYMETADATA_H
#define SHADERTOYMETADATA_H
#include <QObject>
#include <QDateTime>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QStandardPaths>
#include <QUuid>
#include <QProcess>
#include <QTimer>
#include <QMutex>
#include <QDir>
#include <QEventLoop>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonObject>
#include <QJsonArray>
#include <QJsonValue>
#include <QNetworkAccessManager>
#include <QPixmap>
#include <qqmlintegration.h>
#include "komplex_global.h"
struct KOMPLEX_EXPORT ShaderToyMetadata
{
QDateTime date;
QString description;
quint64 flags = 0;
bool hasLiked = false;
QString id;
quint64 likes = 0;
QString name;
quint64 published = 0;
QStringList tags;
bool usePreview = false;
QString username;
QString version;
quint64 views = 0;
};
struct KOMPLEX_EXPORT ShaderToyRenderInput
{
quint8 channel = 0;
QString ctype;
QString filter;
quint64 id = 0;
QString internal;
bool published = false;
QString source;
bool srgb = false;
bool verticalFlip = false;
QString wrap;
};
struct KOMPLEX_EXPORT ShaderToyRenderOutput
{
const quint8 channel = 0;
const quint64 id = 0;
};
struct KOMPLEX_EXPORT ShaderToyRenderPass
{
QByteArray code;
QString description;
QList<ShaderToyRenderInput> inputs;
QString name;
QList<ShaderToyRenderOutput> outputs;
QString type;
};
enum KOMPLEX_EXPORT ShaderToyErrorCode
{
NoError = 0,
NetworkError = (0x10 << 24),
MediaError = (0x20 << 24),
DiskError = (0x30 << 24),
CompileError = (0x40 << 24)
};
struct KOMPLEX_EXPORT ShaderToyError
{
QString message;
ShaderToyErrorCode code;
};
struct KOMPLEX_EXPORT ShaderToyEntry
{
enum Status
{
Idle,
Loading,
Compiling,
Compiled,
Error
};
ShaderToyMetadata metadata;
QList<ShaderToyRenderPass> renderPasses;
QByteArray data;
ShaderToyError error;
QStringList videoSelections;
Status status = Idle;
};
Q_DECLARE_METATYPE(ShaderToyEntry)
Q_DECLARE_METATYPE(ShaderToyError)
#endif // SHADERTOYMETADATA_H
+186 -44
View File
@@ -23,6 +23,7 @@
#include <QList>
#include <QMutex>
#include <QMutexLocker>
#include <QThread>
#include <functional>
#include "fetchresult.h"
@@ -40,6 +41,9 @@ class KOMPLEX_EXPORT SlidingCacheNotifier : public QObject
Q_OBJECT
signals:
auto countChanged() -> void;
auto fetching() -> void;
auto fetchComplete() -> void;
auto windowSizeChanged() -> void;
};
/**
@@ -50,6 +54,12 @@ signals:
template <typename T>
class KOMPLEX_EXPORT SlidingCacheController : public SlidingCacheNotifier
{
/**
* @brief FetchFunction
* Convenience def used by setFetch
*/
typedef std::function<FetchResult<T> (qsizetype offset, qsizetype limit)> FetchFunction;
public:
explicit SlidingCacheController() : SlidingCacheNotifier{}
@@ -70,9 +80,7 @@ public:
* QObject
* @param fetch
*/
auto setFetch(
const std::function<FetchResult<T> (qsizetype offset, qsizetype limit)> &fetch
) -> void
auto setFetch(const FetchFunction &fetch) -> void
{
m_fetch = std::move(fetch);
}
@@ -85,28 +93,28 @@ public:
* @return CacheObject* or nullptr
*/
[[nodiscard]]
auto at(qsizetype index) const -> T
auto at(qsizetype index) const -> const T&
{
QMutexLocker cacheLocker(&m_cacheMutex);
if(!externalBoundaryCheck(index))
{
return {};
return defaultValue;
}
if(!slideWindow(index))
if(!const_cast<SlidingCacheController*>(this)->slideWindow(index))
{
return {};
return defaultValue;
}
qsizetype internalIndex = this->internalIndex(index);
if(!internalBoundaryCheck(index))
if(!internalBoundaryCheck(internalIndex))
{
return {};
return defaultValue;
}
return m_cache.at(index);
return m_cache.at(internalIndex);
}
/**
@@ -127,36 +135,24 @@ public:
return {};
}
if(!slideWindow(index))
if(!const_cast<SlidingCacheController*>(this)->slideWindow(index))
{
return {};
}
qsizetype internalIndex = this->internalIndex(index);
if(!internalBoundaryCheck(index))
if(!internalBoundaryCheck(internalIndex))
{
return {};
}
if(!internalBoundaryCheck(count - 1))
{
count = m_cache.count() - index;
count = m_cache.count() - internalIndex;
}
QList<T> dataChunk;
for(qsizetype i = index; i < count; ++i)
{
T data = at(i);
if(data != T{})
{
dataChunk.append(data);
}
}
return dataChunk;
return m_cache.mid(internalIndex, count);
}
/**
@@ -167,7 +163,7 @@ public:
[[nodiscard]]
auto totalCount() const -> qsizetype
{
if(m_totalCount == std::numeric_limits<qsizetype>::infinity())
if(m_totalCount == nullsize)
{
return 0;
}
@@ -184,7 +180,6 @@ public:
QMutexLocker cacheLocker(&m_cacheMutex);
m_cache.clear();
setTotalCount(std::numeric_limits<qsizetype>::infinity());
}
/**
@@ -196,10 +191,54 @@ public:
QMutexLocker cacheLocker(&m_cacheMutex);
m_cache.clear();
setTotalCount(std::numeric_limits<qsizetype>::infinity());
setTotalCount(nullsize);
m_windowOffset = 0;
}
auto focus(qsizetype index, qsizetype count) -> void
{
if(inFocus(index, count) || !externalBoundaryCheck(index))
{
return;
}
if(externalBoundaryCheck(index + count))
{
slideWindow(index);
}
}
auto init() -> bool
{
if(m_totalCount != nullsize)
{
return false;
}
return slideForward();
}
auto windowSize() const -> qsizetype
{
if(m_windowSize == nullsize)
{
return SLIDING_CACHE_WINDOW_SIZE;
}
return m_windowSize;
}
auto setWindowSize(qsizetype windowSize) -> void
{
if(windowSize == m_windowSize)
{
return;
}
m_windowSize = windowSize;
Q_EMIT windowSizeChanged();
}
protected:
/**
* @brief setTotalCount
@@ -216,6 +255,16 @@ protected:
}
private:
auto inFocus(qsizetype index, qsizetype count) -> bool
{
qsizetype internalIndex = this->internalIndex(index);
return
(
internalBoundaryCheck(internalIndex, internalIndex + count)
);
}
/**
* @brief externalBoundaryCheck
*
@@ -225,12 +274,29 @@ private:
* @return True if index is within the external dataset boundary
* OR an initial fetch has not been performed.
*/
auto externalBoundaryCheck(qsizetype index) -> bool
template<typename... Ts>
auto externalBoundaryCheck(Ts... index) const -> bool
{
return (
index > 0 &&
static_assert
(
(std::is_same_v<Ts, qsizetype> && ...),
"All arguments must be qsizetype"
);
bool safe = false;
((safe = externalBoundaryCheckHelper(index)),...);
return safe;
}
auto externalBoundaryCheckHelper(qsizetype index) const -> bool
{
return
(
index >= 0 &&
(
m_totalCount == std::numeric_limits<qsizetype>::infinity() ||
m_totalCount == nullsize ||
index < m_totalCount
)
);
@@ -243,12 +309,18 @@ private:
* @param index
* @return True if index is within the internal dataset boundary
*/
auto internalBoundaryCheck(qsizetype index) -> bool
template<typename... Ts>
auto internalBoundaryCheck(Ts... index) const -> bool
{
return (
index > 0 &&
index < m_cache.count()
static_assert
(
(std::is_same_v<Ts, qsizetype> && ...),
"All arguments must be qsizetype"
);
bool safe = false;
((safe = ((index >= 0) && (index < m_cache.count()))), ...);
return safe;
}
/**
@@ -273,7 +345,7 @@ private:
}
}
while (index <= m_windowOffset - (SLIDING_CACHE_WINDOW_SIZE - SLIDING_CACHE_PREFETCH_THRESHOLD))
while (index < m_windowOffset)
{
if(!slideBackward())
{
@@ -292,20 +364,50 @@ private:
auto slideForward() -> bool
{
LOG_ERROR_X(!m_fetch,
"SlidingCacheController::slideBackward",
"SlidingCacheController::slideForward",
"Fetch function not set",
false
);
Q_EMIT fetching();
qsizetype movementSize = SLIDING_CACHE_WINDOW_SIZE;
qsizetype prefetchThreshold = SLIDING_CACHE_PREFETCH_THRESHOLD;
if(m_windowSize != nullsize)
{
movementSize = m_windowSize;
if(prefetchThreshold >= m_windowSize)
{
prefetchThreshold = std::floor(
static_cast<qreal>(movementSize) * 0.8
);
}
}
LOG_ERROR_X(movementSize <= 0 || prefetchThreshold <= 0,
"SlidingCacheController::slideForward",
"Invalid movement size",
false
);
//after initial inflation we should only arrive here when the prefetch threshold is reached
if(!m_cache.isEmpty())
{
movementSize -= SLIDING_CACHE_PREFETCH_THRESHOLD;
movementSize -= prefetchThreshold;
}
m_windowOffset += movementSize;
if(m_totalCount != nullsize)
{
m_windowOffset += movementSize;
}
else
{
m_windowOffset = 0;
}
QThread::sleep(KOMPLEX_RATE_LIMIT);
FetchResult<T> result = m_fetch(
m_windowOffset,
@@ -323,6 +425,8 @@ private:
if(result.data.isEmpty())
{
m_windowOffset -= movementSize;
Q_EMIT fetchComplete();
return false;
}
@@ -345,6 +449,8 @@ private:
m_cache.append(std::move(result.data));
}
Q_EMIT fetchComplete();
return true;
}
@@ -361,7 +467,31 @@ private:
false
);
qsizetype movementSize = SLIDING_CACHE_WINDOW_SIZE - SLIDING_CACHE_PREFETCH_THRESHOLD;
Q_EMIT fetching();
qsizetype movementSize = SLIDING_CACHE_WINDOW_SIZE;
qsizetype prefetchThreshold = SLIDING_CACHE_PREFETCH_THRESHOLD;
if(m_windowSize != nullsize)
{
movementSize = m_windowSize;
if(prefetchThreshold >= m_windowSize)
{
prefetchThreshold = std::floor(
static_cast<qreal>(movementSize) * 0.8
);
}
}
LOG_ERROR_X(movementSize <= 0 || prefetchThreshold <= 0,
"SlidingCacheController::slideBackward",
"Invalid movement size",
false
);
QThread::sleep(KOMPLEX_RATE_LIMIT);
m_windowOffset -= movementSize;
if(m_windowOffset < 0)
@@ -377,6 +507,8 @@ private:
if(result.count == 0)
{
m_windowOffset += movementSize;
Q_EMIT fetchComplete();
return false;
}
@@ -405,6 +537,8 @@ private:
}
}
Q_EMIT fetchComplete();
return true;
}
@@ -414,7 +548,7 @@ private:
* @param index Global object index
* @return
*/
auto internalIndex(qsizetype index) -> qsizetype
auto internalIndex(qsizetype index) const -> qsizetype
{
return index - m_windowOffset;
}
@@ -430,7 +564,7 @@ private:
* Total number of results available. Data comes from the return data of
* m_fetch
*/
qsizetype m_totalCount = std::numeric_limits<qsizetype>::infinity();
qsizetype m_totalCount = nullsize;
/**
* @brief m_fetch
@@ -449,6 +583,14 @@ private:
* @brief m_cacheMutex
*/
mutable QMutex m_cacheMutex;
/**
* @brief m_windowSize
* Override for window size
*/
qsizetype m_windowSize = SLIDING_CACHE_WINDOW_SIZE;
T defaultValue;
};
#endif // SLIDINGCACHECONTROLLER_H
+77
View File
@@ -0,0 +1,77 @@
#ifndef VIDEOCACHE_H
#define VIDEOCACHE_H
#include "komplex_global.h"
#include <QObject>
struct KOMPLEX_EXPORT VideoEntry
{
QString type;
qint64 fps = std::numeric_limits<qint64>::infinity();
qint64 height = std::numeric_limits<qint64>::infinity();
qint64 width = std::numeric_limits<qint64>::infinity();
qint64 size = std::numeric_limits<qint64>::infinity();
qint64 id = std::numeric_limits<qint64>::infinity();
QString url;
QString quality;
auto operator == (const VideoEntry &other) const -> bool
{
return (
other.fps == fps &&
other.height == height &&
other.id == id &&
other.quality == quality &&
other.size == size &&
other.type == type &&
other.url == url &&
other.width == width
);
}
auto operator != (const VideoEntry &other) const -> bool
{
return !(other == *this);
}
};
Q_DECLARE_METATYPE(VideoEntry)
struct KOMPLEX_EXPORT VideoCache
{
QString averageColor;
qint64 duration = std::numeric_limits<qint64>::infinity();
qint64 height = std::numeric_limits<qint64>::infinity();
qint64 width = std::numeric_limits<qint64>::infinity();
qint64 id = std::numeric_limits<qint64>::infinity();
QString thumbnail;
QString url;
QString author;
QString authorUrl;
qint64 authorId;
QList<VideoEntry> files;
auto operator == (const VideoCache &other) const -> bool
{
return (
other.averageColor == averageColor &&
other.duration == duration &&
other.height == height &&
other.width == width &&
other.id == id &&
other.thumbnail == thumbnail &&
other.url == url &&
other.author == author &&
other.authorUrl == authorUrl &&
other.authorId == authorId &&
other.files == files
);
}
auto operator != (const VideoCache &other) const -> bool
{
return !(other == *this);
}
};
#endif // VIDEOCACHE_H
+2 -2
View File
@@ -39,7 +39,7 @@ Q_DECLARE_METATYPE(WallpaperInstallData)
struct KOMPLEX_EXPORT WallpaperCache
{
QString uri;
QString uuid;
QString name;
QString author;
QString authorId;
@@ -54,7 +54,7 @@ struct KOMPLEX_EXPORT WallpaperCache
auto operator == (const WallpaperCache &other) const -> bool
{
return (
other.uri == uri &&
other.uuid == uuid &&
other.name == name &&
other.author == author &&
other.authorId == authorId &&
+736
View File
@@ -0,0 +1,736 @@
#include "downloadmanager.h"
#include "common/coreservices.h"
#include "common/exceptions.h"
#include "common/shaderpack.h"
DownloadManager::DownloadManager(QObject *parent)
: QObject{parent}
{
m_compiler = new PackCompiler(this);
QObject::connect
(
m_compiler,
&PackCompiler::progressChanged,
this,
&DownloadManager::compileProgressChanged
);
QObject::connect
(
m_compiler,
&PackCompiler::currentStepChanged,
this,
&DownloadManager::compileStepsCompletedChanged
);
QObject::connect
(
m_compiler,
&PackCompiler::totalStepsChanged,
this,
&DownloadManager::compileStepsChanged
);
}
/**
* [1] Download image from endpoint
* [2] Apply generic single-media template, with an image source
* [3] Optionally ask user if they would like to apply manipulative shader
* [4] Install locally
*/
auto DownloadManager::downloadImage(const QString &author, const QString &authorId, const QString &description, const QUrl &url) noexcept(false) -> void
{
QFuture future = QtConcurrent::run
(
[this, url, author, authorId, description]()
{
QNetworkRequest request(url);
QString id = QUuid::createUuidV7().toString(QUuid::WithoutBraces);
QFuture<QUrl> downloadUri = download(request, id);
downloadUri
.then
(
[this, author, description, id](QUrl result) -> QUrl
{
ShaderPack metadata;
metadata.setAuthor(author);
metadata.setDescription(description);
metadata.setName(QStringLiteral("Pexels Image (%1)").arg(id));
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();
}
);
}
);
}
auto DownloadManager::downloadVideo(const QString &author, const QString &authorId, const QString &description, const QUrl &url) noexcept(false) -> void
{
QFuture future = QtConcurrent::run
(
[this, url, author, authorId, description]()
{
QNetworkRequest request(url);
QString id = QUuid::createUuidV7().toString(QUuid::WithoutBraces);
QFuture<QUrl> downloadUri = download(request, id);
downloadUri
.then
(
[this, author, description, id](QUrl result) -> QUrl
{
ShaderPack metadata;
metadata.setAuthor(author);
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();
}
);
}
);
}
auto DownloadManager::downloadPack(const QString &id) noexcept(false) -> void
{
QFuture aether = QtConcurrent::run
(
[this, id]()
{
QUrl downloadUrl = QUrl
(
QStringLiteral("%1/%2/%3").arg
(
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)
{
install(result);
}
)
.onFailed
(
[this]()
{
reset();
setError(m_compiler->errorTitle(), m_compiler->errorMessage());
}
)
.onCanceled
(
[this]()
{
reset();
}
);
}
);
}
auto DownloadManager::reset() -> void
{
setError(QString(), QString());
setState(Idle);
}
auto DownloadManager::compileProgress() -> qreal
{
if(m_compiler == nullptr)
{
return 0;
}
return m_compiler->progress();
}
auto DownloadManager::compileSteps() -> qint64
{
if(m_compiler == nullptr)
{
return 0;
}
return m_compiler->totalSteps();
}
auto DownloadManager::compileStepsCompleted() -> qint64
{
if(nullptr == m_compiler)
{
return 0;
}
return m_compiler->currentStep();
}
auto DownloadManager::setError(const QString &title, const QString &message) -> void
{
if(title == m_errorTitle && message == m_errorMessage)
{
return;
}
m_errorMessage = std::move(message);
m_errorTitle = std::move(title);
Q_EMIT errorChanged();
}
void DownloadManager::setCompilerOutput(const QString &compilerOutput)
{
if (m_compilerOutput == compilerOutput)
{
return;
}
m_compilerOutput = compilerOutput;
emit compilerOutputChanged();
}
auto DownloadManager::setState(State state) -> void
{
if(state == m_state)
{
return;
}
m_state = state;
Q_EMIT stateChanged();
return;
}
auto DownloadManager::setDownloadProgress(qreal progress) -> void
{
if(qFuzzyCompare(progress, m_downloadProgress))
{
return;
}
m_downloadProgress = progress;
Q_EMIT downloadProgressChanged();
}
auto DownloadManager::install(const QUrl &uri) noexcept(false) -> QUrl
{
if(!uri.isLocalFile())
{
throw FileException(QStringLiteral("URI is not a local file"));
}
QDir tempDirectory(uri.toLocalFile());
QString installLocation = QStringLiteral("%1/.local/share/komplex/packs/%2").arg
(
QStandardPaths::writableLocation(QStandardPaths::HomeLocation),
tempDirectory.dirName()
);
QDir installDirectory(installLocation);
if(installDirectory.exists())
installDirectory.removeRecursively();
QProcess process;
QObject::connect
(
&process,
&QProcess::readyReadStandardOutput,
this,
[this, &process]()
{
QByteArray processData = process.readAllStandardOutput();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
setCompilerOutput(m_compilerOutput + processData);
}
);
QObject::connect
(
&process,
&QProcess::readyReadStandardError,
this,
[this, &process]()
{
QByteArray processData = process.readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
setCompilerOutput(m_compilerOutput + processData);
}
);
QStringList arguments = QStringList
{
QStringLiteral("-R"),
uri.toLocalFile(),
installLocation
};
process.start(QStringLiteral("cp"), arguments);
if(!process.waitForStarted(3000))
{
qWarning() << QStringLiteral("Could not start copy process: %1").arg(process.readAllStandardError());
throw FileException(QStringLiteral("Could not start install process"));
}
if(!process.waitForFinished())
{
qWarning() << QStringLiteral("Copy process took longer than expected (>30s)");
throw FileException(QStringLiteral("Install process took longer than expected (>30s)"));
}
QUrl installUri(installLocation);
installUri.setScheme(QStringLiteral("file://"));
return installUri;
}
auto DownloadManager::download(const QNetworkRequest &request, const QString &id, RequestType type) -> QFuture<QUrl>
{
return QtConcurrent::run
(
[this, request, id]() -> QUrl
{
QEventLoop loop;
QString filename = id;
if(filename.isEmpty())
{
filename = QUuid::createUuidV7().toString();
}
QUrl downloadUri = QStringLiteral("%1/%2").arg
(
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
filename
);
auto manager = CoreServices::networkAccessManager().toStrongRef();
if(manager == nullptr)
{
throw NetworkException
{
QStringLiteral("Network Manager reference has already been deleted")
};
}
QFile downloadFile(downloadUri.toLocalFile());
if(!downloadFile.open(QFile::ReadWrite))
{
throw FileException(QStringLiteral("Could not open temp file location"));
}
QNetworkReply *reply = manager->post(request, nullptr);
QObject::connect
(
reply,
&QNetworkReply::finished,
&loop,
&QEventLoop::quit
);
QObject::connect
(
reply,
&QNetworkReply::errorOccurred,
&loop,
[&loop](QNetworkReply::NetworkError error) -> void
{
loop.quit();
throw NetworkException
(
QStringLiteral("Network Error %1").arg
(
QString::number(static_cast<qint64>(error))
)
);
}
);
QObject::connect
(
reply,
&QNetworkReply::downloadProgress,
this,
[this](qint64 bytesDownloaded, qint64 bytesTotal)
{
setDownloadSize(bytesTotal);
setDownloadedBytes(bytesDownloaded);
setDownloadProgress(static_cast<qreal>(bytesDownloaded) / bytesTotal);
}
);
QObject::connect
(
reply,
&QNetworkReply::readyRead,
this,
[this, &downloadFile, &reply]()
{
if(!downloadFile.isOpen())
{
return;
}
quint64 bytes = reply->bytesAvailable();
quint64 bytesWritten = downloadFile.write(reply->read(bytes));
if(bytesWritten != bytes)
{
throw FileException(QStringLiteral("Could not write temp file data"));
}
}
);
if(!reply->isFinished())
{
loop.exec();
}
if(reply->bytesAvailable() > 0)
{
quint64 bytes = reply->bytesAvailable();
quint64 bytesWritten = downloadFile.write(reply->read(bytes));
if(bytesWritten != bytes)
{
throw FileException(QStringLiteral("Could not write temp file data"));
}
}
downloadFile.close();
manager.clear();
return downloadUri;
}
);
}
auto DownloadManager::readShaderToyEntry(const QUrl &uri) noexcept(false) -> ShaderToyEntry
{
if(!uri.isLocalFile())
{
throw FileException(QStringLiteral("URI is not a local file"));
}
QDir packDir(uri.toLocalFile());
if(!packDir.exists(QStringLiteral("pack.json")))
{
throw FileException(QStringLiteral("Pack file not found"));
}
QFile packFile(packDir.absoluteFilePath(QStringLiteral("pack.json")));
if(!packFile.open(QFile::ReadOnly))
{
throw FileException
(
QStringLiteral("Could not open pack file: %1").arg
(
packFile.errorString()
)
);
}
QByteArray data = packFile.readAll();
QJsonParseError jsonError;
QJsonDocument document = QJsonDocument::fromJson(data, &jsonError);
if(jsonError.error != QJsonParseError::NoError)
{
throw FileException
(
QStringLiteral("Could parse pack file: %1").arg
(
jsonError.errorString()
)
);
}
QJsonObject documentObject = document.object();
QJsonObject rootObject = documentObject[QStringLiteral("Shader")].toObject();
QJsonObject infoObject = rootObject[QStringLiteral("info")].toObject();
QJsonArray tagsArray = infoObject[QStringLiteral("tags")].toArray();
QStringList tags;
for(const QJsonValue &tag : std::as_const(tagsArray))
tags += tag.toString();
ShaderToyEntry entry;
entry.metadata = ShaderToyMetadata
{
QDateTime::fromSecsSinceEpoch(infoObject[QStringLiteral("date")].toInt()),
infoObject[QStringLiteral("description")].toString(),
static_cast<quint64>(infoObject[QStringLiteral("flags")].toInt()),
static_cast<bool>(infoObject[QStringLiteral("hasLiked")].toInt()),
infoObject[QStringLiteral("id")].toString(),
static_cast<quint64>(infoObject[QStringLiteral("likes")].toInt()),
infoObject[QStringLiteral("name")].toString(),
static_cast<quint64>(infoObject[QStringLiteral("published")].toInt()),
tags,
static_cast<bool>(infoObject[QStringLiteral("usePreview")].toInt()),
infoObject[QStringLiteral("username")].toString(),
rootObject[QStringLiteral("ver")].toString(),
static_cast<quint64>(infoObject[QStringLiteral("views")].toInt())
};
QJsonArray ShaderToyRenderPassArray = rootObject[QStringLiteral("renderpass")].toArray();
for(const QJsonValue &ShaderToyRenderPassValue : std::as_const(ShaderToyRenderPassArray))
{
QJsonArray inputArray = ShaderToyRenderPassValue[QStringLiteral("inputs")].toArray();
QJsonArray outputArray = ShaderToyRenderPassValue[QStringLiteral("outputs")].toArray();
QList<ShaderToyRenderInput> inputs;
QList<ShaderToyRenderOutput> outputs;
for(const QJsonValue &inputValue : std::as_const(inputArray))
{
QJsonObject samplerObject = inputValue[QStringLiteral("sampler")].toObject();
inputs.append
(
ShaderToyRenderInput
{
static_cast<quint8>(inputValue[QStringLiteral("channel")].toInt()),
inputValue[QStringLiteral("ctype")].toString(),
samplerObject[QStringLiteral("filter")].toString(),
static_cast<quint64>(inputValue[QStringLiteral("id")].toInt()),
samplerObject[QStringLiteral("internal")].toString(),
static_cast<bool>(inputValue[QStringLiteral("published")].toInt()),
inputValue[QStringLiteral("src")].toString(),
samplerObject[QStringLiteral("srgb")].toBool(),
samplerObject[QStringLiteral("verticalFlip")].toBool(),
samplerObject[QStringLiteral("wrap")].toString()
}
);
}
for(const QJsonValue &outputValue : std::as_const(outputArray))
{
outputs.append
(
ShaderToyRenderOutput
{
static_cast<quint8>(outputValue[QStringLiteral("channel")].toInt()),
static_cast<quint64>(outputValue[QStringLiteral("id")].toInt())
}
);
}
entry.renderPasses.append
(
ShaderToyRenderPass
{
ShaderToyRenderPassValue[QStringLiteral("code")].toVariant().toByteArray(),
ShaderToyRenderPassValue[QStringLiteral("description")].toString(),
inputs,
ShaderToyRenderPassValue[QStringLiteral("name")].toString(),
outputs,
ShaderToyRenderPassValue[QStringLiteral("type")].toString()
}
);
}
return std::move(entry);
}
auto DownloadManager::setDownloadedBytes(qint64 downloadedBytes) -> void
{
if (m_downloadedBytes == downloadedBytes)
return;
m_downloadedBytes = downloadedBytes;
emit downloadedBytesChanged();
}
auto DownloadManager::setDownloadSize(qint64 downloadSize) -> void
{
if (m_downloadSize == downloadSize)
return;
m_downloadSize = downloadSize;
emit downloadSizeChanged();
}
+154
View File
@@ -0,0 +1,154 @@
#ifndef DOWNLOADMANAGER_H
#define DOWNLOADMANAGER_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QFileInfo>
#include <QUuid>
#include <QQmlEngine>
#include <QProcess>
#include <QDir>
#include <QStandardPaths>
#include <QUuid>
#include <QtConcurrent/QtConcurrentRun>
#include "common/komplex_global.h"
#include "common/shadertoymetadata.h"
#include "common/shaderpack.h"
#include "packcompiler.h"
class KOMPLEX_EXPORT DownloadManager : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
enum State
{
Idle,
Downloading,
Compiling,
Installing,
Complete,
Error
};
Q_ENUM(State)
enum RequestType
{
Get,
Post
};
explicit DownloadManager(QObject *parent = nullptr);
/**
* @brief downloadImage
* Downloads the image to tmp from the given url and generates a pack
* out of it
* @param url
*/
auto downloadImage
(
const QString &author,
const QString &authorId,
const QString &description,
const QUrl &url
) noexcept(false) -> void;
/**
* @brief downloadVideo
* Downloads the video to tmp from the given url and generates a pack
* out of it
* @param author
* @param authorId
* @param description
* @param url
*/
auto downloadVideo
(
const QString &author,
const QString &authorId,
const QString &description,
const QUrl &url
) noexcept(false) -> void;
/**
* @brief downloadPack
* Attempts to download, compile and install the wallpaper
* pack from the komplex endpoint.
* @param id
* @return File info of the installed pack
*/
auto downloadPack(const QString &id) noexcept(false) -> void;
auto compilerOutput() const -> const QString & { return m_compilerOutput; }
auto errorTitle() const -> const QString & { return m_errorTitle; }
auto errorMessage() const -> const QString & { return m_errorMessage; }
auto state() const -> State { return m_state; }
auto reset() -> void;
auto downloadProgress() -> qreal { return m_downloadProgress; }
auto compileProgress() -> qreal;
auto compileSteps() -> qint64;
auto compileStepsCompleted() -> qint64;
auto downloadSize() const -> qint64 { return m_downloadSize; }
auto setDownloadSize(qint64 downloadSize) -> void;
auto downloadedBytes() const -> qint64 { return m_downloadedBytes; }
auto setDownloadedBytes(qint64 downloadedBytes) -> void;
protected:
auto setError(const QString &title, const QString &message) -> void;
auto setCompilerOutput(const QString &compilerOutput) -> void;
auto setState(State state) -> void;
auto setDownloadProgress(qreal progress) -> void;
signals:
auto compilerOutputChanged() -> void;
auto errorChanged() -> void;
auto stateChanged() -> void;
auto downloadProgressChanged() -> void;
auto compileProgressChanged() -> void;
auto downloadComplete(const QString &uri) -> void;
auto downloadSizeChanged() -> void;
auto downloadedBytesChanged() -> void;
auto compileStepsChanged() -> void;
auto compileStepsCompletedChanged() -> void;
private:
auto compile(const QUrl &uri) noexcept(false) -> QUrl;
auto install(const QUrl &uri) noexcept(false) -> QUrl;
auto download(const QNetworkRequest &request, const QString &id, RequestType type = Get) -> QFuture<QUrl>;
auto readShaderToyEntry(const QUrl &uri) noexcept(false) -> ShaderToyEntry;
QString m_compilerOutput;
QString m_errorTitle;
QString m_errorMessage;
qreal m_downloadProgress = 0;
qint64 m_downloadSize = 0;
qint64 m_downloadedBytes = 0;
qreal m_compileProgress = 0;
State m_state;
QMutex m_downloadMutex;
PackCompiler *m_compiler = nullptr;
Q_PROPERTY(QString compilerOutput READ compilerOutput WRITE setCompilerOutput NOTIFY compilerOutputChanged FINAL)
Q_PROPERTY(QString errorTitle READ errorTitle NOTIFY errorChanged FINAL)
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged FINAL)
Q_PROPERTY(qreal downloadProgress READ downloadProgress NOTIFY downloadProgressChanged FINAL)
Q_PROPERTY(qreal compileProgress READ compileProgress NOTIFY compileProgressChanged FINAL)
Q_PROPERTY(State state READ state NOTIFY stateChanged FINAL)
Q_PROPERTY(qint64 downloadSize READ downloadSize WRITE setDownloadSize NOTIFY downloadSizeChanged FINAL)
Q_PROPERTY(qint64 downloadedBytes READ downloadedBytes WRITE setDownloadedBytes NOTIFY downloadedBytesChanged FINAL)
Q_PROPERTY(qint64 compileSteps READ compileSteps NOTIFY compileStepsChanged FINAL)
Q_PROPERTY(qint64 compileStepsCompleted READ compileStepsCompleted NOTIFY compileStepsCompletedChanged FINAL)
};
Q_DECLARE_METATYPE(DownloadManager)
#endif // DOWNLOADMANAGER_H
+346
View File
@@ -0,0 +1,346 @@
#include "featuredimagesmodel.h"
FeaturedImagesModel::FeaturedImagesModel(QObject *parent) : QAbstractListModel{parent}
{
m_paginator = new FeaturedImagesPaginator(this);
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
QObject::connect(
notifier,
&PaginationNotifier::resultsPerPageChanged,
this,
&FeaturedImagesModel::resultsPerPageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalResultsChanged,
this,
&FeaturedImagesModel::totalResultsChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalPagesChanged,
this,
&FeaturedImagesModel::totalPagesChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&FeaturedImagesModel::pageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&FeaturedImagesModel::resetDataModel
);
QObject::connect(
notifier,
&PaginationNotifier::fetchComplete,
this,
&FeaturedImagesModel::resetState
);
QObject::connect(
notifier,
&PaginationNotifier::fetching,
this,
&FeaturedImagesModel::onPaginatorFetching
);
}
FeaturedImagesModel::~FeaturedImagesModel()
{
if(m_paginator)
{
delete m_paginator;
}
}
auto FeaturedImagesModel::rowCount(const QModelIndex &) const -> int
{
if(m_paginator != nullptr)
{
return m_paginator->count();
}
return 0;
}
auto FeaturedImagesModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(!boundaryCheck(index.row()))
{
return {};
}
ImageCache dataPoint = m_paginator->at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UuidRole:
data = dataPoint.id;
break;
case AuthorRole:
data = dataPoint.photographer;
break;
case AuthorIdRole:
data = dataPoint.photographerId;
break;
case AuthorUrlRole:
data = dataPoint.photographerUrl;
break;
case DescriptionRole:
data = dataPoint.altText;
break;
case ThumbnailRole:
data = dataPoint.sources.value(QString::fromUtf8("thumbnail"));
break;
case LargeThumbnailRole:
data = dataPoint.sources.value(QString::fromUtf8("largeThumbnail"));
break;
case PortraitUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("portrait"));
break;
case PortraitSizeRole:
data = dataPoint.sourceSizes.value(QString::fromUtf8("portrait"));
break;
case ScreenUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("screen"));
break;
case ScreenSizeRole:
data = dataPoint.sourceSizes.value(QString::fromUtf8("screen"));
break;
case OriginalUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("original"));
break;
case LandscapeUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("landscape"));
break;
case LandscapeSizeRole:
data = dataPoint.sourceSizes.value(QString::fromUtf8("landscape"));
break;
case BackgroundPortraitRole:
data = dataPoint.sources.value(QString::fromUtf8("backgroundPortrait"));
case BackgroundLandscapeRole:
data = dataPoint.sources.value(QString::fromUtf8("backgroundLandscape"));
break;
}
return data;
}
auto FeaturedImagesModel::index(int row, int column, const QModelIndex &parent) const -> QModelIndex
{
Q_UNUSED(parent)
if(!boundaryCheck(row))
{
return {};
}
return createIndex(row, column, &m_paginator[row]);
}
auto FeaturedImagesModel::columnCount(const QModelIndex &) const -> int
{
return 0;
}
auto FeaturedImagesModel::parent(const QModelIndex &) const -> QModelIndex
{
return {};
}
auto FeaturedImagesModel::setData(const QModelIndex &, const QVariant &, int) -> bool
{
return false;
}
auto FeaturedImagesModel::state() const -> FeaturedImagesModel::State
{
return m_state;
}
auto FeaturedImagesModel::setState(State state) -> void
{
if (m_state == state)
{
return;
}
m_state = state;
emit stateChanged();
}
auto FeaturedImagesModel::resetState() -> void
{
setState(Idle);
}
auto FeaturedImagesModel::resetDataModel() -> void
{
//invalidate previous model data
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
endRemoveRows();
//signal new data
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
endInsertRows();
}
auto FeaturedImagesModel::onPaginatorFetching() -> void
{
setState(Loading);
}
auto FeaturedImagesModel::boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || m_paginator == nullptr || index >= m_paginator->count())
{
return false;
}
return true;
}
auto FeaturedImagesModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
}
auto FeaturedImagesModel::errorString() const -> QString
{
return m_errorString;
}
auto FeaturedImagesModel::setErrorString(const QString &errorString) -> void
{
if (m_errorString == errorString)
{
return;
}
m_errorString = errorString;
emit errorStringChanged();
}
auto FeaturedImagesModel::resultsPerPage() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->resultsPerPage();
}
return 0;
}
auto FeaturedImagesModel::setResultsPerPage(qsizetype resultsPerPage) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, resultsPerPage]
{
qsizetype difference = resultsPerPage - m_paginator->resultsPerPage();
m_paginator->setResultsPerPage(resultsPerPage);
if(difference > 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage() - difference;
beginInsertRows
(
QModelIndex(),
firstIndex,
m_paginator->count() - 1
);
endInsertRows();
}
else if(difference < 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage();
beginRemoveRows
(
QModelIndex(),
firstIndex,
firstIndex - difference
);
endRemoveRows();
}
}
);
}
}
auto FeaturedImagesModel::totalResults() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalResults();
}
return 0;
}
auto FeaturedImagesModel::nextPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->next();
}
);
}
}
auto FeaturedImagesModel::previousPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->previous();
}
);
}
}
qsizetype FeaturedImagesModel::page() const
{
if(m_paginator != nullptr)
{
return m_paginator->page();
}
return 0;
}
auto FeaturedImagesModel::totalPages() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalPages();
}
return 0;
}
+351
View File
@@ -0,0 +1,351 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef FeaturedImagesModel_H
#define FeaturedImagesModel_H
#include <QObject>
#include <QQmlEngine>
#include <QList>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QAbstractListModel>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "paginators/featuredimagespaginator.h"
/**
* @brief The FeaturedImagesModel class
*/
class KOMPLEX_EXPORT FeaturedImagesModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
Loading,
Error
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UuidRole = Qt::UserRole + 1,
AuthorRole,
AuthorIdRole,
AuthorUrlRole,
DescriptionRole,
ThumbnailRole,
LargeThumbnailRole,
OriginalUrlRole,
ScreenUrlRole,
PortraitUrlRole,
LandscapeUrlRole,
ScreenSizeRole,
PortraitSizeRole,
LandscapeSizeRole,
BackgroundPortraitRole,
BackgroundLandscapeRole
};
Q_ENUM(DataRole)
explicit FeaturedImagesModel(QObject *parent = nullptr);
~FeaturedImagesModel();
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* User-friendly error string to be reported to the user
* @return
*/
auto errorString() const -> QString;
/**
* @brief resultsPerPage
* @return
*/
auto resultsPerPage() const -> qsizetype;
/**
* @brief setResultsPerPage
* @param resultsPerPage
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void;
/**
* @brief totalResults
* Total number of results available
* @return
*/
auto totalResults() const -> qsizetype;
/**
* @brief page
* @return
*/
auto page() const -> qsizetype;
/**
* @brief totalPages
* Total pages based on the current resultsPerPage
* @return
*/
auto totalPages() const -> qsizetype;
/**
* @brief nextPage
* Function for the QML frontend
*/
Q_INVOKABLE auto nextPage() -> void;
/**
* @brief previousPage
* Function for the QML frontend
*/
Q_INVOKABLE auto previousPage() -> void;
protected:
/**
* @brief setErrorString
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
/**
* @brief setState
* @param state
*/
auto setState(State state) -> void;
/**
* @brief resetState
*/
auto resetState() -> void;
/**
* @brief resetDataModel
* Clears the data model and creates a new one if data exists
*/
auto resetDataModel() -> void;
/**
* @brief onPaginatorFetching
* Sets current state to loading. Triggered when paginator's cache controller
* needs to fetch data from the remote endpoint.
*/
auto onPaginatorFetching() -> void;
signals:
auto stateChanged() -> void;
auto errorStringChanged() -> void;
auto resultsPerPageChanged() -> void;
auto pageChanged() -> void;
auto totalResultsChanged() -> void;
auto totalPagesChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* @brief m_dataRoles
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(AuthorRole),
QByteArray("author")
},
{
static_cast<int>(AuthorIdRole),
QByteArray("authorId")
},
{
static_cast<int>(AuthorUrlRole),
QByteArray("authorUrl")
},
{
static_cast<int>(DescriptionRole),
QByteArray("description")
},
{
static_cast<int>(ThumbnailRole),
QByteArray("thumbnail")
},
{
static_cast<int>(LargeThumbnailRole),
QByteArray("largeThumbnail")
},
{
static_cast<int>(OriginalUrlRole),
QByteArray("original")
},
{
static_cast<int>(PortraitUrlRole),
QByteArray("portrait")
},
{
static_cast<int>(LandscapeUrlRole),
QByteArray("landscape")
},
{
static_cast<int>(BackgroundPortraitRole),
QByteArray("backgroundPortrait")
},
{
static_cast<int>(BackgroundLandscapeRole),
QByteArray("backgroundLandscape")
},
{
static_cast<int>(ScreenUrlRole),
QByteArray("fullScreen")
},
{
static_cast<int>(ScreenSizeRole),
QByteArray("fullScreenSize")
},
{
static_cast<int>(PortraitSizeRole),
QByteArray("portraitSize")
},
{
static_cast<int>(LandscapeSizeRole),
QByteArray("landscapeSize")
}
};
State m_state = Idle;
QString m_errorString = QString();
FeaturedImagesPaginator *m_paginator = nullptr;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
Q_PROPERTY(qsizetype resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qsizetype totalResults READ totalResults NOTIFY totalResultsChanged FINAL)
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
};
Q_DECLARE_METATYPE(FeaturedImagesModel)
#endif // FeaturedImagesModel_H
+332
View File
@@ -0,0 +1,332 @@
#include "featuredpacksmodel.h"
#include "common/wallpapercache.h"
FeaturedPacksModel::FeaturedPacksModel(QObject *parent) : QAbstractListModel{parent}
{
m_paginator = new FeaturedPacksPaginator(this);
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
QObject::connect(
notifier,
&PaginationNotifier::resultsPerPageChanged,
this,
&FeaturedPacksModel::resultsPerPageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalResultsChanged,
this,
&FeaturedPacksModel::totalResultsChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalPagesChanged,
this,
&FeaturedPacksModel::totalPagesChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&FeaturedPacksModel::pageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&FeaturedPacksModel::resetDataModel
);
QObject::connect(
notifier,
&PaginationNotifier::fetchComplete,
this,
&FeaturedPacksModel::resetState
);
QObject::connect(
notifier,
&PaginationNotifier::fetching,
this,
&FeaturedPacksModel::onPaginatorFetching
);
}
FeaturedPacksModel::~FeaturedPacksModel()
{
if(m_paginator)
{
delete m_paginator;
}
}
auto FeaturedPacksModel::rowCount(const QModelIndex &) const -> int
{
if(m_paginator != nullptr)
{
return m_paginator->count();
}
return 0;
}
auto FeaturedPacksModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(index.row() < 0 || m_paginator == nullptr || index.row() >= m_paginator->count())
{
return {};
}
WallpaperCache dataPoint = m_paginator->at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UuidRole:
data = dataPoint.uuid;
break;
case AuthorRole:
data = dataPoint.author;
break;
case DescriptionRole:
data = dataPoint.description;
break;
case NameRole:
data = dataPoint.name;
break;
case ThumbnailRole:
data = dataPoint.thumbnail;
break;
case CreatedDateRole:
data = dataPoint.createdDate;
break;
case AuthorIdRole:
data = dataPoint.authorId;
break;
case PriceRole:
data = dataPoint.price;
break;
case CurrencyRole:
data = dataPoint.currency;
break;
case DownloadCountRole:
data = dataPoint.downloadCount;
break;
case TypeRole:
data = dataPoint.type;
break;
}
return data;
}
auto FeaturedPacksModel::index(int row, int column, const QModelIndex &parent) const -> QModelIndex
{
Q_UNUSED(parent)
if(row < 0 || row >= m_paginator->count())
{
return {};
}
return createIndex(row, column, &m_paginator[row]);
}
auto FeaturedPacksModel::columnCount(const QModelIndex &) const -> int
{
return 0;
}
auto FeaturedPacksModel::parent(const QModelIndex &) const -> QModelIndex
{
return {};
}
auto FeaturedPacksModel::setData(const QModelIndex &, const QVariant &, int) -> bool
{
return false;
}
auto FeaturedPacksModel::state() const -> FeaturedPacksModel::State
{
return m_state;
}
auto FeaturedPacksModel::setState(State state) -> void
{
if (m_state == state)
{
return;
}
m_state = state;
Q_EMIT stateChanged();
}
auto FeaturedPacksModel::resetState() -> void
{
setState(Idle);
}
auto FeaturedPacksModel::resetDataModel() -> void
{
//invalidate previous model data
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
endRemoveRows();
//signal new data
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
endInsertRows();
}
auto FeaturedPacksModel::onPaginatorFetching() -> void
{
setState(Loading);
}
auto FeaturedPacksModel::boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || m_paginator == nullptr || index >= m_paginator->count())
{
return false;
}
return true;
}
auto FeaturedPacksModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
}
auto FeaturedPacksModel::errorString() const -> QString
{
return m_errorString;
}
auto FeaturedPacksModel::setErrorString(const QString &errorString) -> void
{
if (m_errorString == errorString)
{
return;
}
m_errorString = errorString;
Q_EMIT errorStringChanged();
}
auto FeaturedPacksModel::resultsPerPage() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->resultsPerPage();
}
return 0;
}
auto FeaturedPacksModel::setResultsPerPage(qsizetype resultsPerPage) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, resultsPerPage]
{
qsizetype difference = resultsPerPage - m_paginator->resultsPerPage();
m_paginator->setResultsPerPage(resultsPerPage);
if(difference > 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage() - difference;
beginInsertRows
(
QModelIndex(),
firstIndex,
m_paginator->count() - 1
);
endInsertRows();
}
else if(difference < 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage();
beginRemoveRows
(
QModelIndex(),
firstIndex,
firstIndex - difference
);
endRemoveRows();
}
}
);
}
}
auto FeaturedPacksModel::totalResults() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalResults();
}
return 0;
}
auto FeaturedPacksModel::nextPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->next();
}
);
}
}
auto FeaturedPacksModel::previousPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->previous();
}
);
}
}
qsizetype FeaturedPacksModel::page() const
{
if(m_paginator != nullptr)
{
return m_paginator->page();
}
return 0;
}
auto FeaturedPacksModel::totalPages() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalPages();
}
return 0;
}
+317
View File
@@ -0,0 +1,317 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef FEATUREDPACKSMODEL_H
#define FEATUREDPACKSMODEL_H
#include <QObject>
#include <QQmlEngine>
#include <QList>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QAbstractListModel>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "paginators/featuredpackspaginator.h"
/**
* @brief The FeaturedPacksModel class
*/
class KOMPLEX_EXPORT FeaturedPacksModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
Loading,
Error
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UuidRole = Qt::UserRole + 1,
AuthorRole,
AuthorIdRole,
DescriptionRole,
NameRole,
ThumbnailRole,
CreatedDateRole,
PriceRole,
CurrencyRole,
DownloadCountRole,
TypeRole
};
Q_ENUM(DataRole)
explicit FeaturedPacksModel(QObject *parent = nullptr);
~FeaturedPacksModel();
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* User-friendly error string to be reported to the user
* @return
*/
auto errorString() const -> QString;
/**
* @brief resultsPerPage
* @return
*/
auto resultsPerPage() const -> qsizetype;
/**
* @brief setResultsPerPage
* @param resultsPerPage
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void;
/**
* @brief totalResults
* Total number of results available
* @return
*/
auto totalResults() const -> qsizetype;
/**
* @brief page
* @return
*/
auto page() const -> qsizetype;
/**
* @brief totalPages
* Total pages based on the current resultsPerPage
* @return
*/
auto totalPages() const -> qsizetype;
/**
* @brief nextPage
* Function for the QML frontend
*/
Q_INVOKABLE auto nextPage() -> void;
/**
* @brief previousPage
* Function for the QML frontend
*/
Q_INVOKABLE auto previousPage() -> void;
protected:
/**
* @brief setErrorString
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
/**
* @brief setState
* @param state
*/
auto setState(State state) -> void;
/**
* @brief resetState
*/
auto resetState() -> void;
auto resetDataModel() -> void;
auto onPaginatorFetching() -> void;
signals:
auto stateChanged() -> void;
auto errorStringChanged() -> void;
auto resultsPerPageChanged() -> void;
auto pageChanged() -> void;
auto totalResultsChanged() -> void;
auto totalPagesChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* @brief m_dataRoles
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(AuthorRole),
QByteArray("author")
},
{
static_cast<int>(AuthorIdRole),
QByteArray("authorId")
},
{
static_cast<int>(DescriptionRole),
QByteArray("description")
},
{
static_cast<int>(NameRole),
QByteArray("name")
},
{
static_cast<int>(ThumbnailRole),
QByteArray("thumbnail")
},
{
static_cast<int>(CreatedDateRole),
QByteArray("createdDate")
},
{
static_cast<int>(PriceRole),
QByteArray("price")
},
{
static_cast<int>(CurrencyRole),
QByteArray("currency")
},
{
static_cast<int>(DownloadCountRole),
QByteArray("downloadCount")
},
{
static_cast<int>(TypeRole),
QByteArray("type")
}
};
State m_state = Idle;
QString m_errorString = QString();
FeaturedPacksPaginator *m_paginator = nullptr;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
Q_PROPERTY(qsizetype resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qsizetype totalResults READ totalResults NOTIFY totalResultsChanged FINAL)
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
};
Q_DECLARE_METATYPE(FeaturedPacksModel)
#endif // FEATUREDPACKSMODEL_H
+349
View File
@@ -0,0 +1,349 @@
#include "featuredvideosmodel.h"
#include "common/videocache.h"
FeaturedVideosModel::FeaturedVideosModel(QObject *parent) : QAbstractListModel{parent}
{
m_itemModel = new VideoItemModel(this);
m_paginator = new FeaturedVideosPaginator(this);
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
QObject::connect(
notifier,
&PaginationNotifier::resultsPerPageChanged,
this,
&FeaturedVideosModel::resultsPerPageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalResultsChanged,
this,
&FeaturedVideosModel::totalResultsChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalPagesChanged,
this,
&FeaturedVideosModel::totalPagesChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&FeaturedVideosModel::pageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&FeaturedVideosModel::resetDataModel
);
QObject::connect(
notifier,
&PaginationNotifier::fetchComplete,
this,
&FeaturedVideosModel::resetState
);
QObject::connect(
notifier,
&PaginationNotifier::fetching,
this,
&FeaturedVideosModel::onPaginatorFetching
);
}
FeaturedVideosModel::~FeaturedVideosModel()
{
if(m_paginator)
{
delete m_paginator;
}
if(m_itemModel)
{
delete m_itemModel;
}
}
auto FeaturedVideosModel::rowCount(const QModelIndex &) const -> int
{
if(m_paginator != nullptr)
{
return m_paginator->count();
}
return 0;
}
auto FeaturedVideosModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(!boundaryCheck(index.row()))
{
return {};
}
VideoCache dataPoint = m_paginator->at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UuidRole:
data = dataPoint.id;
break;
case AuthorRole:
data = dataPoint.author;
break;
case AuthorIdRole:
data = dataPoint.authorId;
break;
case AuthorUrlRole:
data = dataPoint.authorUrl;
break;
case DurationRole:
data = dataPoint.duration;
break;
case ThumbnailRole:
data = dataPoint.thumbnail;
break;
case UrlRole:
data = dataPoint.url;
break;
case HeightRole:
data = dataPoint.height;
break;
case WidthRole:
data = dataPoint.width;
break;
}
return data;
}
auto FeaturedVideosModel::index(int row, int column, const QModelIndex &parent) const -> QModelIndex
{
Q_UNUSED(parent)
if(!boundaryCheck(row))
{
return {};
}
return createIndex(row, column, &m_paginator[row]);
}
auto FeaturedVideosModel::columnCount(const QModelIndex &) const -> int
{
return 0;
}
auto FeaturedVideosModel::parent(const QModelIndex &) const -> QModelIndex
{
return {};
}
auto FeaturedVideosModel::setData(const QModelIndex &, const QVariant &, int) -> bool
{
return false;
}
auto FeaturedVideosModel::state() const -> FeaturedVideosModel::State
{
return m_state;
}
auto FeaturedVideosModel::setState(State state) -> void
{
if (m_state == state)
{
return;
}
m_state = state;
emit stateChanged();
}
auto FeaturedVideosModel::resetState() -> void
{
setState(Idle);
}
auto FeaturedVideosModel::resetDataModel() -> void
{
//invalidate previous model data
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
endRemoveRows();
//signal new data
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
endInsertRows();
}
auto FeaturedVideosModel::onPaginatorFetching() -> void
{
setState(Loading);
}
auto FeaturedVideosModel::boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || m_paginator == nullptr || index >= m_paginator->count())
{
return false;
}
return true;
}
auto FeaturedVideosModel::itemModel() const -> VideoItemModel*
{
return m_itemModel;
}
auto FeaturedVideosModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
}
auto FeaturedVideosModel::errorString() const -> QString
{
return m_errorString;
}
auto FeaturedVideosModel::setErrorString(const QString &errorString) -> void
{
if (m_errorString == errorString)
{
return;
}
m_errorString = errorString;
emit errorStringChanged();
}
auto FeaturedVideosModel::resultsPerPage() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->resultsPerPage();
}
return 0;
}
auto FeaturedVideosModel::setResultsPerPage(qsizetype resultsPerPage) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, resultsPerPage]
{
qsizetype difference = resultsPerPage - m_paginator->resultsPerPage();
m_paginator->setResultsPerPage(resultsPerPage);
if(difference > 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage() - difference;
beginInsertRows
(
QModelIndex(),
firstIndex,
m_paginator->count() - 1
);
endInsertRows();
}
else if(difference < 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage();
beginRemoveRows
(
QModelIndex(),
firstIndex,
firstIndex - difference
);
endRemoveRows();
}
}
);
}
}
auto FeaturedVideosModel::totalResults() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalResults();
}
return 0;
}
auto FeaturedVideosModel::nextPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->next();
}
);
}
}
auto FeaturedVideosModel::previousPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->previous();
}
);
}
}
auto FeaturedVideosModel::setItem(qint64 index) -> bool
{
if(!boundaryCheck(index))
{
return false;
}
m_itemModel->setDataEntry(m_paginator->at(index));
return true;
}
qsizetype FeaturedVideosModel::page() const
{
if(m_paginator != nullptr)
{
return m_paginator->page();
}
return 0;
}
auto FeaturedVideosModel::totalPages() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalPages();
}
return 0;
}
+320
View File
@@ -0,0 +1,320 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef FEATUREDVIDEOSMODEL_H
#define FEATUREDVIDEOSMODEL_H
#include <QObject>
#include <QQmlEngine>
#include <QList>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QAbstractListModel>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "paginators/featuredvideospaginator.h"
#include "videoitemmodel.h"
/**
* @brief The FeaturedVideosModel class
*/
class KOMPLEX_EXPORT FeaturedVideosModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
Loading,
Error
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UuidRole = Qt::UserRole + 1,
AuthorRole,
AuthorIdRole,
AuthorUrlRole,
DurationRole,
ThumbnailRole,
UrlRole,
HeightRole,
WidthRole
};
Q_ENUM(DataRole)
explicit FeaturedVideosModel(QObject *parent = nullptr);
~FeaturedVideosModel();
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* User-friendly error string to be reported to the user
* @return
*/
auto errorString() const -> QString;
/**
* @brief resultsPerPage
* @return
*/
auto resultsPerPage() const -> qsizetype;
/**
* @brief setResultsPerPage
* @param resultsPerPage
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void;
/**
* @brief totalResults
* Total number of results available
* @return
*/
auto totalResults() const -> qsizetype;
/**
* @brief page
* @return
*/
auto page() const -> qsizetype;
/**
* @brief totalPages
* Total pages based on the current resultsPerPage
* @return
*/
auto totalPages() const -> qsizetype;
/**
* @brief nextPage
* Function for the QML frontend
*/
Q_INVOKABLE auto nextPage() -> void;
/**
* @brief previousPage
* Function for the QML frontend
*/
Q_INVOKABLE auto previousPage() -> void;
/**
* @brief setItem
* Sets the current itemModel to the item at the specified index
* @param index
* @return
*/
Q_INVOKABLE auto setItem(qint64 index) -> bool;
VideoItemModel *itemModel() const;
protected:
/**
* @brief setErrorString
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
/**
* @brief setState
* @param state
*/
auto setState(State state) -> void;
/**
* @brief resetState
*/
auto resetState() -> void;
auto resetDataModel() -> void;
auto onPaginatorFetching() -> void;
signals:
auto stateChanged() -> void;
auto errorStringChanged() -> void;
auto resultsPerPageChanged() -> void;
auto pageChanged() -> void;
auto totalResultsChanged() -> void;
auto totalPagesChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* @brief m_dataRoles
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(AuthorRole),
QByteArray("author")
},
{
static_cast<int>(AuthorIdRole),
QByteArray("authorId")
},
{
static_cast<int>(AuthorUrlRole),
QByteArray("authorUrl")
},
{
static_cast<int>(DurationRole),
QByteArray("duration")
},
{
static_cast<int>(ThumbnailRole),
QByteArray("thumbnail")
},
{
static_cast<int>(UrlRole),
QByteArray("url")
},
{
static_cast<int>(HeightRole),
QByteArray("height")
},
{
static_cast<int>(WidthRole),
QByteArray("width")
}
};
State m_state = Idle;
QString m_errorString = QString();
FeaturedVideosPaginator *m_paginator = nullptr;
VideoItemModel *m_itemModel = nullptr;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
Q_PROPERTY(qsizetype resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qsizetype totalResults READ totalResults NOTIFY totalResultsChanged FINAL)
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
Q_PROPERTY(VideoItemModel *itemModel READ itemModel CONSTANT FINAL)
};
Q_DECLARE_METATYPE(FeaturedVideosModel)
#endif // FEATUREDVIDEOSMODEL_H
+386
View File
@@ -0,0 +1,386 @@
#include "imagesearchmodel.h"
ImageSearchModel::ImageSearchModel(QObject *parent) : QAbstractListModel{parent}
{
m_paginator = new ImageSearchPaginator(this);
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
QObject::connect(
notifier,
&PaginationNotifier::resultsPerPageChanged,
this,
&ImageSearchModel::resultsPerPageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalResultsChanged,
this,
&ImageSearchModel::totalResultsChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalPagesChanged,
this,
&ImageSearchModel::totalPagesChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&ImageSearchModel::pageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&ImageSearchModel::resetDataModel
);
QObject::connect(
notifier,
&PaginationNotifier::fetchComplete,
this,
&ImageSearchModel::resetState
);
QObject::connect(
notifier,
&PaginationNotifier::fetching,
this,
&ImageSearchModel::onPaginatorFetching
);
QObject::connect(
m_paginator,
&ImageSearchPaginator::queryChanged,
this,
&ImageSearchModel::queryChanged
);
}
ImageSearchModel::~ImageSearchModel()
{
if(m_paginator != nullptr)
{
delete m_paginator;
}
}
auto ImageSearchModel::rowCount(const QModelIndex &) const -> int
{
if(m_paginator != nullptr)
{
return m_paginator->count();
}
return 0;
}
auto ImageSearchModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(index.row() < 0 || m_paginator == nullptr || index.row() >= m_paginator->count())
{
return {};
}
ImageCache dataPoint = m_paginator->at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UuidRole:
data = dataPoint.id;
break;
case AuthorRole:
data = dataPoint.photographer;
break;
case AuthorIdRole:
data = dataPoint.photographerId;
break;
case AuthorUrlRole:
data = dataPoint.photographerUrl;
break;
case DescriptionRole:
data = dataPoint.altText;
break;
case ThumbnailRole:
data = dataPoint.sources.value(QString::fromUtf8("thumbnail"));
break;
case LargeThumbnailRole:
data = dataPoint.sources.value(QString::fromUtf8("largeThumbnail"));
break;
case PortraitUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("portrait"));
break;
case PortraitSizeRole:
data = dataPoint.sourceSizes.value(QString::fromUtf8("portrait"));
break;
case ScreenUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("screen"));
break;
case ScreenSizeRole:
data = dataPoint.sourceSizes.value(QString::fromUtf8("screen"));
break;
case OriginalUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("original"));
break;
case LandscapeUrlRole:
data = dataPoint.sources.value(QString::fromUtf8("landscape"));
break;
case LandscapeSizeRole:
data = dataPoint.sourceSizes.value(QString::fromUtf8("landscape"));
break;
case BackgroundPortraitRole:
data = dataPoint.sources.value(QString::fromUtf8("backgroundPortrait"));
case BackgroundLandscapeRole:
data = dataPoint.sources.value(QString::fromUtf8("backgroundLandscape"));
break;
}
return data;
}
auto ImageSearchModel::index(int row, int column, const QModelIndex &parent) const -> QModelIndex
{
Q_UNUSED(parent)
if(row < 0 || row >= m_paginator->count())
{
return {};
}
return createIndex(row, column, &m_paginator->at(row));
}
auto ImageSearchModel::columnCount(const QModelIndex &) const -> int
{
return 0;
}
auto ImageSearchModel::parent(const QModelIndex &) const -> QModelIndex
{
return {};
}
auto ImageSearchModel::setData(const QModelIndex &, const QVariant &, int) -> bool
{
return false;
}
auto ImageSearchModel::state() const -> ImageSearchModel::State
{
return m_state;
}
auto ImageSearchModel::setState(State state) -> void
{
if (m_state == state)
{
return;
}
m_state = state;
emit stateChanged();
}
auto ImageSearchModel::resetState() -> void
{
setState(Idle);
}
auto ImageSearchModel::resetDataModel() -> void
{
//invalidate previous model data
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
endRemoveRows();
//signal new data
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
endInsertRows();
}
auto ImageSearchModel::onPaginatorFetching() -> void
{
setState(Loading);
}
auto ImageSearchModel::boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || m_paginator == nullptr || index >= m_paginator->count())
{
return false;
}
return true;
}
auto ImageSearchModel::hasNextPage() const -> bool
{
return m_paginator->page() < m_paginator->totalPages();
}
auto ImageSearchModel::hasPreviousPage() const -> bool
{
return m_paginator->page() > 0;
}
auto ImageSearchModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
}
auto ImageSearchModel::errorString() const -> QString
{
return m_errorString;
}
auto ImageSearchModel::setErrorString(const QString &errorString) -> void
{
if (m_errorString == errorString)
{
return;
}
m_errorString = errorString;
emit errorStringChanged();
}
auto ImageSearchModel::resultsPerPage() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->resultsPerPage();
}
return 0;
}
auto ImageSearchModel::setResultsPerPage(qsizetype resultsPerPage) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, resultsPerPage]
{
qsizetype difference = resultsPerPage - m_paginator->resultsPerPage();
m_paginator->setResultsPerPage(resultsPerPage);
if(difference > 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage() - difference;
beginInsertRows
(
QModelIndex(),
firstIndex,
m_paginator->count() - 1
);
endInsertRows();
}
else if(difference < 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage();
beginRemoveRows
(
QModelIndex(),
firstIndex,
firstIndex - difference
);
endRemoveRows();
}
}
);
}
}
auto ImageSearchModel::totalResults() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalResults();
}
return 0;
}
auto ImageSearchModel::nextPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->next();
}
);
}
}
auto ImageSearchModel::previousPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->previous();
}
);
}
}
auto ImageSearchModel::query() const -> QString
{
if(m_paginator != nullptr)
{
return m_paginator->query();
}
return {};
}
auto ImageSearchModel::setQuery(const QString &query) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, query]
{
m_paginator->setQuery(query);
}
);
}
}
qsizetype ImageSearchModel::page() const
{
if(m_paginator != nullptr)
{
return m_paginator->page();
}
return 0;
}
auto ImageSearchModel::totalPages() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalPages();
}
return 0;
}
+418
View File
@@ -0,0 +1,418 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef ImageSearchModel_H
#define ImageSearchModel_H
#include <QObject>
#include <QQmlEngine>
#include <QList>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QAbstractListModel>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "paginators/imagesearchpaginator.h"
/**
* @brief The ImageSearchModel class
*/
class KOMPLEX_EXPORT ImageSearchModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
Loading,
Error
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UuidRole = Qt::UserRole + 1,
AuthorRole,
AuthorIdRole,
AuthorUrlRole,
DescriptionRole,
ThumbnailRole,
LargeThumbnailRole,
OriginalUrlRole,
ScreenUrlRole,
PortraitUrlRole,
LandscapeUrlRole,
ScreenSizeRole,
PortraitSizeRole,
LandscapeSizeRole,
BackgroundPortraitRole,
BackgroundLandscapeRole
};
Q_ENUM(DataRole)
explicit ImageSearchModel(QObject *parent = nullptr);
~ImageSearchModel();
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* User-friendly error string to be reported to the user
* @return
*/
auto errorString() const -> QString;
/**
* @brief resultsPerPage
* @return
*/
auto resultsPerPage() const -> qsizetype;
/**
* @brief setResultsPerPage
* @param resultsPerPage
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void;
/**
* @brief totalResults
* Total number of results available
* @return
*/
auto totalResults() const -> qsizetype;
/**
* @brief page
* @return
*/
auto page() const -> qsizetype;
/**
* @brief totalPages
* Total pages based on the current resultsPerPage
* @return
*/
auto totalPages() const -> qsizetype;
/**
* @brief nextPage
* Function for the QML frontend
*/
Q_INVOKABLE auto nextPage() -> void;
/**
* @brief previousPage
* Function for the QML frontend
*/
Q_INVOKABLE auto previousPage() -> void;
/**
* @brief query
* Current search query
* @return
*/
auto query() const -> QString;
/**
* @brief setQuery
* Sets the current search query
* @param query
*/
auto setQuery(const QString &query) -> void;
/**
* @brief hasNextPage
* Calculates if there are more pages based on the current page calculation
* @return
*/
auto hasNextPage() const -> bool;
/**
* @brief hasPreviousPage
* If page is greater than 1, returns true
* @return
*/
auto hasPreviousPage() const -> bool;
protected:
/**
* @brief setErrorString
* Sets the error string to be displayed to the user
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
/**
* @brief setState
* Sets the current state for QML
* @param state
*/
auto setState(State state) -> void;
/**
* @brief resetState
*/
auto resetState() -> void;
/**
* @brief resetDataModel
* Clears the data model and creates a new one if data exists
*/
auto resetDataModel() -> void;
/**
* @brief onPaginatorFetching
* Sets current state to loading. Triggered when paginator's cache controller
* needs to fetch data from the remote endpoint.
*/
auto onPaginatorFetching() -> void;
signals:
/**
* @brief stateChanged
* Signaled when reported state changes
*/
auto stateChanged() -> void;
/**
* @brief errorStringChanged
* Signaled when reported error message changes
*/
auto errorStringChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto resultsPerPageChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto pageChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto totalResultsChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto totalPagesChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto queryChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* @brief m_dataRoles
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(AuthorRole),
QByteArray("author")
},
{
static_cast<int>(AuthorIdRole),
QByteArray("authorId")
},
{
static_cast<int>(AuthorUrlRole),
QByteArray("authorUrl")
},
{
static_cast<int>(DescriptionRole),
QByteArray("description")
},
{
static_cast<int>(ThumbnailRole),
QByteArray("thumbnail")
},
{
static_cast<int>(LargeThumbnailRole),
QByteArray("largeThumbnail")
},
{
static_cast<int>(OriginalUrlRole),
QByteArray("original")
},
{
static_cast<int>(PortraitUrlRole),
QByteArray("portrait")
},
{
static_cast<int>(LandscapeUrlRole),
QByteArray("landscape")
},
{
static_cast<int>(BackgroundPortraitRole),
QByteArray("backgroundPortrait")
},
{
static_cast<int>(BackgroundLandscapeRole),
QByteArray("backgroundLandscape")
},
{
static_cast<int>(ScreenUrlRole),
QByteArray("fullScreen")
},
{
static_cast<int>(ScreenSizeRole),
QByteArray("fullScreenSize")
},
{
static_cast<int>(PortraitSizeRole),
QByteArray("portraitSize")
},
{
static_cast<int>(LandscapeSizeRole),
QByteArray("landscapeSize")
}
};
State m_state = Idle;
QString m_errorString = QString();
ImageSearchPaginator *m_paginator = nullptr;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
Q_PROPERTY(qsizetype resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qsizetype totalResults READ totalResults NOTIFY totalResultsChanged FINAL)
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
Q_PROPERTY(bool hasNextPage READ hasNextPage NOTIFY pageChanged FINAL)
Q_PROPERTY(bool hasPreviousPage READ hasPreviousPage NOTIFY pageChanged FINAL)
Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged FINAL)
};
Q_DECLARE_METATYPE(ImageSearchModel)
#endif // ImageSearchModel_H
+188 -24
View File
@@ -1,33 +1,96 @@
#include "newestpacksmodel.h"
#include "common/coreservices.h"
#include "common/logging.h"
#include "common/wallpapercache.h"
NewestPacksModel::NewestPacksModel(QObject *parent) : QAbstractListModel{parent}
{
setState(Loading);
m_paginator = new NewestPacksPaginator(this);
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
QObject::connect(
notifier,
&PaginationNotifier::resultsPerPageChanged,
this,
&NewestPacksModel::resultsPerPageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalResultsChanged,
this,
&NewestPacksModel::totalResultsChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalPagesChanged,
this,
&NewestPacksModel::totalPagesChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&NewestPacksModel::pageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&NewestPacksModel::resetDataModel
);
QObject::connect(
notifier,
&PaginationNotifier::fetchComplete,
this,
&NewestPacksModel::resetState
);
QObject::connect(
notifier,
&PaginationNotifier::fetching,
this,
&NewestPacksModel::onPaginatorFetching
);
}
NewestPacksModel::~NewestPacksModel()
{
if(m_paginator)
{
delete m_paginator;
}
}
auto NewestPacksModel::rowCount(const QModelIndex &) const -> int
{
return m_wallpaperCache.count();
if(m_paginator != nullptr)
{
return m_paginator->count();
}
return 0;
}
auto NewestPacksModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(index.row() < 0)
if(index.row() < 0 || m_paginator == nullptr || index.row() >= m_paginator->count())
{
return {};
}
WallpaperCache dataPoint = m_wallpaperCache.at(index.row());
WallpaperCache dataPoint = m_paginator->at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UriRole:
data = dataPoint.uri;
case UuidRole:
data = dataPoint.uuid;
break;
case AuthorRole:
data = dataPoint.author;
@@ -68,8 +131,10 @@ auto NewestPacksModel::index(int row, int column, const QModelIndex &parent) con
{
Q_UNUSED(parent)
WallpaperCache data = m_wallpaperCache.at(row);
return createIndex(row, column, &data);
if(row < 0 || row >= m_paginator->count())
return {};
return createIndex(row, column, &m_paginator[row]);
}
auto NewestPacksModel::columnCount(const QModelIndex &) const -> int
@@ -108,6 +173,22 @@ auto NewestPacksModel::resetState() -> void
setState(Idle);
}
auto NewestPacksModel::resetDataModel() -> void
{
//invalidate previous model data
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
endRemoveRows();
//signal new data
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
endInsertRows();
}
auto NewestPacksModel::onPaginatorFetching() -> void
{
setState(Loading);
}
auto NewestPacksModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
@@ -129,30 +210,113 @@ auto NewestPacksModel::setErrorString(const QString &errorString) -> void
emit errorStringChanged();
}
auto NewestPacksModel::resultsPerPage() const -> qint64
auto NewestPacksModel::resultsPerPage() const -> qsizetype
{
return m_resultsPerPage;
if(m_paginator != nullptr)
{
return m_paginator->resultsPerPage();
}
return 0;
}
auto NewestPacksModel::setResultsPerPage(qint64 resultsPerPage) -> void
auto NewestPacksModel::setResultsPerPage(qsizetype resultsPerPage) -> void
{
if (m_resultsPerPage == resultsPerPage)
return;
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, resultsPerPage]
{
qsizetype difference = resultsPerPage - m_paginator->resultsPerPage();
m_paginator->setResultsPerPage(resultsPerPage);
m_resultsPerPage = resultsPerPage;
emit resultsPerPageChanged();
if(difference > 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage() - difference;
beginInsertRows
(
QModelIndex(),
firstIndex,
m_paginator->count() - 1
);
endInsertRows();
}
else if(difference < 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage();
beginRemoveRows
(
QModelIndex(),
firstIndex,
firstIndex - difference
);
endRemoveRows();
}
}
);
}
}
qint64 NewestPacksModel::page() const
auto NewestPacksModel::totalResults() const -> qsizetype
{
return m_page;
if(m_paginator != nullptr)
{
return m_paginator->totalResults();
}
return 0;
}
void NewestPacksModel::setPage(qint64 page)
auto NewestPacksModel::nextPage() const -> void
{
if (m_page == page)
return;
m_page = page;
emit pageChanged();
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->next();
}
);
}
}
auto NewestPacksModel::previousPage() const -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->previous();
}
);
}
}
qsizetype NewestPacksModel::page() const
{
if(m_paginator != nullptr)
{
return m_paginator->page();
}
return 0;
}
auto NewestPacksModel::totalPages() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalPages();
}
return 0;
}
+171 -23
View File
@@ -35,15 +35,22 @@
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "paginators/newestpackspaginator.h"
/**
* @brief The NewestPacksModel class
*/
class KOMPLEX_EXPORT NewestPacksModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
@@ -52,8 +59,11 @@ public:
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UriRole = Qt::UserRole + 1,
UuidRole = Qt::UserRole + 1,
AuthorRole,
AuthorIdRole,
DescriptionRole,
@@ -68,61 +78,204 @@ public:
Q_ENUM(DataRole)
explicit NewestPacksModel(QObject *parent = nullptr);
~NewestPacksModel();
/**
* @brief rowCount
* @param parent
* @return
*/
[[nodiscard]]
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
auto data(const QModelIndex &index, int role = Qt::DisplayRole) const -> QVariant override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
[[nodiscard]]
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
[[nodiscard]]
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
[[nodiscard]]
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
[[nodiscard]]
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
auto setState(State state) -> void;
auto resetState() -> void;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
[[nodiscard]]
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* @return
*/
[[nodiscard]]
auto errorString() const -> QString;
/**
* @brief resultsPerPage
* @return
*/
auto resultsPerPage() const -> qsizetype;
/**
* @brief setResultsPerPage
* @param resultsPerPage
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void;
/**
* @brief totalResults
* @return
*/
auto totalResults() const -> qsizetype;
/**
* @brief page
* @return
*/
auto page() const -> qsizetype;
/**
* @brief totalPages
* @return
*/
auto totalPages() const -> qsizetype;
/**
* @brief nextPage
*/
Q_INVOKABLE auto nextPage() const -> void;
/**
* @brief previousPage
*/
Q_INVOKABLE auto previousPage() const -> void;
protected:
/**
* @brief setErrorString
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
auto resultsPerPage() const -> qint64;
auto setResultsPerPage(qint64 resultsPerPage) -> void;
/**
* @brief setState
* @param state
*/
auto setState(State state) -> void;
qint64 page() const;
void setPage(qint64 page);
/**
* @brief resetState
*/
auto resetState() -> void;
/**
* @brief resetDataModel
*/
auto resetDataModel() -> void;
auto onPaginatorFetching() -> void;
signals:
auto installedWallpapersChanged() -> void;
auto stateChanged() -> void;
auto errorStringChanged() -> void;
auto resultsPerPageChanged() -> void;
void pageChanged();
auto pageChanged() -> void;
auto totalResultsChanged() -> void;
auto totalPagesChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* @brief m_dataRoles
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UriRole),
QByteArray("uri")
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(AuthorRole),
QByteArray("author")
},
{
static_cast<int>(AuthorIdRole),
QByteArray("authorId")
},
{
static_cast<int>(DescriptionRole),
QByteArray("description")
@@ -156,23 +309,18 @@ private:
QByteArray("type")
}
};
static inline const QString m_endpointUri = QString("");
State m_state = Idle;
QString m_errorString = QString();
QString m_installDirectoryUri;
qint64 m_page = 0;
qint64 m_resultsPerPage = 0;
NewestPacksPaginator m_wallpaperCache;
NewestPacksPaginator *m_paginator = nullptr;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
Q_PROPERTY(qint64 resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qint64 page READ page WRITE setPage NOTIFY pageChanged FINAL)
Q_PROPERTY(qsizetype resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qsizetype totalResults READ totalResults NOTIFY totalResultsChanged FINAL)
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
};
Q_DECLARE_METATYPE(NewestPacksModel)
+942
View File
@@ -0,0 +1,942 @@
#include "packcompiler.h"
#include "common/exceptions.h"
#include <utility>
PackCompiler::PackCompiler(QObject *parent)
: QObject(parent)
{
if(m_variableExpressions.isEmpty())
{
for(const QString &variable : m_updateVariables)
{
m_variableExpressions.append
(
QRegularExpression
(
QStringLiteral("\\b(?<!ubuf\\.)%1\\b").arg
(
variable
)
)
);
}
}
}
PackCompiler::~PackCompiler() = default;
auto PackCompiler::reset() -> void
{
setError({}, {});
setProgress(std::numeric_limits<qreal>::infinity());
setTotalSteps(0);
setCurrentStep(0);
setCompilerOutput({});
setStatus({});
setState(Idle);
}
auto PackCompiler::process(const QUrl &uri) -> QFuture<QUrl>
{
return QtConcurrent::run
(
[this, uri] () -> QUrl
{
if(!uri.isLocalFile())
{
setError
(
QStringLiteral("File Error"),
QStringLiteral("URI %1 is not a local file").arg
(
uri.toString()
)
);
return {};
}
reset();
setStatus(QStringLiteral("Compiling %1").arg(uri.fileName()));
setState(Compiling);
if(!validateDirectory(uri))
{
throw FileException
(
QStringLiteral("Source directory is invalid")
);
}
QUrl buildUri
(
QStringLiteral("file://%1/komplex/build/%2").arg
(
QStandardPaths::writableLocation
(
QStandardPaths::TempLocation
),
uri.fileName()
)
);
try
{
extract(uri, buildUri);
prepareShaders(buildUri);
compile(buildUri);
}
catch (FileException e)
{
removeDirectory(buildUri);
setError(QStringLiteral("File Error"), e.message);
throw e;
}
catch (ShaderCompilerException e)
{
removeDirectory(buildUri);
setError(QStringLiteral("Compiler Error"), e.message);
throw e;
}
return buildUri;
}
);
}
auto PackCompiler::prepareShaders(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
)
);
}
QDir sourceDirectory(uri.toLocalFile());
QDir shaderDirectory
(
sourceDirectory.absoluteFilePath
(
QStringLiteral("shaders")
)
);
QStringList entries = shaderDirectory.entryList
(
QDir::NoDotAndDotDot | QDir::Files
);
setTotalSteps(entries.count() * 2);
setProgress(0);
QByteArray commonFragmentData = loadCommonFragmentData(uri);
if(commonFragmentData.length() > 0)
{
setTotalSteps(m_totalSteps -= 1);
incrementCompileStep();
}
QByteArray commonVertexData = loadCommonVertexData(uri);
if(commonVertexData.length() > 0)
{
setTotalSteps(m_totalSteps -= 1);
incrementCompileStep();
}
QByteArray globalData = loadGlobalData(uri);
if(globalData.length() > 0)
{
setTotalSteps(m_totalSteps -= 1);
incrementCompileStep();
}
for(const QString &entry : std::as_const(entries))
{
auto commonFragMatch = m_commonFragmentExpression.match(entry);
auto commonVertMatch = m_commonVertexExpression.match(entry);
if(commonFragMatch.hasMatch() || commonVertMatch.hasMatch())
{
continue;
}
auto fragMatch = m_fragmentExpression.match(entry);
auto vertMatch = m_vertexExpression.match(entry);
QFile file(shaderDirectory.absoluteFilePath(entry));
if(!file.open(QFile::ReadWrite))
{
throw FileException
(
QStringLiteral("Could not open file %1 for preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
)
);
}
QByteArray fileData = file.readAll();
if(fileData.length() != file.size())
{
throw FileException
(
QStringLiteral("Could not read file %1 for preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
)
);
}
file.close();
QByteArray commonData;
if(fragMatch.hasMatch())
{
commonData = commonFragmentData;
}
else if(vertMatch.hasMatch())
{
commonData = commonVertexData;
}
else
{
throw FileException
(
QStringLiteral("File %1 is an unrecognized shader type (frag/vert)").arg
(
shaderDirectory.absoluteFilePath(entry)
)
);
}
QByteArray combinedData = QByteArray
(
globalData + QByteArray("\n") +
commonData + QByteArray("\n") +
fileData
);
for(const QRegularExpression &expression : std::as_const(m_variableExpressions))
{
auto match = expression.match(combinedData);
if(match.hasMatch())
{
QByteArray replacement = QByteArray("ubuf.") + match.captured().toLocal8Bit();
combinedData.replace(match.captured().toLocal8Bit(), replacement);
}
}
QByteArray preparedData = QByteArray
(
m_header.toLocal8Bit() + QByteArray("\n") +
combinedData + QByteArray("\n") +
m_footer.toLocal8Bit()
);
if(!file.open(QFile::ReadWrite | QFile::Truncate))
{
throw FileException
(
QStringLiteral("Could not open file %1 for writing preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
)
);
}
if(file.write(preparedData) != preparedData.length())
{
throw FileException
(
QStringLiteral("Could not write file %1 preperation").arg
(
shaderDirectory.absoluteFilePath(entry)
)
);
}
file.close();
incrementCompileStep();
}
}
auto PackCompiler::loadCommonFragmentData(const QUrl &uri) -> QByteArray
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
)
);
}
QDir sourceDirectory
(
QStringLiteral("%1/shaders/").arg
(
uri.toLocalFile()
)
);
const QStringList entries = sourceDirectory.entryList
(
QDir::NoDotAndDotDot | QDir::Files
);
QByteArray data;
for(const QString &entry : entries)
{
if (entry.toLower() != QStringLiteral("common.frag"))
{
continue;
}
QFile file(sourceDirectory.absoluteFilePath(entry));
if(!file.open(QFile::ReadWrite))
{
throw FileException(QStringLiteral("Could not open common shader data"));
}
data = file.readAll();
if(data.length() != file.size())
{
throw FileException(QStringLiteral("Common fragment shader file read error"));
}
file.close();
break;
}
return data;
}
auto PackCompiler::loadCommonVertexData(const QUrl &uri) -> QByteArray
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
)
);
}
QDir sourceDirectory
(
QStringLiteral("%1/shaders/").arg
(
uri.toLocalFile()
)
);
const QStringList entries = sourceDirectory.entryList
(
QDir::NoDotAndDotDot | QDir::Files
);
QByteArray data;
for(const QString &entry : entries)
{
if (entry.toLower() != QStringLiteral("common.vert"))
{
continue;
}
QFile file(sourceDirectory.absoluteFilePath(entry));
if(!file.open(QFile::ReadWrite))
{
throw FileException(QStringLiteral("Could not open common vertex shader data"));
}
data = file.readAll();
if(data.length() != file.size())
{
throw FileException(QStringLiteral("Common vertex shader file read error"));
}
file.close();
break;
}
return data;
}
auto PackCompiler::loadGlobalData(const QUrl &uri) -> QByteArray
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("URI %1 is not a local file uri").arg
(
uri.toString()
)
);
}
QDir sourceDirectory
(
QStringLiteral("%1/shaders/").arg
(
uri.toLocalFile()
)
);
const QStringList entries = sourceDirectory.entryList
(
QDir::NoDotAndDotDot | QDir::Files
);
QByteArray data;
for(const QString &entry : entries)
{
if (entry.toLower() != QStringLiteral("global.glsl"))
{
continue;
}
QFile file(sourceDirectory.absoluteFilePath(entry));
if(!file.open(QFile::ReadWrite))
{
throw FileException
(
QStringLiteral("Could not open global shader data")
);
}
data = file.readAll();
if(data.length() != file.size())
{
throw FileException
(
QStringLiteral("Global shader file read error")
);
}
file.close();
break;
}
return data;
}
auto PackCompiler::validateDirectory(const QUrl &uri) -> bool
{
QDir directory(uri.toLocalFile());
return
(
directory.exists(QStringLiteral("shaders")) &&
directory.exists(QStringLiteral("pack.json"))
);
}
auto PackCompiler::extract(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void
{
if(!sourceUri.isLocalFile() || !sourceUri.isValid())
{
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
}
QUrl outputUri
(
QStringLiteral("file://%1_proc").arg
(
sourceUri.toLocalFile()
)
);
QStringList arguments =
{
QStringLiteral("-xzf"),
sourceUri.toLocalFile(),
QStringLiteral("-C"),
outputUri.toLocalFile()
};
QProcess *process = new QProcess(this);
QObject::connect
(
process,
&QProcess::readyReadStandardOutput,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardOutput();
setCompilerOutput(m_compilerOutput + processData);
}
);
QObject::connect
(
process,
&QProcess::readyReadStandardError,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
setCompilerOutput(m_compilerOutput + processData);
}
);
process->start(QStringLiteral("tar"), arguments);
if(!process->waitForStarted(3000))
{
process->deleteLater();
throw FileException(QStringLiteral("Could not start preprocessor"));
}
if(!process->waitForFinished())
{
process->deleteLater();
throw FileException(QStringLiteral("Preprocessor timeout"));
}
if(process->exitCode() != 0)
{
process->deleteLater();
throw ShaderCompilerException(m_compilerOutput);
}
process->deleteLater();
}
auto PackCompiler::copyFile(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void
{
if(!QFile::exists(sourceUri.toLocalFile()))
{
return;
}
if(!QFile::copy(sourceUri.toLocalFile(), destinationUri.toLocalFile()))
{
throw FileException(QStringLiteral("Could not copy file"));
}
}
auto PackCompiler::compile(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isLocalFile() || !uri.isValid())
{
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
}
setState(Compiling);
QDir packDirectory(uri.toLocalFile());
QDir shaderDirectory
(
packDirectory.absoluteFilePath
(
QStringLiteral("shaders")
)
);
shaderDirectory.setNameFilters
(
{
QStringLiteral("*.frag"),
QStringLiteral("*.vert")
}
);
const QStringList shaders = shaderDirectory.entryList
(
QDir::Files | QDir::NoDotAndDotDot
);
for(const QString &shader : shaders)
{
if(shader.startsWith(QStringLiteral("common."), Qt::CaseInsensitive))
{
continue;
}
QUrl shaderUri
(
QStringLiteral("file://%1").arg
(
shaderDirectory.absoluteFilePath(shader)
)
);
preprocess(shaderUri);
appendVersion(shaderUri);
compileShader(shaderUri);
incrementCompileStep();
}
}
auto PackCompiler::preprocess(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isLocalFile() || !uri.isValid())
{
throw FileException(QStringLiteral("Uri needs to be a local file"), 0);
}
QUrl outputUri
(
QStringLiteral("file://%1_proc").arg
(
uri.toLocalFile()
)
);
QStringList arguments =
{
QStringLiteral("-P"),
uri.toLocalFile(),
outputUri.toLocalFile()
};
QProcess *process = new QProcess(this);
QObject::connect
(
process,
&QProcess::readyReadStandardOutput,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardOutput();
setCompilerOutput(m_compilerOutput + processData);
}
);
QObject::connect
(
process,
&QProcess::readyReadStandardError,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
setCompilerOutput(m_compilerOutput + processData);
}
);
process->start(QStringLiteral("cpp"), arguments);
if(!process->waitForStarted(3000))
{
process->deleteLater();
throw FileException(QStringLiteral("Could not start preprocessor"));
}
if(!process->waitForFinished())
{
process->deleteLater();
throw FileException(QStringLiteral("Preprocessor timeout"));
}
if(process->exitCode() != 0)
{
process->deleteLater();
throw ShaderCompilerException(m_compilerOutput);
}
process->deleteLater();
QFile::remove(uri.toLocalFile());
QFile::rename(outputUri.toLocalFile(), uri.toLocalFile());
}
auto PackCompiler::appendVersion(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isValid() || !uri.isLocalFile())
{
throw FileException(QStringLiteral("File is not a valid local file"));
}
QFile file(uri.toLocalFile());
if(!file.open(QFile::ReadWrite))
{
throw FileException(QStringLiteral("Could not open file for appending"));
}
QByteArray data = file.readAll();
file.seek(0);
file.write(m_version);
file.write(QByteArray("\n\n"));
file.write(data);
file.close();
}
auto PackCompiler::compileShader(const QUrl &uri) noexcept(false) -> void
{
if(!uri.isLocalFile())
{
throw FileException
(
QStringLiteral("Uri needs to be a local file")
);
}
QString qsb = QStringLiteral("/usr/lib/qt6/bin/qsb");
if(!QFile::exists(qsb))
{
throw FileException(QStringLiteral("QSB missing"));
}
QUrl outputUri
(
QStringLiteral("file://%1.qsb").arg
(
uri.toLocalFile()
)
);
QStringList arguments =
{
QStringLiteral("--glsl"),
QStringLiteral("330es, 330, 440"),
QStringLiteral("-o"),
outputUri.toLocalFile(),
uri.toLocalFile()
};
QProcess *process = new QProcess(this);
QString path = uri.toDisplayString(QUrl::RemoveFilename | QUrl::RemoveScheme).remove(QStringLiteral("//"));
process->setWorkingDirectory(path);
QObject::connect
(
process,
&QProcess::readyReadStandardOutput,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardOutput();
setCompilerOutput(m_compilerOutput + processData);
}
);
QObject::connect
(
process,
&QProcess::readyReadStandardError,
this,
[this, process]()
{
QByteArray processData = process->readAllStandardError();
if(!processData.isValidUtf8())
{
qWarning() << QStringLiteral("Process output not valid UTF8 data");
return;
}
setCompilerOutput(m_compilerOutput + processData);
}
);
process->start(qsb, arguments);
if(!process->waitForStarted(3000))
{
process->deleteLater();
throw FileException(QStringLiteral("Could not start shader compiler"));
}
if(!process->waitForFinished())
{
process->deleteLater();
throw FileException(QStringLiteral("Shader compiler timeout"));
}
if(process->exitCode() != 0)
{
process->deleteLater();
throw ShaderCompilerException(m_compilerOutput);
}
process->deleteLater();
if(!QFile::remove(uri.toLocalFile()))
{
throw FileException(QStringLiteral("Could not clean up"));
}
}
auto PackCompiler::removeDirectory(const QUrl &uri) -> bool
{
QStringList arguments =
{
QStringLiteral("-rf"),
uri.toLocalFile()
};
QProcess *process = new QProcess(this);
process->start(QStringLiteral("rm"), arguments);
if(!process->waitForStarted(3000))
{
process->deleteLater();
return false;
}
if(!process->waitForFinished())
{
process->deleteLater();
return false;
}
if(process->exitCode() != 0)
{
process->deleteLater();
return false;
}
process->deleteLater();
return true;
}
auto PackCompiler::setProgress(qreal progress) -> void
{
if(qFuzzyCompare(progress, m_progress))
{
return;
}
m_progress = progress;
Q_EMIT progressChanged();
}
void PackCompiler::setCompilerOutput(const QString &compilerOutput)
{
if (m_compilerOutput == compilerOutput)
{
return;
}
m_compilerOutput = compilerOutput;
emit compilerOutputChanged();
}
auto PackCompiler::setError(const QString &title, const QString &message, const QUrl &uri) -> void
{
if(title == m_errorTitle && message == m_errorMessage)
{
return;
}
m_errorMessage = std::move(message);
m_errorTitle = std::move(title);
if(uri.isValid() && uri.isLocalFile())
{
QFile errorFile(uri.toLocalFile());
if(errorFile.open(QFile::ReadWrite | QFile::Append))
{
errorFile.write(message.toLocal8Bit() + QByteArray("\n"));
}
}
Q_EMIT errorTitleChanged();
Q_EMIT errorMessageChanged();
Q_EMIT errorOcurred();
}
auto PackCompiler::setState(State state) -> void
{
if(state == m_state)
{
return;
}
m_state = state;
Q_EMIT stateChanged();
}
auto PackCompiler::setStatus(const QString &status) -> void
{
if (m_status == status)
{
return;
}
m_status = status;
Q_EMIT statusChanged();
}
auto PackCompiler::setTotalSteps(qint64 steps) -> void
{
if(steps == m_totalSteps)
{
return;
}
m_totalSteps = steps;
Q_EMIT totalStepsChanged();
}
auto PackCompiler::setCurrentStep(qint64 step) -> void
{
if(step == m_currentStep)
{
return;
}
m_currentStep = step;
Q_EMIT currentStepChanged();
}
auto PackCompiler::incrementCompileStep() -> void
{
setCurrentStep(m_currentStep + 1);
setProgress
(
static_cast<qreal>(m_currentStep) / m_totalSteps
);
}
+248
View File
@@ -0,0 +1,248 @@
#ifndef PACKCOMPILER_H
#define PACKCOMPILER_H
#include <QDir>
#include <QFile>
#include <QFuture>
#include <QtConcurrent/QtConcurrentRun>
#include <QStandardPaths>
#include <QProcess>
#include <QRegularExpression>
#include <QMutex>
#include <QMutexLocker>
#include <QImage>
#include <QRgb>
#include <QColor>
#include <QtQuick/QQuickItem>
#include <qdir.h>
#include <qobject.h>
#include <qtmetamacros.h>
#include <QPainter>
#include <QtConcurrent/qtconcurrentrun.h>
#include <qcontainerfwd.h>
#include <qmargins.h>
#include <qstandardpaths.h>
#include <qtmetamacros.h>
#include <qurl.h>
#include "common/komplex_global.h"
/**
* @brief The PackCompiler class
* [1] Extract Pack (GZip)
* [2] Verify directory is a pack and has shaders
* [3] Load shader code
* [4] Append Common and Global files, if they exist
* [5] Add uniform and replace variable use
* [6] Run C Preprocessor (cpp -P) to process macros
* [7] Append version macro
* [8] Compile with Qt Shader Baker
*/
class KOMPLEX_EXPORT PackCompiler : public QObject
{
Q_OBJECT
QML_ELEMENT
public:
enum State
{
Idle,
Compiling,
Complete,
Error
};
Q_ENUM(State)
explicit PackCompiler(QObject *parent = nullptr);
~PackCompiler() override;
auto compilerOutput() const -> const QString & { return m_compilerOutput; }
auto progress() -> qreal { return m_progress; }
auto currentStep() -> qint64 { return m_currentStep; }
auto totalSteps() -> qint64 { return m_totalSteps; }
auto errorTitle() const -> const QString & { return m_errorTitle; }
auto errorMessage() const -> const QString & { return m_errorMessage; }
auto reset() -> void;
auto process(const QUrl &uri) -> QFuture<QUrl>;
auto status() const -> const QString & { return m_status; }
auto state() const -> State { return m_state; }
protected:
/**
* @brief prepareShaders
* Scans the pack's shader directory and sends each file to
* prepareFile()
* @param uri
* Directory to prepare
*/
auto prepareShaders(const QUrl &uri) noexcept(false) -> void;
/**
* @brief prepareFile
* Prepares the individual file by appending the header, footer,
* common files and replacing standard variable names
* @param uri
*/
auto prepareFile(const QUrl &uri) noexcept(false) -> void;
/**
* @brief validateDirectory
*
* @param uri
* @return true
* @return false
*/
auto validateDirectory(const QUrl &uri) -> bool;
auto extract(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void;
auto copyFile(const QUrl &sourceUri, const QUrl &destinationUri) noexcept(false) -> void;
auto compile(const QUrl &uri) noexcept(false) -> void;
auto preprocess(const QUrl &uri) noexcept(false) -> void;
auto appendVersion(const QUrl &uri) noexcept(false) -> void;
auto compileShader(const QUrl &uri) noexcept(false) -> void;
auto loadCommonFragmentData(const QUrl &uri) -> QByteArray;
auto loadCommonVertexData(const QUrl &uri) -> QByteArray;
auto loadGlobalData(const QUrl &uri) -> QByteArray;
auto setError(const QString &title, const QString &message, const QUrl &uri = {}) -> void;
auto setCompilerOutput(const QString &compilerOutput) -> void;
auto setState(State state) -> void;
auto setProgress(qreal progress) -> void;
auto setTotalSteps(qint64 steps) -> void;
auto setCurrentStep(qint64 step) -> void;
auto setStatus(const QString &status) -> void;
auto incrementCompileStep() -> void;
auto removeDirectory(const QUrl &uri) -> bool;
signals:
auto compilerOutputChanged() -> void;
auto errorOcurred() -> void;
auto errorTitleChanged() -> void;
auto errorMessageChanged() -> void;
auto stateChanged() -> void;
auto progressChanged() -> void;
auto currentStepChanged() -> void;
auto totalStepsChanged() -> void;
auto compileComplete(const QUrl &uri) -> void;
auto statusChanged() -> void;
auto packReady(const QString &) -> void;
auto errorStepChanged() -> void;
auto errorRatingChanged() -> void;
private:
static inline const QStringList m_updateVariables
{
QStringLiteral("iTime"),
QStringLiteral("iTimeDelta"),
QStringLiteral("iFrameRate"),
QStringLiteral("iSampleRate"),
QStringLiteral("iFrame"),
QStringLiteral("iDate"),
QStringLiteral("iMouse"),
QStringLiteral("iResolution"),
QStringLiteral("iColorTheme"),
QStringLiteral("iChannelTime"),
QStringLiteral("iChannelResolution")
};
static inline const QByteArray m_version
{
R"(#version 450)"
};
static inline const QString m_header
{
R"(layout(location = 0) in vec2 qt_TexCoord0;
layout(location = 0) out vec4 fragColor;
layout(std140, binding = 0) uniform buf {
mat4 qt_Matrix;
float qt_Opacity;
float iTime;
float iTimeDelta;
float iFrameRate;
float iSampleRate;
int iFrame;
vec4 iDate;
vec4 iMouse;
vec3 iResolution;
float iChannelTime[4];
vec3 iChannelResolution[4];
vec4 iColorTheme[4];
} ubuf;
layout(binding = 1) uniform sampler2D iChannel0;
layout(binding = 2) uniform sampler2D iChannel1;
layout(binding = 3) uniform sampler2D iChannel2;
layout(binding = 4) uniform sampler2D iChannel3;
vec2 fragCoord = vec2(qt_TexCoord0.x, 1.0 - qt_TexCoord0.y) * ubuf.iResolution.xy;)"
};
static inline const QString m_footer
{
R"(void main() {
vec4 color = vec4(0.0);
mainImage(color, fragCoord);
fragColor = color;
})"
};
QString m_compilerOutput;
QString m_errorMessage;
QString m_errorTitle;
QString m_status;
State m_state;
qreal m_currentStep = 0;
qreal m_progress = 0;
qreal m_totalSteps = 0;
QMutex m_downloadMutex;
static inline QList<QRegularExpression> m_variableExpressions;
static inline const QRegularExpression m_commonFragmentExpression = QRegularExpression
(
QString("^common\\.frag$"),
QRegularExpression::CaseInsensitiveOption
);
static inline const QRegularExpression m_commonVertexExpression = QRegularExpression
(
QString("^common\\.vert$"),
QRegularExpression::CaseInsensitiveOption
);
static inline const QRegularExpression m_fragmentExpression = QRegularExpression
(
QString("^.{1,}\\.frag$"),
QRegularExpression::CaseInsensitiveOption |
QRegularExpression::DotMatchesEverythingOption
);
static inline const QRegularExpression m_vertexExpression = QRegularExpression
(
QString("^.{1,}\\.vert$"),
QRegularExpression::CaseInsensitiveOption |
QRegularExpression::DotMatchesEverythingOption
);
Q_PROPERTY(QString compilerOutput READ compilerOutput WRITE setCompilerOutput NOTIFY compilerOutputChanged FINAL)
Q_PROPERTY(QString errorTitle READ errorTitle NOTIFY errorTitleChanged FINAL)
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged FINAL)
Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged FINAL)
Q_PROPERTY(qint64 totalSteps READ totalSteps NOTIFY totalStepsChanged FINAL)
Q_PROPERTY(qint64 currentStep READ currentStep NOTIFY currentStepChanged FINAL)
Q_PROPERTY(QString status READ status WRITE setStatus NOTIFY statusChanged FINAL)
Q_PROPERTY(State state READ state NOTIFY stateChanged FINAL)
};
Q_DECLARE_METATYPE(PackCompiler)
#endif // PackCompiler_H
+375
View File
@@ -0,0 +1,375 @@
#include "packsearchmodel.h"
PackSearchModel::PackSearchModel(QObject *parent) : QAbstractListModel{parent}
{
m_paginator = new PackSearchPaginator(this);
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
QObject::connect(
notifier,
&PaginationNotifier::resultsPerPageChanged,
this,
&PackSearchModel::resultsPerPageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalResultsChanged,
this,
&PackSearchModel::totalResultsChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalPagesChanged,
this,
&PackSearchModel::totalPagesChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&PackSearchModel::pageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&PackSearchModel::resetDataModel
);
QObject::connect(
notifier,
&PaginationNotifier::fetchComplete,
this,
&PackSearchModel::resetState
);
QObject::connect(
notifier,
&PaginationNotifier::fetching,
this,
&PackSearchModel::onPaginatorFetching
);
QObject::connect(
m_paginator,
&PaginationNotifier::queryChanged,
this,
&PackSearchModel::queryChanged
);
}
PackSearchModel::~PackSearchModel()
{
if(m_paginator)
{
delete m_paginator;
}
}
auto PackSearchModel::rowCount(const QModelIndex &) const -> int
{
if(m_paginator != nullptr)
{
return m_paginator->count();
}
return 0;
}
auto PackSearchModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(m_paginator == nullptr)
{
return {};
}
if(index.row() < 0 || index.row() >= m_paginator->count() )
{
return {};
}
WallpaperCache dataPoint = m_paginator->at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UuidRole:
data = dataPoint.uuid;
break;
case AuthorRole:
data = dataPoint.author;
break;
case DescriptionRole:
data = dataPoint.description;
break;
case NameRole:
data = dataPoint.name;
break;
case ThumbnailRole:
data = dataPoint.thumbnail;
break;
case CreatedDateRole:
data = dataPoint.createdDate;
break;
case AuthorIdRole:
data = dataPoint.authorId;
break;
case PriceRole:
data = dataPoint.price;
break;
case CurrencyRole:
data = dataPoint.currency;
break;
case DownloadCountRole:
data = dataPoint.downloadCount;
break;
case TypeRole:
data = dataPoint.type;
break;
}
return data;
}
auto PackSearchModel::index(int row, int column, const QModelIndex &parent) const -> QModelIndex
{
Q_UNUSED(parent)
if(row < 0 || row >= m_paginator->count())
return {};
return createIndex(row, column, &m_paginator[row]);
}
auto PackSearchModel::columnCount(const QModelIndex &) const -> int
{
return 0;
}
auto PackSearchModel::parent(const QModelIndex &) const -> QModelIndex
{
return {};
}
auto PackSearchModel::setData(const QModelIndex &, const QVariant &, int) -> bool
{
return false;
}
auto PackSearchModel::state() const -> PackSearchModel::State
{
return m_state;
}
auto PackSearchModel::setState(State state) -> void
{
if (m_state == state)
{
return;
}
m_state = state;
emit stateChanged();
}
auto PackSearchModel::resetState() -> void
{
setState(Idle);
}
auto PackSearchModel::resetDataModel() -> void
{
//invalidate previous model data
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
endRemoveRows();
//signal new data
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
endInsertRows();
}
auto PackSearchModel::boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || m_paginator == nullptr || index >= m_paginator->count())
{
return false;
}
return true;
}
auto PackSearchModel::hasNextPage() const -> bool
{
return m_paginator->page() < m_paginator->totalPages();
}
auto PackSearchModel::hasPreviousPage() const -> bool
{
return m_paginator->page() > 0;
}
auto PackSearchModel::onPaginatorFetching() -> void
{
setState(Loading);
}
auto PackSearchModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
}
auto PackSearchModel::errorString() const -> QString
{
return m_errorString;
}
auto PackSearchModel::setErrorString(const QString &errorString) -> void
{
if (m_errorString == errorString)
{
return;
}
m_errorString = errorString;
emit errorStringChanged();
}
auto PackSearchModel::resultsPerPage() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->resultsPerPage();
}
return 0;
}
auto PackSearchModel::setResultsPerPage(qsizetype resultsPerPage) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, resultsPerPage]
{
qsizetype difference = resultsPerPage - m_paginator->resultsPerPage();
m_paginator->setResultsPerPage(resultsPerPage);
if(difference > 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage() - difference;
beginInsertRows
(
QModelIndex(),
firstIndex,
m_paginator->count() - 1
);
endInsertRows();
}
else if(difference < 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage();
beginRemoveRows
(
QModelIndex(),
firstIndex,
firstIndex - difference
);
endRemoveRows();
}
}
);
}
}
auto PackSearchModel::totalResults() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalResults();
}
return 0;
}
auto PackSearchModel::nextPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->next();
}
);
}
}
auto PackSearchModel::previousPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->previous();
}
);
}
}
auto PackSearchModel::query() const -> QString
{
if(m_paginator != nullptr)
{
return m_paginator->query();
}
return {};
}
auto PackSearchModel::setQuery(const QString &query) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, query]
{
m_paginator->setQuery(query);
}
);
}
}
qsizetype PackSearchModel::page() const
{
if(m_paginator != nullptr)
{
return m_paginator->page();
}
return 0;
}
auto PackSearchModel::totalPages() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalPages();
}
return 0;
}
+392
View File
@@ -0,0 +1,392 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef PackSearchModel_H
#define PackSearchModel_H
#include <QObject>
#include <QQmlEngine>
#include <QList>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QAbstractListModel>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "paginators/packsearchpaginator.h"
/**
* @brief The PackSearchModel class
*/
class KOMPLEX_EXPORT PackSearchModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
Loading,
Error
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UuidRole = Qt::UserRole + 1,
AuthorRole,
AuthorIdRole,
DescriptionRole,
NameRole,
ThumbnailRole,
CreatedDateRole,
PriceRole,
CurrencyRole,
DownloadCountRole,
TypeRole
};
Q_ENUM(DataRole)
explicit PackSearchModel(QObject *parent = nullptr);
~PackSearchModel();
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* User-friendly error string to be reported to the user
* @return
*/
auto errorString() const -> QString;
/**
* @brief resultsPerPage
* @return
*/
auto resultsPerPage() const -> qsizetype;
/**
* @brief setResultsPerPage
* @param resultsPerPage
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void;
/**
* @brief totalResults
* Total number of results available
* @return
*/
auto totalResults() const -> qsizetype;
/**
* @brief page
* @return
*/
auto page() const -> qsizetype;
/**
* @brief totalPages
* Total pages based on the current resultsPerPage
* @return
*/
auto totalPages() const -> qsizetype;
/**
* @brief nextPage
* Function for the QML frontend
*/
Q_INVOKABLE auto nextPage() -> void;
/**
* @brief previousPage
* Function for the QML frontend
*/
Q_INVOKABLE auto previousPage() -> void;
/**
* @brief query
* Current search query
* @return
*/
auto query() const -> QString;
/**
* @brief setQuery
* Sets the current search query
* @param query
*/
auto setQuery(const QString &query) -> void;
/**
* @brief hasNextPage
* Calculates if there are more pages based on the current page calculation
* @return
*/
auto hasNextPage() const -> bool;
/**
* @brief hasPreviousPage
* If page is greater than 1, returns true
* @return
*/
auto hasPreviousPage() const -> bool;
protected:
/**
* @brief onPaginatorFetching
* Sets current state to loading. Triggered when paginator's cache controller
* needs to fetch data from the remote endpoint.
*/
auto onPaginatorFetching() -> void;
/**
* @brief setErrorString
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
/**
* @brief setState
* @param state
*/
auto setState(State state) -> void;
/**
* @brief resetState
*/
auto resetState() -> void;
/**
* @brief resetDataModel
* Clears the data model and creates a new one if data exists
*/
auto resetDataModel() -> void;
signals:
/**
* @brief stateChanged
* Signaled when reported state changes
*/
auto stateChanged() -> void;
/**
* @brief errorStringChanged
* Signaled when reported error message changes
*/
auto errorStringChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto resultsPerPageChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto pageChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto totalResultsChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto totalPagesChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto queryChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* Data role map that connects PackSearchModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(AuthorRole),
QByteArray("author")
},
{
static_cast<int>(AuthorIdRole),
QByteArray("authorId")
},
{
static_cast<int>(DescriptionRole),
QByteArray("description")
},
{
static_cast<int>(NameRole),
QByteArray("name")
},
{
static_cast<int>(ThumbnailRole),
QByteArray("thumbnail")
},
{
static_cast<int>(CreatedDateRole),
QByteArray("createdDate")
},
{
static_cast<int>(PriceRole),
QByteArray("price")
},
{
static_cast<int>(CurrencyRole),
QByteArray("currency")
},
{
static_cast<int>(DownloadCountRole),
QByteArray("downloadCount")
},
{
static_cast<int>(TypeRole),
QByteArray("type")
}
};
State m_state = Idle;
QString m_errorString = QString();
PackSearchPaginator *m_paginator = nullptr;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
Q_PROPERTY(qsizetype resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qsizetype totalResults READ totalResults NOTIFY totalResultsChanged FINAL)
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
Q_PROPERTY(bool hasNextPage READ hasNextPage NOTIFY pageChanged FINAL)
Q_PROPERTY(bool hasPreviousPage READ hasPreviousPage NOTIFY pageChanged FINAL)
Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged FINAL)
};
Q_DECLARE_METATYPE(PackSearchModel)
#endif // PackSearchModel_H
@@ -34,11 +34,13 @@
class KOMPLEX_EXPORT FeaturedCubemapsPaginator : public WallpaperPaginator
{
public:
explicit FeaturedCubemapsPaginator() : WallpaperPaginator()
explicit FeaturedCubemapsPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/cubemaps/featured/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_CUBEMAPS_FEATURED)
);
controller()->setWindowSize(20);
}
};
@@ -29,16 +29,18 @@
#include <QJsonArray>
#include <QJsonObject>
#include "wallpaperpaginator.h"
#include "imagepaginator.h"
class KOMPLEX_EXPORT FeaturedImagesPaginator : public WallpaperPaginator
class KOMPLEX_EXPORT FeaturedImagesPaginator : public ImagePaginator
{
public:
explicit FeaturedImagesPaginator() : WallpaperPaginator()
explicit FeaturedImagesPaginator(QObject *parent = nullptr) : ImagePaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/images/featured/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_IMAGES_FEATURED)
);
controller()->setWindowSize(20);
}
};
@@ -34,11 +34,13 @@
class KOMPLEX_EXPORT FeaturedPacksPaginator : public WallpaperPaginator
{
public:
explicit FeaturedPacksPaginator() : WallpaperPaginator()
explicit FeaturedPacksPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/packs/featured/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_PACKS_FEATURED)
);
controller()->setWindowSize(32);
}
};
@@ -34,11 +34,13 @@
class KOMPLEX_EXPORT FeaturedShadersPaginator : public WallpaperPaginator
{
public:
explicit FeaturedShadersPaginator() : WallpaperPaginator()
explicit FeaturedShadersPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/shaders/featured/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_SHADERS_FEATURED)
);
controller()->setWindowSize(20);
}
};
@@ -16,8 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef SEARCHVIDEOSPAGINATOR_H
#define SEARCHVIDEOSPAGINATOR_H
#ifndef FEATUREDVIDEOSPAGINATOR_H
#define FEATUREDVIDEOSPAGINATOR_H
#include <QObject>
#include <QNetworkAccessManager>
@@ -29,17 +29,19 @@
#include <QJsonArray>
#include <QJsonObject>
#include "wallpaperpaginator.h"
#include "videopaginator.h"
class KOMPLEX_EXPORT SearchVideosPaginator : public WallpaperPaginator
class KOMPLEX_EXPORT FeaturedVideosPaginator : public VideoPaginator
{
public:
explicit SearchVideosPaginator() : WallpaperPaginator()
explicit FeaturedVideosPaginator(QObject *parent = nullptr) : VideoPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/videos/search/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_VIDEOS_FEATURED)
);
controller()->setWindowSize(20);
}
};
#endif // SEARCHVIDEOSPAGINATOR_H
#endif // FEATUREDVIDEOSPAGINATOR_H
@@ -0,0 +1,377 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef IMAGEPAGINATOR_H
#define IMAGEPAGINATOR_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonArray>
#include <QJsonObject>
#include "common/logging.h"
#include "common/paginator.h"
#include "common/imagecache.h"
#include "common/coreservices.h"
/**
* @brief The ImagePaginator class
* Most of the media endpoints for the Komplex API have the same data structure so
* child classes can make use of this generic controller where possible
*/
class KOMPLEX_EXPORT ImagePaginator : public Paginator<ImageCache>
{
Q_OBJECT
public:
explicit ImagePaginator(QObject *parent = nullptr) : Paginator<ImageCache>(parent)
{
SlidingCacheController<ImageCache> *controller = this->controller();
controller->setFetch(
std::bind(&ImagePaginator::fetch, this, std::placeholders::_1, std::placeholders::_2)
);
}
/**
* @brief uri
* URI of the API Endpoint. This is set by the child class
* @return
*/
[[nodiscard]]
auto uri() const -> QString
{
return m_uri;
}
signals:
/**
* @brief uriChanged
*/
auto uriChanged() -> void;
protected:
/**
* @brief fetch
* Used to fetch results from the API endpoint
* for the CacheController. It is intended to be passed
* to the Cache Controller not meant to be called directly.
* @param offset Offset index to start the results from
* @param limit Number of results to attempt to fetch
* @return FetchResult<ImageCache>
*/
[[nodiscard]]
auto fetch(
qsizetype offset,
qsizetype limit
) const -> FetchResult<ImageCache>
{
LOG_ERROR_X(m_uri.isEmpty(),
"ImagePaginator::fetch",
"Uri not set",
{}
);
if(queryable() && query().isEmpty())
{
return {};
}
QUrl url(
QString::fromUtf8("%1/%2/%3").arg(
KOMPLEX_API_HOST,
KOMPLEX_API_VERSION,
m_uri
)
);
QNetworkRequest request(url);
request.setHeaders(
QHttpHeaders::fromMultiMap(
{
{
QByteArray("query"),
query().toUtf8()
},
{
QByteArray("offset"),
QString::number(offset).toUtf8()
},
{
QByteArray("limit"),
QString::number(limit).toUtf8()
},
{
QByteArray("session_token"),
CoreServices::sessionToken()
}
}
)
);
QNetworkReply *reply = getNetworkReply(request);
if(reply == nullptr)
{
return {};
}
QJsonDocument document = getDocument(reply);
QJsonObject rootObject = document.object();
const QJsonArray resultsArray = rootObject.value(QString::fromUtf8("photos")).toArray();
QList<ImageCache> fetchedResults;
for(const auto result : resultsArray)
{
if(!result.isObject())
{
continue;
}
QJsonObject resultObject = result.toObject();
const QVariantMap sources = resultObject.value(QString::fromUtf8("src")).toObject().toVariantMap();
QMap<QString, QString> sourceMap;
QMapIterator<QString,QVariant> sourceIterator(sources);
QString original;
while(sourceIterator.hasNext())
{
sourceIterator.next();
if(sourceIterator.key().toLower() == QString::fromUtf8("original"))
{
original = sourceIterator.value().toString();
break;
}
}
QSize screenSize = CoreServices::screenSize();
QSize portraitSize(screenSize.height(),screenSize.width());
QSize landscapeSize(screenSize.width(),screenSize.height());
if(screenSize.height() > screenSize.width())
{
portraitSize = screenSize;
landscapeSize = QSize(screenSize.height(),screenSize.width());
}
sourceMap.clear();
sourceMap = QMap<QString,QString>
{
{
QString::fromUtf8("original"),
original
},
{
QString::fromUtf8("screen"),
QString::fromUtf8("%1?auto=compress&cs=tinysrgb&fit=crop&h=%2&w=%3").arg(
original,
QString::number(screenSize.height()),
QString::number(screenSize.width())
)
},
{
QString::fromUtf8("portrait"),
QString::fromUtf8("%1?auto=compress&cs=tinysrgb&fit=crop&h=%2&w=%3").arg(
original,
QString::number(portraitSize.height()),
QString::number(portraitSize.width())
)
},
{
QString::fromUtf8("landscape"),
QString::fromUtf8("%1?auto=compress&cs=tinysrgb&fit=crop&h=%2&w=%3").arg(
original,
QString::number(landscapeSize.height()),
QString::number(landscapeSize.width())
)
},
{
QString::fromUtf8("backgroundPortrait"),
QString::fromUtf8("%1?auto=compress&cs=tinysrgb&fit=crop&h=%2&w=%3").arg(
original,
QString::number(portraitSize.height() / 2),
QString::number(portraitSize.width() / 2)
)
},
{
QString::fromUtf8("backgroundLandscape"),
QString::fromUtf8("%1?auto=compress&cs=tinysrgb&fit=crop&h=%2&w=%3").arg(
original,
QString::number(landscapeSize.height() / 2),
QString::number(landscapeSize.width() / 2)
)
},
{
QString::fromUtf8("thumbnail"),
QString::fromUtf8("%1?auto=compress&cs=tinysrgb&fit=crop&h=144&w=256%3").arg(
original
)
},
{
QString::fromUtf8("largeThumbnail"),
QString::fromUtf8("%1?auto=compress&cs=tinysrgb&fit=crop&h=450&w=800%3").arg(
original
)
}
};
QMap<QString, QString> sizeMap =
{
{
QString::fromUtf8("original"),
QString()
},
{
QString::fromUtf8("screen"),
QString::fromUtf8("%1x%2").arg(
QString::number(screenSize.width()),
QString::number(screenSize.height())
)
},
{
QString::fromUtf8("portrait"),
QString::fromUtf8("%1x%2").arg(
QString::number(portraitSize.width()),
QString::number(portraitSize.height())
)
},
{
QString::fromUtf8("landscape"),
QString::fromUtf8("%1x%2").arg(
QString::number(landscapeSize.width()),
QString::number(landscapeSize.height())
)
}
};
fetchedResults.append(
{
resultObject.value(QString::fromUtf8("alt")).toString(),
resultObject.value(QString::fromUtf8("avg_color")).toString().toUtf8(),
resultObject.value(QString::fromUtf8("height")).toInteger(),
resultObject.value(QString::fromUtf8("width")).toInteger(),
resultObject.value(QString::fromUtf8("id")).toInteger(),
resultObject.value(QString::fromUtf8("liked")).toBool(),
resultObject.value(QString::fromUtf8("photographer")).toString(),
resultObject.value(QString::fromUtf8("photographer_url")).toString(),
resultObject.value(QString::fromUtf8("photographer_id")).toInteger(),
std::move(sourceMap),
std::move(sizeMap),
resultObject.value(QString::fromUtf8("url")).toString()
}
);
}
FetchResult<ImageCache> result
{
static_cast<qsizetype>(rootObject.value(QString::fromUtf8("total_results")).toInteger()),
fetchedResults.count(),
std::move(fetchedResults)
};
return std::move(result);
}
/**
* @brief getNetworkReply
* Processes the request and blocks until completion.
* @param request
* @return
*/
[[nodiscard]]
auto getNetworkReply(const QNetworkRequest &request) const -> QNetworkReply*
{
QEventLoop loop;
QWeakPointer<QNetworkAccessManager> managerReference = CoreServices::networkAccessManager();
QSharedPointer<QNetworkAccessManager> manager = managerReference.toStrongRef();
LOG_ERROR_X(!manager,
"NewestPacksPaginator::getNetworkReply",
"Network manager reference has already been deleted",
nullptr
);
QNetworkReply *reply = manager->post(request, nullptr);
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
QObject::connect(reply, &QNetworkReply::errorOccurred, &loop,
[&loop](QNetworkReply::NetworkError error) -> void
{
loop.quit();
}
);
if(!reply->isFinished())
{
loop.exec();
}
manager.clear();
LOG_ERROR_X(reply->error() != QNetworkReply::NoError,
"NewestPacksPaginator::getNetworkReply",
reply->errorString().toStdString().c_str(),
nullptr
);
return reply;
}
/**
* @brief setUri
* Sets the API Endpoint URI to fetch from
* @param uri
*/
auto setUri(const QString &uri) -> void
{
if(uri == m_uri)
{
return;
}
m_uri = uri;
Q_EMIT uriChanged();
}
private:
/**
* @brief m_uri
* API Endpoint URI
*/
QString m_uri;
/**
* @brief s_sizeExpression
* Regular expression used to extract size data from the url
*/
inline static QRegularExpression s_sizeExpression = QRegularExpression
(
QString::fromUtf8("[h]\\=\\d{1,}\\&[w]\\=\\d{1,}")
);
};
#endif // IMAGEPAGINATOR_H
@@ -0,0 +1,49 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef IMAGESEARCHPAGINATOR_H
#define IMAGESEARCHPAGINATOR_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonArray>
#include <QJsonObject>
#include "imagepaginator.h"
#include "common/komplex_global.h"
class KOMPLEX_EXPORT ImageSearchPaginator : public ImagePaginator
{
public:
explicit ImageSearchPaginator(QObject *parent = nullptr) : ImagePaginator(parent)
{
setUri(
QString::fromUtf8(KOMPLEX_ENDPOINT_IMAGES_SEARCH)
);
setQueryable(true);
}
};
#endif // IMAGESEARCHPAGINATOR_H
@@ -34,10 +34,10 @@
class KOMPLEX_EXPORT NewestCubemapsPaginator : public WallpaperPaginator
{
public:
explicit NewestCubemapsPaginator() : WallpaperPaginator()
explicit NewestCubemapsPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/cubemaps/newest/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_CUBEMAPS_NEWEST)
);
}
};
@@ -34,11 +34,13 @@
class KOMPLEX_EXPORT NewestPacksPaginator : public WallpaperPaginator
{
public:
explicit NewestPacksPaginator() : WallpaperPaginator()
explicit NewestPacksPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/packs/newest/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_PACKS_NEWEST)
);
controller()->setWindowSize(20);
}
};
@@ -34,10 +34,10 @@
class KOMPLEX_EXPORT NewestShadersPaginator : public WallpaperPaginator
{
public:
explicit NewestShadersPaginator() : WallpaperPaginator()
explicit NewestShadersPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/shaders/newest/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_SHADERS_NEWEST)
);
}
};
@@ -16,8 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef SEARCHIMAGESPAGINATOR_H
#define SEARCHIMAGESPAGINATOR_H
#ifndef PACKSEARCHPAGINATOR_H
#define PACKSEARCHPAGINATOR_H
#include <QObject>
#include <QNetworkAccessManager>
@@ -31,15 +31,17 @@
#include "wallpaperpaginator.h"
class KOMPLEX_EXPORT SearchImagesPaginator : public WallpaperPaginator
class KOMPLEX_EXPORT PackSearchPaginator : public WallpaperPaginator
{
public:
explicit SearchImagesPaginator() : WallpaperPaginator()
explicit PackSearchPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/images/search/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_PACKS_SEARCH)
);
setQueryable(true);
}
};
#endif // SEARCHIMAGESPAGINATOR_H
#endif // PACKSEARCHPAGINATOR_H
@@ -34,10 +34,10 @@
class KOMPLEX_EXPORT SearchCubemapsPaginator : public WallpaperPaginator
{
public:
explicit SearchCubemapsPaginator() : WallpaperPaginator()
explicit SearchCubemapsPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/cubemaps/search/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_CUBEMAPS_SEARCH)
);
}
};
@@ -34,10 +34,10 @@
class KOMPLEX_EXPORT SearchShadersPaginator : public WallpaperPaginator
{
public:
explicit SearchShadersPaginator() : WallpaperPaginator()
explicit SearchShadersPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/shaders/search/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_SHADERS_SEARCH)
);
}
};
@@ -0,0 +1,288 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef VIDEOPAGINATOR_H
#define VIDEOPAGINATOR_H
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QJsonDocument>
#include <QJsonParseError>
#include <QJsonArray>
#include <QJsonObject>
#include "common/logging.h"
#include "common/paginator.h"
#include "common/videocache.h"
#include "common/coreservices.h"
/**
* @brief The VideoPaginator class
* Most of the media endpoints for the Komplex API have the same data structure so
* child classes can make use of this generic controller where possible
*/
class KOMPLEX_EXPORT VideoPaginator : public Paginator<VideoCache>
{
Q_OBJECT
public:
explicit VideoPaginator(QObject *parent = nullptr) : Paginator<VideoCache>(parent)
{
SlidingCacheController<VideoCache> *controller = this->controller();
controller->setFetch(
std::bind(&VideoPaginator::fetch, this, std::placeholders::_1, std::placeholders::_2)
);
}
/**
* @brief uri
* URI of the API Endpoint. This is set by the child class
* @return
*/
[[nodiscard]]
auto uri() const -> QString
{
return m_uri;
}
signals:
/**
* @brief uriChanged
*/
auto uriChanged() -> void;
protected:
/**
* @brief fetch
* Used to fetch results from the API endpoint
* for the CacheController. It is intended to be passed
* to the Cache Controller not meant to be called directly.
* @param offset Offset index to start the results from
* @param limit Number of results to attempt to fetch
* @return FetchResult<ImageCache>
*/
[[nodiscard]]
auto fetch(
qsizetype offset,
qsizetype limit
) const -> FetchResult<VideoCache>
{
LOG_ERROR_X(m_uri.isEmpty(),
"VideoPaginator::fetch",
"Uri not set",
{}
);
if(queryable() && query().isEmpty())
{
return {};
}
QUrl url(
QString::fromUtf8("%1/%2/%3").arg(
KOMPLEX_API_HOST,
KOMPLEX_API_VERSION,
m_uri
)
);
QNetworkRequest request(url);
request.setHeaders(
QHttpHeaders::fromMultiMap(
{
{
QByteArray("query"),
query().toUtf8()
},
{
QByteArray("offset"),
QString::number(offset).toUtf8()
},
{
QByteArray("limit"),
QString::number(limit).toUtf8()
},
{
QByteArray("session_token"),
CoreServices::sessionToken()
}
}
)
);
QNetworkReply *reply = getNetworkReply(request);
if(reply == nullptr)
{
return {};
}
QJsonDocument document = getDocument(reply);
QJsonObject rootObject = document.object();
const QJsonArray resultsArray = rootObject.value(QString::fromUtf8("videos")).toArray();
QList<VideoCache> fetchedResults;
for(const QJsonValue &result : resultsArray)
{
if(!result.isObject())
{
continue;
}
QJsonObject resultObject = result.toObject();
QJsonObject userObject = resultObject.value(QString::fromUtf8("user")).toObject();
QList<VideoEntry> videos;
const QJsonArray videosArray = resultObject.value(QString::fromUtf8("video_files")).toArray();
for(const QJsonValue &entry : videosArray)
{
if(!entry.isObject())
{
continue;
}
QJsonObject videoObject = entry.toObject();
videos.append
(
{
videoObject.value(QString::fromUtf8("file_type")).toString(),
videoObject.value(QString::fromUtf8("fps")).toInteger(),
videoObject.value(QString::fromUtf8("height")).toInteger(),
videoObject.value(QString::fromUtf8("width")).toInteger(),
videoObject.value(QString::fromUtf8("size")).toInteger(),
videoObject.value(QString::fromUtf8("id")).toInteger(),
videoObject.value(QString::fromUtf8("link")).toString(),
videoObject.value(QString::fromUtf8("quality")).toString()
}
);
}
fetchedResults.append
(
{
resultObject.value(QString::fromUtf8("avg_color")).toString(),
resultObject.value(QString::fromUtf8("duration")).toInteger(),
resultObject.value(QString::fromUtf8("height")).toInteger(),
resultObject.value(QString::fromUtf8("width")).toInteger(),
resultObject.value(QString::fromUtf8("id")).toInteger(),
resultObject.value(QString::fromUtf8("image")).toString(),
resultObject.value(QString::fromUtf8("url")).toString(),
userObject.value(QString::fromUtf8("name")).toString(),
userObject.value(QString::fromUtf8("url")).toString(),
userObject.value(QString::fromUtf8("id")).toInteger(),
std::move(videos)
}
);
}
FetchResult<VideoCache> result
{
static_cast<qsizetype>(rootObject.value(QString::fromUtf8("total_results")).toInteger()),
fetchedResults.count(),
std::move(fetchedResults)
};
return std::move(result);
}
/**
* @brief getNetworkReply
* Processes the request and blocks until completion.
* @param request
* @return
*/
[[nodiscard]]
auto getNetworkReply(const QNetworkRequest &request) const -> QNetworkReply*
{
QEventLoop loop;
QWeakPointer<QNetworkAccessManager> managerReference = CoreServices::networkAccessManager();
QSharedPointer<QNetworkAccessManager> manager = managerReference.toStrongRef();
LOG_ERROR_X(!manager,
"NewestPacksPaginator::getNetworkReply",
"Network manager reference has already been deleted",
nullptr
);
QNetworkReply *reply = manager->post(request, nullptr);
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
QObject::connect
(
reply,
&QNetworkReply::errorOccurred,
&loop,
[&loop](QNetworkReply::NetworkError error) -> void
{
loop.quit();
}
);
if(!reply->isFinished())
{
loop.exec();
}
LOG_ERROR_X(reply->error() != QNetworkReply::NoError,
"NewestPacksPaginator::getNetworkReply",
reply->errorString().toStdString().c_str(),
nullptr
);
return reply;
}
/**
* @brief setUri
* Sets the API Endpoint URI to fetch from
* @param uri
*/
auto setUri(const QString &uri) -> void
{
if(uri == m_uri)
{
return;
}
m_uri = uri;
Q_EMIT uriChanged();
}
private:
/**
* @brief m_uri
* API Endpoint URI
*/
QString m_uri;
/**
* @brief m_query
* The query string used in fetch operations
*/
QString m_query;
};
#endif // VIDEOPAGINATOR_H
@@ -16,8 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef SEARCHPACKSPAGINATOR_H
#define SEARCHPACKSPAGINATOR_H
#ifndef VIDEOSEARCHPAGINATOR_H
#define VIDEOSEARCHPAGINATOR_H
#include <QObject>
#include <QNetworkAccessManager>
@@ -29,17 +29,19 @@
#include <QJsonArray>
#include <QJsonObject>
#include "wallpaperpaginator.h"
#include "videopaginator.h"
class KOMPLEX_EXPORT SearchPacksPaginator : public WallpaperPaginator
class KOMPLEX_EXPORT VideoSearchPaginator : public VideoPaginator
{
public:
explicit SearchPacksPaginator() : WallpaperPaginator()
explicit VideoSearchPaginator(QObject *parent = nullptr) : VideoPaginator(parent)
{
setUri(
QString::fromUtf8("%1/v2/packs/search/").arg(KOMPLEX_API_HOST)
QString::fromUtf8(KOMPLEX_ENDPOINT_VIDEOS_SEARCH)
);
setQueryable(true);
}
};
#endif // SEARCHPACKSPAGINATOR_H
#endif // VIDEOSEARCHPAGINATOR_H
@@ -43,7 +43,7 @@ class KOMPLEX_EXPORT WallpaperPaginator : public Paginator<WallpaperCache>
{
Q_OBJECT
public:
explicit WallpaperPaginator() : Paginator<WallpaperCache>()
explicit WallpaperPaginator(QObject *parent = nullptr) : Paginator<WallpaperCache>(parent)
{
SlidingCacheController<WallpaperCache> *controller = this->controller();
controller->setFetch(
@@ -62,35 +62,35 @@ public:
return m_uri;
}
/**
* @brief query
* Current query string, if the API Endpoint supports queries
* @return
*/
[[nodiscard]]
auto query() const -> QString
{
return m_query;
}
// /**
// * @brief query
// * Current query string, if the API Endpoint supports queries
// * @return
// */
// [[nodiscard]]
// auto query() const -> QString
// {
// return m_query;
// }
/**
* @brief setQuery
* Sets the new query string and updates the controller
* @param query
*/
auto setQuery(const QString &query) -> void
{
if(query == m_query)
{
return;
}
// /**
// * @brief setQuery
// * Sets the new query string and updates the controller
// * @param query
// */
// auto setQuery(const QString &query) -> void
// {
// if(query == m_query)
// {
// return;
// }
m_query = query;
Q_EMIT queryChanged();
// m_query = query;
// Q_EMIT queryChanged();
reset();
setOffset(0);
}
// reset();
// setOffset(0);
// }
signals:
/**
@@ -98,11 +98,6 @@ signals:
*/
auto uriChanged() -> void;
/**
* @brief queryChanged
*/
auto queryChanged() -> void;
protected:
/**
* @brief fetch
@@ -125,26 +120,37 @@ protected:
{}
);
QUrl url(m_uri);
if(queryable() && query().isEmpty())
{
return {};
}
QUrl url(
QString::fromUtf8("%1/%2/%3").arg(
KOMPLEX_API_HOST,
KOMPLEX_API_VERSION,
m_uri
)
);
QNetworkRequest request(url);
request.setHeaders(
QHttpHeaders::fromMultiMap(
{
{
QByteArray("Query"),
m_query.toUtf8()
QByteArray("query"),
query().toUtf8()
},
{
QByteArray("Offset"),
QByteArray("offset"),
QString::number(offset).toUtf8()
},
{
QByteArray("Limit"),
QByteArray("limit"),
QString::number(limit).toUtf8()
},
{
QByteArray("SessionToken"),
QByteArray("session_token"),
CoreServices::sessionToken()
}
}
@@ -176,14 +182,15 @@ protected:
fetchedResults.append(
{
resultObject.value(QString::fromUtf8("uri")).toString(),
resultObject.value(QString::fromUtf8("name")).toString(),
resultObject.value(QString::fromUtf8("uuid")).toString(),
resultObject.value(QString::fromUtf8("title")).toString(),
resultObject.value(QString::fromUtf8("author")).toString(),
resultObject.value(QString::fromUtf8("authorId")).toString(),
resultObject.value(QString::fromUtf8("author_id")).toString(),
resultObject.value(QString::fromUtf8("description")).toString(),
resultObject.value(QString::fromUtf8("thumbnail")).toString(),
QDateTime::fromString(
resultObject.value(QString::fromUtf8("createdDate")).toString()
resultObject.value(QString::fromUtf8("creation")).toString(),
QString::fromUtf8("yyyy-MM-dd HH:mm:ss")
),
resultObject.value(QString::fromUtf8("price")).toDouble(),
resultObject.value(QString::fromUtf8("currency")).toString(),
@@ -197,12 +204,14 @@ protected:
);
}
return
FetchResult<WallpaperCache> result
{
static_cast<qsizetype>(rootObject.value(QString::fromUtf8("total_results")).toInteger()),
fetchedResults.count(),
std::move(fetchedResults)
};
return std::move(result);
}
/**
@@ -257,8 +266,9 @@ protected:
[[nodiscard]]
auto getDocument(QNetworkReply *reply) const -> QJsonDocument
{
QByteArray data = reply->readAll();
QJsonParseError documentError;
QJsonDocument document = QJsonDocument::fromJson(reply->readAll(), &documentError);
QJsonDocument document = QJsonDocument::fromJson(data, &documentError);
LOG_ERROR_X(documentError.error != QJsonParseError::NoError,
"NewestPacksPaginator::getDocument",
@@ -293,11 +303,11 @@ private:
*/
QString m_uri;
/**
* @brief m_query
* The query string used in fetch operations
*/
QString m_query;
// /**
// * @brief m_query
// * The query string used in fetch operations
// */
// QString m_query;
};
#endif // WALLPAPERPAGINATOR_H
+1 -1
View File
@@ -9,7 +9,7 @@
SettingsManager::SettingsManager(QObject *parent) : QObject(parent)
{
m_homeLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation).at(0);
m_homeLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
m_shaderPackLocation = m_homeLocation + QString("/.local/share/komplex/packs");
m_configLocation = m_homeLocation + QString("/.config/plasma-org.kde.plasma.desktop-appletsrc");
+203
View File
@@ -0,0 +1,203 @@
#include "videoitemmodel.h"
VideoItemModel::VideoItemModel(QObject *parent) : QAbstractListModel{parent}
{
QObject::connect(
this,
&VideoItemModel::dataEntryChanged,
this,
&VideoItemModel::resetDataModel
);
}
auto VideoItemModel::rowCount(const QModelIndex &) const -> int
{
return m_dataEntry.files.count();
}
auto VideoItemModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(!boundaryCheck(index.row()))
{
return {};
}
VideoEntry dataPoint = m_dataEntry.files.at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UuidRole:
data = dataPoint.id;
break;
case UrlRole:
data = dataPoint.url;
break;
case HeightRole:
data = dataPoint.height;
break;
case WidthRole:
data = dataPoint.width;
break;
case FileTypeRole:
data = dataPoint.type;
break;
case FpsRole:
data = dataPoint.fps;
break;
case SizeRole:
data = dataPoint.size;
break;
case QualityRole:
data = dataPoint.quality;
break;
case TextRole:
data = friendlyText(dataPoint);
break;
}
return data;
}
auto VideoItemModel::index(int row, int column, const QModelIndex &parent) const -> QModelIndex
{
Q_UNUSED(parent)
if(!boundaryCheck(row))
{
return {};
}
return createIndex(row, column, &m_dataEntry.files[row]);
}
auto VideoItemModel::columnCount(const QModelIndex &) const -> int
{
return 0;
}
auto VideoItemModel::parent(const QModelIndex &) const -> QModelIndex
{
return {};
}
auto VideoItemModel::setData(const QModelIndex &, const QVariant &, int) -> bool
{
return false;
}
auto VideoItemModel::state() const -> VideoItemModel::State
{
return m_state;
}
auto VideoItemModel::setState(State state) -> void
{
if (m_state == state)
{
return;
}
m_state = state;
emit stateChanged();
}
auto VideoItemModel::resetState() -> void
{
setState(Idle);
}
auto VideoItemModel::resetDataModel() -> void
{
if(m_lastCount > 0)
{
//invalidate previous model data
beginRemoveRows(QModelIndex(), 0, m_lastCount - 1);
endRemoveRows();
}
m_lastCount = m_dataEntry.files.count();
//signal new data
beginInsertRows(QModelIndex(), 0, m_dataEntry.files.count() - 1);
endInsertRows();
}
auto VideoItemModel::boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || index >= m_dataEntry.files.count())
{
return false;
}
return true;
}
auto VideoItemModel::setDataEntry(const VideoCache &entry) -> void
{
if(entry == m_dataEntry)
{
return;
}
m_dataEntry = entry;
Q_EMIT dataEntryChanged();
}
auto VideoItemModel::friendlyText(const VideoEntry &video) const -> QString
{
qint64 size = video.size;
qint64 sizeIndex = 0;
while(size >= 1000)
{
size = static_cast<qint64>(std::ceil(static_cast<qreal>(size) / 1000));
++sizeIndex;
}
if(!video.quality.isEmpty())
{
return QString("%1/%2 [%3x%4 %5FPS] (%6%7)").arg
(
video.quality.toUpper(),
video.type.toUpper(),
QString::number(video.width),
QString::number(video.height),
QString::number(video.fps),
QString::number(size),
m_sizeTexts[sizeIndex]
);
}
return QString("%1 [%2x%3 %4FPS] (%5%6)").arg
(
video.type.toUpper(),
QString::number(video.width),
QString::number(video.height),
QString::number(video.fps),
QString::number(size),
m_sizeTexts[sizeIndex]
);
}
auto VideoItemModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
}
auto VideoItemModel::errorString() const -> QString
{
return m_errorString;
}
auto VideoItemModel::setErrorString(const QString &errorString) -> void
{
if (m_errorString == errorString)
{
return;
}
m_errorString = errorString;
emit errorStringChanged();
}
+294
View File
@@ -0,0 +1,294 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef VideoItemModel_H
#define VideoItemModel_H
#include <QObject>
#include <QQmlEngine>
#include <QList>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QAbstractListModel>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "common/komplex_global.h"
#include "common/videocache.h"
/**
* @brief The VideoItemModel class
*/
class KOMPLEX_EXPORT VideoItemModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
Loading,
Error
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UuidRole = Qt::UserRole + 1,
FileTypeRole,
FpsRole,
HeightRole,
WidthRole,
SizeRole,
UrlRole,
QualityRole,
TextRole
};
Q_ENUM(DataRole)
explicit VideoItemModel(QObject *parent = nullptr);
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* User-friendly error string to be reported to the user
* @return
*/
auto errorString() const -> QString;
/**
* @brief setDataEntry
* Set the dataEntry from the Search or List model
* @param entry
*/
auto setDataEntry(const VideoCache &entry) -> void;
/**
* @brief friendlyText
* Generates the friendly text for comboboxes and the like
* @param video
* @return
*/
auto friendlyText(const VideoEntry &video) const -> QString;
protected:
/**
* @brief setErrorString
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
/**
* @brief setState
* @param state
*/
auto setState(State state) -> void;
/**
* @brief resetState
*/
auto resetState() -> void;
/**
* @brief resetDataModel
* Clears the data model and creates a new one if data exists
*/
auto resetDataModel() -> void;
signals:
auto dataEntryChanged() -> void;
/**
* @brief stateChanged
* Signaled when reported state changes
*/
auto stateChanged() -> void;
/**
* @brief errorStringChanged
* Signaled when reported error message changes
*/
auto errorStringChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* Size texts used in friendlyText()
*/
QStringList m_sizeTexts
{
QString::fromUtf8("B"),
QString::fromUtf8("KB"),
QString::fromUtf8("MB"),
QString::fromUtf8("GB")
};
/**
* Data role map that connects VideoItemModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(FileTypeRole),
QByteArray("fileType")
},
{
static_cast<int>(FpsRole),
QByteArray("fps")
},
{
static_cast<int>(HeightRole),
QByteArray("height")
},
{
static_cast<int>(WidthRole),
QByteArray("width")
},
{
static_cast<int>(SizeRole),
QByteArray("size")
},
{
static_cast<int>(UrlRole),
QByteArray("url")
},
{
static_cast<int>(QualityRole),
QByteArray("quality")
},
{
static_cast<int>(TextRole),
QByteArray("text")
}
};
State m_state = Idle;
QString m_errorString = QString();
VideoCache m_dataEntry;
qint64 m_lastCount = 0;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
};
Q_DECLARE_METATYPE(VideoItemModel)
#endif // VideoItemModel_H
+393
View File
@@ -0,0 +1,393 @@
#include "videosearchmodel.h"
VideoSearchModel::VideoSearchModel(QObject *parent) : QAbstractListModel{parent}
{
m_itemModel = new VideoItemModel(this);
m_paginator = new VideoSearchPaginator(this);
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
QObject::connect(
notifier,
&PaginationNotifier::resultsPerPageChanged,
this,
&VideoSearchModel::resultsPerPageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalResultsChanged,
this,
&VideoSearchModel::totalResultsChanged
);
QObject::connect(
notifier,
&PaginationNotifier::totalPagesChanged,
this,
&VideoSearchModel::totalPagesChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&VideoSearchModel::pageChanged
);
QObject::connect(
notifier,
&PaginationNotifier::pageChanged,
this,
&VideoSearchModel::resetDataModel
);
QObject::connect(
notifier,
&PaginationNotifier::fetchComplete,
this,
&VideoSearchModel::resetState
);
QObject::connect(
notifier,
&PaginationNotifier::fetching,
this,
&VideoSearchModel::onPaginatorFetching
);
QObject::connect(
m_paginator,
&VideoSearchPaginator::queryChanged,
this,
&VideoSearchModel::queryChanged
);
}
VideoSearchModel::~VideoSearchModel()
{
if(m_paginator)
{
delete m_paginator;
}
if(m_itemModel)
{
delete m_itemModel;
}
}
auto VideoSearchModel::rowCount(const QModelIndex &) const -> int
{
if(m_paginator != nullptr)
{
return m_paginator->count();
}
return 0;
}
auto VideoSearchModel::data(const QModelIndex &index, int role) const -> QVariant
{
if(!boundaryCheck(index.row()))
{
return {};
}
VideoCache dataPoint = m_paginator->at(index.row());
QVariant data;
switch(static_cast<DataRole>(role))
{
case UuidRole:
data = dataPoint.id;
break;
case AuthorRole:
data = dataPoint.author;
break;
case AuthorIdRole:
data = dataPoint.authorId;
break;
case AuthorUrlRole:
data = dataPoint.authorUrl;
break;
case DurationRole:
data = dataPoint.duration;
break;
case ThumbnailRole:
data = dataPoint.thumbnail;
break;
case UrlRole:
data = dataPoint.url;
break;
case HeightRole:
data = dataPoint.height;
break;
case WidthRole:
data = dataPoint.width;
break;
}
return data;
}
auto VideoSearchModel::index(int row, int column, const QModelIndex &parent) const -> QModelIndex
{
Q_UNUSED(parent)
if(!boundaryCheck(row))
{
return {};
}
return createIndex(row, column, &m_paginator[row]);
}
auto VideoSearchModel::columnCount(const QModelIndex &) const -> int
{
return 0;
}
auto VideoSearchModel::parent(const QModelIndex &) const -> QModelIndex
{
return {};
}
auto VideoSearchModel::setData(const QModelIndex &, const QVariant &, int) -> bool
{
return false;
}
auto VideoSearchModel::state() const -> VideoSearchModel::State
{
return m_state;
}
auto VideoSearchModel::setState(State state) -> void
{
if (m_state == state)
{
return;
}
m_state = state;
emit stateChanged();
}
auto VideoSearchModel::resetState() -> void
{
setState(Idle);
}
auto VideoSearchModel::resetDataModel() -> void
{
//invalidate previous model data
if(m_lastCount > 0)
{
beginRemoveRows(QModelIndex(), 0, m_lastCount - 1);
endRemoveRows();
}
m_lastCount = m_paginator->count();
//signal new data
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
endInsertRows();
}
auto VideoSearchModel::setItem(qint64 index) -> bool
{
if(!boundaryCheck(index))
{
return false;
}
m_itemModel->setDataEntry(m_paginator->at(index));
return true;
}
auto VideoSearchModel::boundaryCheck(qsizetype index) const -> bool
{
if(index < 0 || m_paginator == nullptr || index >= m_paginator->count())
{
return false;
}
return true;
}
auto VideoSearchModel::itemModel() const -> VideoItemModel*
{
return m_itemModel;
}
auto VideoSearchModel::hasNextPage() const -> bool
{
return m_paginator->page() < m_paginator->totalPages();
}
auto VideoSearchModel::hasPreviousPage() const -> bool
{
return m_paginator->page() > 0;
}
auto VideoSearchModel::onPaginatorFetching() -> void
{
setState(Loading);
}
auto VideoSearchModel::roleNames() const -> QHash<int, QByteArray>
{
return m_dataRoles;
}
auto VideoSearchModel::errorString() const -> QString
{
return m_errorString;
}
auto VideoSearchModel::setErrorString(const QString &errorString) -> void
{
if (m_errorString == errorString)
{
return;
}
m_errorString = errorString;
emit errorStringChanged();
}
auto VideoSearchModel::resultsPerPage() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->resultsPerPage();
}
return 0;
}
auto VideoSearchModel::setResultsPerPage(qsizetype resultsPerPage) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, resultsPerPage]
{
qsizetype difference = resultsPerPage - m_paginator->resultsPerPage();
m_paginator->setResultsPerPage(resultsPerPage);
m_lastCount = m_paginator->resultsPerPage();
if(difference > 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage() - difference;
beginInsertRows
(
QModelIndex(),
firstIndex,
m_paginator->count() - 1
);
endInsertRows();
}
else if(difference < 0)
{
qsizetype firstIndex = m_paginator->resultsPerPage();
beginRemoveRows
(
QModelIndex(),
firstIndex,
firstIndex - difference
);
endRemoveRows();
}
}
);
}
}
auto VideoSearchModel::totalResults() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalResults();
}
return 0;
}
auto VideoSearchModel::nextPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->next();
}
);
}
}
auto VideoSearchModel::previousPage() -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this]
{
m_paginator->previous();
}
);
}
}
auto VideoSearchModel::query() const -> QString
{
if(m_paginator != nullptr)
{
return m_paginator->query();
}
return {};
}
auto VideoSearchModel::setQuery(const QString &query) -> void
{
if(m_paginator != nullptr)
{
QFuture<void> future = QtConcurrent::run
(
[this, query]
{
m_paginator->setQuery(query);
}
);
}
}
qsizetype VideoSearchModel::page() const
{
if(m_paginator != nullptr)
{
return m_paginator->page();
}
return 0;
}
auto VideoSearchModel::totalPages() const -> qsizetype
{
if(m_paginator != nullptr)
{
return m_paginator->totalPages();
}
return 0;
}
+396
View File
@@ -0,0 +1,396 @@
/*
* Komplex Wallpaper Engine
* Copyright (C) 2026 @DigitalArtifex
* https://digitalartifex.dev - https://github.com/DigitalArtifex
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>
*/
#ifndef VideoSearchModel_H
#define VideoSearchModel_H
#include <QObject>
#include <QQmlEngine>
#include <QList>
#include <QStandardPaths>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QJsonParseError>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QAbstractListModel>
#include <QProcess>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QEventLoop>
#include <QtConcurrent/QtConcurrentRun>
#include "paginators/videosearchpaginator.h"
#include "videoitemmodel.h"
/**
* @brief The VideoSearchModel class
*/
class KOMPLEX_EXPORT VideoSearchModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
/**
* @brief Used to control the UI state
*/
enum State
{
Idle,
Loading,
Error
};
Q_ENUM(State)
/**
* @brief Data roles used by the view to request data
*/
enum DataRole {
UuidRole = Qt::UserRole + 1,
AuthorRole,
AuthorIdRole,
AuthorUrlRole,
DurationRole,
ThumbnailRole,
UrlRole,
HeightRole,
WidthRole
};
Q_ENUM(DataRole)
explicit VideoSearchModel(QObject *parent = nullptr);
~VideoSearchModel();
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
/**
* @brief data
* Used by the view to pull data from the model.
* Required by QAbstractListModel
* @param index
* @param role
* @return
*/
auto data(
const QModelIndex &index,
int role = Qt::DisplayRole
) const -> QVariant override;
/**
* @brief index
* Used by the view to create an index for the data point.
* Required by QAbstractListModel
* @param row
* @param column
* @param parent
* @return
*/
auto index(
int row,
int column,
const QModelIndex &parent = QModelIndex()
) const -> QModelIndex override;
/**
* @brief columnCount
* Required by QAbstractListModel, but just returns 0
* since we dont use cols
* @param parent
* @return
*/
auto columnCount(
const QModelIndex &parent = QModelIndex()
) const -> int override;
/**
* @brief parent
* @param index
* @return
*/
auto parent(const QModelIndex &index) const -> QModelIndex override;
/**
* @brief setData
* Required by QAbstractListModel but not used
* @param index
* @param value
* @param role
* @return true always
*/
auto setData(
const QModelIndex &index,
const QVariant &value,
int role = Qt::EditRole
) -> bool override;
/**
* @brief state
* Current Model State
* @return
*/
auto state() const -> State;
/**
* @brief roleNames
* Used to tell the view what data roles are available
* and their QML friendly names
* @return
*/
auto roleNames() const -> QHash<int, QByteArray> override;
/**
* @brief errorString
* User-friendly error string to be reported to the user
* @return
*/
auto errorString() const -> QString;
/**
* @brief resultsPerPage
* @return
*/
auto resultsPerPage() const -> qsizetype;
/**
* @brief setResultsPerPage
* @param resultsPerPage
*/
auto setResultsPerPage(qsizetype resultsPerPage) -> void;
/**
* @brief totalResults
* Total number of results available
* @return
*/
auto totalResults() const -> qsizetype;
/**
* @brief page
* @return
*/
auto page() const -> qsizetype;
/**
* @brief totalPages
* Total pages based on the current resultsPerPage
* @return
*/
auto totalPages() const -> qsizetype;
/**
* @brief nextPage
* Function for the QML frontend
*/
Q_INVOKABLE auto nextPage() -> void;
/**
* @brief previousPage
* Function for the QML frontend
*/
Q_INVOKABLE auto previousPage() -> void;
/**
* @brief query
* Current search query
* @return
*/
auto query() const -> QString;
/**
* @brief setQuery
* Sets the current search query
* @param query
*/
auto setQuery(const QString &query) -> void;
/**
* @brief hasNextPage
* Calculates if there are more pages based on the current page calculation
* @return
*/
auto hasNextPage() const -> bool;
/**
* @brief hasPreviousPage
* If page is greater than 1, returns true
* @return
*/
auto hasPreviousPage() const -> bool;
/**
* @brief setItem
* Sets the current itemModel to the item at the specified index
* @param index
* @return
*/
Q_INVOKABLE auto setItem(qint64 index) -> bool;
VideoItemModel *itemModel() const;
protected:
/**
* @brief onPaginatorFetching
* Sets current state to loading. Triggered when paginator's cache controller
* needs to fetch data from the remote endpoint.
*/
auto onPaginatorFetching() -> void;
/**
* @brief setErrorString
* @param errorString
*/
auto setErrorString(const QString &errorString) -> void;
/**
* @brief setState
* @param state
*/
auto setState(State state) -> void;
/**
* @brief resetState
*/
auto resetState() -> void;
/**
* @brief resetDataModel
* Clears the data model and creates a new one if data exists
*/
auto resetDataModel() -> void;
signals:
/**
* @brief stateChanged
* Signaled when reported state changes
*/
auto stateChanged() -> void;
/**
* @brief errorStringChanged
* Signaled when reported error message changes
*/
auto errorStringChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto resultsPerPageChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto pageChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto totalResultsChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto totalPagesChanged() -> void;
/**
* @brief pageChanged
* Forwarding signal connected in constructor
*/
auto queryChanged() -> void;
private:
/**
* @brief boundaryCheck
* Helper function to check the requested index boundary
* @param index
* @return
*/
auto boundaryCheck(qsizetype index) const -> bool;
/**
* Data role map that connects VideoSearchModel::DataRole to it's QML accessor name
*/
static inline const QHash<int, QByteArray> m_dataRoles =
{
{
static_cast<int>(UuidRole),
QByteArray("uuid")
},
{
static_cast<int>(AuthorRole),
QByteArray("author")
},
{
static_cast<int>(AuthorIdRole),
QByteArray("authorId")
},
{
static_cast<int>(AuthorUrlRole),
QByteArray("authorUrl")
},
{
static_cast<int>(DurationRole),
QByteArray("duration")
},
{
static_cast<int>(ThumbnailRole),
QByteArray("thumbnail")
},
{
static_cast<int>(UrlRole),
QByteArray("url")
},
{
static_cast<int>(HeightRole),
QByteArray("height")
},
{
static_cast<int>(WidthRole),
QByteArray("width")
}
};
State m_state = Idle;
QString m_errorString = QString();
VideoSearchPaginator *m_paginator = nullptr;
VideoItemModel *m_itemModel = nullptr;
qint64 m_lastCount = 0;
Q_PROPERTY(State state READ state WRITE setState RESET resetState NOTIFY stateChanged FINAL)
Q_PROPERTY(QString errorString READ errorString WRITE setErrorString NOTIFY errorStringChanged FINAL)
Q_PROPERTY(qsizetype resultsPerPage READ resultsPerPage WRITE setResultsPerPage NOTIFY resultsPerPageChanged FINAL)
Q_PROPERTY(qsizetype totalResults READ totalResults NOTIFY totalResultsChanged FINAL)
Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL)
Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL)
Q_PROPERTY(bool hasNextPage READ hasNextPage NOTIFY pageChanged FINAL)
Q_PROPERTY(bool hasPreviousPage READ hasPreviousPage NOTIFY pageChanged FINAL)
Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged FINAL)
Q_PROPERTY(VideoItemModel *itemModel READ itemModel CONSTANT FINAL)
};
Q_DECLARE_METATYPE(VideoSearchModel)
#endif // VideoSearchModel_H
+67 -3
View File
@@ -2,12 +2,76 @@
> Media Hub and Settings Manager for the Komplex Wallpaper Plugin
<table width="100%">
<tr>
<td colspan="2">
<img src="https://git.digitalartifex.dev/digitalartifex/komplex-hub/raw/branch/main/images/screenshots/screenshot_01_home.png" />
</td>
</tr>
<tr>
<td>
<img src="https://git.digitalartifex.dev/digitalartifex/komplex-hub/raw/branch/main/images/screenshots/screenshot_02_no_results.png" />
</td>
<td>
<img src="https://git.digitalartifex.dev/digitalartifex/komplex-hub/raw/branch/main/images/screenshots/screenshot_03_images.png" />
</td>
</tr>
<tr>
<td>
<img src="https://git.digitalartifex.dev/digitalartifex/komplex-hub/raw/branch/main/images/screenshots/screenshot_04_videos.png" />
</td>
<td>
<img src="https://git.digitalartifex.dev/digitalartifex/komplex-hub/raw/branch/main/images/screenshots/screenshot_05_live.png" />
</td>
</tr>
<tr>
<td>
<img src="https://git.digitalartifex.dev/digitalartifex/komplex-hub/raw/branch/main/images/screenshots/screenshot_06_installed.png" />
</td>
<td>
<img src="https://git.digitalartifex.dev/digitalartifex/komplex-hub/raw/branch/main/images/screenshots/screenshot_07_settings.png" />
</td>
</tr>
</table>
Most of the development of Komplex and it's associated apps will now happen here, instead of Github.
## Installation
Requirements
#### Requirements
- Qt 6.10+
- Qt 6.10+ -- May work with previous versions, but currently untested
- Qt6 Core
- Qt6 Gui
- Qt6 Widgets
- Qt6 Networking
- Qt6 Quick
- Qt6 Quick Effects
- Qt6 Quick Controls
- Qt6 Shader Tools
- CMake
- clang
This app is currently under development and is pre-alpha
#### Build
```console
$ git clone gitea@git.digitalartifex.dev:digitalartifex/komplex-hub.git
$ mkdir build
$ cmake -S ./ -B ./build/
$ cmake --build ./build
```
#### Install
```console
$ cmake --install ./build
```
## Accounts
Accounts are not an integral part of Komplex. They do not enable any "pro" benefits, they do not cost anything and will not be required to use the millions of free wallpaper, image and video offerings available.
Accounts ***will*** be required to view any content that gets flagged as ***Not Safe For Work*** and any content submitted by an artist for sale.
Content purchases will be processed through the website using Paypal as will artist payouts.
## Status
This app is currently under development and is pre-alpha. The API is now being hosted on https://komplex.dev. However, there is no download functionality as of yet. BETA should be here within a few weeks.
@@ -1 +0,0 @@
{"requests":[{"kind":"cache","version":2},{"kind":"codemodel","version":2},{"kind":"toolchains","version":1},{"kind":"cmakeFiles","version":1}]}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,50 +0,0 @@
{
"backtraceGraph" :
{
"commands" :
[
"install"
],
"files" :
[
"CMakeLists.txt"
],
"nodes" :
[
{
"file" : 0
},
{
"command" : 0,
"file" : 0,
"line" : 42,
"parent" : 0
}
]
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" :
[
{
"backtrace" : 1,
"component" : "Unspecified",
"destination" : "bin",
"paths" :
[
"KomplexHub"
],
"targetId" : "KomplexHub::@6890427a1f51a3e7e1df",
"targetIndex" : 14,
"type" : "target"
}
],
"paths" :
{
"build" : ".",
"source" : "."
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "App",
"source" : "App"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies",
"source" : "Dependencies"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components",
"source" : "Dependencies/Components"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports",
"source" : "Dependencies/Components/imports"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/application",
"source" : "Dependencies/Components/imports/application"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/compat",
"source" : "Dependencies/Components/imports/compat"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/compat/Components",
"source" : "Dependencies/Components/imports/compat/Components"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/compat/Extras",
"source" : "Dependencies/Components/imports/compat/Extras"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/compat/Layers",
"source" : "Dependencies/Components/imports/compat/Layers"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/compat/Profiling",
"source" : "Dependencies/Components/imports/compat/Profiling"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/components",
"source" : "Dependencies/Components/imports/components"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/designeffects",
"source" : "Dependencies/Components/imports/designeffects"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/effects_qt6",
"source" : "Dependencies/Components/imports/effects_qt6"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/flowview",
"source" : "Dependencies/Components/imports/flowview"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/logichelper",
"source" : "Dependencies/Components/imports/logichelper"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/multitext",
"source" : "Dependencies/Components/imports/multitext"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/tools",
"source" : "Dependencies/Components/imports/tools"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/tools/eventsimulator",
"source" : "Dependencies/Components/imports/tools/eventsimulator"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/tools/eventsystem",
"source" : "Dependencies/Components/imports/tools/eventsystem"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "Dependencies/Components/imports/utils",
"source" : "Dependencies/Components/imports/utils"
}
}
@@ -1,19 +0,0 @@
{
"backtraceGraph" :
{
"commands" : [],
"files" : [],
"nodes" : []
},
"codemodelVersion" :
{
"major" : 2,
"minor" : 9
},
"installers" : [],
"paths" :
{
"build" : "KomplexHubContent",
"source" : "KomplexHubContent"
}
}

Some files were not shown because too many files have changed in this diff Show More