Compare commits
80 Commits
53f95a775d
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5b2500c841 | |||
| c08b654f5b | |||
| 90f65a8a54 | |||
| d2821b30c3 | |||
| 541b57e5a7 | |||
| ad4119ec6c | |||
| 01716fcccf | |||
| 5dbf9a8383 | |||
| 549bf794b6 | |||
| 6d32ed6bce | |||
| 5a150c29f9 | |||
| 7854a3f440 | |||
| 827168b4a8 | |||
| 96ddc611e5 | |||
| 0b8e6c1704 | |||
| c978f4ffc7 | |||
| 69e5fb6594 | |||
| dc18e6e9b2 | |||
| e9f6ad537e | |||
| dde16907bc | |||
| 5dd894f384 | |||
| fb47b92353 | |||
| 49db588226 | |||
| f2596aaa40 | |||
| 98687febb9 | |||
| fcceb77987 | |||
| 5354103844 | |||
| bf1903ddcd | |||
| 25a51257c1 | |||
| 6a4dbced85 | |||
| 32085a6a52 | |||
| 7871f3a8cc | |||
| 0062043427 | |||
| 0a98f83a9b | |||
| d8b091d7b8 | |||
| 8a9417a5e5 | |||
| ac71b74ed0 | |||
| 3f9b33c74d | |||
| eb061e9034 | |||
| 576f9e0f29 | |||
| 5f5c2db53f | |||
| 3137318976 | |||
| 8b497d9496 | |||
| e0540e5089 | |||
| 856797e0f0 | |||
| 473defcd44 | |||
| bbaefdfe88 | |||
| d01f880338 | |||
| b3f6e55198 | |||
| b53048bebc | |||
| e95606be63 | |||
| b1270ec0f2 | |||
| 67a7d9cc8f | |||
| 2cb14c7f8a | |||
| 03295cd579 | |||
| 1dc136647a | |||
| 7bdbb40a5d | |||
| 380761988b | |||
| e51e4a4d8c | |||
| faf8aacd15 | |||
| 4955fa8793 | |||
| c92ce16e49 | |||
| 8bf00f0986 | |||
| 8aecedf669 | |||
| 34787c2d9d | |||
| 8587dfa163 | |||
| 957d3554b3 | |||
| 423afc0b50 | |||
| 733777f89e | |||
| ef36ce6ffb | |||
| 8668cc7445 | |||
| 84278ab0e1 | |||
| 7a7f85e5ad | |||
| cb4985b291 | |||
| b8f437c203 | |||
| 66cc7beb41 | |||
| 63850186fd | |||
| f73b26a9cc | |||
| 59a2204386 | |||
| 15a625008e |
@@ -20,13 +20,12 @@ 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
|
||||
images/icons/icons8-video.svg
|
||||
)
|
||||
qt_add_resources(${CMAKE_PROJECT_NAME} "configuration"
|
||||
PREFIX "/"
|
||||
@@ -59,6 +58,18 @@ qt_add_resources(${CMAKE_PROJECT_NAME} "app_images"
|
||||
"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"
|
||||
@@ -75,7 +86,6 @@ 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"
|
||||
)
|
||||
|
||||
include(qds)
|
||||
|
||||
@@ -17,7 +17,7 @@ qt6_add_qml_module(KomplexHubContent
|
||||
"pages/SettingsPage.qml"
|
||||
"pages/UserProfilePage.qml"
|
||||
"pages/WallpaperSettingsPage.qml"
|
||||
QML_FILES pages/VideoSearchPage.qml
|
||||
"pages/VideoSearchPage.qml"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import KomplexHubContent
|
||||
|
||||
Rectangle {
|
||||
property MenuButton currentMenuButton
|
||||
property bool popup: false
|
||||
|
||||
id: windowRoot
|
||||
|
||||
@@ -35,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 {
|
||||
@@ -125,7 +161,6 @@ Rectangle {
|
||||
currentMenuButton = this
|
||||
|
||||
searchContainer.preferredHeight = 50
|
||||
// searchContainer.searchTerm = pageLoader.page.query
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +187,7 @@ Rectangle {
|
||||
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
Layout.minimumHeight: 100
|
||||
}
|
||||
|
||||
MenuButton {
|
||||
@@ -174,6 +210,13 @@ Rectangle {
|
||||
searchContainer.preferredHeight = 0
|
||||
}
|
||||
}
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation
|
||||
{
|
||||
duration: 250
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,6 +293,7 @@ Rectangle {
|
||||
{
|
||||
pageLoader.loading = false
|
||||
pageLoader.updateSearchTerm();
|
||||
popupConnection.target = pageLoader.item
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -317,25 +361,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
|
||||
|
||||
@@ -8,29 +8,33 @@ import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
|
||||
Item {
|
||||
Item
|
||||
{
|
||||
readonly property bool searchable: false
|
||||
property int resultsPerRow: (homePageRoot.width - (64 + Constants.largeMargin)) / (resultWidth + Constants.largeMargin) + 1
|
||||
property int resultWidth: 256
|
||||
property int resultHeight: 256
|
||||
property int resultHeight: 245
|
||||
property bool popup: false
|
||||
|
||||
clip: true
|
||||
|
||||
id: homePageRoot
|
||||
|
||||
NewestPacksModel
|
||||
{
|
||||
id: newestPacksModel
|
||||
id: packsModel
|
||||
resultsPerPage: homePageRoot.resultsPerRow
|
||||
}
|
||||
|
||||
FeaturedImagesModel
|
||||
{
|
||||
id: featuredImagesModel
|
||||
id: imagesModel
|
||||
resultsPerPage: homePageRoot.resultsPerRow
|
||||
}
|
||||
|
||||
FeaturedVideosModel
|
||||
{
|
||||
id: featuredVideosModel
|
||||
id: videosModel
|
||||
resultsPerPage: homePageRoot.resultsPerRow
|
||||
}
|
||||
|
||||
@@ -39,59 +43,34 @@ Item {
|
||||
anchors.fill: parent
|
||||
color: palette.base
|
||||
|
||||
ScrollView
|
||||
ColumnLayout
|
||||
{
|
||||
id: newPacksView
|
||||
id: resultsLayout
|
||||
anchors.fill: parent
|
||||
anchors.margins: Constants.largeMargin
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
width: newPacksView.width
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
width: parent.width
|
||||
height: 420
|
||||
anchors.margins: Constants.mediumMargin
|
||||
|
||||
Text
|
||||
{
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.preferredHeight: 50
|
||||
|
||||
color: palette.text
|
||||
font.pixelSize: Constants.h2Font.pixelSize
|
||||
font.bold: true
|
||||
text: qsTr("Newest Wallpaper Packs")
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
}
|
||||
|
||||
RowLayout
|
||||
HorizontalPaginator
|
||||
{
|
||||
id: packsPaginator
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 256
|
||||
Layout.preferredHeight: 245
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
Rectangle
|
||||
model: packsModel
|
||||
delegate: ItemDelegate
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
color: "transparent"
|
||||
|
||||
clip: true
|
||||
Row
|
||||
{
|
||||
clip: true
|
||||
spacing: Constants.mediumMargin
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: newPacksMoreButton.left
|
||||
anchors.leftMargin: Constants.largeMargin
|
||||
anchors.rightMargin: Constants.largeMargin
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: newestPacksModel
|
||||
|
||||
delegate: Item {
|
||||
width: resultWidth
|
||||
height: resultHeight
|
||||
|
||||
@@ -101,6 +80,7 @@ Item {
|
||||
required property string uuid
|
||||
required property string thumbnail
|
||||
required property string authorId
|
||||
required property int index
|
||||
|
||||
SearchResultItem
|
||||
{
|
||||
@@ -110,92 +90,40 @@ Item {
|
||||
description: parent.description
|
||||
thumbnail: parent.thumbnail
|
||||
uuid: parent.uuid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle
|
||||
selected: packsPaginator.currentIndex === parent.index
|
||||
|
||||
onTriggered: () => packsPaginator.currentIndex = parent.index
|
||||
|
||||
function onViewMoreTriggered()
|
||||
{
|
||||
id: newestGradientMap
|
||||
anchors.top: parent.top
|
||||
anchors.right: newPacksMoreButton.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: newPacksMoreButton
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
height: Constants.largeMargin
|
||||
}
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
width: parent.width
|
||||
height: 420
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
RowLayout
|
||||
HorizontalPaginator
|
||||
{
|
||||
id: imagesPaginator
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 256
|
||||
Layout.preferredHeight: 245
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
Rectangle
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
color: "transparent"
|
||||
|
||||
clip: true
|
||||
Row
|
||||
{
|
||||
clip: true
|
||||
spacing: Constants.mediumMargin
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: featuredImagesMoreButton.left
|
||||
anchors.leftMargin: Constants.largeMargin
|
||||
anchors.rightMargin: Constants.largeMargin
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: featuredImagesModel
|
||||
|
||||
delegate: Item
|
||||
model: imagesModel
|
||||
delegate: ItemDelegate
|
||||
{
|
||||
width: resultWidth
|
||||
height: resultHeight
|
||||
@@ -205,100 +133,50 @@ Item {
|
||||
required property string uuid
|
||||
required property string thumbnail
|
||||
required property string authorId
|
||||
required property int index
|
||||
|
||||
SearchResultItem
|
||||
{
|
||||
anchors.fill: parent
|
||||
title: parent.author
|
||||
author: qsTr("Pexels Images")
|
||||
description: parent.description
|
||||
thumbnail: parent.thumbnail
|
||||
uuid: parent.uuid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pexels: true
|
||||
selected: imagesPaginator.currentIndex === parent.index
|
||||
|
||||
Rectangle
|
||||
onTriggered: () => imagesPaginator.currentIndex = parent.index
|
||||
|
||||
onViewMoreTriggered: () =>
|
||||
{
|
||||
anchors.top: parent.top
|
||||
anchors.right: featuredImagesMoreButton.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: featuredImagesMoreButton
|
||||
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
|
||||
showImagePopup(parent.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
height: Constants.largeMargin
|
||||
}
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
width: parent.width
|
||||
height: 420
|
||||
|
||||
Text
|
||||
{
|
||||
Layout.alignment: Qt.AlignTop
|
||||
Layout.preferredHeight: 50
|
||||
|
||||
color: palette.text
|
||||
font.pixelSize: Constants.h2Font.pixelSize
|
||||
font.bold: true
|
||||
text: qsTr("Featured Videos")
|
||||
text: qsTr("Popular Videos")
|
||||
verticalAlignment: Qt.AlignVCenter
|
||||
}
|
||||
|
||||
RowLayout
|
||||
HorizontalPaginator
|
||||
{
|
||||
id: videosPaginator
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 256
|
||||
Layout.preferredHeight: 245
|
||||
Layout.alignment: Qt.AlignTop
|
||||
|
||||
Rectangle
|
||||
model: videosModel
|
||||
delegate: ItemDelegate
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
color: "transparent"
|
||||
|
||||
clip: true
|
||||
Row
|
||||
{
|
||||
clip: true
|
||||
spacing: Constants.mediumMargin
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.right: featuredVideosMoreButton.left
|
||||
anchors.leftMargin: Constants.largeMargin
|
||||
anchors.rightMargin: Constants.largeMargin
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: featuredVideosModel
|
||||
|
||||
delegate: Item {
|
||||
width: resultWidth
|
||||
height: resultHeight
|
||||
|
||||
@@ -307,54 +185,37 @@ Item {
|
||||
required property string authorId
|
||||
required property string authorUrl
|
||||
required property string thumbnail
|
||||
required property int index
|
||||
|
||||
SearchResultItem
|
||||
{
|
||||
anchors.fill: parent
|
||||
title: parent.author
|
||||
author: parent.author
|
||||
description: "Video provided by Pexels"
|
||||
thumbnail: parent.thumbnail
|
||||
uuid: parent.uuid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pexels: true
|
||||
selected: videosPaginator.currentIndex === parent.index
|
||||
|
||||
Rectangle
|
||||
onTriggered: () => packsPaginator.currentIndex = parent.index
|
||||
|
||||
onViewMoreTriggered:() =>
|
||||
{
|
||||
anchors.top: parent.top
|
||||
anchors.right: featuredVideosMoreButton.left
|
||||
height: resultHeight
|
||||
width: resultWidth / 4
|
||||
viewMoreImagePopup.opacity = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gradient: Gradient
|
||||
/* spacer */
|
||||
Item { Layout.fillHeight: true }
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: () =>
|
||||
{
|
||||
orientation: Gradient.Horizontal
|
||||
GradientStop { position: 0.0; color: "transparent" }
|
||||
GradientStop { position: 1.0; color: palette.light }
|
||||
}
|
||||
opacity: 0.5
|
||||
}
|
||||
|
||||
SquareButton
|
||||
{
|
||||
id: featuredVideosMoreButton
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
imagesModel.nextPage()
|
||||
videosModel.nextPage()
|
||||
packsModel.nextPage()
|
||||
}
|
||||
|
||||
KeroLoadingAnimation
|
||||
@@ -362,26 +223,135 @@ Item {
|
||||
id: loadingAnimation
|
||||
anchors.fill: parent
|
||||
|
||||
OpacityAnimator on opacity {
|
||||
duration: 150
|
||||
visible: opacity > 0
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
visible: opacity > 0
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "loading"
|
||||
when: newestPacksModel.state == NewestPacksModel.Loading ||
|
||||
featuredImagesModel.state == FeaturedImagesModel.Loading ||
|
||||
featuredVideosModel.state == FeaturedVideosModel.Loading;
|
||||
when: packsModel.state === NewestPacksModel.Loading ||
|
||||
imagesModel.state === FeaturedImagesModel.Loading ||
|
||||
videosModel.state === FeaturedVideosModel.Loading;
|
||||
|
||||
PropertyChanges {
|
||||
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.ThumbnailRole)
|
||||
viewMoreImagePopup.small = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.SmallUrlRole)
|
||||
viewMoreImagePopup.medium = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.MediumUrlRole)
|
||||
viewMoreImagePopup.large = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LargeUrlRole)
|
||||
viewMoreImagePopup.extraLarge = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.ExtraLargeUrlRole)
|
||||
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.smallSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.SmallSizeRole)
|
||||
viewMoreImagePopup.mediumSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.MediumSizeRole)
|
||||
viewMoreImagePopup.largeSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LargeSizeRole)
|
||||
viewMoreImagePopup.extraLargeSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.ExtraLargeSizeRole)
|
||||
viewMoreImagePopup.originalSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.OriginalSizeRole)
|
||||
viewMoreImagePopup.portraitSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.PortraitSizeRole)
|
||||
viewMoreImagePopup.landscapeSize = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LandscapeSizeRole)
|
||||
viewMoreImagePopup.opacity = 1
|
||||
popupContainer.opacity = 1
|
||||
homePageRoot.popup = true
|
||||
}
|
||||
|
||||
function closePopup()
|
||||
{
|
||||
viewMoreImagePopup.opacity = 0
|
||||
popupContainer.opacity = 0
|
||||
homePageRoot.popup = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,217 +9,118 @@ 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
|
||||
id: rootItem
|
||||
|
||||
id: imageSearchPageRoot
|
||||
property string query
|
||||
readonly property bool searchable: paginator.searchable
|
||||
property bool popup: false
|
||||
|
||||
ImageSearchModel
|
||||
{
|
||||
id: searchModel
|
||||
query: imageSearchPageRoot.query
|
||||
resultsPerPage: imageSearchPageRoot.resultsPerPage
|
||||
query: rootItem.query
|
||||
resultsPerPage: paginator.resultsPerPage
|
||||
}
|
||||
|
||||
Rectangle
|
||||
PaginatorGrid
|
||||
{
|
||||
id: paginator
|
||||
anchors.fill: parent
|
||||
color: palette.base
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: resultsContainer
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: buttonBoxLayout.top
|
||||
|
||||
color: "transparent"
|
||||
|
||||
ScrollView
|
||||
{
|
||||
id: resultsView
|
||||
anchors.fill: parent
|
||||
|
||||
RowLayout
|
||||
{
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: parent.top
|
||||
anchors.margins: Constants.largeMargin
|
||||
|
||||
Item
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: emptyWidth / 2
|
||||
Layout.maximumWidth: emptyWidth / 2
|
||||
}
|
||||
|
||||
GridLayout
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
columns: imageSearchPageRoot.resultsPerRow
|
||||
columnSpacing: Constants.mediumMargin
|
||||
rowSpacing: Constants.mediumMargin
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: searchModel
|
||||
loading: model.state === ImageSearchModel.Loading
|
||||
|
||||
delegate: Item
|
||||
delegate: ItemDelegate
|
||||
{
|
||||
id: resultDelegate
|
||||
|
||||
width: 256
|
||||
height: 245
|
||||
|
||||
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
|
||||
author: qsTr("Pexels Images")
|
||||
description: parent.description
|
||||
thumbnail: parent.thumbnail
|
||||
uuid: parent.uuid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
selected: paginator.currentIndex === parent.index
|
||||
|
||||
RowLayout
|
||||
onTriggered: () => paginator.currentIndex = parent.index
|
||||
|
||||
onViewMoreTriggered: () =>
|
||||
{
|
||||
id: buttonBoxLayout
|
||||
height: 35
|
||||
showImagePopup(parent.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: Constants.largeMargin
|
||||
|
||||
SquareButton
|
||||
Rectangle
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: 128
|
||||
|
||||
icon.source: "qrc:/images/icons/icons8-back.svg"
|
||||
icon.height: 16
|
||||
icon.width: 16
|
||||
text: qsTr("Previous")
|
||||
enabled: searchModel.hasPreviousPage
|
||||
|
||||
onTriggered: () => searchModel.previousPage()
|
||||
}
|
||||
|
||||
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: searchModel.hasNextPage
|
||||
|
||||
onTriggered: () => searchModel.nextPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeroErrorAvatar
|
||||
{
|
||||
id: errorOverlay
|
||||
|
||||
id: popupContainer
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
}
|
||||
color: palette.base
|
||||
|
||||
KeroNoResultsAvatar
|
||||
ImageView
|
||||
{
|
||||
id: noResultsOverlay
|
||||
|
||||
id: viewMoreImagePopup
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation
|
||||
{
|
||||
duration: 250
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeroLoadingAnimation
|
||||
Behavior on opacity {
|
||||
NumberAnimation
|
||||
{
|
||||
id: loadingOverlay
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
duration: 250
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State
|
||||
function showImagePopup(index)
|
||||
{
|
||||
name: "loading"
|
||||
when: searchModel.state == ImageSearchModel.Loading
|
||||
viewMoreImagePopup.author = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.AuthorRole)
|
||||
viewMoreImagePopup.authorUrl = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.AuthorUrlRole)
|
||||
viewMoreImagePopup.description = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.DescriptionRole)
|
||||
viewMoreImagePopup.uuid = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.UuidRole)
|
||||
viewMoreImagePopup.thumbnail = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.ThumbnailRole)
|
||||
viewMoreImagePopup.small = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.SmallUrlRole)
|
||||
viewMoreImagePopup.medium = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.MediumUrlRole)
|
||||
viewMoreImagePopup.large = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.LargeUrlRole)
|
||||
viewMoreImagePopup.extraLarge = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.ExtraLargeUrlRole)
|
||||
viewMoreImagePopup.original = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.OriginalUrlRole)
|
||||
viewMoreImagePopup.portrait = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.PortraitUrlRole)
|
||||
viewMoreImagePopup.landscape = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.LandscapeUrlRole)
|
||||
viewMoreImagePopup.smallSize = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.SmallSizeRole)
|
||||
viewMoreImagePopup.mediumSize = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.MediumSizeRole)
|
||||
viewMoreImagePopup.largeSize = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.LargeSizeRole)
|
||||
viewMoreImagePopup.extraLargeSize = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.ExtraLargeSizeRole)
|
||||
viewMoreImagePopup.originalSize = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.OriginalSizeRole)
|
||||
viewMoreImagePopup.portraitSize = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.PortraitSizeRole)
|
||||
viewMoreImagePopup.landscapeSize = searchModel.data(searchModel.index(index,0), FeaturedImagesModel.LandscapeSizeRole)
|
||||
viewMoreImagePopup.opacity = 1
|
||||
popupContainer.opacity = 1
|
||||
rootItem.popup = true
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
function closePopup()
|
||||
{
|
||||
target: loadingOverlay
|
||||
opacity: 1
|
||||
viewMoreImagePopup.opacity = 0
|
||||
popupContainer.opacity = 0
|
||||
rootItem.popup = false
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: resultsView
|
||||
opacity: 0
|
||||
}
|
||||
},
|
||||
State
|
||||
{
|
||||
name: "empty"
|
||||
when: searchModel.totalResults === 0
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: noResultsOverlay
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: resultsView
|
||||
opacity: 0
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: buttonBoxLayout
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
State
|
||||
{
|
||||
name: "error"
|
||||
when: searchModel.state == ImageSearchModel.Error
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: errorOverlay
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: resultsView
|
||||
opacity: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,76 +3,59 @@ import QtQuick.Controls
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
|
||||
Item {
|
||||
id: imageSearchPageRoot
|
||||
Item
|
||||
{
|
||||
id: rootItem
|
||||
|
||||
SearchResultList {
|
||||
id: searchResultList
|
||||
property string query
|
||||
readonly property bool searchable: paginator.searchable
|
||||
|
||||
PackSearchModel
|
||||
{
|
||||
id: searchModel
|
||||
query: rootItem.query
|
||||
resultsPerPage: paginator.resultsPerPage
|
||||
}
|
||||
|
||||
PaginatorGrid
|
||||
{
|
||||
id: paginator
|
||||
anchors.fill: parent
|
||||
color: palette.base
|
||||
}
|
||||
model: searchModel
|
||||
loading: model.state === PackSearchModel.Loading
|
||||
|
||||
KeroErrorAvatar {
|
||||
id: errorOverlay
|
||||
delegate: ItemDelegate
|
||||
{
|
||||
id: resultDelegate
|
||||
|
||||
width: 256
|
||||
height: 245
|
||||
|
||||
required property string name
|
||||
required property string author
|
||||
required property string description
|
||||
required property string uuid
|
||||
required property string thumbnail
|
||||
required property string authorId
|
||||
|
||||
SearchResultItem
|
||||
{
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
title: parent.author
|
||||
description: parent.description
|
||||
thumbnail: parent.thumbnail
|
||||
uuid: parent.uuid
|
||||
|
||||
selected: resultDelegate.highlighted
|
||||
}
|
||||
|
||||
KeroNoResultsAvatar {
|
||||
id: noResultsOverlay
|
||||
|
||||
MouseArea
|
||||
{
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
KeroLoadingAnimation {
|
||||
id: loadingOverlay
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "loading"
|
||||
when: searchResultList.state === "loading"
|
||||
|
||||
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
|
||||
onClicked: paginator.currentIndex = index
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,217 +9,55 @@ 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
|
||||
id: rootItem
|
||||
|
||||
id: videoSearchPageRoot
|
||||
property string query
|
||||
readonly property bool searchable: paginator.searchable
|
||||
|
||||
VideoSearchModel
|
||||
{
|
||||
id: searchModel
|
||||
query: videoSearchPageRoot.query
|
||||
resultsPerPage: videoSearchPageRoot.resultsPerPage
|
||||
query: rootItem.query
|
||||
resultsPerPage: paginator.resultsPerPage
|
||||
}
|
||||
|
||||
Rectangle
|
||||
PaginatorGrid
|
||||
{
|
||||
id: paginator
|
||||
anchors.fill: parent
|
||||
color: palette.base
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: resultsContainer
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: buttonBoxLayout.top
|
||||
|
||||
color: "transparent"
|
||||
|
||||
ScrollView
|
||||
{
|
||||
id: resultsView
|
||||
anchors.fill: parent
|
||||
|
||||
RowLayout
|
||||
{
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.top: parent.top
|
||||
anchors.margins: Constants.largeMargin
|
||||
|
||||
Item
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredWidth: emptyWidth / 2
|
||||
Layout.maximumWidth: emptyWidth / 2
|
||||
}
|
||||
|
||||
GridLayout
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
|
||||
columns: videoSearchPageRoot.resultsPerRow
|
||||
columnSpacing: Constants.mediumMargin
|
||||
rowSpacing: Constants.mediumMargin
|
||||
|
||||
Repeater
|
||||
{
|
||||
model: searchModel
|
||||
loading: model.state === VideoSearchModel.Loading
|
||||
|
||||
delegate: Item {
|
||||
width: resultWidth
|
||||
height: resultHeight
|
||||
delegate: ItemDelegate
|
||||
{
|
||||
id: resultDelegate
|
||||
|
||||
width: 256
|
||||
height: 245
|
||||
|
||||
required property string uuid
|
||||
required property string author
|
||||
required property string authorId
|
||||
required property string authorUrl
|
||||
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
|
||||
author: parent.author
|
||||
description: "Video provided by Pexels"
|
||||
description: parent.description
|
||||
thumbnail: parent.thumbnail
|
||||
uuid: parent.uuid
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
selected: resultDelegate.highlighted
|
||||
}
|
||||
|
||||
RowLayout
|
||||
MouseArea
|
||||
{
|
||||
id: buttonBoxLayout
|
||||
height: 35
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: Constants.largeMargin
|
||||
|
||||
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: searchModel.hasPreviousPage
|
||||
|
||||
onTriggered: () => searchModel.previousPage()
|
||||
}
|
||||
|
||||
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: searchModel.hasNextPage
|
||||
|
||||
onTriggered: () => searchModel.nextPage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
KeroErrorAvatar
|
||||
{
|
||||
id: errorOverlay
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
KeroNoResultsAvatar
|
||||
{
|
||||
id: noResultsOverlay
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
KeroLoadingAnimation
|
||||
{
|
||||
id: loadingOverlay
|
||||
|
||||
anchors.fill: parent
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
states: [
|
||||
State
|
||||
{
|
||||
name: "loading"
|
||||
when: searchModel.state == VideoSearchModel.Loading
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: loadingOverlay
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: resultsView
|
||||
opacity: 0
|
||||
}
|
||||
},
|
||||
State
|
||||
{
|
||||
name: "empty"
|
||||
when: searchModel.totalResults === 0
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: noResultsOverlay
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: resultsView
|
||||
opacity: 0
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: buttonBoxLayout
|
||||
visible: false
|
||||
}
|
||||
},
|
||||
State
|
||||
{
|
||||
name: "error"
|
||||
when: searchModel.state == VideoSearchModel.Error
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: errorOverlay
|
||||
opacity: 1
|
||||
}
|
||||
PropertyChanges
|
||||
{
|
||||
target: resultsView
|
||||
opacity: 0
|
||||
onClicked: paginator.currentIndex = index
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -14,5 +14,9 @@ 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
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
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 small
|
||||
property string original
|
||||
property string medium
|
||||
property string large
|
||||
property string extraLarge
|
||||
property string portraitSize
|
||||
property string landscapeSize
|
||||
property string smallSize
|
||||
property string originalSize
|
||||
property string mediumSize
|
||||
property string largeSize
|
||||
property string extraLargeSize
|
||||
|
||||
property int imageHeight
|
||||
property int imageWidth
|
||||
|
||||
id: rootItem
|
||||
|
||||
Rectangle
|
||||
{
|
||||
anchors.fill: parent
|
||||
color: palette.base.alpha(1)
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
anchors.fill: parent
|
||||
anchors.margins: Constants.largeMargin
|
||||
spacing: Constants.largeMargin
|
||||
|
||||
RowLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
|
||||
|
||||
/** Spacer **/
|
||||
Item { Layout.fillWidth: true }
|
||||
|
||||
Image
|
||||
{
|
||||
width: imageWidth
|
||||
height: imageHeight
|
||||
transform: Image.PreserveAspectFit
|
||||
source: rootItem.large
|
||||
}
|
||||
|
||||
/** Spacer **/
|
||||
Item { Layout.fillWidth: true }
|
||||
}
|
||||
|
||||
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:[
|
||||
"Small: " + smallSize,
|
||||
"Medium: " + mediumSize,
|
||||
"Large: " + largeSize,
|
||||
"Extra Large: " + extraLargeSize,
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
||||
// Text {
|
||||
// property var texts: [
|
||||
// small,
|
||||
// medium,
|
||||
// large,
|
||||
// extraLarge,
|
||||
// portrait,
|
||||
// landscape
|
||||
// ]
|
||||
// text: texts[downloadSelector.currentIndex]
|
||||
// elide: Text.ElideLeft
|
||||
|
||||
// Layout.fillWidth: true
|
||||
// }
|
||||
|
||||
/** 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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2,15 +2,19 @@ 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 uuid: ""
|
||||
property bool selected: false
|
||||
property bool pexels: false
|
||||
|
||||
signal triggered
|
||||
signal viewMoreTriggered
|
||||
|
||||
id: searchResultItemRoot
|
||||
width: 256
|
||||
@@ -21,11 +25,34 @@ Item {
|
||||
{
|
||||
id: searchResultItemContainer
|
||||
anchors.fill: parent
|
||||
|
||||
border.color: palette.alternateBase.lighter(1.75)
|
||||
|
||||
color: palette.alternateBase.lighter(1.25)
|
||||
|
||||
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)
|
||||
{
|
||||
searchResultItemRoot.triggered()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
anchors.fill: parent
|
||||
@@ -48,9 +75,26 @@ Item {
|
||||
id: thumnailImage
|
||||
source: searchResultItemRoot.thumbnail
|
||||
}
|
||||
|
||||
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: searchResultItemRoot.pexels
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
Text
|
||||
{
|
||||
color: palette.text
|
||||
text: searchResultItemRoot.title
|
||||
|
||||
@@ -62,7 +106,10 @@ Item {
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
}
|
||||
|
||||
Text {
|
||||
Item { Layout.fillHeight: true }
|
||||
|
||||
Text
|
||||
{
|
||||
color: palette.text
|
||||
font.pixelSize: 12
|
||||
text: "By: " + searchResultItemRoot.author
|
||||
@@ -70,80 +117,73 @@ Item {
|
||||
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
|
||||
Layout.preferredWidth: 250
|
||||
visible: !searchResultItemRoot.pexels
|
||||
}
|
||||
|
||||
Text {
|
||||
Text
|
||||
{
|
||||
id: descriptionText
|
||||
clip: true
|
||||
color: palette.text
|
||||
font.pixelSize: 12
|
||||
text: searchResultItemRoot.description
|
||||
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
||||
textFormat: Text.PlainText
|
||||
Layout.maximumHeight: 32
|
||||
Layout.preferredHeight: 32
|
||||
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
|
||||
|
||||
text: qsTr("View More")
|
||||
opacity: 0
|
||||
|
||||
onTriggered: () => {
|
||||
searchResultItemRoot.viewMoreTriggered()
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
property string lastState
|
||||
id: mouseArea
|
||||
|
||||
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"
|
||||
Item { Layout.fillHeight: true }
|
||||
}
|
||||
}
|
||||
|
||||
onReleased: () => {
|
||||
if(!mouseArea.containsMouse)
|
||||
return;
|
||||
QtObject
|
||||
{
|
||||
id: states
|
||||
property bool clicked: false
|
||||
property bool hovered: false
|
||||
property alias selected: searchResultItemRoot.selected
|
||||
property bool idle: true
|
||||
|
||||
selected = !selected
|
||||
onIdleChanged: () =>
|
||||
{
|
||||
if(idle)
|
||||
{
|
||||
clicked = false
|
||||
hovered = false
|
||||
selected = false
|
||||
}
|
||||
}
|
||||
|
||||
onSelectedChanged: () => {
|
||||
if(selected) {
|
||||
searchResultItemRoot.triggered()
|
||||
searchResultItemRoot.state = "selected"
|
||||
}
|
||||
else {
|
||||
searchResultItemRoot.state = ""
|
||||
}
|
||||
}
|
||||
|
||||
states: [
|
||||
State {
|
||||
name: "hovered"
|
||||
when: states.hovered && !states.selected
|
||||
|
||||
PropertyChanges {
|
||||
target: searchResultItemContainer
|
||||
@@ -153,14 +193,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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@ 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
|
||||
@@ -30,7 +28,7 @@ qt_add_qml_module(
|
||||
SOURCES paginators/featuredpackspaginator.h
|
||||
SOURCES paginators/featuredimagespaginator.h
|
||||
SOURCES paginators/wallpaperpaginator.h
|
||||
SOURCES paginators/searchpackspaginator.h
|
||||
SOURCES paginators/packsearchpaginator.h
|
||||
SOURCES paginators/imagesearchpaginator.h
|
||||
SOURCES paginators/newestshaderspaginator.h
|
||||
SOURCES paginators/newestcubemapspaginator.h
|
||||
@@ -54,6 +52,10 @@ qt_add_qml_module(
|
||||
SOURCES imagesearchmodel.h
|
||||
SOURCES videosearchmodel.h
|
||||
SOURCES videosearchmodel.cpp
|
||||
SOURCES
|
||||
SOURCES
|
||||
SOURCES packsearchmodel.cpp
|
||||
SOURCES packsearchmodel.h
|
||||
|
||||
)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ struct KOMPLEX_EXPORT ImageCache
|
||||
QString photographerUrl;
|
||||
qint64 photographerId;
|
||||
QMap<QString, QString> sources;
|
||||
QMap<QString, QString> sourceSizes;
|
||||
QString url;
|
||||
|
||||
auto operator == (const ImageCache &other) const -> bool
|
||||
@@ -33,6 +34,7 @@ struct KOMPLEX_EXPORT ImageCache
|
||||
other.photographerUrl == photographerUrl &&
|
||||
other.photographerId == photographerId &&
|
||||
other.sources == sources &&
|
||||
other.sourceSizes == sourceSizes &&
|
||||
other.url == url
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -61,4 +63,7 @@
|
||||
#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
|
||||
|
||||
@@ -39,12 +39,14 @@ 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;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,7 +59,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
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,9 +82,17 @@ public:
|
||||
* Attempts to get the next page and notifies pageChanged
|
||||
*/
|
||||
auto next() -> void
|
||||
{
|
||||
if(m_offset != nullsize)
|
||||
{
|
||||
setOffset(m_offset + m_resultsPerPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller()->init();
|
||||
setOffset(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief previous
|
||||
@@ -76,9 +100,17 @@ public:
|
||||
* Attempts to get the previous page and notifies pageChanged
|
||||
*/
|
||||
auto previous() -> void
|
||||
{
|
||||
if(m_offset != nullsize && m_offset > m_resultsPerPage)
|
||||
{
|
||||
setOffset(m_offset - m_resultsPerPage);
|
||||
}
|
||||
else
|
||||
{
|
||||
controller()->init();
|
||||
setOffset(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief resultsPerPage
|
||||
@@ -95,8 +127,6 @@ public:
|
||||
*/
|
||||
auto setResultsPerPage(qsizetype resultsPerPage) -> void
|
||||
{
|
||||
QMutexLocker dataLocker(&m_dataMutex);
|
||||
|
||||
if(resultsPerPage == m_resultsPerPage)
|
||||
{
|
||||
return;
|
||||
@@ -104,18 +134,53 @@ 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 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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,7 +189,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,16 +208,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,6 +250,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
|
||||
@@ -198,16 +277,11 @@ protected:
|
||||
*/
|
||||
auto setOffset(qsizetype offset) -> void
|
||||
{
|
||||
if(offset == m_offset && offset != std::numeric_limits<qsizetype>::infinity())
|
||||
if(offset == m_offset)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(offset == std::numeric_limits<qsizetype>::infinity())
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
m_offset = offset;
|
||||
|
||||
if(m_offset >= totalResults())
|
||||
@@ -220,26 +294,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();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -257,26 +316,34 @@ protected:
|
||||
*/
|
||||
auto reset() -> void
|
||||
{
|
||||
m_dataMutex.lock();
|
||||
|
||||
m_data.clear();
|
||||
m_query.clear();
|
||||
m_offset = nullsize;
|
||||
controller()->reset();
|
||||
m_dataMutex.unlock();
|
||||
|
||||
Q_EMIT totalPagesChanged();
|
||||
Q_EMIT dataChanged();
|
||||
Q_EMIT pageChanged();
|
||||
|
||||
setOffset(std::numeric_limits<qsizetype>::infinity());
|
||||
}
|
||||
|
||||
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
|
||||
@@ -294,16 +361,22 @@ 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;
|
||||
};
|
||||
|
||||
#endif // PAGINATOR_H
|
||||
|
||||
@@ -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,25 +93,26 @@ public:
|
||||
* @return CacheObject* or nullptr
|
||||
*/
|
||||
[[nodiscard]]
|
||||
auto at(qsizetype index) const -> T
|
||||
auto at(qsizetype index) const -> const T&
|
||||
{
|
||||
QMutexLocker cacheLocker(&m_cacheMutex);
|
||||
T defaultValue;
|
||||
|
||||
if(!externalBoundaryCheck(index))
|
||||
{
|
||||
return {};
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
if(!const_cast<SlidingCacheController*>(this)->slideWindow(index))
|
||||
{
|
||||
return {};
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
qsizetype internalIndex = this->internalIndex(index);
|
||||
|
||||
if(!internalBoundaryCheck(index))
|
||||
{
|
||||
return {};
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
return m_cache.at(index);
|
||||
@@ -144,19 +153,7 @@ public:
|
||||
count = m_cache.count() - index;
|
||||
}
|
||||
|
||||
QList<T> dataChunk;
|
||||
|
||||
for(qsizetype i = index; (i - index) < count; ++i)
|
||||
{
|
||||
T data = m_cache.at(i);
|
||||
|
||||
if(data != T{})
|
||||
{
|
||||
dataChunk.append(data);
|
||||
}
|
||||
}
|
||||
|
||||
return dataChunk;
|
||||
return m_cache.mid(index, count);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +164,7 @@ public:
|
||||
[[nodiscard]]
|
||||
auto totalCount() const -> qsizetype
|
||||
{
|
||||
if(m_totalCount == std::numeric_limits<qsizetype>::infinity())
|
||||
if(m_totalCount == nullsize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -195,10 +192,53 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief setTotalCount
|
||||
@@ -215,6 +255,16 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
auto inFocus(qsizetype index, qsizetype count) -> bool
|
||||
{
|
||||
qsizetype internalIndex = this->internalIndex(index);
|
||||
|
||||
return
|
||||
(
|
||||
internalBoundaryCheck(internalIndex, internalIndex + count)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief externalBoundaryCheck
|
||||
*
|
||||
@@ -224,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) const -> bool
|
||||
template<typename... Ts>
|
||||
auto externalBoundaryCheck(Ts... index) const -> bool
|
||||
{
|
||||
return (
|
||||
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
|
||||
)
|
||||
);
|
||||
@@ -242,12 +309,18 @@ private:
|
||||
* @param index
|
||||
* @return True if index is within the internal dataset boundary
|
||||
*/
|
||||
auto internalBoundaryCheck(qsizetype index) const -> 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -280,14 +353,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
if(m_totalCount == std::numeric_limits<qsizetype>::infinity())
|
||||
{
|
||||
if(!slideForward())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -299,20 +364,41 @@ 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;
|
||||
}
|
||||
|
||||
if(m_totalCount != std::numeric_limits<qsizetype>::infinity())
|
||||
if(m_totalCount != nullsize)
|
||||
{
|
||||
m_windowOffset += movementSize;
|
||||
}
|
||||
@@ -321,6 +407,8 @@ private:
|
||||
m_windowOffset = 0;
|
||||
}
|
||||
|
||||
QThread::sleep(KOMPLEX_RATE_LIMIT);
|
||||
|
||||
FetchResult<T> result = m_fetch(
|
||||
m_windowOffset,
|
||||
movementSize
|
||||
@@ -337,6 +425,8 @@ private:
|
||||
if(result.data.isEmpty())
|
||||
{
|
||||
m_windowOffset -= movementSize;
|
||||
|
||||
Q_EMIT fetchComplete();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -359,6 +449,8 @@ private:
|
||||
m_cache.append(std::move(result.data));
|
||||
}
|
||||
|
||||
Q_EMIT fetchComplete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -375,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)
|
||||
@@ -391,6 +507,8 @@ private:
|
||||
if(result.count == 0)
|
||||
{
|
||||
m_windowOffset += movementSize;
|
||||
|
||||
Q_EMIT fetchComplete();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -419,6 +537,8 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
Q_EMIT fetchComplete();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -444,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
|
||||
@@ -463,6 +583,12 @@ private:
|
||||
* @brief m_cacheMutex
|
||||
*/
|
||||
mutable QMutex m_cacheMutex;
|
||||
|
||||
/**
|
||||
* @brief m_windowSize
|
||||
* Override for window size
|
||||
*/
|
||||
qsizetype m_windowSize = nullsize;
|
||||
};
|
||||
|
||||
#endif // SLIDINGCACHECONTROLLER_H
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
FeaturedImagesModel::FeaturedImagesModel(QObject *parent) : QAbstractListModel{parent}
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
m_paginator = new FeaturedImagesPaginator(this);
|
||||
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
|
||||
|
||||
@@ -37,10 +35,24 @@ FeaturedImagesModel::FeaturedImagesModel(QObject *parent) : QAbstractListModel{p
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::dataChanged,
|
||||
&PaginationNotifier::pageChanged,
|
||||
this,
|
||||
&FeaturedImagesModel::resetDataModel
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetchComplete,
|
||||
this,
|
||||
&FeaturedImagesModel::resetState
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetching,
|
||||
this,
|
||||
&FeaturedImagesModel::onPaginatorFetching
|
||||
);
|
||||
}
|
||||
|
||||
auto FeaturedImagesModel::rowCount(const QModelIndex &) const -> int
|
||||
@@ -55,12 +67,12 @@ auto FeaturedImagesModel::rowCount(const QModelIndex &) const -> int
|
||||
|
||||
auto FeaturedImagesModel::data(const QModelIndex &index, int role) const -> QVariant
|
||||
{
|
||||
if(index.row() < 0 || m_paginator == nullptr)
|
||||
if(!boundaryCheck(index.row()))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
ImageCache dataPoint = m_data.at(index.row());
|
||||
ImageCache dataPoint = m_paginator->at(index.row());
|
||||
|
||||
QVariant data;
|
||||
|
||||
@@ -105,6 +117,27 @@ auto FeaturedImagesModel::data(const QModelIndex &index, int role) const -> QVar
|
||||
case ExtraLargeUrlRole:
|
||||
data = dataPoint.sources.value(QString::fromUtf8("large2x"));
|
||||
break;
|
||||
case PortraitSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("portrait"));
|
||||
break;
|
||||
case LandscapeSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("landscape"));
|
||||
break;
|
||||
case SmallSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("small"));
|
||||
break;
|
||||
case OriginalSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("original"));
|
||||
break;
|
||||
case MediumSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("medium"));
|
||||
break;
|
||||
case LargeSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("large"));
|
||||
break;
|
||||
case ExtraLargeSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("large2x"));
|
||||
break;
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -114,10 +147,12 @@ auto FeaturedImagesModel::index(int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if(row < 0 || row >= m_data.count())
|
||||
if(!boundaryCheck(row))
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return createIndex(row, column, &m_data[row]);
|
||||
return createIndex(row, column, &m_paginator[row]);
|
||||
}
|
||||
|
||||
auto FeaturedImagesModel::columnCount(const QModelIndex &) const -> int
|
||||
@@ -158,25 +193,28 @@ auto FeaturedImagesModel::resetState() -> void
|
||||
|
||||
auto FeaturedImagesModel::resetDataModel() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
//invalidate previous model data
|
||||
beginRemoveRows(QModelIndex(), 0, m_data.count());
|
||||
m_data.clear();
|
||||
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
|
||||
endRemoveRows();
|
||||
|
||||
//signal new data
|
||||
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
|
||||
auto dataset = m_paginator->data();
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
for(const ImageCache& data : std::as_const(dataset))
|
||||
auto FeaturedImagesModel::onPaginatorFetching() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
}
|
||||
|
||||
auto FeaturedImagesModel::boundaryCheck(qsizetype index) const -> bool
|
||||
{
|
||||
if(index < 0 || m_paginator == nullptr || index >= m_paginator->count())
|
||||
{
|
||||
m_data.append(data);
|
||||
return false;
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
|
||||
setState(Idle);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto FeaturedImagesModel::roleNames() const -> QHash<int, QByteArray>
|
||||
@@ -213,9 +251,15 @@ auto FeaturedImagesModel::resultsPerPage() const -> qsizetype
|
||||
auto FeaturedImagesModel::setResultsPerPage(qsizetype resultsPerPage) -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this, resultsPerPage]
|
||||
{
|
||||
m_paginator->setResultsPerPage(resultsPerPage);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto FeaturedImagesModel::totalResults() const -> qsizetype
|
||||
@@ -228,20 +272,32 @@ auto FeaturedImagesModel::totalResults() const -> qsizetype
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto FeaturedImagesModel::nextPage() const -> void
|
||||
auto FeaturedImagesModel::nextPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->next();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto FeaturedImagesModel::previousPage() const -> void
|
||||
auto FeaturedImagesModel::previousPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->previous();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
qsizetype FeaturedImagesModel::page() const
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
#include "paginators/featuredimagespaginator.h"
|
||||
|
||||
@@ -74,7 +75,14 @@ public:
|
||||
OriginalUrlRole,
|
||||
MediumUrlRole,
|
||||
LargeUrlRole,
|
||||
ExtraLargeUrlRole
|
||||
ExtraLargeUrlRole,
|
||||
PortraitSizeRole,
|
||||
LandscapeSizeRole,
|
||||
SmallSizeRole,
|
||||
OriginalSizeRole,
|
||||
MediumSizeRole,
|
||||
LargeSizeRole,
|
||||
ExtraLargeSizeRole
|
||||
};
|
||||
Q_ENUM(DataRole)
|
||||
|
||||
@@ -200,13 +208,13 @@ public:
|
||||
* @brief nextPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto nextPage() const -> void;
|
||||
Q_INVOKABLE auto nextPage() -> void;
|
||||
|
||||
/**
|
||||
* @brief previousPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto previousPage() const -> void;
|
||||
Q_INVOKABLE auto previousPage() -> void;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -226,8 +234,19 @@ protected:
|
||||
*/
|
||||
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;
|
||||
@@ -238,6 +257,18 @@ signals:
|
||||
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 =
|
||||
{
|
||||
{
|
||||
@@ -291,6 +322,34 @@ private:
|
||||
{
|
||||
static_cast<int>(ExtraLargeUrlRole),
|
||||
QByteArray("extraLarge")
|
||||
},
|
||||
{
|
||||
static_cast<int>(PortraitSizeRole),
|
||||
QByteArray("portraitSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(LandscapeSizeRole),
|
||||
QByteArray("landscapeSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(SmallSizeRole),
|
||||
QByteArray("smallSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(OriginalSizeRole),
|
||||
QByteArray("originalSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(MediumSizeRole),
|
||||
QByteArray("mediumSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(LargeSizeRole),
|
||||
QByteArray("largeSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(ExtraLargeSizeRole),
|
||||
QByteArray("extraLargeSize")
|
||||
}
|
||||
};
|
||||
State m_state = Idle;
|
||||
@@ -299,8 +358,6 @@ private:
|
||||
|
||||
FeaturedImagesPaginator *m_paginator = nullptr;
|
||||
|
||||
mutable QList<ImageCache> m_data;
|
||||
|
||||
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)
|
||||
|
||||
@@ -36,10 +36,24 @@ FeaturedPacksModel::FeaturedPacksModel(QObject *parent) : QAbstractListModel{par
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::dataChanged,
|
||||
&PaginationNotifier::pageChanged,
|
||||
this,
|
||||
&FeaturedPacksModel::resetDataModel
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetchComplete,
|
||||
this,
|
||||
&FeaturedPacksModel::resetState
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetching,
|
||||
this,
|
||||
&FeaturedPacksModel::onPaginatorFetching
|
||||
);
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::rowCount(const QModelIndex &) const -> int
|
||||
@@ -54,12 +68,12 @@ auto FeaturedPacksModel::rowCount(const QModelIndex &) const -> int
|
||||
|
||||
auto FeaturedPacksModel::data(const QModelIndex &index, int role) const -> QVariant
|
||||
{
|
||||
if(index.row() < 0 || m_paginator == nullptr)
|
||||
if(index.row() < 0 || m_paginator == nullptr || index.row() >= m_paginator->count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
WallpaperCache dataPoint = m_data.at(index.row());
|
||||
WallpaperCache dataPoint = m_paginator->at(index.row());
|
||||
|
||||
QVariant data;
|
||||
|
||||
@@ -107,10 +121,12 @@ auto FeaturedPacksModel::index(int row, int column, const QModelIndex &parent) c
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if(row < 0 || row >= m_data.count())
|
||||
if(row < 0 || row >= m_paginator->count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return createIndex(row, column, &m_data[row]);
|
||||
return createIndex(row, column, &m_paginator[row]);
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::columnCount(const QModelIndex &) const -> int
|
||||
@@ -141,7 +157,7 @@ auto FeaturedPacksModel::setState(State state) -> void
|
||||
}
|
||||
|
||||
m_state = state;
|
||||
emit stateChanged();
|
||||
Q_EMIT stateChanged();
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::resetState() -> void
|
||||
@@ -152,22 +168,19 @@ auto FeaturedPacksModel::resetState() -> void
|
||||
auto FeaturedPacksModel::resetDataModel() -> void
|
||||
{
|
||||
//invalidate previous model data
|
||||
beginRemoveRows(QModelIndex(), 0, m_data.count());
|
||||
m_data.clear();
|
||||
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
|
||||
endRemoveRows();
|
||||
|
||||
//signal new data
|
||||
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
|
||||
auto dataset = m_paginator->data();
|
||||
|
||||
for(const WallpaperCache& data : std::as_const(dataset))
|
||||
{
|
||||
m_data.append(data);
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::onPaginatorFetching() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::roleNames() const -> QHash<int, QByteArray>
|
||||
{
|
||||
return m_dataRoles;
|
||||
@@ -186,7 +199,7 @@ auto FeaturedPacksModel::setErrorString(const QString &errorString) -> void
|
||||
}
|
||||
|
||||
m_errorString = errorString;
|
||||
emit errorStringChanged();
|
||||
Q_EMIT errorStringChanged();
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::resultsPerPage() const -> qsizetype
|
||||
@@ -202,9 +215,15 @@ auto FeaturedPacksModel::resultsPerPage() const -> qsizetype
|
||||
auto FeaturedPacksModel::setResultsPerPage(qsizetype resultsPerPage) -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this, resultsPerPage]
|
||||
{
|
||||
m_paginator->setResultsPerPage(resultsPerPage);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::totalResults() const -> qsizetype
|
||||
@@ -217,20 +236,32 @@ auto FeaturedPacksModel::totalResults() const -> qsizetype
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::nextPage() const -> void
|
||||
auto FeaturedPacksModel::nextPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->next();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto FeaturedPacksModel::previousPage() const -> void
|
||||
auto FeaturedPacksModel::previousPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->previous();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
qsizetype FeaturedPacksModel::page() const
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
#include "paginators/featuredpackspaginator.h"
|
||||
|
||||
@@ -198,13 +199,13 @@ public:
|
||||
* @brief nextPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto nextPage() const -> void;
|
||||
Q_INVOKABLE auto nextPage() -> void;
|
||||
|
||||
/**
|
||||
* @brief previousPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto previousPage() const -> void;
|
||||
Q_INVOKABLE auto previousPage() -> void;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -226,6 +227,8 @@ protected:
|
||||
|
||||
auto resetDataModel() -> void;
|
||||
|
||||
auto onPaginatorFetching() -> void;
|
||||
|
||||
signals:
|
||||
auto stateChanged() -> void;
|
||||
auto errorStringChanged() -> void;
|
||||
@@ -236,6 +239,10 @@ signals:
|
||||
auto totalPagesChanged() -> void;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_dataRoles
|
||||
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
|
||||
*/
|
||||
static inline const QHash<int, QByteArray> m_dataRoles =
|
||||
{
|
||||
{
|
||||
@@ -289,8 +296,6 @@ private:
|
||||
|
||||
FeaturedPacksPaginator *m_paginator = nullptr;
|
||||
|
||||
mutable QList<WallpaperCache> m_data;
|
||||
|
||||
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)
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
FeaturedVideosModel::FeaturedVideosModel(QObject *parent) : QAbstractListModel{parent}
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
m_paginator = new FeaturedVideosPaginator(this);
|
||||
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
|
||||
|
||||
@@ -38,10 +36,24 @@ FeaturedVideosModel::FeaturedVideosModel(QObject *parent) : QAbstractListModel{p
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::dataChanged,
|
||||
&PaginationNotifier::pageChanged,
|
||||
this,
|
||||
&FeaturedVideosModel::resetDataModel
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetchComplete,
|
||||
this,
|
||||
&FeaturedVideosModel::resetState
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetching,
|
||||
this,
|
||||
&FeaturedVideosModel::onPaginatorFetching
|
||||
);
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::rowCount(const QModelIndex &) const -> int
|
||||
@@ -56,12 +68,12 @@ auto FeaturedVideosModel::rowCount(const QModelIndex &) const -> int
|
||||
|
||||
auto FeaturedVideosModel::data(const QModelIndex &index, int role) const -> QVariant
|
||||
{
|
||||
if(index.row() < 0 || m_paginator == nullptr)
|
||||
if(index.row() < 0 || m_paginator == nullptr || index.row() >= m_paginator->count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
VideoCache dataPoint = m_data.at(index.row());
|
||||
VideoCache dataPoint = m_paginator->at(index.row());
|
||||
|
||||
QVariant data;
|
||||
|
||||
@@ -103,10 +115,17 @@ auto FeaturedVideosModel::index(int row, int column, const QModelIndex &parent)
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if(row < 0 || row >= m_data.count())
|
||||
if(m_paginator == nullptr)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return createIndex(row, column, &m_data[row]);
|
||||
if(row < 0 || row >= m_paginator->count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return createIndex(row, column, &m_paginator[row]);
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::columnCount(const QModelIndex &) const -> int
|
||||
@@ -147,25 +166,18 @@ auto FeaturedVideosModel::resetState() -> void
|
||||
|
||||
auto FeaturedVideosModel::resetDataModel() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
//invalidate previous model data
|
||||
beginRemoveRows(QModelIndex(), 0, m_data.count());
|
||||
m_data.clear();
|
||||
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
|
||||
endRemoveRows();
|
||||
|
||||
//signal new data
|
||||
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
|
||||
auto dataset = m_paginator->data();
|
||||
|
||||
for(const VideoCache& data : std::as_const(dataset))
|
||||
{
|
||||
m_data.append(data);
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
setState(Idle);
|
||||
auto FeaturedVideosModel::onPaginatorFetching() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::roleNames() const -> QHash<int, QByteArray>
|
||||
@@ -202,9 +214,15 @@ auto FeaturedVideosModel::resultsPerPage() const -> qsizetype
|
||||
auto FeaturedVideosModel::setResultsPerPage(qsizetype resultsPerPage) -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this, resultsPerPage]
|
||||
{
|
||||
m_paginator->setResultsPerPage(resultsPerPage);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::totalResults() const -> qsizetype
|
||||
@@ -217,20 +235,32 @@ auto FeaturedVideosModel::totalResults() const -> qsizetype
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::nextPage() const -> void
|
||||
auto FeaturedVideosModel::nextPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->next();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto FeaturedVideosModel::previousPage() const -> void
|
||||
auto FeaturedVideosModel::previousPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->previous();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
qsizetype FeaturedVideosModel::page() const
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
#include "paginators/featuredvideospaginator.h"
|
||||
|
||||
@@ -196,13 +197,13 @@ public:
|
||||
* @brief nextPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto nextPage() const -> void;
|
||||
Q_INVOKABLE auto nextPage() -> void;
|
||||
|
||||
/**
|
||||
* @brief previousPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto previousPage() const -> void;
|
||||
Q_INVOKABLE auto previousPage() -> void;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@@ -224,6 +225,8 @@ protected:
|
||||
|
||||
auto resetDataModel() -> void;
|
||||
|
||||
auto onPaginatorFetching() -> void;
|
||||
|
||||
signals:
|
||||
auto stateChanged() -> void;
|
||||
auto errorStringChanged() -> void;
|
||||
@@ -234,6 +237,10 @@ signals:
|
||||
auto totalPagesChanged() -> void;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief m_dataRoles
|
||||
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
|
||||
*/
|
||||
static inline const QHash<int, QByteArray> m_dataRoles =
|
||||
{
|
||||
{
|
||||
@@ -279,8 +286,6 @@ private:
|
||||
|
||||
FeaturedVideosPaginator *m_paginator = nullptr;
|
||||
|
||||
mutable QList<VideoCache> m_data;
|
||||
|
||||
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)
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
ImageSearchModel::ImageSearchModel(QObject *parent) : QAbstractListModel{parent}
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
m_paginator = new ImageSearchPaginator(this);
|
||||
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
|
||||
|
||||
@@ -37,11 +35,25 @@ ImageSearchModel::ImageSearchModel(QObject *parent) : QAbstractListModel{parent}
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::dataChanged,
|
||||
&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,
|
||||
@@ -50,6 +62,14 @@ ImageSearchModel::ImageSearchModel(QObject *parent) : QAbstractListModel{parent}
|
||||
);
|
||||
}
|
||||
|
||||
ImageSearchModel::~ImageSearchModel()
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
delete m_paginator;
|
||||
}
|
||||
}
|
||||
|
||||
auto ImageSearchModel::rowCount(const QModelIndex &) const -> int
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
@@ -62,12 +82,12 @@ auto ImageSearchModel::rowCount(const QModelIndex &) const -> int
|
||||
|
||||
auto ImageSearchModel::data(const QModelIndex &index, int role) const -> QVariant
|
||||
{
|
||||
if(index.row() < 0 || m_paginator == nullptr)
|
||||
if(index.row() < 0 || m_paginator == nullptr || index.row() >= m_paginator->count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
ImageCache dataPoint = m_data.at(index.row());
|
||||
ImageCache dataPoint = m_paginator->at(index.row());
|
||||
|
||||
QVariant data;
|
||||
|
||||
@@ -112,6 +132,27 @@ auto ImageSearchModel::data(const QModelIndex &index, int role) const -> QVarian
|
||||
case ExtraLargeUrlRole:
|
||||
data = dataPoint.sources.value(QString::fromUtf8("large2x"));
|
||||
break;
|
||||
case PortraitSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("portrait"));
|
||||
break;
|
||||
case LandscapeSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("landscape"));
|
||||
break;
|
||||
case SmallSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("small"));
|
||||
break;
|
||||
case OriginalSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("original"));
|
||||
break;
|
||||
case MediumSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("medium"));
|
||||
break;
|
||||
case LargeSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("large"));
|
||||
break;
|
||||
case ExtraLargeSizeRole:
|
||||
data = dataPoint.sourceSizes.value(QString::fromUtf8("large2x"));
|
||||
break;
|
||||
}
|
||||
|
||||
return data;
|
||||
@@ -121,10 +162,12 @@ auto ImageSearchModel::index(int row, int column, const QModelIndex &parent) con
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if(row < 0 || row >= m_data.count())
|
||||
if(row < 0 || row >= m_paginator->count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return createIndex(row, column, &m_data[row]);
|
||||
return createIndex(row, column, &m_paginator->at(row));
|
||||
}
|
||||
|
||||
auto ImageSearchModel::columnCount(const QModelIndex &) const -> int
|
||||
@@ -165,33 +208,26 @@ auto ImageSearchModel::resetState() -> void
|
||||
|
||||
auto ImageSearchModel::resetDataModel() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
//invalidate previous model data
|
||||
beginRemoveRows(QModelIndex(), 0, m_data.count());
|
||||
m_data.clear();
|
||||
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
|
||||
endRemoveRows();
|
||||
|
||||
//signal new data
|
||||
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
|
||||
auto dataset = m_paginator->data();
|
||||
|
||||
for(const ImageCache& data : std::as_const(dataset))
|
||||
{
|
||||
m_data.append(data);
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
|
||||
setState(Idle);
|
||||
}
|
||||
|
||||
auto ImageSearchModel::hasNextPage() -> bool
|
||||
auto ImageSearchModel::onPaginatorFetching() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
}
|
||||
|
||||
auto ImageSearchModel::hasNextPage() const -> bool
|
||||
{
|
||||
return m_paginator->page() < m_paginator->totalPages();
|
||||
}
|
||||
|
||||
auto ImageSearchModel::hasPreviousPage() -> bool
|
||||
auto ImageSearchModel::hasPreviousPage() const -> bool
|
||||
{
|
||||
return m_paginator->page() > 0;
|
||||
}
|
||||
@@ -231,7 +267,42 @@ 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();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,20 +316,32 @@ auto ImageSearchModel::totalResults() const -> qsizetype
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto ImageSearchModel::nextPage() const -> void
|
||||
auto ImageSearchModel::nextPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->next();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto ImageSearchModel::previousPage() const -> void
|
||||
auto ImageSearchModel::previousPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->previous();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto ImageSearchModel::query() const -> QString
|
||||
@@ -274,9 +357,15 @@ auto ImageSearchModel::query() const -> QString
|
||||
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
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
#include "paginators/imagesearchpaginator.h"
|
||||
|
||||
@@ -74,11 +75,19 @@ public:
|
||||
OriginalUrlRole,
|
||||
MediumUrlRole,
|
||||
LargeUrlRole,
|
||||
ExtraLargeUrlRole
|
||||
ExtraLargeUrlRole,
|
||||
PortraitSizeRole,
|
||||
LandscapeSizeRole,
|
||||
SmallSizeRole,
|
||||
OriginalSizeRole,
|
||||
MediumSizeRole,
|
||||
LargeSizeRole,
|
||||
ExtraLargeSizeRole
|
||||
};
|
||||
Q_ENUM(DataRole)
|
||||
|
||||
explicit ImageSearchModel(QObject *parent = nullptr);
|
||||
~ImageSearchModel();
|
||||
|
||||
auto rowCount(const QModelIndex &parent = QModelIndex()) const -> int override;
|
||||
|
||||
@@ -200,13 +209,13 @@ public:
|
||||
* @brief nextPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto nextPage() const -> void;
|
||||
Q_INVOKABLE auto nextPage() -> void;
|
||||
|
||||
/**
|
||||
* @brief previousPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto previousPage() const -> void;
|
||||
Q_INVOKABLE auto previousPage() -> void;
|
||||
|
||||
/**
|
||||
* @brief query
|
||||
@@ -217,20 +226,36 @@ public:
|
||||
|
||||
/**
|
||||
* @brief setQuery
|
||||
* Sets the current
|
||||
* 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;
|
||||
@@ -240,23 +265,67 @@ protected:
|
||||
*/
|
||||
auto resetState() -> void;
|
||||
|
||||
/**
|
||||
* @brief resetDataModel
|
||||
* Clears the data model and creates a new one if data exists
|
||||
*/
|
||||
auto resetDataModel() -> void;
|
||||
|
||||
auto hasNextPage() -> bool;
|
||||
|
||||
auto hasPreviousPage() -> bool;
|
||||
/**
|
||||
* @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 m_dataRoles
|
||||
* Data role map that connects ImageSearchModel::DataRole to it's QML accessor name
|
||||
*/
|
||||
static inline const QHash<int, QByteArray> m_dataRoles =
|
||||
{
|
||||
{
|
||||
@@ -310,6 +379,34 @@ private:
|
||||
{
|
||||
static_cast<int>(ExtraLargeUrlRole),
|
||||
QByteArray("extraLarge")
|
||||
},
|
||||
{
|
||||
static_cast<int>(PortraitSizeRole),
|
||||
QByteArray("portraitSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(LandscapeSizeRole),
|
||||
QByteArray("landscapeSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(SmallSizeRole),
|
||||
QByteArray("smallSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(OriginalSizeRole),
|
||||
QByteArray("originalSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(MediumSizeRole),
|
||||
QByteArray("mediumSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(LargeSizeRole),
|
||||
QByteArray("largeSize")
|
||||
},
|
||||
{
|
||||
static_cast<int>(ExtraLargeSizeRole),
|
||||
QByteArray("extraLargeSize")
|
||||
}
|
||||
};
|
||||
State m_state = Idle;
|
||||
@@ -318,8 +415,6 @@ private:
|
||||
|
||||
ImageSearchPaginator *m_paginator = nullptr;
|
||||
|
||||
mutable QList<ImageCache> m_data;
|
||||
|
||||
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)
|
||||
|
||||
@@ -38,10 +38,24 @@ NewestPacksModel::NewestPacksModel(QObject *parent) : QAbstractListModel{parent}
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::dataChanged,
|
||||
&PaginationNotifier::pageChanged,
|
||||
this,
|
||||
&NewestPacksModel::resetDataModel
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetchComplete,
|
||||
this,
|
||||
&NewestPacksModel::resetState
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::fetching,
|
||||
this,
|
||||
&NewestPacksModel::onPaginatorFetching
|
||||
);
|
||||
}
|
||||
|
||||
auto NewestPacksModel::rowCount(const QModelIndex &) const -> int
|
||||
@@ -56,12 +70,12 @@ auto NewestPacksModel::rowCount(const QModelIndex &) const -> int
|
||||
|
||||
auto NewestPacksModel::data(const QModelIndex &index, int role) const -> QVariant
|
||||
{
|
||||
if(index.row() < 0 || m_paginator == nullptr)
|
||||
if(index.row() < 0 || m_paginator == nullptr || index.row() >= m_paginator->count())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
WallpaperCache dataPoint = m_data.at(index.row());
|
||||
WallpaperCache dataPoint = m_paginator->at(index.row());
|
||||
|
||||
QVariant data;
|
||||
|
||||
@@ -109,10 +123,10 @@ auto NewestPacksModel::index(int row, int column, const QModelIndex &parent) con
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if(row < 0 || row >= m_data.count())
|
||||
if(row < 0 || row >= m_paginator->count())
|
||||
return {};
|
||||
|
||||
return createIndex(row, column, &m_data[row]);
|
||||
return createIndex(row, column, &m_paginator[row]);
|
||||
}
|
||||
|
||||
auto NewestPacksModel::columnCount(const QModelIndex &) const -> int
|
||||
@@ -153,23 +167,18 @@ auto NewestPacksModel::resetState() -> void
|
||||
|
||||
auto NewestPacksModel::resetDataModel() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
//invalidate previous model data
|
||||
beginRemoveRows(QModelIndex(), 0, m_data.count());
|
||||
m_data.clear();
|
||||
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
|
||||
endRemoveRows();
|
||||
|
||||
//signal new data
|
||||
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
|
||||
auto dataset = m_paginator->data();
|
||||
|
||||
for(const WallpaperCache& data : std::as_const(dataset))
|
||||
{
|
||||
m_data.append(data);
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
setState(Idle);
|
||||
}
|
||||
|
||||
auto NewestPacksModel::onPaginatorFetching() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
}
|
||||
|
||||
auto NewestPacksModel::roleNames() const -> QHash<int, QByteArray>
|
||||
@@ -224,17 +233,29 @@ auto NewestPacksModel::totalResults() const -> qsizetype
|
||||
auto NewestPacksModel::nextPage() const -> void
|
||||
{
|
||||
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
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
#include "paginators/newestpackspaginator.h"
|
||||
|
||||
@@ -236,6 +237,8 @@ protected:
|
||||
*/
|
||||
auto resetDataModel() -> void;
|
||||
|
||||
auto onPaginatorFetching() -> void;
|
||||
|
||||
signals:
|
||||
auto stateChanged() -> void;
|
||||
auto errorStringChanged() -> void;
|
||||
@@ -299,8 +302,6 @@ private:
|
||||
|
||||
NewestPacksPaginator *m_paginator = nullptr;
|
||||
|
||||
mutable QList<WallpaperCache> m_data;
|
||||
|
||||
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)
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
#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
|
||||
);
|
||||
}
|
||||
|
||||
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::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]
|
||||
{
|
||||
m_paginator->setResultsPerPage(resultsPerPage);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
/*
|
||||
* 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);
|
||||
|
||||
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:
|
||||
/**
|
||||
* 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
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_CUBEMAPS_FEATURED)
|
||||
);
|
||||
|
||||
controller()->setWindowSize(20);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_IMAGES_FEATURED)
|
||||
);
|
||||
|
||||
controller()->setWindowSize(20);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_PACKS_FEATURED)
|
||||
);
|
||||
|
||||
controller()->setWindowSize(20);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_SHADERS_FEATURED)
|
||||
);
|
||||
|
||||
controller()->setWindowSize(20);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_VIDEOS_FEATURED)
|
||||
);
|
||||
|
||||
controller()->setWindowSize(20);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -62,46 +62,12 @@ 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 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();
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief uriChanged
|
||||
*/
|
||||
auto uriChanged() -> void;
|
||||
|
||||
/**
|
||||
* @brief queryChanged
|
||||
*/
|
||||
auto queryChanged() -> void;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief fetch
|
||||
@@ -124,6 +90,11 @@ protected:
|
||||
{}
|
||||
);
|
||||
|
||||
if(queryable() && query().isEmpty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QUrl url(
|
||||
QString::fromUtf8("%1/%2/%3").arg(
|
||||
KOMPLEX_API_HOST,
|
||||
@@ -138,7 +109,7 @@ protected:
|
||||
{
|
||||
{
|
||||
QByteArray("query"),
|
||||
m_query.toUtf8()
|
||||
query().toUtf8()
|
||||
},
|
||||
{
|
||||
QByteArray("offset"),
|
||||
@@ -181,13 +152,28 @@ protected:
|
||||
|
||||
const QVariantMap sources = resultObject.value(QString::fromUtf8("src")).toObject().toVariantMap();
|
||||
QMap<QString, QString> sourceMap;
|
||||
QMap<QString, QString> sizeMap;
|
||||
|
||||
QMapIterator<QString,QVariant> sourceIterator(sources);
|
||||
|
||||
while(sourceIterator.hasNext())
|
||||
{
|
||||
sourceIterator.next();
|
||||
sourceMap.insert(sourceIterator.key(), sourceIterator.value().toString());
|
||||
|
||||
QString url = sourceIterator.value().toString();
|
||||
sourceMap.insert(sourceIterator.key(), url);
|
||||
|
||||
auto matches = s_sizeExpression.match(url);
|
||||
|
||||
if(matches.hasMatch())
|
||||
{
|
||||
QString size = matches.captured();
|
||||
size.remove(QString::fromUtf8("w="));
|
||||
size.remove(QString::fromUtf8("h="));
|
||||
size.replace(QLatin1Char('&'), QLatin1Char('x'));
|
||||
|
||||
sizeMap.insert(sourceIterator.key(), std::move(size));
|
||||
}
|
||||
}
|
||||
|
||||
fetchedResults.append(
|
||||
@@ -202,6 +188,7 @@ protected:
|
||||
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()
|
||||
}
|
||||
);
|
||||
@@ -307,10 +294,13 @@ private:
|
||||
QString m_uri;
|
||||
|
||||
/**
|
||||
* @brief m_query
|
||||
* The query string used in fetch operations
|
||||
* @brief s_sizeExpression
|
||||
* Regular expression used to extract size data from the url
|
||||
*/
|
||||
QString m_query;
|
||||
inline static QRegularExpression s_sizeExpression = QRegularExpression
|
||||
(
|
||||
QString::fromUtf8("[h]\\=\\d{1,}\\&[w]\\=\\d{1,}")
|
||||
);
|
||||
};
|
||||
|
||||
#endif // IMAGEPAGINATOR_H
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_IMAGES_SEARCH)
|
||||
);
|
||||
|
||||
setQueryable(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_PACKS_NEWEST)
|
||||
);
|
||||
|
||||
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 SEARCHPACKSPAGINATOR_H
|
||||
#define SEARCHPACKSPAGINATOR_H
|
||||
#ifndef PACKSEARCHPAGINATOR_H
|
||||
#define PACKSEARCHPAGINATOR_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QNetworkAccessManager>
|
||||
@@ -31,15 +31,17 @@
|
||||
|
||||
#include "wallpaperpaginator.h"
|
||||
|
||||
class KOMPLEX_EXPORT SearchPacksPaginator : public WallpaperPaginator
|
||||
class KOMPLEX_EXPORT PackSearchPaginator : public WallpaperPaginator
|
||||
{
|
||||
public:
|
||||
explicit SearchPacksPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
|
||||
explicit PackSearchPaginator(QObject *parent = nullptr) : WallpaperPaginator(parent)
|
||||
{
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_PACKS_SEARCH)
|
||||
);
|
||||
|
||||
setQueryable(true);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SEARCHPACKSPAGINATOR_H
|
||||
#endif // PACKSEARCHPAGINATOR_H
|
||||
@@ -62,47 +62,12 @@ 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 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();
|
||||
|
||||
reset();
|
||||
setOffset(0);
|
||||
}
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief uriChanged
|
||||
*/
|
||||
auto uriChanged() -> void;
|
||||
|
||||
/**
|
||||
* @brief queryChanged
|
||||
*/
|
||||
auto queryChanged() -> void;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief fetch
|
||||
@@ -125,6 +90,11 @@ protected:
|
||||
{}
|
||||
);
|
||||
|
||||
if(queryable() && query().isEmpty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QUrl url(
|
||||
QString::fromUtf8("%1/%2/%3").arg(
|
||||
KOMPLEX_API_HOST,
|
||||
@@ -139,7 +109,7 @@ protected:
|
||||
{
|
||||
{
|
||||
QByteArray("query"),
|
||||
m_query.toUtf8()
|
||||
query().toUtf8()
|
||||
},
|
||||
{
|
||||
QByteArray("offset"),
|
||||
@@ -258,7 +228,12 @@ protected:
|
||||
|
||||
QNetworkReply *reply = manager->post(request, nullptr);
|
||||
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||
QObject::connect(reply, &QNetworkReply::errorOccurred, &loop,
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
reply,
|
||||
&QNetworkReply::errorOccurred,
|
||||
&loop,
|
||||
[&loop](QNetworkReply::NetworkError error) -> void
|
||||
{
|
||||
loop.quit();
|
||||
|
||||
@@ -39,6 +39,8 @@ public:
|
||||
setUri(
|
||||
QString::fromUtf8(KOMPLEX_ENDPOINT_VIDEOS_SEARCH)
|
||||
);
|
||||
|
||||
setQueryable(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -98,11 +98,6 @@ signals:
|
||||
*/
|
||||
auto uriChanged() -> void;
|
||||
|
||||
/**
|
||||
* @brief queryChanged
|
||||
*/
|
||||
auto queryChanged() -> void;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief fetch
|
||||
@@ -125,6 +120,11 @@ protected:
|
||||
{}
|
||||
);
|
||||
|
||||
if(queryable() && query().isEmpty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
QUrl url(
|
||||
QString::fromUtf8("%1/%2/%3").arg(
|
||||
KOMPLEX_API_HOST,
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
VideoSearchModel::VideoSearchModel(QObject *parent) : QAbstractListModel{parent}
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
m_paginator = new VideoSearchPaginator(this);
|
||||
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
|
||||
|
||||
@@ -37,11 +35,25 @@ VideoSearchModel::VideoSearchModel(QObject *parent) : QAbstractListModel{parent}
|
||||
|
||||
QObject::connect(
|
||||
notifier,
|
||||
&PaginationNotifier::dataChanged,
|
||||
&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,
|
||||
@@ -62,12 +74,17 @@ auto VideoSearchModel::rowCount(const QModelIndex &) const -> int
|
||||
|
||||
auto VideoSearchModel::data(const QModelIndex &index, int role) const -> QVariant
|
||||
{
|
||||
if(index.row() < 0 || m_paginator == nullptr)
|
||||
if(m_paginator == nullptr)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
VideoCache dataPoint = m_data.at(index.row());
|
||||
if(index.row() < 0 || index.row() >= m_paginator->count() )
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
VideoCache dataPoint = m_paginator->at(index.row());
|
||||
|
||||
QVariant data;
|
||||
|
||||
@@ -109,10 +126,10 @@ auto VideoSearchModel::index(int row, int column, const QModelIndex &parent) con
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
|
||||
if(row < 0 || row >= m_data.count())
|
||||
if(row < 0 || row >= m_paginator->count())
|
||||
return {};
|
||||
|
||||
return createIndex(row, column, &m_data[row]);
|
||||
return createIndex(row, column, &m_paginator[row]);
|
||||
}
|
||||
|
||||
auto VideoSearchModel::columnCount(const QModelIndex &) const -> int
|
||||
@@ -153,37 +170,30 @@ auto VideoSearchModel::resetState() -> void
|
||||
|
||||
auto VideoSearchModel::resetDataModel() -> void
|
||||
{
|
||||
setState(Loading);
|
||||
|
||||
//invalidate previous model data
|
||||
beginRemoveRows(QModelIndex(), 0, m_data.count());
|
||||
m_data.clear();
|
||||
beginRemoveRows(QModelIndex(), 0, m_paginator->count());
|
||||
endRemoveRows();
|
||||
|
||||
//signal new data
|
||||
beginInsertRows(QModelIndex(), 0, m_paginator->count() - 1);
|
||||
auto dataset = m_paginator->data();
|
||||
|
||||
for(const VideoCache& data : std::as_const(dataset))
|
||||
{
|
||||
m_data.append(data);
|
||||
}
|
||||
|
||||
endInsertRows();
|
||||
|
||||
setState(Idle);
|
||||
}
|
||||
|
||||
auto VideoSearchModel::hasNextPage() -> bool
|
||||
auto VideoSearchModel::hasNextPage() const -> bool
|
||||
{
|
||||
return m_paginator->page() < m_paginator->totalPages();
|
||||
}
|
||||
|
||||
auto VideoSearchModel::hasPreviousPage() -> bool
|
||||
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;
|
||||
@@ -218,9 +228,15 @@ auto VideoSearchModel::resultsPerPage() const -> qsizetype
|
||||
auto VideoSearchModel::setResultsPerPage(qsizetype resultsPerPage) -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this, resultsPerPage]
|
||||
{
|
||||
m_paginator->setResultsPerPage(resultsPerPage);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto VideoSearchModel::totalResults() const -> qsizetype
|
||||
@@ -233,20 +249,32 @@ auto VideoSearchModel::totalResults() const -> qsizetype
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto VideoSearchModel::nextPage() const -> void
|
||||
auto VideoSearchModel::nextPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->next();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto VideoSearchModel::previousPage() const -> void
|
||||
auto VideoSearchModel::previousPage() -> void
|
||||
{
|
||||
if(m_paginator != nullptr)
|
||||
{
|
||||
QFuture<void> future = QtConcurrent::run
|
||||
(
|
||||
[this]
|
||||
{
|
||||
m_paginator->previous();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
auto VideoSearchModel::query() const -> QString
|
||||
@@ -262,9 +290,15 @@ auto VideoSearchModel::query() const -> QString
|
||||
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
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QEventLoop>
|
||||
#include <QtConcurrent/QtConcurrentRun>
|
||||
|
||||
#include "paginators/videosearchpaginator.h"
|
||||
|
||||
@@ -196,13 +197,13 @@ public:
|
||||
* @brief nextPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto nextPage() const -> void;
|
||||
Q_INVOKABLE auto nextPage() -> void;
|
||||
|
||||
/**
|
||||
* @brief previousPage
|
||||
* Function for the QML frontend
|
||||
*/
|
||||
Q_INVOKABLE auto previousPage() const -> void;
|
||||
Q_INVOKABLE auto previousPage() -> void;
|
||||
|
||||
/**
|
||||
* @brief query
|
||||
@@ -213,12 +214,34 @@ public:
|
||||
|
||||
/**
|
||||
* @brief setQuery
|
||||
* Sets the current
|
||||
* 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
|
||||
@@ -236,23 +259,59 @@ protected:
|
||||
*/
|
||||
auto resetState() -> void;
|
||||
|
||||
/**
|
||||
* @brief resetDataModel
|
||||
* Clears the data model and creates a new one if data exists
|
||||
*/
|
||||
auto resetDataModel() -> void;
|
||||
|
||||
auto hasNextPage() -> bool;
|
||||
|
||||
auto hasPreviousPage() -> bool;
|
||||
|
||||
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:
|
||||
/**
|
||||
* Data role map that connects VideoSearchModel::DataRole to it's QML accessor name
|
||||
*/
|
||||
static inline const QHash<int, QByteArray> m_dataRoles =
|
||||
{
|
||||
{
|
||||
@@ -298,8 +357,6 @@ private:
|
||||
|
||||
VideoSearchPaginator *m_paginator = nullptr;
|
||||
|
||||
mutable QList<VideoCache> m_data;
|
||||
|
||||
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)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"><path d="M 14 10 C 12.128906 10 8.585938 12.070313 2.3125 21.925781 C 1.996094 22.421875 1.929688 23.023438 2.097656 23.574219 C 2.035156 23.707031 2 23.851563 2 24 L 2 39 C 2 40.070313 2.863281 41 3.957031 41 L 19.992188 41 C 21.109375 41 22.125 40.332031 22.605469 39.324219 C 22.617188 39.300781 22.628906 39.277344 22.636719 39.25 L 24.523438 34.324219 C 24.648438 34.066406 24.8125 34 25 34 C 25.1875 34 25.351563 34.066406 25.476563 34.324219 L 27.363281 39.25 C 27.371094 39.277344 27.382813 39.300781 27.394531 39.324219 C 27.875 40.332031 28.890625 41 30.007813 41 L 46.042969 41 C 47.136719 41 48 40.070313 48 39 L 48 24 C 48 23.855469 47.96875 23.714844 47.90625 23.582031 C 48.0625 23.074219 48.015625 22.519531 47.753906 22.042969 C 44.757813 16.550781 40.460938 10 37 10 C 32 10 32 15.269531 32 17 C 32 17.027344 32 17.054688 32 17.082031 C 32.066406 18.65625 33.1875 21 36 21 C 36.496094 21 36.972656 20.851563 37.386719 20.578125 C 37.585938 21.382813 37.773438 22.203125 37.949219 23 L 28.828125 23 C 28.007813 23 27.441406 23.355469 26.941406 23.605469 C 26.445313 23.855469 26.007813 24 25.953125 24 L 24.042969 24 C 23.992188 24 23.554688 23.855469 23.058594 23.605469 C 22.558594 23.355469 21.992188 23 21.171875 23 L 12.121094 23 C 12.441406 22.0625 12.777344 21.097656 13.125 20.171875 C 13.5625 20.6875 14.164063 21 15 21 C 17.8125 21 18.933594 18.65625 19 17.082031 C 19 17.054688 19 17.027344 19 17 C 19 15.269531 19 10 14 10 Z M 14 12 C 17 12 17 15.082031 17 17 C 17 17 16.917969 19 15 19 C 14 19 14 15.582031 14 14 C 13.003906 14 10 23 10 23 L 4 23 C 4 23 11 12 14 12 Z M 37 12 C 40 12 46 23 46 23 L 40 23 C 40 23 38.082031 14 37 14 C 37 15.582031 37.082031 19 36 19 C 34.082031 19 34 17 34 17 C 34 15.082031 34 12 37 12 Z M 4 25 L 21.171875 25 C 21.226563 25 21.660156 25.144531 22.160156 25.394531 C 22.660156 25.644531 23.226563 26 24.042969 26 L 25.953125 26 C 26.773438 26 27.339844 25.644531 27.839844 25.394531 C 28.335938 25.144531 28.773438 25 28.828125 25 L 46 25 L 46 39 L 30.007813 39 C 29.679688 39 29.371094 38.808594 29.203125 38.464844 L 27.316406 33.535156 C 27.308594 33.511719 27.296875 33.484375 27.285156 33.460938 C 26.839844 32.53125 25.910156 32 25 32 C 24.089844 32 23.160156 32.53125 22.714844 33.460938 C 22.703125 33.484375 22.691406 33.511719 22.683594 33.535156 L 20.796875 38.464844 C 20.628906 38.808594 20.320313 39 19.992188 39 L 4 39 Z M 6.976563 27.03125 C 6.421875 27.03125 5.96875 27.464844 5.96875 28 L 5.96875 36.011719 C 5.96875 36.515625 6.480469 37.011719 7 37.011719 L 18 37.011719 C 18.507813 37.011719 18.839844 36.386719 19.035156 36.011719 C 19.964844 33.976563 20.230469 31.71875 21.21875 28.296875 C 21.410156 27.707031 21.261719 27.03125 19.988281 27.03125 Z M 29.972656 27.03125 C 28.699219 27.03125 28.550781 27.707031 28.746094 28.296875 C 29.734375 31.71875 29.996094 33.976563 30.925781 36.011719 C 31.121094 36.386719 31.457031 37.011719 31.964844 37.011719 L 42.964844 37.011719 C 43.484375 37.011719 43.996094 36.515625 43.996094 36.011719 L 43.996094 28 C 43.996094 27.464844 43.539063 27.03125 42.984375 27.03125 Z"/></svg>
|
||||
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0"?><svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"> <path d="M15,29h13V16H15V29z M23.167,9c0.238,0,0.47,0.085,0.65,0.241L29.37,14H46L34.418,3.256C34.234,3.091,33.997,3,33.75,3 H4.357l5.5,6H23.167z M8,24.167V10c0-0.016,0.006-0.03,0.007-0.046c0-0.004-0.001-0.009-0.001-0.013L3,4.48v30.27 c0,0.23,0.08,0.454,0.226,0.632L13,47V30.369l-4.759-5.552C8.085,24.636,8,24.405,8,24.167z M30,16v5h9.586l-1.293-1.293 c-0.391-0.391-0.391-1.023,0-1.414s1.023-0.391,1.414,0l3,3c0.391,0.391,0.391,1.023,0,1.414l-3,3C39.512,25.902,39.256,26,39,26 s-0.512-0.098-0.707-0.293c-0.391-0.391-0.391-1.023,0-1.414L39.586,23H30v7c0,0.552-0.447,1-1,1h-7v9.586l1.293-1.293 c0.391-0.391,1.023-0.391,1.414,0s0.391,1.023,0,1.414l-3,3C21.512,43.902,21.256,44,21,44s-0.512-0.098-0.707-0.293l-3-3 c-0.391-0.391-0.391-1.023,0-1.414s1.023-0.391,1.414,0L20,40.586V31h-5v17h31c0.553,0,1-0.448,1-1V16H30z M10,23.796l3,3.5V15.414 l-3-3V23.796z M22.797,11H11.69l2.75,3h11.857L22.797,11z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"><path d="M 12.78125 5.96875 C 11.75 6.082031 10.976563 6.964844 11 8 L 11 42 C 10.988281 42.722656 11.367188 43.390625 11.992188 43.753906 C 12.613281 44.121094 13.386719 44.121094 14.007813 43.753906 C 14.632813 43.390625 15.011719 42.722656 15 42 L 15 8 C 15.007813 7.457031 14.796875 6.9375 14.414063 6.554688 C 14.03125 6.171875 13.511719 5.960938 12.96875 5.96875 C 12.90625 5.964844 12.84375 5.964844 12.78125 5.96875 Z M 36.78125 5.96875 C 35.75 6.082031 34.976563 6.964844 35 8 L 35 42 C 34.988281 42.722656 35.367188 43.390625 35.992188 43.753906 C 36.613281 44.121094 37.386719 44.121094 38.007813 43.753906 C 38.632813 43.390625 39.011719 42.722656 39 42 L 39 8 C 39.007813 7.457031 38.796875 6.9375 38.414063 6.554688 C 38.03125 6.171875 37.511719 5.960938 36.96875 5.96875 C 36.90625 5.964844 36.84375 5.964844 36.78125 5.96875 Z M 6.78125 14.96875 C 5.75 15.082031 4.976563 15.964844 5 17 L 5 33 C 4.988281 33.722656 5.367188 34.390625 5.992188 34.753906 C 6.613281 35.121094 7.386719 35.121094 8.007813 34.753906 C 8.632813 34.390625 9.011719 33.722656 9 33 L 9 17 C 9.007813 16.457031 8.796875 15.9375 8.414063 15.554688 C 8.03125 15.171875 7.511719 14.960938 6.96875 14.96875 C 6.90625 14.964844 6.84375 14.964844 6.78125 14.96875 Z M 42.78125 14.96875 C 41.75 15.082031 40.976563 15.964844 41 17 L 41 33 C 40.988281 33.722656 41.367188 34.390625 41.992188 34.753906 C 42.613281 35.121094 43.386719 35.121094 44.007813 34.753906 C 44.632813 34.390625 45.011719 33.722656 45 33 L 45 17 C 45.007813 16.457031 44.796875 15.9375 44.414063 15.554688 C 44.03125 15.171875 43.511719 14.960938 42.96875 14.96875 C 42.90625 14.964844 42.84375 14.964844 42.78125 14.96875 Z M 18.78125 15.96875 C 17.75 16.082031 16.976563 16.964844 17 18 L 17 32 C 16.988281 32.722656 17.367188 33.390625 17.992188 33.753906 C 18.613281 34.121094 19.386719 34.121094 20.007813 33.753906 C 20.632813 33.390625 21.011719 32.722656 21 32 L 21 18 C 21.007813 17.457031 20.796875 16.9375 20.414063 16.554688 C 20.03125 16.171875 19.511719 15.960938 18.96875 15.96875 C 18.90625 15.964844 18.84375 15.964844 18.78125 15.96875 Z M 30.78125 15.96875 C 29.75 16.082031 28.976563 16.964844 29 18 L 29 32 C 28.988281 32.722656 29.367188 33.390625 29.992188 33.753906 C 30.613281 34.121094 31.386719 34.121094 32.007813 33.753906 C 32.632813 33.390625 33.011719 32.722656 33 32 L 33 18 C 33.007813 17.457031 32.796875 16.9375 32.414063 16.554688 C 32.03125 16.171875 31.511719 15.960938 30.96875 15.96875 C 30.90625 15.964844 30.84375 15.964844 30.78125 15.96875 Z M 0.90625 20.96875 C 0.863281 20.976563 0.820313 20.988281 0.78125 21 C 0.316406 21.105469 -0.0117188 21.523438 0 22 L 0 28 C -0.00390625 28.359375 0.183594 28.695313 0.496094 28.878906 C 0.808594 29.058594 1.191406 29.058594 1.503906 28.878906 C 1.816406 28.695313 2.003906 28.359375 2 28 L 2 22 C 2.011719 21.710938 1.894531 21.433594 1.6875 21.238281 C 1.476563 21.039063 1.191406 20.941406 0.90625 20.96875 Z M 24.78125 20.96875 C 23.75 21.082031 22.976563 21.964844 23 23 L 23 27 C 22.988281 27.722656 23.367188 28.390625 23.992188 28.753906 C 24.613281 29.121094 25.386719 29.121094 26.007813 28.753906 C 26.632813 28.390625 27.011719 27.722656 27 27 L 27 23 C 27.007813 22.457031 26.796875 21.9375 26.414063 21.554688 C 26.03125 21.171875 25.511719 20.960938 24.96875 20.96875 C 24.90625 20.964844 24.84375 20.964844 24.78125 20.96875 Z M 48.90625 20.96875 C 48.863281 20.976563 48.820313 20.988281 48.78125 21 C 48.316406 21.105469 47.988281 21.523438 48 22 L 48 28 C 47.996094 28.359375 48.183594 28.695313 48.496094 28.878906 C 48.808594 29.058594 49.191406 29.058594 49.503906 28.878906 C 49.816406 28.695313 50.003906 28.359375 50 28 L 50 22 C 50.011719 21.710938 49.894531 21.433594 49.6875 21.238281 C 49.476563 21.039063 49.191406 20.941406 48.90625 20.96875 Z"/></svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1 @@
|
||||
<svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="100px" height="100px"><path d="M 19.09375 5 C 18.097656 5 17.1875 5.53125 16.5625 6.46875 L 14.9375 9 L 6 9 C 3.242188 9 1 11.242188 1 14 L 1 38 C 1 40.757813 3.242188 43 6 43 L 44 43 C 46.757813 43 49 40.757813 49 38 L 49 14 C 49 11.242188 46.757813 9 44 9 L 34.9375 9 L 33.34375 6.4375 C 32.730469 5.519531 31.808594 5 30.8125 5 Z M 10 14 C 11.101563 14 12 14.898438 12 16 C 12 17.101563 11.101563 18 10 18 C 8.898438 18 8 17.101563 8 16 C 8 14.898438 8.898438 14 10 14 Z M 25 15 C 31.066406 15 36 19.933594 36 26 C 36 32.066406 31.066406 37 25 37 C 18.933594 37 14 32.066406 14 26 C 14 19.933594 18.933594 15 25 15 Z M 25 17 C 20.039063 17 16 21.039063 16 26 C 16 30.964844 20.039063 35 25 35 C 29.964844 35 34 30.964844 34 26 C 34 21.039063 29.964844 17 25 17 Z"/></svg>
|
||||
|
After Width: | Height: | Size: 857 B |
@@ -0,0 +1 @@
|
||||
<svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"><path d="M 25 4 L 4 17.34375 L 4 32.652344 L 25 46 L 46 32.65625 L 46 17.34375 Z M 25 29.183594 L 19.066406 25.070313 L 25 21.023438 L 30.933594 25.070313 Z M 27 17.605469 L 27 9.949219 L 40.429688 18.484375 L 34.410156 22.65625 Z M 23 17.605469 L 15.589844 22.65625 L 9.570313 18.484375 L 23 9.949219 Z M 12.09375 25.042969 L 8 27.832031 L 8 22.203125 Z M 15.570313 27.453125 L 23 32.605469 L 23 40.050781 L 9.589844 31.527344 Z M 27 32.605469 L 34.429688 27.453125 L 40.410156 31.527344 L 27 40.050781 Z M 37.90625 25.042969 L 42 22.203125 L 42 27.832031 Z"/></svg>
|
||||
|
After Width: | Height: | Size: 670 B |
@@ -0,0 +1 @@
|
||||
<svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="50px" height="50px"><path d="M25 23.844l18.096-10.447L25.504 3.136c-.311-.182-.697-.182-1.008 0L6.905 13.397 25 23.844zM24 25.577L6 15.185V35.5c0 .355.188.685.496.864L24 46.575V25.577zM26 25.577v20.998l17.504-10.211C43.812 36.185 44 35.855 44 35.5V15.186L26 25.577z"/></svg>
|
||||
|
After Width: | Height: | Size: 357 B |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0"?><svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="100px" height="100px"> <path d="M 15 1 C 14.448 1 14 1.448 14 2 L 14 6 L 16 6 L 16 2 C 16 1.448 15.552 1 15 1 z M 16 6 L 16 18.585938 L 18.292969 16.292969 C 18.683969 15.901969 19.316031 15.901969 19.707031 16.292969 C 20.098031 16.683969 20.098031 17.316031 19.707031 17.707031 L 15.707031 21.707031 C 15.512031 21.902031 15.256 22 15 22 C 14.744 22 14.487969 21.902031 14.292969 21.707031 L 10.292969 17.707031 C 9.9019687 17.316031 9.9019688 16.683969 10.292969 16.292969 C 10.683969 15.901969 11.316031 15.901969 11.707031 16.292969 L 14 18.585938 L 14 6 L 6 6 C 4.895 6 4 6.895 4 8 L 4 25 C 4 26.105 4.895 27 6 27 L 24 27 C 25.105 27 26 26.105 26 25 L 26 8 C 26 6.895 25.105 6 24 6 L 16 6 z"/></svg>
|
||||
|
After Width: | Height: | Size: 812 B |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0"?><svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="100px" height="100px"> <path d="M 6 3 A 1 1 0 0 0 5 4 A 1 1 0 0 0 5 4.0039062 L 5 15 L 5 25.996094 A 1 1 0 0 0 5 26 A 1 1 0 0 0 6 27 A 1 1 0 0 0 6.5800781 26.8125 L 6.5820312 26.814453 L 26.416016 15.908203 A 1 1 0 0 0 27 15 A 1 1 0 0 0 26.388672 14.078125 L 6.5820312 3.1855469 L 6.5800781 3.1855469 A 1 1 0 0 0 6 3 z"/></svg>
|
||||
|
After Width: | Height: | Size: 434 B |
@@ -0,0 +1 @@
|
||||
<?xml version="1.0"?><svg fill="#FFFFFF" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="100px" height="100px"> <path d="M22,6H8C6.895,6,6,6.895,6,8v14c0,1.105,0.895,2,2,2h14c1.105,0,2-0.895,2-2V8C24,6.895,23.105,6,22,6z"/></svg>
|
||||
|
After Width: | Height: | Size: 247 B |
|
After Width: | Height: | Size: 1.0 MiB |
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="256" height="256">
|
||||
<path d="M0 0 C84.48 0 168.96 0 256 0 C256 84.48 256 168.96 256 256 C171.52 256 87.04 256 0 256 C0 171.52 0 87.04 0 0 Z " fill="#181818" transform="translate(0,0)"/>
|
||||
<path d="M0 0 C1.09441406 0.84304687 1.09441406 0.84304687 2.2109375 1.703125 C3.02304688 2.32703125 3.83515625 2.9509375 4.671875 3.59375 C16.47013653 13.39538265 25.38731594 28.22446593 27.03222656 43.60986328 C28.60593213 62.04285713 25.62016469 78.91524518 13.76953125 93.76171875 C5.01402855 103.96349254 -4.93033814 111.41182902 -17.7890625 115.703125 C-18.4694458 115.96569092 -19.1498291 116.22825684 -19.85083008 116.4987793 C-29.75386424 119.8404508 -40.1667607 119.02518869 -50.4765625 118.890625 C-57.1796875 118.82875 -63.8828125 118.766875 -70.7890625 118.703125 C-70.7890625 145.763125 -70.7890625 172.823125 -70.7890625 200.703125 C-108.4090625 200.703125 -146.0290625 200.703125 -184.7890625 200.703125 C-184.7890625 163.083125 -184.7890625 125.463125 -184.7890625 86.703125 C-157.7290625 86.703125 -130.6690625 86.703125 -102.7890625 86.703125 C-102.7890625 73.503125 -102.7890625 60.303125 -102.7890625 46.703125 C-99.26329541 30.24954527 -99.26329541 30.24954527 -96.2890625 24.578125 C-95.7784729 23.58437866 -95.7784729 23.58437866 -95.25756836 22.57055664 C-86.70637388 6.77129742 -71.67156051 -4.50909354 -54.7890625 -10.171875 C-36.32361252 -14.71432194 -15.42912627 -11.02876174 0 0 Z " fill="#FDFDFD" transform="translate(184.7890625,55.296875)"/>
|
||||
<path d="M0 0 C27.06 0 54.12 0 82 0 C82 27.06 82 54.12 82 82 C54.94 82 27.88 82 0 82 C0 54.94 0 27.88 0 0 Z " fill="#181818" transform="translate(0,174)"/>
|
||||
<path d="M0 0 C8.54223462 5.26240815 13.58712715 12.26138144 16.7265625 21.6796875 C17.61615271 33.71103045 16.47172139 42.47747774 8.6640625 51.9921875 C2.30756952 58.68544832 -5.98410523 62.52737517 -15.21582031 62.79321289 C-16.80274318 62.79305528 -18.38967179 62.78744838 -19.9765625 62.77734375 C-21.23324738 62.77522133 -21.23324738 62.77522133 -22.51531982 62.77305603 C-25.18472907 62.76746947 -27.8540537 62.75491944 -30.5234375 62.7421875 C-32.33593629 62.73717076 -34.14843639 62.73260816 -35.9609375 62.72851562 C-40.39846998 62.71750444 -44.83593941 62.70024905 -49.2734375 62.6796875 C-49.3730552 57.16623069 -49.4452566 51.65330922 -49.49316406 46.13916016 C-49.51315613 44.26732241 -49.54035918 42.39554612 -49.57519531 40.52392578 C-49.99909869 17.1469011 -49.99909869 17.1469011 -41.2734375 7.4296875 C-29.8843011 -4.33043054 -14.910255 -7.11351788 0 0 Z " fill="#1A1A1A" transform="translate(163.2734375,79.3203125)"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.6 KiB |