Compare commits
3 Commits
471c91e622
...
63e45eb4d4
| Author | SHA1 | Date | |
|---|---|---|---|
|
63e45eb4d4
|
|||
|
1d5bcb9365
|
|||
|
e6d7d908b1
|
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Rectangle
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Rectangle
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Rectangle
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ import QtQuick.Effects
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
@@ -64,7 +64,7 @@ Item
|
||||
id: content
|
||||
width: pageArea.width
|
||||
|
||||
VerticalSpacer{ height: Constants.largeMargin }
|
||||
VerticalSpacer{ height: Constants.largeMargin; width: Constants.largeMargin }
|
||||
|
||||
Rectangle
|
||||
{
|
||||
@@ -153,11 +153,6 @@ Item
|
||||
{
|
||||
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
|
||||
{
|
||||
@@ -322,11 +317,6 @@ Item
|
||||
{
|
||||
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
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: loadingAnimation
|
||||
opacity: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@@ -661,7 +657,6 @@ Item
|
||||
viewMoreImagePopup.description = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.DescriptionRole)
|
||||
viewMoreImagePopup.uuid = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.UuidRole)
|
||||
viewMoreImagePopup.thumbnail = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LargeThumbnailRole)
|
||||
viewMoreImagePopup.original = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.OriginalUrlRole)
|
||||
viewMoreImagePopup.portrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.PortraitUrlRole)
|
||||
viewMoreImagePopup.landscape = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.LandscapeUrlRole)
|
||||
viewMoreImagePopup.backgroundPortrait = imagesModel.data(imagesModel.index(index,0), FeaturedImagesModel.BackgroundPortraitRole)
|
||||
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Dialogs
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
@@ -3,7 +3,7 @@ import QtQuick.Controls
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Rectangle
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ import QtCore
|
||||
import Qt.labs.folderlistmodel 2.15
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
//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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import KomplexHub
|
||||
import KomplexHub.Kero
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
property DownloadManager manager: null
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
anchors.fill: parent
|
||||
|
||||
VerticalSpacer { }
|
||||
|
||||
KeroSuccessAvatar
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredHeight: 512
|
||||
Layout.maximumHeight: 512
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 36
|
||||
Layout.maximumHeight: 36
|
||||
Layout.margins: Constants.largeMargin
|
||||
|
||||
Item
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
SquareButton
|
||||
{
|
||||
Layout.preferredWidth: 186
|
||||
Layout.fillHeight: true
|
||||
text: qsTr("Okay")
|
||||
|
||||
onTriggered: () =>
|
||||
{
|
||||
if(manager != null)
|
||||
{
|
||||
manager.reset()
|
||||
}
|
||||
}
|
||||
}
|
||||
SquareButton
|
||||
{
|
||||
Layout.preferredWidth: 186
|
||||
Layout.fillHeight: true
|
||||
|
||||
text: qsTr("Set Wallpaper")
|
||||
icon.source: "qrc:/images/icons/icons8-download.svg"
|
||||
}
|
||||
}
|
||||
|
||||
VerticalSpacer {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Effects
|
||||
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Plugin
|
||||
import KomplexHub.Kero
|
||||
|
||||
Item
|
||||
{
|
||||
property string thumbnail
|
||||
property DownloadManager manager
|
||||
|
||||
Rectangle
|
||||
{
|
||||
anchors.fill: parent
|
||||
color: palette.base
|
||||
|
||||
BackgroundImage
|
||||
{
|
||||
source: thumbnail
|
||||
}
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
anchors.fill: parent
|
||||
anchors.margins: Constants.largeMargin
|
||||
|
||||
Item { Layout.preferredHeight: 64; Layout.fillWidth: true }
|
||||
|
||||
KeroBuildingAnimation
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
|
||||
VerticalSpacer {}
|
||||
|
||||
Text
|
||||
{
|
||||
text: qsTr("Download Progress")
|
||||
font: Constants.h3Font
|
||||
color : palette.text
|
||||
Layout.preferredHeight: Constants.largeMargin
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Constants.largeMargin
|
||||
|
||||
ProgressBar
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
value: manager.downloadProgress
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: manager.downloadedBytes
|
||||
font: Constants.h4Font
|
||||
color : palette.text
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: "/"
|
||||
font: Constants.h4Font
|
||||
color : palette.text
|
||||
Layout.preferredHeight: 32
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: manager.downloadSize
|
||||
font: Constants.h4Font
|
||||
color : palette.text
|
||||
Layout.preferredHeight: 32
|
||||
}
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: qsTr("Install Progress")
|
||||
font: Constants.h3Font
|
||||
color : palette.text
|
||||
height: 32
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: Constants.largeMargin
|
||||
|
||||
ProgressBar
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
value: manager.compileProgress
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: manager.compileStepsCompleted
|
||||
font: Constants.h4Font
|
||||
color : palette.text
|
||||
Layout.preferredHeight: Constants.largeMargin
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: "/"
|
||||
font: Constants.h4Font
|
||||
color : palette.text
|
||||
Layout.preferredHeight: Constants.largeMargin
|
||||
}
|
||||
|
||||
Text
|
||||
{
|
||||
text: manager.compileSteps
|
||||
font: Constants.h4Font
|
||||
color : palette.text
|
||||
Layout.preferredHeight: Constants.largeMargin
|
||||
}
|
||||
}
|
||||
|
||||
Item { Layout.preferredHeight: Constants.largeMargin * 2; Layout.fillWidth: true }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import KomplexHub
|
||||
import KomplexHub.Kero
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
property DownloadManager manager: null
|
||||
|
||||
ColumnLayout
|
||||
{
|
||||
anchors.fill: parent
|
||||
|
||||
VerticalSpacer { }
|
||||
|
||||
KeroWarningAvatar
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.preferredHeight: 512
|
||||
Layout.maximumHeight: 512
|
||||
}
|
||||
|
||||
RowLayout
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 36
|
||||
Layout.maximumHeight: 36
|
||||
Layout.margins: Constants.largeMargin
|
||||
|
||||
Item
|
||||
{
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
SquareButton
|
||||
{
|
||||
Layout.preferredWidth: 186
|
||||
Layout.fillHeight: true
|
||||
text: qsTr("Okay")
|
||||
|
||||
onTriggered: () =>
|
||||
{
|
||||
if(manager != null)
|
||||
{
|
||||
manager.reset()
|
||||
}
|
||||
}
|
||||
}
|
||||
SquareButton
|
||||
{
|
||||
Layout.preferredWidth: 186
|
||||
Layout.fillHeight: true
|
||||
text: qsTr("Set Wallpaper")
|
||||
}
|
||||
}
|
||||
|
||||
VerticalSpacer {}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import QtQuick.Effects
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
@@ -17,7 +17,6 @@ Item
|
||||
property string thumbnail
|
||||
property string portrait
|
||||
property string landscape
|
||||
property string original
|
||||
property string fullScreen
|
||||
property string portraitSize
|
||||
property string landscapeSize
|
||||
@@ -30,29 +29,21 @@ Item
|
||||
|
||||
id: rootItem
|
||||
|
||||
DownloadManager
|
||||
{
|
||||
id: downloadManager
|
||||
}
|
||||
|
||||
Rectangle
|
||||
{
|
||||
id: pageView
|
||||
anchors.fill: parent
|
||||
color: palette.base
|
||||
|
||||
Image
|
||||
BackgroundImage
|
||||
{
|
||||
id: backgroundImage
|
||||
source: width > height ? backgroundLandscape : backgroundPortrait
|
||||
transform: Image.PreserveAspectCrop
|
||||
anchors.fill: parent
|
||||
visible: false
|
||||
}
|
||||
|
||||
MultiEffect
|
||||
{
|
||||
anchors.fill: backgroundImage
|
||||
source: backgroundImage
|
||||
blurEnabled: true
|
||||
blurMax: 64
|
||||
blur: 1.0
|
||||
opacity: 0.25
|
||||
saturation: -0.8
|
||||
source: width > height ? backgroundLandscape : backgroundPortrait
|
||||
}
|
||||
|
||||
ColumnLayout
|
||||
@@ -61,36 +52,15 @@ Item
|
||||
anchors.margins: Constants.largeMargin
|
||||
spacing: Constants.largeMargin
|
||||
|
||||
RowLayout
|
||||
ImageFrame
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignTop| Qt.AlignHCenter
|
||||
Layout.topMargin: 32
|
||||
|
||||
Rectangle
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Constants.largeMargin
|
||||
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
|
||||
@@ -158,6 +128,8 @@ Item
|
||||
Layout.preferredWidth: 128
|
||||
text: qsTr("Download")
|
||||
icon.source: "qrc:/images/icons/icons8-download.svg"
|
||||
|
||||
onTriggered: () => rootItem.download()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,5 +163,177 @@ Item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
states:
|
||||
[
|
||||
State
|
||||
{
|
||||
name: "downloading"
|
||||
when: downloadManager.state === DownloadManager.Downloading
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: pageView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: downloadView
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: completedView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: errorView
|
||||
opacity: 0
|
||||
}
|
||||
},
|
||||
State
|
||||
{
|
||||
name: "complete"
|
||||
when: downloadManager.state === DownloadManager.Complete
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: pageView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: downloadView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: completedView
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: errorView
|
||||
opacity: 0
|
||||
}
|
||||
},
|
||||
State
|
||||
{
|
||||
name: "error"
|
||||
when: downloadManager.state === DownloadManager.Error
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: pageView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: downloadView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: completedView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: errorView
|
||||
opacity: 1
|
||||
}
|
||||
},
|
||||
State
|
||||
{
|
||||
name: "idle"
|
||||
when: downloadManager.state === DownloadManager.Idle
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: pageView
|
||||
opacity: 1
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: downloadView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: completedView
|
||||
opacity: 0
|
||||
}
|
||||
|
||||
PropertyChanges
|
||||
{
|
||||
target: errorView
|
||||
opacity: 0
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
DownloadView
|
||||
{
|
||||
id: downloadView
|
||||
anchors.fill: parent
|
||||
|
||||
manager: downloadManager
|
||||
thumbnail: rootItem.thumbnail
|
||||
opacity: 0
|
||||
visible: opacity > 0.01
|
||||
}
|
||||
|
||||
CompletedView
|
||||
{
|
||||
id: completedView
|
||||
anchors.fill: parent
|
||||
|
||||
opacity: 0
|
||||
visible: opacity > 0.01
|
||||
manager: downloadManager
|
||||
}
|
||||
|
||||
ErrorView
|
||||
{
|
||||
id: errorView
|
||||
anchors.fill: parent
|
||||
|
||||
opacity: 0
|
||||
visible: opacity > 0.01
|
||||
manager: downloadManager
|
||||
}
|
||||
|
||||
function download()
|
||||
{
|
||||
let url = ""
|
||||
|
||||
switch(downloadSelector.currentIndex)
|
||||
{
|
||||
case 1:
|
||||
url = portrait
|
||||
break;
|
||||
case 2:
|
||||
url = landscape
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
url = fullScreen
|
||||
break;
|
||||
}
|
||||
|
||||
downloadManager.downloadImage(author, authorUrl, description, url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Rectangle
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Constants.largeMargin
|
||||
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
|
||||
@@ -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
|
||||
|
||||
@@ -5,7 +5,7 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
import KomplexHub.Controls
|
||||
import KomplexHub.Kero
|
||||
import KomplexHubPlugin
|
||||
import KomplexHub.Plugin
|
||||
|
||||
Item
|
||||
{
|
||||
|
||||
@@ -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: () =>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Rectangle
|
||||
{
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Constants.largeMargin
|
||||
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
|
||||
|
||||
@@ -11,5 +11,6 @@ qt6_add_qml_module(KomplexHubModule_Kero
|
||||
"KeroLoadingAnimation.qml"
|
||||
"KeroNoResultsAvatar.qml"
|
||||
"KeroWarningAvatar.qml"
|
||||
QML_FILES KeroHeader.qml
|
||||
"KeroHeader.qml"
|
||||
"KeroSuccessAvatar.qml"
|
||||
)
|
||||
@@ -4,9 +4,9 @@ import QtQuick.Layouts
|
||||
import KomplexHub
|
||||
|
||||
Item {
|
||||
property string title: qsTr("Loading")
|
||||
property string description: qsTr("Kero is busy looking for wallpapers..we promise")
|
||||
property color color: palette.window
|
||||
property string title: qsTr("Building")
|
||||
property string description: qsTr("Kero is getting your wallpaper ready")
|
||||
property color color: "transparent"
|
||||
|
||||
id: keroLoadingOverlayRoot
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
|
||||
import KomplexHub
|
||||
|
||||
Item {
|
||||
property string title: qsTr("Success!")
|
||||
property string description: qsTr("Your new wallpaper is ready!")
|
||||
property color color: "transparent"
|
||||
|
||||
id: keroHelloAvatarRoot
|
||||
|
||||
Rectangle {
|
||||
id: keroHelloAvatarBackground
|
||||
anchors.fill: parent
|
||||
color: keroHelloAvatarRoot.color
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
Rectangle {
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Layout.minimumWidth: 64
|
||||
Layout.minimumHeight: 64
|
||||
Layout.maximumWidth: 512
|
||||
Layout.maximumHeight: 512
|
||||
Layout.alignment: Qt.AlignCenter
|
||||
|
||||
color: "transparent"
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
|
||||
source: "qrc:/images/kero/kero_success.png"
|
||||
antialiasing: true
|
||||
fillMode: Image.PreserveAspectFit
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
Text {
|
||||
color: palette.text
|
||||
text: keroHelloAvatarRoot.title
|
||||
font: Constants.h1Font
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||
}
|
||||
|
||||
Text {
|
||||
id: errorText
|
||||
text: keroHelloAvatarRoot.description
|
||||
color: palette.text.darker()
|
||||
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
|
||||
Layout.bottomMargin: Constants.largeMargin
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ add_library(
|
||||
qt_add_qml_module(
|
||||
KomplexHubPlugin
|
||||
URI
|
||||
KomplexHubPlugin
|
||||
"KomplexHub.Plugin"
|
||||
VERSION
|
||||
1.0
|
||||
SOURCES
|
||||
|
||||
@@ -11,6 +11,8 @@ auto CoreServices::networkAccessManager() -> QWeakPointer<QNetworkAccessManager>
|
||||
QMutexLocker locker(&s_networkAccessMutex);
|
||||
|
||||
if(!s_networkAccessPointer)
|
||||
{
|
||||
if(!s_networkAccessManager)
|
||||
{
|
||||
s_networkAccessManager = new QNetworkAccessManager(QCoreApplication::instance());
|
||||
s_networkAccessManager->setAutoDeleteReplies(true);
|
||||
@@ -29,11 +31,12 @@ auto CoreServices::networkAccessManager() -> QWeakPointer<QNetworkAccessManager>
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef KOMPLEX_LOCAL_DEV
|
||||
#ifdef KOMPLEX_LOCAL_DEV
|
||||
reply->ignoreSslErrors();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
s_networkAccessPointer = QSharedPointer<QNetworkAccessManager>(
|
||||
s_networkAccessManager,
|
||||
|
||||
@@ -31,6 +31,44 @@ DownloadManager::DownloadManager(QObject *parent)
|
||||
this,
|
||||
&DownloadManager::compileStepsChanged
|
||||
);
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
&m_moveProcess,
|
||||
&QProcess::readyReadStandardOutput,
|
||||
this,
|
||||
[this]()
|
||||
{
|
||||
QByteArray processData = m_moveProcess.readAllStandardOutput();
|
||||
|
||||
if(!processData.isValidUtf8())
|
||||
{
|
||||
qWarning() << QStringLiteral("Process output not valid UTF8 data");
|
||||
return;
|
||||
}
|
||||
|
||||
setCompilerOutput(m_compilerOutput + processData);
|
||||
}
|
||||
);
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
&m_moveProcess,
|
||||
&QProcess::readyReadStandardError,
|
||||
this,
|
||||
[this]()
|
||||
{
|
||||
QByteArray processData = m_moveProcess.readAllStandardError();
|
||||
|
||||
if(!processData.isValidUtf8())
|
||||
{
|
||||
qWarning() << QStringLiteral("Process output not valid UTF8 data");
|
||||
return;
|
||||
}
|
||||
|
||||
setCompilerOutput(m_compilerOutput + processData);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,30 +77,42 @@ DownloadManager::DownloadManager(QObject *parent)
|
||||
* [3] Optionally ask user if they would like to apply manipulative shader
|
||||
* [4] Install locally
|
||||
*/
|
||||
auto DownloadManager::downloadImage(const QString &author, const QString &authorId, const QString &description, const QUrl &url) noexcept(false) -> void
|
||||
auto DownloadManager::downloadImage(const QString &author, const QString &authorId, const QString &description, const QUrl &url) -> void
|
||||
{
|
||||
QFuture future = QtConcurrent::run
|
||||
(
|
||||
[this, url, author, authorId, description]()
|
||||
{
|
||||
// QFuture future = QtConcurrent::run
|
||||
// (
|
||||
// [this, url, author, authorId, description]()
|
||||
// {
|
||||
QNetworkRequest request(url);
|
||||
QString requestUrl = request.url().toString();
|
||||
QString id = QUuid::createUuidV7().toString(QUuid::WithoutBraces);
|
||||
|
||||
QFuture<QUrl> downloadUri = download(request, id);
|
||||
setState(Downloading);
|
||||
|
||||
downloadUri
|
||||
//QFuture<QUrl> downloadUri = download(request, id, Get);
|
||||
if(m_downloadFuture.isRunning())
|
||||
{
|
||||
m_downloadFuture.cancelChain();
|
||||
}
|
||||
|
||||
m_downloadFuture = download(request, id, Get);
|
||||
|
||||
m_downloadFuture
|
||||
.then
|
||||
(
|
||||
[this, author, description, id](QUrl result) -> QUrl
|
||||
{
|
||||
setState(Installing);
|
||||
|
||||
ShaderPack metadata;
|
||||
metadata.setAuthor(author);
|
||||
metadata.setDescription(description);
|
||||
metadata.setName(QStringLiteral("Pexels Image (%1)").arg(id));
|
||||
metadata.setSource(QStringLiteral("./images/%1").arg(result.fileName()));
|
||||
|
||||
QUrl packUri
|
||||
(
|
||||
QStringLiteral("%1/%2").arg
|
||||
QStringLiteral("file://%1/%2").arg
|
||||
(
|
||||
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
|
||||
id
|
||||
@@ -71,7 +121,7 @@ auto DownloadManager::downloadImage(const QString &author, const QString &author
|
||||
|
||||
QUrl packImageUri
|
||||
(
|
||||
QStringLiteral("%1/%2/images/%3").arg
|
||||
QStringLiteral("file://%1/%2/images/%3").arg
|
||||
(
|
||||
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
|
||||
id,
|
||||
@@ -80,7 +130,12 @@ auto DownloadManager::downloadImage(const QString &author, const QString &author
|
||||
);
|
||||
|
||||
QDir packDirectory(packUri.toLocalFile());
|
||||
packDirectory.mkpath(packUri.toLocalFile());
|
||||
|
||||
if(!packDirectory.mkpath(packUri.toLocalFile()))
|
||||
{
|
||||
throw FileException(QStringLiteral("Could not create directory"));
|
||||
}
|
||||
|
||||
packDirectory.mkdir(QStringLiteral("images"));
|
||||
|
||||
QFile::rename(result.toLocalFile(), packImageUri.toLocalFile());
|
||||
@@ -99,7 +154,7 @@ auto DownloadManager::downloadImage(const QString &author, const QString &author
|
||||
throw FileException(packFile.errorString());
|
||||
}
|
||||
|
||||
QByteArray data = metadata.json().toJson(QJsonDocument::Compact);
|
||||
QByteArray data = metadata.json().toJson(QJsonDocument::Indented);
|
||||
|
||||
if(packFile.write(data) != data.length())
|
||||
{
|
||||
@@ -113,10 +168,18 @@ auto DownloadManager::downloadImage(const QString &author, const QString &author
|
||||
}
|
||||
)
|
||||
.then
|
||||
(
|
||||
[this](QUrl result) -> QUrl
|
||||
{
|
||||
return install(result);
|
||||
}
|
||||
)
|
||||
.then
|
||||
(
|
||||
[this](QUrl result)
|
||||
{
|
||||
install(result);
|
||||
setLastInstalledFile(result.toLocalFile());
|
||||
setState(Complete);
|
||||
}
|
||||
)
|
||||
.onCanceled
|
||||
@@ -127,17 +190,36 @@ auto DownloadManager::downloadImage(const QString &author, const QString &author
|
||||
}
|
||||
)
|
||||
.onFailed
|
||||
(
|
||||
[this] (const NetworkException &e)
|
||||
{
|
||||
reset();
|
||||
setError(QStringLiteral("Network Exception %1").arg(QString::number(e.errorCode)), e.message);
|
||||
}
|
||||
)
|
||||
.onFailed
|
||||
(
|
||||
[this] (const FileException &e)
|
||||
{
|
||||
reset();
|
||||
setError(QStringLiteral("File Exception %1").arg(QString::number(e.errorCode)), e.message);
|
||||
}
|
||||
)
|
||||
.onFailed
|
||||
(
|
||||
[this] ()
|
||||
{
|
||||
reset();
|
||||
setError(QStringLiteral("Unknown Exception"), QString());
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
// downloadUri.waitForFinished();
|
||||
// }
|
||||
// );
|
||||
}
|
||||
|
||||
auto DownloadManager::downloadVideo(const QString &author, const QString &authorId, const QString &description, const QUrl &url) noexcept(false) -> void
|
||||
auto DownloadManager::downloadVideo(const QString &author, const QString &authorId, const QString &description, const QUrl &url) -> void
|
||||
{
|
||||
QFuture future = QtConcurrent::run
|
||||
(
|
||||
@@ -236,7 +318,7 @@ auto DownloadManager::downloadVideo(const QString &author, const QString &author
|
||||
);
|
||||
}
|
||||
|
||||
auto DownloadManager::downloadPack(const QString &id) noexcept(false) -> void
|
||||
auto DownloadManager::downloadPack(const QString &id) -> void
|
||||
{
|
||||
QFuture aether = QtConcurrent::run
|
||||
(
|
||||
@@ -267,9 +349,16 @@ auto DownloadManager::downloadPack(const QString &id) noexcept(false) -> void
|
||||
)
|
||||
.then
|
||||
(
|
||||
[this](QUrl result)
|
||||
[this](QUrl result) -> QUrl
|
||||
{
|
||||
install(result);
|
||||
return install(result);
|
||||
}
|
||||
)
|
||||
.then
|
||||
(
|
||||
[this] (QUrl result)
|
||||
{
|
||||
setState(Complete);
|
||||
}
|
||||
)
|
||||
.onFailed
|
||||
@@ -337,6 +426,8 @@ auto DownloadManager::setError(const QString &title, const QString &message) ->
|
||||
m_errorMessage = std::move(message);
|
||||
m_errorTitle = std::move(title);
|
||||
Q_EMIT errorChanged();
|
||||
|
||||
setState(Error);
|
||||
}
|
||||
|
||||
void DownloadManager::setCompilerOutput(const QString &compilerOutput)
|
||||
@@ -383,89 +474,45 @@ auto DownloadManager::install(const QUrl &uri) noexcept(false) -> QUrl
|
||||
|
||||
QDir tempDirectory(uri.toLocalFile());
|
||||
|
||||
QString installLocation = QStringLiteral("%1/.local/share/komplex/packs/%2").arg
|
||||
QUrl installLocation = QStringLiteral("%1/.local/share/komplex/packs/%2").arg
|
||||
(
|
||||
QStandardPaths::writableLocation(QStandardPaths::HomeLocation),
|
||||
tempDirectory.dirName()
|
||||
);
|
||||
|
||||
QDir installDirectory(installLocation);
|
||||
QDir installDirectory(installLocation.toLocalFile());
|
||||
|
||||
if(installDirectory.exists())
|
||||
installDirectory.removeRecursively();
|
||||
|
||||
QProcess process;
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
&process,
|
||||
&QProcess::readyReadStandardOutput,
|
||||
this,
|
||||
[this, &process]()
|
||||
{
|
||||
QByteArray processData = process.readAllStandardOutput();
|
||||
|
||||
if(!processData.isValidUtf8())
|
||||
{
|
||||
qWarning() << QStringLiteral("Process output not valid UTF8 data");
|
||||
return;
|
||||
}
|
||||
|
||||
setCompilerOutput(m_compilerOutput + processData);
|
||||
}
|
||||
);
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
&process,
|
||||
&QProcess::readyReadStandardError,
|
||||
this,
|
||||
[this, &process]()
|
||||
{
|
||||
QByteArray processData = process.readAllStandardError();
|
||||
|
||||
if(!processData.isValidUtf8())
|
||||
{
|
||||
qWarning() << QStringLiteral("Process output not valid UTF8 data");
|
||||
return;
|
||||
}
|
||||
|
||||
setCompilerOutput(m_compilerOutput + processData);
|
||||
}
|
||||
);
|
||||
|
||||
QStringList arguments = QStringList
|
||||
{
|
||||
QStringLiteral("-R"),
|
||||
uri.toLocalFile(),
|
||||
installLocation
|
||||
installLocation.toLocalFile()
|
||||
};
|
||||
|
||||
process.start(QStringLiteral("cp"), arguments);
|
||||
m_moveProcess.start(QStringLiteral("mv"), arguments);
|
||||
|
||||
if(!process.waitForStarted(3000))
|
||||
if(!m_moveProcess.waitForStarted(3000))
|
||||
{
|
||||
qWarning() << QStringLiteral("Could not start copy process: %1").arg(process.readAllStandardError());
|
||||
qWarning() << QStringLiteral("Could not start copy process: %1").arg(m_moveProcess.readAllStandardError());
|
||||
throw FileException(QStringLiteral("Could not start install process"));
|
||||
}
|
||||
|
||||
if(!process.waitForFinished())
|
||||
if(!m_moveProcess.waitForFinished())
|
||||
{
|
||||
qWarning() << QStringLiteral("Copy process took longer than expected (>30s)");
|
||||
throw FileException(QStringLiteral("Install process took longer than expected (>30s)"));
|
||||
}
|
||||
|
||||
QUrl installUri(installLocation);
|
||||
installUri.setScheme(QStringLiteral("file://"));
|
||||
|
||||
return installUri;
|
||||
return installLocation;
|
||||
}
|
||||
|
||||
auto DownloadManager::download(const QNetworkRequest &request, const QString &id, RequestType type) -> QFuture<QUrl>
|
||||
{
|
||||
return QtConcurrent::run
|
||||
(
|
||||
[this, request, id]() -> QUrl
|
||||
[this, request, id, type]() -> QUrl
|
||||
{
|
||||
QEventLoop loop;
|
||||
QString filename = id;
|
||||
@@ -475,10 +522,10 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
|
||||
filename = QUuid::createUuidV7().toString();
|
||||
}
|
||||
|
||||
QUrl downloadUri = QStringLiteral("%1/%2").arg
|
||||
QUrl downloadUri = QStringLiteral("file://%1/%2").arg
|
||||
(
|
||||
QStandardPaths::writableLocation(QStandardPaths::TempLocation),
|
||||
filename
|
||||
request.url().fileName()
|
||||
);
|
||||
|
||||
auto manager = CoreServices::networkAccessManager().toStrongRef();
|
||||
@@ -493,20 +540,23 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
|
||||
|
||||
QFile downloadFile(downloadUri.toLocalFile());
|
||||
|
||||
if(!downloadFile.open(QFile::ReadWrite))
|
||||
if(downloadFile.exists() && !downloadFile.remove())
|
||||
{
|
||||
throw FileException(QStringLiteral("Could not open temp file location"));
|
||||
throw FileException(downloadFile.errorString());
|
||||
}
|
||||
|
||||
QNetworkReply *reply = manager->post(request, nullptr);
|
||||
QNetworkReply *reply = nullptr;
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
reply,
|
||||
&QNetworkReply::finished,
|
||||
&loop,
|
||||
&QEventLoop::quit
|
||||
);
|
||||
switch(type)
|
||||
{
|
||||
case Post:
|
||||
reply = manager->post(request, nullptr);
|
||||
break;
|
||||
default:
|
||||
case Get:
|
||||
reply = manager->get(request, nullptr);
|
||||
break;
|
||||
}
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
@@ -545,40 +595,35 @@ auto DownloadManager::download(const QNetworkRequest &request, const QString &id
|
||||
reply,
|
||||
&QNetworkReply::readyRead,
|
||||
this,
|
||||
[this, &downloadFile, &reply]()
|
||||
[this, downloadUri, reply]()
|
||||
{
|
||||
if(!downloadFile.isOpen())
|
||||
QFile downloadFile(downloadUri.toLocalFile());
|
||||
|
||||
if(!downloadFile.open(QFile::ReadWrite | QFile::Append))
|
||||
{
|
||||
return;
|
||||
throw FileException(QStringLiteral("Could not open temp file location"));
|
||||
}
|
||||
|
||||
quint64 bytes = reply->bytesAvailable();
|
||||
quint64 bytesWritten = downloadFile.write(reply->read(bytes));
|
||||
quint64 bytesWritten = downloadFile.write(reply->readAll()/*bytes)*/);
|
||||
|
||||
if(bytesWritten != bytes)
|
||||
{
|
||||
throw FileException(QStringLiteral("Could not write temp file data"));
|
||||
}
|
||||
downloadFile.close();
|
||||
}
|
||||
);
|
||||
|
||||
QObject::connect
|
||||
(
|
||||
reply,
|
||||
&QNetworkReply::finished,
|
||||
&loop,
|
||||
&QEventLoop::quit
|
||||
);
|
||||
|
||||
if(!reply->isFinished())
|
||||
{
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
if(reply->bytesAvailable() > 0)
|
||||
{
|
||||
quint64 bytes = reply->bytesAvailable();
|
||||
quint64 bytesWritten = downloadFile.write(reply->read(bytes));
|
||||
|
||||
if(bytesWritten != bytes)
|
||||
{
|
||||
throw FileException(QStringLiteral("Could not write temp file data"));
|
||||
}
|
||||
}
|
||||
|
||||
downloadFile.close();
|
||||
manager.clear();
|
||||
|
||||
return downloadUri;
|
||||
@@ -717,6 +762,19 @@ auto DownloadManager::readShaderToyEntry(const QUrl &uri) noexcept(false) -> Sha
|
||||
return std::move(entry);
|
||||
}
|
||||
|
||||
auto DownloadManager::lastInstalledFile() const -> const QString &
|
||||
{
|
||||
return m_lastInstalledFile;
|
||||
}
|
||||
|
||||
auto DownloadManager::setLastInstalledFile(const QString &lastInstalledFile) -> void
|
||||
{
|
||||
if (m_lastInstalledFile == lastInstalledFile)
|
||||
return;
|
||||
m_lastInstalledFile = lastInstalledFile;
|
||||
emit lastInstalledFileChanged();
|
||||
}
|
||||
|
||||
auto DownloadManager::setDownloadedBytes(qint64 downloadedBytes) -> void
|
||||
{
|
||||
if (m_downloadedBytes == downloadedBytes)
|
||||
|
||||
@@ -68,13 +68,13 @@ public:
|
||||
* out of it
|
||||
* @param url
|
||||
*/
|
||||
auto downloadImage
|
||||
Q_INVOKABLE auto downloadImage
|
||||
(
|
||||
const QString &author,
|
||||
const QString &authorId,
|
||||
const QString &description,
|
||||
const QUrl &url
|
||||
) noexcept(false) -> void;
|
||||
) -> void;
|
||||
|
||||
/**
|
||||
* @brief downloadVideo
|
||||
@@ -85,13 +85,13 @@ public:
|
||||
* @param description
|
||||
* @param url
|
||||
*/
|
||||
auto downloadVideo
|
||||
Q_INVOKABLE auto downloadVideo
|
||||
(
|
||||
const QString &author,
|
||||
const QString &authorId,
|
||||
const QString &description,
|
||||
const QUrl &url
|
||||
) noexcept(false) -> void;
|
||||
) -> void;
|
||||
|
||||
/**
|
||||
* @brief downloadPack
|
||||
@@ -100,13 +100,13 @@ public:
|
||||
* @param id
|
||||
* @return File info of the installed pack
|
||||
*/
|
||||
auto downloadPack(const QString &id) noexcept(false) -> void;
|
||||
Q_INVOKABLE auto downloadPack(const QString &id) -> void;
|
||||
|
||||
auto compilerOutput() const -> const QString & { return m_compilerOutput; }
|
||||
auto errorTitle() const -> const QString & { return m_errorTitle; }
|
||||
auto errorMessage() const -> const QString & { return m_errorMessage; }
|
||||
auto state() const -> State { return m_state; }
|
||||
auto reset() -> void;
|
||||
Q_INVOKABLE auto reset() -> void;
|
||||
auto downloadProgress() -> qreal { return m_downloadProgress; }
|
||||
auto compileProgress() -> qreal;
|
||||
auto compileSteps() -> qint64;
|
||||
@@ -118,6 +118,9 @@ public:
|
||||
auto downloadedBytes() const -> qint64 { return m_downloadedBytes; }
|
||||
auto setDownloadedBytes(qint64 downloadedBytes) -> void;
|
||||
|
||||
auto lastInstalledFile() const -> const QString &;
|
||||
auto setLastInstalledFile(const QString &lastInstalledFile) -> void;
|
||||
|
||||
protected:
|
||||
auto setError(const QString &title, const QString &message) -> void;
|
||||
auto setCompilerOutput(const QString &compilerOutput) -> void;
|
||||
@@ -136,12 +139,16 @@ signals:
|
||||
auto compileStepsChanged() -> void;
|
||||
auto compileStepsCompletedChanged() -> void;
|
||||
|
||||
auto lastInstalledFileChanged() -> void;
|
||||
|
||||
private:
|
||||
auto compile(const QUrl &uri) noexcept(false) -> QUrl;
|
||||
auto install(const QUrl &uri) noexcept(false) -> QUrl;
|
||||
auto download(const QNetworkRequest &request, const QString &id, RequestType type = Get) -> QFuture<QUrl>;
|
||||
auto readShaderToyEntry(const QUrl &uri) noexcept(false) -> ShaderToyEntry;
|
||||
|
||||
QString m_lastInstalledFile;
|
||||
|
||||
QString m_compilerOutput;
|
||||
QString m_errorTitle;
|
||||
QString m_errorMessage;
|
||||
@@ -156,6 +163,10 @@ private:
|
||||
|
||||
PackCompiler *m_compiler = nullptr;
|
||||
|
||||
QProcess m_moveProcess;
|
||||
|
||||
QFuture<QUrl> m_downloadFuture;
|
||||
|
||||
Q_PROPERTY(QString compilerOutput READ compilerOutput WRITE setCompilerOutput NOTIFY compilerOutputChanged FINAL)
|
||||
Q_PROPERTY(QString errorTitle READ errorTitle NOTIFY errorChanged FINAL)
|
||||
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged FINAL)
|
||||
@@ -166,6 +177,7 @@ private:
|
||||
Q_PROPERTY(qint64 downloadedBytes READ downloadedBytes WRITE setDownloadedBytes NOTIFY downloadedBytesChanged FINAL)
|
||||
Q_PROPERTY(qint64 compileSteps READ compileSteps NOTIFY compileStepsChanged FINAL)
|
||||
Q_PROPERTY(qint64 compileStepsCompleted READ compileStepsCompleted NOTIFY compileStepsCompletedChanged FINAL)
|
||||
Q_PROPERTY(QString lastInstalledFile READ lastInstalledFile WRITE setLastInstalledFile NOTIFY lastInstalledFileChanged FINAL)
|
||||
};
|
||||
Q_DECLARE_METATYPE(DownloadManager)
|
||||
|
||||
|
||||
@@ -5,49 +5,56 @@ FeaturedImagesModel::FeaturedImagesModel(QObject *parent) : QAbstractListModel{p
|
||||
m_paginator = new FeaturedImagesPaginator(this);
|
||||
PaginationNotifier *notifier = static_cast<PaginationNotifier*>(m_paginator);
|
||||
|
||||
QObject::connect(
|
||||
QObject::connect
|
||||
(
|
||||
notifier,
|
||||
&PaginationNotifier::resultsPerPageChanged,
|
||||
this,
|
||||
&FeaturedImagesModel::resultsPerPageChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
QObject::connect
|
||||
(
|
||||
notifier,
|
||||
&PaginationNotifier::totalResultsChanged,
|
||||
this,
|
||||
&FeaturedImagesModel::totalResultsChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
QObject::connect
|
||||
(
|
||||
notifier,
|
||||
&PaginationNotifier::totalPagesChanged,
|
||||
this,
|
||||
&FeaturedImagesModel::totalPagesChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
QObject::connect
|
||||
(
|
||||
notifier,
|
||||
&PaginationNotifier::pageChanged,
|
||||
this,
|
||||
&FeaturedImagesModel::pageChanged
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
QObject::connect
|
||||
(
|
||||
notifier,
|
||||
&PaginationNotifier::pageChanged,
|
||||
this,
|
||||
&FeaturedImagesModel::resetDataModel
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
QObject::connect
|
||||
(
|
||||
notifier,
|
||||
&PaginationNotifier::fetchComplete,
|
||||
this,
|
||||
&FeaturedImagesModel::resetState
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
QObject::connect
|
||||
(
|
||||
notifier,
|
||||
&PaginationNotifier::fetching,
|
||||
this,
|
||||
|
||||
Reference in New Issue
Block a user