From 3d0655edd1397f9307204e53b4bbba649852cfe7 Mon Sep 17 00:00:00 2001 From: Digital Artifex <7929434+DigitalArtifex@users.noreply.github.com> Date: Thu, 13 Aug 2026 08:12:45 -0400 Subject: [PATCH] Added Featured List Pages --- CMakeLists.txt | 1 + KomplexHubContent/CMakeLists.txt | 3 + KomplexHubContent/pages/HomePage.qml | 100 ++++++++++++++++++ .../Controls/HorizontalPaginator.qml | 4 + KomplexHubPlugin/common/paginator.h | 23 ++++ .../common/slidingcachecontroller.h | 7 ++ KomplexHubPlugin/featuredimagesmodel.cpp | 1 - KomplexHubPlugin/featuredimagesmodel.h | 1 - KomplexHubPlugin/featuredvideosmodel.cpp | 18 ++++ KomplexHubPlugin/featuredvideosmodel.h | 17 ++- 10 files changed, 172 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0122d67..84194f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ qt_standard_project_setup() qt_add_executable(${CMAKE_PROJECT_NAME} ) + qt_add_resources(${CMAKE_PROJECT_NAME} "configuration" PREFIX "/" FILES diff --git a/KomplexHubContent/CMakeLists.txt b/KomplexHubContent/CMakeLists.txt index 1394b19..567171f 100644 --- a/KomplexHubContent/CMakeLists.txt +++ b/KomplexHubContent/CMakeLists.txt @@ -18,6 +18,9 @@ qt6_add_qml_module(KomplexHubContent "pages/UserProfilePage.qml" "pages/WallpaperSettingsPage.qml" "pages/VideoSearchPage.qml" + QML_FILES pages/FeaturedVideosPage.qml + QML_FILES pages/FeaturedPacksPage.qml + QML_FILES pages/FeaturedImagesPage.qml ) diff --git a/KomplexHubContent/pages/HomePage.qml b/KomplexHubContent/pages/HomePage.qml index de5fc22..30511ca 100644 --- a/KomplexHubContent/pages/HomePage.qml +++ b/KomplexHubContent/pages/HomePage.qml @@ -116,6 +116,11 @@ Item } } } + + onViewMoreTriggered: () => + { + showFeaturedPacksPage() + } } Text @@ -168,6 +173,11 @@ Item } } } + + onViewMoreTriggered: () => + { + showFeaturedImagesPage() + } } Text @@ -215,6 +225,11 @@ Item onViewMoreTriggered:() => showVideoPopup(parent.index) } } + + onViewMoreTriggered: () => + { + showFeaturedVideosPage() + } } /* spacer */ @@ -301,6 +316,51 @@ Item } } + FeaturedVideosPage + { + id: featuredVideosPage + anchors.fill: parent + opacity: 0 + visible: opacity > 0.01 + + Behavior on opacity { + NumberAnimation + { + duration: 250 + } + } + } + + FeaturedPacksPage + { + id: featuredPacksPage + anchors.fill: parent + opacity: 0 + visible: opacity > 0.01 + + Behavior on opacity { + NumberAnimation + { + duration: 250 + } + } + } + + FeaturedImagesPage + { + id: featuredImagesPage + anchors.fill: parent + opacity: 0 + visible: opacity > 0.01 + + Behavior on opacity { + NumberAnimation + { + duration: 250 + } + } + } + states: [ State { name: "loading" @@ -364,6 +424,27 @@ Item } ] + function showFeaturedVideosPage() + { + resultsLayout.opacity = 0 + featuredVideosPage.opacity = 1 + popup = true + } + + function showFeaturedPacksPage() + { + resultsLayout.opacity = 0 + featuredPacksPage.opacity = 1 + popup = true + } + + function showFeaturedImagesPage() + { + resultsLayout.opacity = 0 + featuredImagesPage.opacity = 1 + popup = true + } + function showImagePopup(index) { viewMoreImagePopup.author = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.AuthorRole) @@ -415,6 +496,25 @@ Item function closePopup() { + if(featuredVideosPage.popup) + { + featuredVideosPage.closePopup() + return + } + if(featuredImagesPage.popup) + { + featuredImagesPage.closePopup() + return + } + if(featuredPacksPage.popup) + { + featuredPacksPage.closePopup() + return + } + + featuredVideosPage.opacity = 0 + featuredImagesPage.opacity = 0 + featuredPacksPage.opacity = 0 viewMoreImagePopup.opacity = 0 viewMoreVideoPopup.opacity = 0 viewMoreWallpaperPopup.opacity = 0 diff --git a/KomplexHubModule/Controls/HorizontalPaginator.qml b/KomplexHubModule/Controls/HorizontalPaginator.qml index a1a51ee..3676e99 100644 --- a/KomplexHubModule/Controls/HorizontalPaginator.qml +++ b/KomplexHubModule/Controls/HorizontalPaginator.qml @@ -25,6 +25,8 @@ Item property Component delegate + signal viewMoreTriggered() + id: rootItem Item @@ -162,6 +164,8 @@ Item icon.source: "qrc:/images/icons/icons8-forward.svg" icon.height: 24 icon.width: 24 + + onTriggered: () => viewMoreTriggered() } } } diff --git a/KomplexHubPlugin/common/paginator.h b/KomplexHubPlugin/common/paginator.h index 01acaa7..bcd967a 100644 --- a/KomplexHubPlugin/common/paginator.h +++ b/KomplexHubPlugin/common/paginator.h @@ -120,6 +120,7 @@ public: * @brief resultsPerPage * @return */ + [[nodiscard]] auto resultsPerPage() const -> qsizetype { return m_resultsPerPage; @@ -204,6 +205,7 @@ public: * @brief data * @return */ + [[nodiscard]] auto data() const -> const QList { if(boundaryCheck(m_resultsPerPage)) @@ -219,6 +221,7 @@ public: * @brief count * @return */ + [[nodiscard]] auto count() const -> qsizetype { if(m_offset == nullsize) @@ -240,6 +243,7 @@ public: * @param index * @return */ + [[nodiscard]] auto at(qsizetype index) const -> const T& { return m_cacheController.at(m_offset + index); @@ -251,6 +255,7 @@ public: * The total number of results as reported by the controller * @return */ + [[nodiscard]] auto totalResults() const -> qsizetype { return m_cacheController.totalCount(); @@ -261,6 +266,7 @@ public: * Calculates the current page * @return */ + [[nodiscard]] auto page() const -> qsizetype { return std::floor( @@ -273,6 +279,7 @@ public: * Calculates the total number of pages available * @return */ + [[nodiscard]] auto totalPages() const -> qsizetype { return std::ceil( @@ -280,6 +287,22 @@ public: ); } + /** + * @brief setWindowSize + * Sets the controller window size + * @return + */ + auto setWindowSize(qsizetype size) -> void + { + m_cacheController.setWindowSize(size); + } + + [[nodiscard]] + auto windowSize() const -> qsizetype + { + return m_cacheController.windowSize(); + } + protected: auto queryable() const -> bool diff --git a/KomplexHubPlugin/common/slidingcachecontroller.h b/KomplexHubPlugin/common/slidingcachecontroller.h index a5b88e4..0bd3335 100644 --- a/KomplexHubPlugin/common/slidingcachecontroller.h +++ b/KomplexHubPlugin/common/slidingcachecontroller.h @@ -337,6 +337,13 @@ private: return false; } + qsizetype windowSize = this->windowSize(); + + if(windowSize == 0) + { + windowSize = SLIDING_CACHE_WINDOW_SIZE; + } + while (index >= m_windowOffset + (SLIDING_CACHE_WINDOW_SIZE - SLIDING_CACHE_PREFETCH_THRESHOLD)) { if(!slideForward()) diff --git a/KomplexHubPlugin/featuredimagesmodel.cpp b/KomplexHubPlugin/featuredimagesmodel.cpp index fa38c0c..9a1e213 100644 --- a/KomplexHubPlugin/featuredimagesmodel.cpp +++ b/KomplexHubPlugin/featuredimagesmodel.cpp @@ -245,7 +245,6 @@ auto FeaturedImagesModel::resultsPerPage() const -> qsizetype auto FeaturedImagesModel::setResultsPerPage(qsizetype resultsPerPage) -> void { - if(m_paginator != nullptr) { QFuture future = QtConcurrent::run diff --git a/KomplexHubPlugin/featuredimagesmodel.h b/KomplexHubPlugin/featuredimagesmodel.h index add3097..cf2e336 100644 --- a/KomplexHubPlugin/featuredimagesmodel.h +++ b/KomplexHubPlugin/featuredimagesmodel.h @@ -248,7 +248,6 @@ signals: auto stateChanged() -> void; auto errorStringChanged() -> void; auto resultsPerPageChanged() -> void; - auto pageChanged() -> void; auto totalResultsChanged() -> void; auto totalPagesChanged() -> void; diff --git a/KomplexHubPlugin/featuredvideosmodel.cpp b/KomplexHubPlugin/featuredvideosmodel.cpp index 2344376..b6baa12 100644 --- a/KomplexHubPlugin/featuredvideosmodel.cpp +++ b/KomplexHubPlugin/featuredvideosmodel.cpp @@ -205,6 +205,24 @@ auto FeaturedVideosModel::itemModel() const -> VideoItemModel* return m_itemModel; } +auto FeaturedVideosModel::windowSize() const -> qsizetype +{ + if(m_paginator == nullptr) + { + return 0; + } + + return m_paginator->windowSize(); +} + +auto FeaturedVideosModel::setWindowSize(qsizetype size) -> void +{ + if(m_paginator != nullptr) + { + m_paginator->setWindowSize(size); + } +} + auto FeaturedVideosModel::roleNames() const -> QHash { return m_dataRoles; diff --git a/KomplexHubPlugin/featuredvideosmodel.h b/KomplexHubPlugin/featuredvideosmodel.h index a818680..b2546b8 100644 --- a/KomplexHubPlugin/featuredvideosmodel.h +++ b/KomplexHubPlugin/featuredvideosmodel.h @@ -217,6 +217,20 @@ public: VideoItemModel *itemModel() const; + /** + * @brief windowSize + * Paginator cache size + * @return + */ + auto windowSize() const -> qsizetype; + + /** + * @brief setWindowSize + * Set the paginator cache size + * @param size + */ + auto setWindowSize(qsizetype size) -> void; + protected: /** * @brief setErrorString @@ -243,7 +257,7 @@ signals: auto stateChanged() -> void; auto errorStringChanged() -> void; auto resultsPerPageChanged() -> void; - + auto windowSizeChanged() -> void; auto pageChanged() -> void; auto totalResultsChanged() -> void; auto totalPagesChanged() -> void; @@ -314,6 +328,7 @@ private: Q_PROPERTY(qsizetype totalPages READ totalPages NOTIFY totalPagesChanged FINAL) Q_PROPERTY(qsizetype page READ page NOTIFY pageChanged FINAL) Q_PROPERTY(VideoItemModel *itemModel READ itemModel CONSTANT FINAL) + Q_PROPERTY(qsizetype windowSize READ windowSize WRITE setWindowSize NOTIFY windowSizeChanged FINAL) }; Q_DECLARE_METATYPE(FeaturedVideosModel)