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
@@ -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 PackView.qml
QML_FILES VerticalSpacer.qml
QML_FILES DownloadView.qml
QML_FILES ImageFrame.qml
QML_FILES BackgroundImage.qml
QML_FILES CompletedView.qml
QML_FILES ErrorView.qml
)
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
import KomplexHub.Plugin
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.Controls
import KomplexHub.Kero
import KomplexHubPlugin
import KomplexHub.Plugin
Item
{
@@ -26,24 +26,10 @@ Item
anchors.fill: parent
color: palette.base
Image
BackgroundImage
{
id: backgroundImage
source: thumbnail
transform: Image.PreserveAspectCrop
anchors.fill: parent
visible: false
}
MultiEffect
{
anchors.fill: backgroundImage
source: backgroundImage
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
source: rootItem.thumbnail
}
ColumnLayout
@@ -52,36 +38,15 @@ Item
anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin
RowLayout
ImageFrame
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: 32
Layout.topMargin: Constants.largeMargin
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Rectangle
{
Layout.fillWidth: true
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Layout.alignment: Qt.AlignHCenter
color: palette.base.darker()
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
transform: Image.PreserveAspectCrop
source: rootItem.thumbnail
visible: !(status === Image.Loading)
}
}
source: rootItem.thumbnail
}
Text
@@ -116,18 +81,6 @@ Item
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
+1 -1
View File
@@ -5,7 +5,7 @@ import QtQuick.Layouts
import KomplexHub
import KomplexHub.Controls
import KomplexHub.Kero
import KomplexHubPlugin
import KomplexHub.Plugin
Item
{
+54 -45
View File
@@ -16,7 +16,7 @@ Item {
signal triggered
signal viewMoreTriggered
id: mainItem
id: rootItem
width: 256
height: 256
clip: true
@@ -48,7 +48,7 @@ Item {
onReleased: () => {
if(!states.selected)
{
mainItem.triggered()
rootItem.triggered()
}
}
}
@@ -57,47 +57,13 @@ Item {
{
anchors.fill: parent
Rectangle
ImageFrame
{
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: mainItem.thumbnail
visible: !(status === Image.Loading)
fillMode: Image.PreserveAspectCrop
onStatusChanged: () =>
{
// if(status === Image.Error)
// {
// if(retries <= 3)
// {
// ++retries
// let src = source
// source = ""
// source = src
// }
// }
}
}
source: rootItem.thumbnail
Image
{
@@ -112,14 +78,57 @@ Item {
opacity: 0.5
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
{
color: palette.text
text: mainItem.title
text: rootItem.title
font.pixelSize: 16
font.bold: true
@@ -135,12 +144,12 @@ Item {
{
color: palette.text
font.pixelSize: 12
text: "By: " + mainItem.author
text: "By: " + rootItem.author
leftPadding: 12
Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
Layout.preferredWidth: 250
visible: !mainItem.pexels
visible: !rootItem.pexels
}
Text
@@ -149,7 +158,7 @@ Item {
clip: true
color: palette.text
font.pixelSize: 12
text: mainItem.description
text: rootItem.description
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
textFormat: Text.PlainText
elide: Text.ElideRight
@@ -176,7 +185,7 @@ Item {
opacity: 0
onTriggered: () => {
mainItem.viewMoreTriggered()
rootItem.viewMoreTriggered()
}
}
@@ -189,7 +198,7 @@ Item {
id: states
property bool clicked: false
property bool hovered: false
property alias selected: mainItem.selected
property alias selected: rootItem.selected
property bool idle: true
onIdleChanged: () =>
+3 -3
View File
@@ -1,9 +1,9 @@
import QtQuick
import QtQuick.Layouts
Rectangle
{
height: 36
Layout.fillHeight: true
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.Controls
import KomplexHub.Kero
import KomplexHubPlugin
import KomplexHub.Plugin
Item
{
@@ -46,24 +46,10 @@ Item
anchors.fill: parent
color: palette.base
Image
BackgroundImage
{
id: backgroundImage
source: thumbnail
anchors.fill: parent
visible: false
fillMode: Image.PreserveAspectFit
}
MultiEffect
{
anchors.fill: backgroundImage
source: backgroundImage
blurEnabled: true
blurMax: 64
blur: 1.0
opacity: 0.25
saturation: -0.8
source: rootItem.thumbnail
}
ColumnLayout
@@ -72,36 +58,15 @@ Item
anchors.margins: Constants.largeMargin
spacing: Constants.largeMargin
RowLayout
ImageFrame
{
Layout.fillWidth: true
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
Layout.topMargin: 32
Layout.topMargin: Constants.largeMargin
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Rectangle
{
Layout.fillWidth: true
Layout.preferredHeight: width / 1.77777777778
Layout.maximumWidth: 800
Layout.alignment: Qt.AlignHCenter
color: palette.base.darker()
Throbber
{
anchors.fill: parent
id: loadingThrobber
visible: viewImage.status === Image.Loading
}
Image
{
id: viewImage
anchors.fill: parent
source: rootItem.thumbnail
visible: !(status === Image.Loading)
fillMode: Image.PreserveAspectCrop
}
}
source: rootItem.thumbnail
}
Text