Added modules to reduce redunant code

This commit is contained in:
Digital Artifex
2026-08-17 13:06:31 -04:00
parent 1d5bcb9365
commit 63e45eb4d4
19 changed files with 167 additions and 174 deletions
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Rectangle Rectangle
{ {
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Rectangle Rectangle
{ {
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Rectangle Rectangle
{ {
+12 -17
View File
@@ -6,7 +6,7 @@ import QtQuick.Effects
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
@@ -64,7 +64,7 @@ Item
id: content id: content
width: pageArea.width width: pageArea.width
VerticalSpacer{ height: Constants.largeMargin } VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin }
Rectangle Rectangle
{ {
@@ -153,11 +153,6 @@ Item
{ {
showWallpaperPopup(parent.index) showWallpaperPopup(parent.index)
} }
onThumbnailChanged: () =>
{
console.log(index + " " + thumbnail + " " + parent.thumbnail)
}
} }
} }
@@ -225,13 +220,13 @@ Item
} }
} }
VerticalSpacer{ height: Constants.largeMargin } VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin }
} }
} }
} }
} }
VerticalSpacer{ height: Constants.largeMargin } VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin }
Rectangle Rectangle
{ {
@@ -322,11 +317,6 @@ Item
{ {
showWallpaperPopup(parent.index) showWallpaperPopup(parent.index)
} }
onThumbnailChanged: () =>
{
console.log(index + " " + thumbnail + " " + parent.thumbnail)
}
} }
} }
@@ -390,13 +380,13 @@ Item
} }
} }
VerticalSpacer{ height: Constants.largeMargin } VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin }
} }
} }
} }
} }
VerticalSpacer{ height: Constants.largeMargin } VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin }
} }
} }
@@ -607,6 +597,12 @@ Item
target: pageArea target: pageArea
opacity: 0 opacity: 0
} }
PropertyChanges
{
target: loadingAnimation
opacity: 0
}
} }
] ]
@@ -661,7 +657,6 @@ Item
viewMoreImagePopup.description = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.DescriptionRole) viewMoreImagePopup.description = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.DescriptionRole)
viewMoreImagePopup.uuid = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.UuidRole) viewMoreImagePopup.uuid = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.UuidRole)
viewMoreImagePopup.thumbnail = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LargeThumbnailRole) viewMoreImagePopup.thumbnail = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LargeThumbnailRole)
viewMoreImagePopup.original = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.OriginalUrlRole)
viewMoreImagePopup.portrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.PortraitUrlRole) viewMoreImagePopup.portrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.PortraitUrlRole)
viewMoreImagePopup.landscape = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LandscapeUrlRole) viewMoreImagePopup.landscape = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LandscapeUrlRole)
viewMoreImagePopup.backgroundPortrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.BackgroundPortraitRole) viewMoreImagePopup.backgroundPortrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.BackgroundPortraitRole)
+1 -1
View File
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
@@ -5,7 +5,7 @@ import QtQuick.Dialogs
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Rectangle { Rectangle {
id: root id: root
+1 -1
View File
@@ -3,7 +3,7 @@ import QtQuick.Controls
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
+1 -1
View File
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Rectangle Rectangle
{ {
+1 -1
View File
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
@@ -33,7 +33,7 @@ import QtCore
import Qt.labs.folderlistmodel 2.15 import Qt.labs.folderlistmodel 2.15
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHubPlugin import KomplexHub.Plugin
//import com.github.digitalartifex.komplex 1.0 as Komplex //import com.github.digitalartifex.komplex 1.0 as Komplex
@@ -0,0 +1,32 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Effects
Item
{
property alias source: image.source
property alias imageOpacity: effect.opacity
property alias blur: effect.blur
property alias saturation: effect.saturation
Image
{
anchors.fill: parent
id: image
source: thumbnail
fillMode: Image.PreserveAspectFit
visible: false
}
MultiEffect
{
id: effect
anchors.fill: image
source: image
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
}
}
+5
View File
@@ -22,5 +22,10 @@ qt6_add_qml_module(KomplexHubModule_Controls
QML_FILES VideoView.qml QML_FILES VideoView.qml
QML_FILES PackView.qml QML_FILES PackView.qml
QML_FILES VerticalSpacer.qml QML_FILES VerticalSpacer.qml
QML_FILES DownloadView.qml
QML_FILES ImageFrame.qml
QML_FILES BackgroundImage.qml
QML_FILES CompletedView.qml
QML_FILES ErrorView.qml
) )
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
+34
View File
@@ -0,0 +1,34 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Item
{
property alias source: viewImage.source
id: rootItem
Rectangle
{
anchors.fill: parent
Layout.alignment: Qt.AlignCenter
color: palette.base.darker()
border.color: palette.midlight
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
transform: Image.PreserveAspectCrop
source: rootItem.source
visible: !(status === Image.Loading)
}
}
}
+8 -55
View File
@@ -6,7 +6,7 @@ import QtQuick.Effects
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
@@ -26,24 +26,10 @@ Item
anchors.fill: parent anchors.fill: parent
color: palette.base color: palette.base
Image BackgroundImage
{ {
id: backgroundImage
source: thumbnail
transform: Image.PreserveAspectCrop
anchors.fill: parent anchors.fill: parent
visible: false source: rootItem.thumbnail
}
MultiEffect
{
anchors.fill: backgroundImage
source: backgroundImage
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
} }
ColumnLayout ColumnLayout
@@ -52,36 +38,15 @@ Item
anchors.margins: Constants.largeMargin anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin spacing: Constants.largeMargin
RowLayout ImageFrame
{ {
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: 32 Layout.topMargin: Constants.largeMargin
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Rectangle source: rootItem.thumbnail
{
Layout.fillWidth: true
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Layout.alignment: Qt.AlignHCenter
color: palette.base.darker()
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
transform: Image.PreserveAspectCrop
source: rootItem.thumbnail
visible: !(status === Image.Loading)
}
}
} }
Text Text
@@ -116,18 +81,6 @@ Item
Layout.preferredHeight: 32 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 RowLayout
{ {
Layout.fillWidth: true Layout.fillWidth: true
+1 -1
View File
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
+54 -45
View File
@@ -16,7 +16,7 @@ Item {
signal triggered signal triggered
signal viewMoreTriggered signal viewMoreTriggered
id: mainItem id: rootItem
width: 256 width: 256
height: 256 height: 256
clip: true clip: true
@@ -48,7 +48,7 @@ Item {
onReleased: () => { onReleased: () => {
if(!states.selected) if(!states.selected)
{ {
mainItem.triggered() rootItem.triggered()
} }
} }
} }
@@ -57,47 +57,13 @@ Item {
{ {
anchors.fill: parent anchors.fill: parent
Rectangle ImageFrame
{ {
Layout.preferredWidth: 250 Layout.preferredWidth: 250
Layout.preferredHeight: 141 Layout.preferredHeight: 141
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
Layout.topMargin: 3 Layout.topMargin: 3
source: rootItem.thumbnail
border.color: palette.alternateBase.lighter(1.75)
color: palette.base.lighter(1.25)
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
property int retries: 0
id: viewImage
anchors.fill: parent
source: mainItem.thumbnail
visible: !(status === Image.Loading)
fillMode: Image.PreserveAspectCrop
onStatusChanged: () =>
{
// if(status === Image.Error)
// {
// if(retries <= 3)
// {
// ++retries
// let src = source
// source = ""
// source = src
// }
// }
}
}
Image Image
{ {
@@ -112,14 +78,57 @@ Item {
opacity: 0.5 opacity: 0.5
source: "qrc:/images/icons/pexels-icon-filled-256.svg" source: "qrc:/images/icons/pexels-icon-filled-256.svg"
visible: mainItem.pexels visible: rootItem.pexels
} }
} }
// Rectangle
// {
// Layout.preferredWidth: 250
// Layout.preferredHeight: 141
// Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
// Layout.topMargin: 3
// border.color: palette.alternateBase.lighter(1.75)
// color: palette.base.lighter(1.25)
// // Throbber
// // {
// // anchors.fill: parent
// // id: loadingThrobber
// // visible: viewImage.status === Image.Loading
// // }
// // Image
// // {
// // property int retries: 0
// // id: viewImage
// // anchors.fill: parent
// // source: rootItem.thumbnail
// // visible: !(status === Image.Loading)
// // fillMode: Image.PreserveAspectCrop
// // onStatusChanged: () =>
// // {
// // // if(status === Image.Error)
// // // {
// // // if(retries <= 3)
// // // {
// // // ++retries
// // // let src = source
// // // source = ""
// // // source = src
// // // }
// // // }
// // }
// // }
// }
Text Text
{ {
color: palette.text color: palette.text
text: mainItem.title text: rootItem.title
font.pixelSize: 16 font.pixelSize: 16
font.bold: true font.bold: true
@@ -135,12 +144,12 @@ Item {
{ {
color: palette.text color: palette.text
font.pixelSize: 12 font.pixelSize: 12
text: "By: " + mainItem.author text: "By: " + rootItem.author
leftPadding: 12 leftPadding: 12
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
Layout.preferredWidth: 250 Layout.preferredWidth: 250
visible: !mainItem.pexels visible: !rootItem.pexels
} }
Text Text
@@ -149,7 +158,7 @@ Item {
clip: true clip: true
color: palette.text color: palette.text
font.pixelSize: 12 font.pixelSize: 12
text: mainItem.description text: rootItem.description
wrapMode: Text.WrapAtWordBoundaryOrAnywhere wrapMode: Text.WrapAtWordBoundaryOrAnywhere
textFormat: Text.PlainText textFormat: Text.PlainText
elide: Text.ElideRight elide: Text.ElideRight
@@ -176,7 +185,7 @@ Item {
opacity: 0 opacity: 0
onTriggered: () => { onTriggered: () => {
mainItem.viewMoreTriggered() rootItem.viewMoreTriggered()
} }
} }
@@ -189,7 +198,7 @@ Item {
id: states id: states
property bool clicked: false property bool clicked: false
property bool hovered: false property bool hovered: false
property alias selected: mainItem.selected property alias selected: rootItem.selected
property bool idle: true property bool idle: true
onIdleChanged: () => onIdleChanged: () =>
+3 -3
View File
@@ -1,9 +1,9 @@
import QtQuick import QtQuick
import QtQuick.Layouts
Rectangle Rectangle
{ {
height: 36 Layout.fillHeight: true
color: "transparent" color: "transparent"
anchors.left: parent.left
anchors.right: parent.right
} }
+8 -43
View File
@@ -6,7 +6,7 @@ import QtQuick.Effects
import KomplexHub import KomplexHub
import KomplexHub.Controls import KomplexHub.Controls
import KomplexHub.Kero import KomplexHub.Kero
import KomplexHubPlugin import KomplexHub.Plugin
Item Item
{ {
@@ -46,24 +46,10 @@ Item
anchors.fill: parent anchors.fill: parent
color: palette.base color: palette.base
Image BackgroundImage
{ {
id: backgroundImage
source: thumbnail
anchors.fill: parent anchors.fill: parent
visible: false source: rootItem.thumbnail
fillMode: Image.PreserveAspectFit
}
MultiEffect
{
anchors.fill: backgroundImage
source: backgroundImage
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
} }
ColumnLayout ColumnLayout
@@ -72,36 +58,15 @@ Item
anchors.margins: Constants.largeMargin anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin spacing: Constants.largeMargin
RowLayout ImageFrame
{ {
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: 32 Layout.topMargin: Constants.largeMargin
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Rectangle source: rootItem.thumbnail
{
Layout.fillWidth: true
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Layout.alignment: Qt.AlignHCenter
color: palette.base.darker()
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
source: rootItem.thumbnail
visible: !(status === Image.Loading)
fillMode: Image.PreserveAspectCrop
}
}
} }
Text Text