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
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import "../../imports"
|
|
|
|
import "../../shared"
|
|
|
|
|
|
|
|
Popup {
|
2021-08-03 08:48:06 +00:00
|
|
|
enum Category {
|
|
|
|
Trending,
|
|
|
|
Recent,
|
|
|
|
Favorite,
|
|
|
|
Search
|
|
|
|
}
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
id: popup
|
|
|
|
property var gifSelected: function () {}
|
|
|
|
property var searchGif: Backpressure.debounce(searchBox, 500, function (query) {
|
|
|
|
chatsModel.gif.search(query)
|
|
|
|
});
|
2021-08-03 08:48:06 +00:00
|
|
|
property var toggleCategory: function(newCategory) {
|
|
|
|
previousCategory = currentCategory
|
|
|
|
currentCategory = newCategory
|
|
|
|
searchBox.text = ""
|
|
|
|
if (currentCategory === StatusGifPopup.Category.Trending) {
|
|
|
|
chatsModel.gif.getTrendings()
|
|
|
|
} else if(currentCategory === StatusGifPopup.Category.Favorite) {
|
|
|
|
chatsModel.gif.getFavorites()
|
|
|
|
} else if(currentCategory === StatusGifPopup.Category.Recent) {
|
|
|
|
chatsModel.gif.getRecents()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
property var toggleFavorite: function(item) {
|
|
|
|
chatsModel.gif.toggleFavorite(item.id, currentCategory === StatusGifPopup.Category.Favorite)
|
|
|
|
}
|
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
|
|
|
|
layer.effect: DropShadow{
|
|
|
|
verticalOffset: 3
|
|
|
|
radius: 8
|
|
|
|
samples: 15
|
|
|
|
fast: true
|
|
|
|
cached: true
|
|
|
|
color: "#22000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onOpened: {
|
|
|
|
searchBox.text = ""
|
|
|
|
searchBox.forceActiveFocus(Qt.MouseFocusReason)
|
2021-08-02 07:11:28 +00:00
|
|
|
if (appSettings.isTenorWarningAccepted) {
|
2021-08-03 08:48:06 +00:00
|
|
|
chatsModel.gif.getTrendings()
|
2021-08-02 07:11:28 +00:00
|
|
|
} else {
|
|
|
|
confirmationPopup.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onClosed: {
|
2021-09-20 12:19:20 +00:00
|
|
|
popup.currentCategory = StatusGifPopup.Category.Trending
|
|
|
|
popup.previousCategory = StatusGifPopup.Category.Trending
|
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
if (confirmationPopup.opened) {
|
|
|
|
confirmationPopup.close()
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
property int headerMargin: 8
|
|
|
|
|
|
|
|
id: gifHeader
|
|
|
|
Layout.fillWidth: true
|
|
|
|
height: searchBox.height + gifHeader.headerMargin
|
|
|
|
|
|
|
|
SearchBox {
|
|
|
|
id: searchBox
|
2021-08-03 08:48:06 +00:00
|
|
|
placeholderText: qsTr("Search Tenor")
|
|
|
|
enabled: appSettings.isTenorWarningAccepted
|
2021-07-21 08:26:31 +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
|
|
|
|
Keys.onReleased: {
|
2021-08-03 08:48:06 +00:00
|
|
|
if (searchBox.text === "") {
|
|
|
|
toggleCategory(previousCategory)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (popup.currentCategory !== StatusGifPopup.Category.Search) {
|
|
|
|
popup.previousCategory = popup.currentCategory
|
|
|
|
popup.currentCategory = StatusGifPopup.Category.Search
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
Qt.callLater(searchGif, searchBox.text);
|
|
|
|
}
|
|
|
|
}
|
2021-08-03 08:48:06 +00:00
|
|
|
|
|
|
|
StatusIconButton {
|
|
|
|
id: clearBtn
|
|
|
|
icon.name: "close-icon"
|
|
|
|
type: "secondary"
|
|
|
|
visible: searchBox.text !== ""
|
|
|
|
icon.width: 14
|
|
|
|
icon.height: 14
|
|
|
|
width: 14
|
|
|
|
height: 14
|
|
|
|
anchors.right: searchBox.right
|
|
|
|
anchors.rightMargin: Style.current.padding
|
|
|
|
anchors.verticalCenter: searchBox.verticalCenter
|
|
|
|
onClicked: toggleCategory(previousCategory)
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
StyledText {
|
2021-08-03 08:48:06 +00:00
|
|
|
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-02 07:11:28 +00:00
|
|
|
visible: searchBox.text === ""
|
|
|
|
color: Style.current.secondaryText
|
|
|
|
font.pixelSize: 13
|
|
|
|
topPadding: gifHeader.headerMargin
|
|
|
|
leftPadding: gifHeader.headerMargin
|
|
|
|
}
|
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
Loader {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.rightMargin: Style.current.smallPadding / 2
|
2021-08-03 08:48:06 +00:00
|
|
|
Layout.leftMargin: Style.current.smallPadding / 2
|
2021-07-21 08:26:31 +00:00
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
2021-08-03 08:48:06 +00:00
|
|
|
Layout.preferredHeight: {
|
|
|
|
const headerTextHeight = searchBox.text === "" ? headerText.height : 0
|
|
|
|
return 400 - gifHeader.height - headerTextHeight
|
|
|
|
}
|
|
|
|
sourceComponent: chatsModel.gif.columnA.rowCount() == 0 ? empty : gifItems
|
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
|
|
|
id: categorySelector
|
|
|
|
Layout.fillWidth: true
|
|
|
|
leftPadding: Style.current.smallPadding / 2
|
|
|
|
rightPadding: Style.current.smallPadding / 2
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
StatusCategoryButton {
|
|
|
|
source: `../../app/img/gifCategories/trending.svg`
|
|
|
|
active: StatusGifPopup.Category.Trending === popup.currentCategory
|
|
|
|
changeCategory: function () {
|
|
|
|
toggleCategory(StatusGifPopup.Category.Trending)
|
|
|
|
}
|
|
|
|
enabled: appSettings.isTenorWarningAccepted
|
|
|
|
}
|
|
|
|
StatusCategoryButton {
|
|
|
|
source: `../../app/img/gifCategories/recent.svg`
|
|
|
|
active: StatusGifPopup.Category.Recent === popup.currentCategory
|
|
|
|
changeCategory: function () {
|
|
|
|
toggleCategory(StatusGifPopup.Category.Recent)
|
|
|
|
}
|
|
|
|
enabled: appSettings.isTenorWarningAccepted
|
|
|
|
}
|
|
|
|
StatusCategoryButton {
|
|
|
|
source: `../../app/img/gifCategories/favorite.svg`
|
|
|
|
active: StatusGifPopup.Category.Favorite === popup.currentCategory
|
|
|
|
changeCategory: function () {
|
|
|
|
toggleCategory(StatusGifPopup.Category.Favorite)
|
|
|
|
}
|
|
|
|
enabled: appSettings.isTenorWarningAccepted
|
|
|
|
}
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
Popup {
|
|
|
|
id: confirmationPopup
|
|
|
|
modal: false
|
|
|
|
anchors.centerIn: parent
|
|
|
|
height: 290
|
|
|
|
width: 280
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Column {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 12
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: gifImage
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-08-03 08:48:06 +00:00
|
|
|
source: `./assets/img/gif-${Style.current.name}.svg`
|
2021-08-02 07:11:28 +00:00
|
|
|
}
|
2021-09-20 12:19:20 +00:00
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
StyledText {
|
|
|
|
id: title
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: qsTr("Enable Tenor GIFs?")
|
|
|
|
font.weight: Font.Medium
|
|
|
|
font.pixelSize: Style.current.primaryTextFontSize
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: headline
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: removeBtn
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
2021-09-15 11:40:56 +00:00
|
|
|
text: qsTr("Enable")
|
2021-08-02 07:11:28 +00:00
|
|
|
onClicked: {
|
|
|
|
appSettings.isTenorWarningAccepted = true
|
2021-08-03 08:48:06 +00:00
|
|
|
chatsModel.gif.getTrendings()
|
2021-08-02 07:11:28 +00:00
|
|
|
confirmationPopup.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
2021-08-03 08:48:06 +00:00
|
|
|
StyledText {
|
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
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
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 === "") {
|
|
|
|
chatsModel.gif.getTrendings()
|
|
|
|
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
|
2021-07-21 08:26:31 +00:00
|
|
|
ScrollView {
|
|
|
|
id: scrollView
|
|
|
|
property ScrollBar vScrollBar: ScrollBar.vertical
|
|
|
|
clip: true
|
|
|
|
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-07-21 08:26:31 +00:00
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2021-08-02 07:11:28 +00:00
|
|
|
spacing: Style.current.halfPadding
|
2021-07-21 08:26:31 +00:00
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
StatusGifColumn {
|
|
|
|
gifList.model: chatsModel.gif.columnA
|
2021-08-02 07:11:28 +00:00
|
|
|
gifWidth: (popup.width / 3) - Style.current.padding
|
2021-07-29 13:33:22 +00:00
|
|
|
gifSelected: popup.gifSelected
|
2021-08-03 08:48:06 +00:00
|
|
|
toggleFavorite: popup.toggleFavorite
|
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 {
|
|
|
|
gifList.model: chatsModel.gif.columnB
|
2021-08-02 07:11:28 +00:00
|
|
|
gifWidth: (popup.width / 3) - Style.current.padding
|
2021-07-29 13:33:22 +00:00
|
|
|
gifSelected: popup.gifSelected
|
2021-08-03 08:48:06 +00:00
|
|
|
toggleFavorite: popup.toggleFavorite
|
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 {
|
|
|
|
gifList.model: chatsModel.gif.columnC
|
2021-08-02 07:11:28 +00:00
|
|
|
gifWidth: (popup.width / 3) - Style.current.padding
|
2021-07-29 13:33:22 +00:00
|
|
|
gifSelected: popup.gifSelected
|
2021-08-03 08:48:06 +00:00
|
|
|
toggleFavorite: popup.toggleFavorite
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
|
2021-07-21 08:26:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;formeditorColor:"#ffffff";height:440;width:360}
|
|
|
|
}
|
|
|
|
##^##*/
|