2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtGraphicalEffects 1.15
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-25 11:48:23 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2024-07-12 09:46:43 +00:00
|
|
|
import StatusQ.Core 0.1
|
2024-10-15 19:26:12 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2024-07-12 09:46:43 +00:00
|
|
|
import StatusQ.Core.Backpressure 0.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.panels 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2021-10-27 21:27:49 +00:00
|
|
|
import shared.controls 1.0
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
import "./StatusGifPopup"
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
Popup {
|
2022-08-16 08:55:56 +00:00
|
|
|
id: root
|
|
|
|
|
2024-09-04 14:27:24 +00:00
|
|
|
property GifStore gifStore
|
|
|
|
property bool gifUnfurlingEnabled
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
property var gifSelected: function () {}
|
|
|
|
property var searchGif: Backpressure.debounce(searchBox, 500, function (query) {
|
2024-09-04 14:27:24 +00:00
|
|
|
root.gifStore.searchGifs(query)
|
2022-08-16 08:55:56 +00:00
|
|
|
})
|
2021-08-03 08:48:06 +00:00
|
|
|
property var toggleCategory: function(newCategory) {
|
|
|
|
previousCategory = currentCategory
|
|
|
|
currentCategory = newCategory
|
|
|
|
searchBox.text = ""
|
2022-08-30 16:33:43 +00:00
|
|
|
if (currentCategory === GifPopupDefinitions.Category.Trending) {
|
2024-09-04 14:27:24 +00:00
|
|
|
root.gifStore.getTrendingsGifs()
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Favorite) {
|
2024-09-04 14:27:24 +00:00
|
|
|
root.gifStore.getFavoritesGifs()
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Recent) {
|
2024-09-04 14:27:24 +00:00
|
|
|
root.gifStore.getRecentsGifs()
|
2022-01-13 08:58:42 +00:00
|
|
|
}
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
property var toggleFavorite: function(item) {
|
2024-09-04 14:27:24 +00:00
|
|
|
root.gifStore.toggleFavoriteGif(item.id, currentCategory === GifPopupDefinitions.Category.Favorite)
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
property alias searchString: searchBox.text
|
2022-08-30 16:33:43 +00:00
|
|
|
property int currentCategory: GifPopupDefinitions.Category.Trending
|
|
|
|
property int previousCategory: GifPopupDefinitions.Category.Trending
|
2024-09-04 14:27:24 +00:00
|
|
|
property bool loading: root.gifStore.gifLoading
|
2021-08-03 08:48:06 +00:00
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
modal: false
|
|
|
|
width: 360
|
|
|
|
|
|
|
|
background: Rectangle {
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
|
|
|
color: Theme.palette.background
|
|
|
|
border.color: Theme.palette.border
|
2021-07-21 08:26:31 +00:00
|
|
|
layer.enabled: true
|
2022-07-05 07:20:57 +00:00
|
|
|
layer.effect: DropShadow {
|
2021-07-21 08:26:31 +00:00
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-03 22:12:17 +00:00
|
|
|
onAboutToShow: {
|
2021-07-21 08:26:31 +00:00
|
|
|
searchBox.text = ""
|
2022-07-05 07:20:57 +00:00
|
|
|
searchBox.input.edit.forceActiveFocus()
|
2024-09-04 14:27:24 +00:00
|
|
|
if (root.gifUnfurlingEnabled) {
|
|
|
|
root.gifStore.getTrendingsGifs()
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
2022-08-30 16:33:43 +00:00
|
|
|
root.currentCategory = GifPopupDefinitions.Category.Trending
|
|
|
|
root.previousCategory = GifPopupDefinitions.Category.Trending
|
2021-09-20 12:19:20 +00:00
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
if (confirmationPopupLoader.active) {
|
|
|
|
confirmationPopupLoader.active = false
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
2023-05-31 20:58:23 +00:00
|
|
|
padding: 0
|
|
|
|
|
|
|
|
Item {
|
2021-07-21 08:26:31 +00:00
|
|
|
anchors.fill: parent
|
2022-08-16 08:55:56 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Item {
|
2022-10-03 22:12:17 +00:00
|
|
|
readonly property int headerMargin: 8
|
2022-08-16 08:55:56 +00:00
|
|
|
|
|
|
|
id: gifHeader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: searchBox.height + gifHeader.headerMargin
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
|
|
|
placeholderText: qsTr("Search")
|
2024-09-04 14:27:24 +00:00
|
|
|
enabled: root.gifUnfurlingEnabled
|
2022-08-16 08:55:56 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: gifHeader.headerMargin
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: gifHeader.headerMargin
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: gifHeader.headerMargin
|
2022-10-03 22:12:17 +00:00
|
|
|
input.edit.onTextChanged: {
|
2022-08-16 08:55:56 +00:00
|
|
|
if (searchBox.text === "") {
|
2022-10-03 22:12:17 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Trending)
|
2022-08-16 08:55:56 +00:00
|
|
|
return
|
|
|
|
}
|
2022-08-30 16:33:43 +00:00
|
|
|
if (root.currentCategory !== GifPopupDefinitions.Category.Search) {
|
2022-08-16 08:55:56 +00:00
|
|
|
root.previousCategory = root.currentCategory
|
2022-08-30 16:33:43 +00:00
|
|
|
root.currentCategory = GifPopupDefinitions.Category.Search
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
|
|
|
Qt.callLater(searchGif, searchBox.text)
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: headerText
|
|
|
|
text: {
|
2022-08-30 16:33:43 +00:00
|
|
|
if (currentCategory === GifPopupDefinitions.Category.Trending) {
|
2022-08-16 08:55:56 +00:00
|
|
|
return qsTr("TRENDING")
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Favorite) {
|
2022-08-16 08:55:56 +00:00
|
|
|
return qsTr("FAVORITES")
|
2022-08-30 16:33:43 +00:00
|
|
|
} else if(currentCategory === GifPopupDefinitions.Category.Recent) {
|
2022-08-16 08:55:56 +00:00
|
|
|
return qsTr("RECENT")
|
|
|
|
}
|
|
|
|
return ""
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2022-08-16 08:55:56 +00:00
|
|
|
visible: searchBox.text === ""
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.secondaryText
|
2022-08-16 08:55:56 +00:00
|
|
|
font.pixelSize: 13
|
|
|
|
topPadding: gifHeader.headerMargin
|
|
|
|
leftPadding: gifHeader.headerMargin
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-08-02 07:11:28 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
Loader {
|
|
|
|
id: gifsLoader
|
2024-09-04 14:27:24 +00:00
|
|
|
active: root.opened && root.gifUnfurlingEnabled
|
2022-08-16 08:55:56 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
|
|
|
Layout.preferredHeight: {
|
|
|
|
const headerTextHeight = searchBox.text === "" ? headerText.height : 0
|
|
|
|
return 400 - gifHeader.height - headerTextHeight
|
|
|
|
}
|
2024-09-04 14:27:24 +00:00
|
|
|
sourceComponent: root.gifStore.gifColumnA.rowCount() === 0 ? emptyPlaceholderComponent : gifItemsComponent
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-10-25 11:48:23 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
Row {
|
|
|
|
id: categorySelector
|
|
|
|
Layout.fillWidth: true
|
2024-10-15 19:26:12 +00:00
|
|
|
leftPadding: Theme.smallPadding / 2
|
|
|
|
rightPadding: Theme.smallPadding / 2
|
2022-08-16 08:55:56 +00:00
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
|
|
|
|
StatusTabBarIconButton {
|
|
|
|
icon.name: "flash"
|
2022-08-30 16:33:43 +00:00
|
|
|
highlighted: GifPopupDefinitions.Category.Trending === root.currentCategory
|
2022-08-16 08:55:56 +00:00
|
|
|
onClicked: {
|
2022-08-30 16:33:43 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Trending)
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2024-09-04 14:27:24 +00:00
|
|
|
enabled: root.gifUnfurlingEnabled
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-10-25 11:48:23 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusTabBarIconButton {
|
|
|
|
icon.name: "time"
|
2022-08-30 16:33:43 +00:00
|
|
|
highlighted: GifPopupDefinitions.Category.Recent === root.currentCategory
|
2022-08-16 08:55:56 +00:00
|
|
|
onClicked: {
|
2022-08-30 16:33:43 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Recent)
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2024-09-04 14:27:24 +00:00
|
|
|
enabled: root.gifUnfurlingEnabled
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-10-25 11:48:23 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusTabBarIconButton {
|
|
|
|
icon.name: "favourite"
|
2022-08-30 16:33:43 +00:00
|
|
|
highlighted: GifPopupDefinitions.Category.Favorite === root.currentCategory
|
2022-08-16 08:55:56 +00:00
|
|
|
onClicked: {
|
2022-08-30 16:33:43 +00:00
|
|
|
toggleCategory(GifPopupDefinitions.Category.Favorite)
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2024-09-04 14:27:24 +00:00
|
|
|
enabled: root.gifUnfurlingEnabled
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
2022-08-16 08:55:56 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: 'black'
|
|
|
|
opacity: 0.4
|
2024-10-15 19:26:12 +00:00
|
|
|
radius: Theme.radius
|
2022-08-16 08:55:56 +00:00
|
|
|
anchors.fill: parent
|
2022-08-30 16:33:43 +00:00
|
|
|
visible: confirmationPopupLoader.active
|
2022-08-16 08:55:56 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
Loader {
|
|
|
|
id: confirmationPopupLoader
|
2022-08-16 08:55:56 +00:00
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
|
2022-08-30 16:33:43 +00:00
|
|
|
sourceComponent: ConfirmationPopup {
|
|
|
|
visible: true
|
2024-09-04 14:27:24 +00:00
|
|
|
|
|
|
|
onEnableGifsRequested: {
|
2024-10-25 18:12:37 +00:00
|
|
|
root.gifStore.setGifUnfurlingEnabled(true)
|
2024-09-04 14:27:24 +00:00
|
|
|
root.gifStore.getTrendingsGifs()
|
|
|
|
}
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
2024-09-04 14:27:24 +00:00
|
|
|
active: !root.gifUnfurlingEnabled
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2022-08-30 16:33:43 +00:00
|
|
|
id: gifItemsComponent
|
2021-09-20 08:20:05 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2023-05-31 20:58:23 +00:00
|
|
|
id: scrollView
|
|
|
|
contentWidth: availableWidth
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
Row {
|
2021-09-23 02:52:17 +00:00
|
|
|
id: gifs
|
2023-05-31 20:58:23 +00:00
|
|
|
width: scrollView.availableWidth
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-09-23 02:52:17 +00:00
|
|
|
property string lastHoveredId
|
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
StatusGifColumn {
|
2024-09-04 14:27:24 +00:00
|
|
|
gifStore: root.gifStore
|
|
|
|
|
|
|
|
gifList.model: root.gifStore.gifColumnA
|
2024-10-15 19:26:12 +00:00
|
|
|
gifWidth: (root.width / 3) - Theme.padding
|
2022-08-16 08:55:56 +00:00
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2024-09-04 14:27:24 +00:00
|
|
|
|
2021-09-23 02:52:17 +00:00
|
|
|
onGifHovered: {
|
|
|
|
gifs.lastHoveredId = id
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
StatusGifColumn {
|
2024-09-04 14:27:24 +00:00
|
|
|
gifStore: root.gifStore
|
|
|
|
|
|
|
|
gifList.model: root.gifStore.gifColumnB
|
2024-10-15 19:26:12 +00:00
|
|
|
gifWidth: (root.width / 3) - Theme.padding
|
2022-08-16 08:55:56 +00:00
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2024-09-04 14:27:24 +00:00
|
|
|
|
2021-09-23 02:52:17 +00:00
|
|
|
onGifHovered: {
|
|
|
|
gifs.lastHoveredId = id
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
StatusGifColumn {
|
2024-09-04 14:27:24 +00:00
|
|
|
gifStore: root.gifStore
|
|
|
|
|
|
|
|
gifList.model: root.gifStore.gifColumnC
|
2024-10-15 19:26:12 +00:00
|
|
|
gifWidth: (root.width / 3) - Theme.padding
|
2022-08-16 08:55:56 +00:00
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2024-09-04 14:27:24 +00:00
|
|
|
|
2021-09-23 02:52:17 +00:00
|
|
|
onGifHovered: {
|
|
|
|
gifs.lastHoveredId = id
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-08-30 16:33:43 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: emptyPlaceholderComponent
|
|
|
|
|
|
|
|
EmptyPlaceholder {
|
2024-10-15 19:26:12 +00:00
|
|
|
Layout.margins: Theme.smallPadding
|
2022-08-30 16:33:43 +00:00
|
|
|
currentCategory: root.currentCategory
|
2023-03-20 18:58:20 +00:00
|
|
|
loading: root.loading
|
2022-08-30 16:33:43 +00:00
|
|
|
onDoRetry: searchBox.text === ""
|
2024-09-04 14:27:24 +00:00
|
|
|
? root.gifStore.getTrendingsGifs()
|
2022-08-30 16:33:43 +00:00
|
|
|
: searchGif(searchBox.text)
|
|
|
|
}
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|