2021-07-21 08:26:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
2021-10-21 15:07:13 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
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
|
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
|
|
|
|
|
|
|
Popup {
|
2022-08-16 08:55:56 +00:00
|
|
|
id: root
|
|
|
|
|
2021-08-03 08:48:06 +00:00
|
|
|
enum Category {
|
|
|
|
Trending,
|
|
|
|
Recent,
|
|
|
|
Favorite,
|
|
|
|
Search
|
|
|
|
}
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
property var gifSelected: function () {}
|
|
|
|
property var searchGif: Backpressure.debounce(searchBox, 500, function (query) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.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-01-13 08:58:42 +00:00
|
|
|
if (currentCategory === StatusGifPopup.Category.Trending) {
|
|
|
|
RootStore.getTrendingsGifs()
|
|
|
|
} else if(currentCategory === StatusGifPopup.Category.Favorite) {
|
|
|
|
RootStore.getFavoritesGifs()
|
|
|
|
} else if(currentCategory === StatusGifPopup.Category.Recent) {
|
|
|
|
RootStore.getRecentsGifs()
|
|
|
|
}
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
property var toggleFavorite: function(item) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.toggleFavoriteGif(item.id, currentCategory === StatusGifPopup.Category.Favorite)
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
property alias searchString: searchBox.text
|
2021-08-03 08:48:06 +00:00
|
|
|
property int currentCategory: StatusGifPopup.Category.Trending
|
|
|
|
property int previousCategory: StatusGifPopup.Category.Trending
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
modal: false
|
|
|
|
width: 360
|
|
|
|
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.background
|
|
|
|
border.color: Style.current.border
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
searchBox.text = ""
|
2022-07-05 07:20:57 +00:00
|
|
|
searchBox.input.edit.forceActiveFocus()
|
2021-12-08 21:20:43 +00:00
|
|
|
if (RootStore.isTenorWarningAccepted) {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.getTrendingsGifs()
|
2021-08-02 07:11:28 +00:00
|
|
|
} else {
|
|
|
|
confirmationPopup.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
2022-08-16 08:55:56 +00:00
|
|
|
root.currentCategory = StatusGifPopup.Category.Trending
|
|
|
|
root.previousCategory = StatusGifPopup.Category.Trending
|
2021-09-20 12:19:20 +00:00
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
if (confirmationPopup.opened) {
|
|
|
|
confirmationPopup.close()
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
contentItem: 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 {
|
|
|
|
property int headerMargin: 8
|
|
|
|
|
|
|
|
id: gifHeader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: searchBox.height + gifHeader.headerMargin
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
|
|
|
placeholderText: qsTr("Search")
|
|
|
|
enabled: RootStore.isTenorWarningAccepted
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: gifHeader.headerMargin
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: gifHeader.headerMargin
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: gifHeader.headerMargin
|
|
|
|
Keys.onReleased: {
|
|
|
|
if (searchBox.text === "") {
|
|
|
|
toggleCategory(previousCategory)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (root.currentCategory !== StatusGifPopup.Category.Search) {
|
|
|
|
root.previousCategory = root.currentCategory
|
|
|
|
root.currentCategory = StatusGifPopup.Category.Search
|
|
|
|
}
|
|
|
|
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: {
|
|
|
|
if (currentCategory === StatusGifPopup.Category.Trending) {
|
|
|
|
return qsTr("TRENDING")
|
|
|
|
} else if(currentCategory === StatusGifPopup.Category.Favorite) {
|
|
|
|
return qsTr("FAVORITES")
|
|
|
|
} else if(currentCategory === StatusGifPopup.Category.Recent) {
|
|
|
|
return qsTr("RECENT")
|
|
|
|
}
|
|
|
|
return ""
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
2022-08-16 08:55:56 +00:00
|
|
|
visible: searchBox.text === ""
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
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
|
|
|
|
active: root.opened && RootStore.isTenorWarningAccepted
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.rightMargin: Style.current.smallPadding / 2
|
|
|
|
Layout.leftMargin: Style.current.smallPadding / 2
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
|
|
|
Layout.preferredHeight: {
|
|
|
|
const headerTextHeight = searchBox.text === "" ? headerText.height : 0
|
|
|
|
return 400 - gifHeader.height - headerTextHeight
|
|
|
|
}
|
|
|
|
sourceComponent: RootStore.gifColumnA.rowCount() === 0 ? empty : gifItems
|
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
|
|
|
|
leftPadding: Style.current.smallPadding / 2
|
|
|
|
rightPadding: Style.current.smallPadding / 2
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
|
|
|
|
StatusTabBarIconButton {
|
|
|
|
icon.name: "flash"
|
|
|
|
highlighted: StatusGifPopup.Category.Trending === root.currentCategory
|
|
|
|
onClicked: {
|
|
|
|
toggleCategory(StatusGifPopup.Category.Trending)
|
|
|
|
}
|
|
|
|
enabled: RootStore.isTenorWarningAccepted
|
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"
|
|
|
|
highlighted: StatusGifPopup.Category.Recent === root.currentCategory
|
|
|
|
onClicked: {
|
|
|
|
toggleCategory(StatusGifPopup.Category.Recent)
|
|
|
|
}
|
|
|
|
enabled: RootStore.isTenorWarningAccepted
|
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"
|
|
|
|
highlighted: StatusGifPopup.Category.Favorite === root.currentCategory
|
|
|
|
onClicked: {
|
|
|
|
toggleCategory(StatusGifPopup.Category.Favorite)
|
|
|
|
}
|
|
|
|
enabled: RootStore.isTenorWarningAccepted
|
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
|
|
|
|
radius: Style.current.radius
|
|
|
|
anchors.fill: parent
|
|
|
|
visible: confirmationPopup.opened
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
Popup {
|
|
|
|
id: confirmationPopup
|
2022-08-16 08:55:56 +00:00
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
anchors.centerIn: parent
|
2022-08-16 08:55:56 +00:00
|
|
|
height: 278
|
|
|
|
width: 291
|
|
|
|
|
|
|
|
horizontalPadding: 6
|
|
|
|
verticalPadding: 32
|
|
|
|
|
|
|
|
modal: false
|
2021-08-02 07:11:28 +00:00
|
|
|
closePolicy: Popup.NoAutoClose
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
radius: Style.current.radius
|
|
|
|
color: Style.current.background
|
|
|
|
border.color: Style.current.border
|
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: DropShadow{
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
SVGImage {
|
|
|
|
id: gifImage
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
source: Style.svg(`gifs-${Style.current.name}`)
|
|
|
|
}
|
2021-08-02 07:11:28 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: title
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: gifImage.bottom
|
|
|
|
anchors.topMargin: 8
|
|
|
|
text: qsTr("Enable Tenor GIFs?")
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
}
|
2021-09-20 12:19:20 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusBaseText {
|
|
|
|
id: headline
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: title.bottom
|
|
|
|
anchors.topMargin: 4
|
2021-08-02 07:11:28 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
text: qsTr("Once enabled, GIFs posted in the chat may share your metadata with Tenor.")
|
|
|
|
width: parent.width
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
font.pixelSize: 13
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
2021-08-02 07:11:28 +00:00
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusButton {
|
|
|
|
id: removeBtn
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
text: qsTr("Enable")
|
|
|
|
|
|
|
|
size: StatusBaseButton.Size.Small
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
RootStore.setIsTenorWarningAccepted(true)
|
|
|
|
RootStore.getTrendingsGifs()
|
|
|
|
confirmationPopup.close()
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2021-08-03 08:48:06 +00:00
|
|
|
id: empty
|
|
|
|
Rectangle {
|
|
|
|
height: parent.height
|
|
|
|
width: parent.width
|
2021-09-20 08:20:05 +00:00
|
|
|
color: Style.current.background
|
|
|
|
|
2022-08-16 08:55:56 +00:00
|
|
|
StatusBaseText {
|
2021-09-15 11:40:56 +00:00
|
|
|
id: emptyText
|
2021-08-03 08:48:06 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
text: {
|
|
|
|
if(currentCategory === StatusGifPopup.Category.Favorite) {
|
|
|
|
return qsTr("Favorite GIFs will appear here")
|
|
|
|
} else if(currentCategory === StatusGifPopup.Category.Recent) {
|
|
|
|
return qsTr("Recent GIFs will appear here")
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
|
2021-09-15 11:40:56 +00:00
|
|
|
return qsTr("Error while contacting Tenor API, please retry.")
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
}
|
2021-09-15 11:40:56 +00:00
|
|
|
|
2021-10-25 11:48:23 +00:00
|
|
|
StatusButton {
|
2021-09-15 11:40:56 +00:00
|
|
|
id: retryBtn
|
|
|
|
anchors.top: emptyText.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-09-20 12:19:20 +00:00
|
|
|
|
2021-09-15 11:40:56 +00:00
|
|
|
text: qsTr("Retry")
|
|
|
|
visible: currentCategory === StatusGifPopup.Category.Trending || currentCategory === StatusGifPopup.Category.Search
|
|
|
|
onClicked: {
|
|
|
|
if (searchBox.text === "") {
|
2022-01-13 08:58:42 +00:00
|
|
|
RootStore.getTrendingsGifs()
|
|
|
|
|
2021-09-15 11:40:56 +00:00
|
|
|
return
|
|
|
|
}
|
2021-09-20 12:19:20 +00:00
|
|
|
|
2021-09-15 11:40:56 +00:00
|
|
|
searchGif(searchBox.text)
|
|
|
|
}
|
|
|
|
}
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: gifItems
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2021-07-21 08:26:31 +00:00
|
|
|
id: scrollView
|
|
|
|
property ScrollBar vScrollBar: ScrollBar.vertical
|
|
|
|
topPadding: Style.current.smallPadding
|
|
|
|
leftPadding: Style.current.smallPadding
|
|
|
|
rightPadding: Style.current.smallPadding
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOn
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
Row {
|
2021-09-23 02:52:17 +00:00
|
|
|
id: gifs
|
2022-07-20 14:54:30 +00:00
|
|
|
width: scrollView.availableWidth
|
2021-08-02 07:11:28 +00:00
|
|
|
spacing: Style.current.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 {
|
2022-01-13 08:58:42 +00:00
|
|
|
gifList.model: RootStore.gifColumnA
|
2022-08-16 08:55:56 +00:00
|
|
|
gifWidth: (root.width / 3) - Style.current.padding
|
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2022-01-13 08:58:42 +00:00
|
|
|
store: RootStore
|
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 {
|
2022-01-13 08:58:42 +00:00
|
|
|
gifList.model: RootStore.gifColumnB
|
2022-08-16 08:55:56 +00:00
|
|
|
gifWidth: (root.width / 3) - Style.current.padding
|
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2022-01-13 08:58:42 +00:00
|
|
|
store: RootStore
|
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 {
|
2022-01-13 08:58:42 +00:00
|
|
|
gifList.model: RootStore.gifColumnC
|
2022-08-16 08:55:56 +00:00
|
|
|
gifWidth: (root.width / 3) - Style.current.padding
|
|
|
|
gifSelected: root.gifSelected
|
|
|
|
toggleFavorite: root.toggleFavorite
|
2021-09-23 02:52:17 +00:00
|
|
|
lastHoveredId: gifs.lastHoveredId
|
2022-01-13 08:58:42 +00:00
|
|
|
store: RootStore
|
2021-09-23 02:52:17 +00:00
|
|
|
onGifHovered: {
|
|
|
|
gifs.lastHoveredId = id
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorColor:"#ffffff";height:440;width:360}
|
|
|
|
}
|
|
|
|
##^##*/
|