2020-09-29 08:41:27 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtGraphicalEffects 1.0
|
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-10-21 15:07:13 +00:00
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
import StatusQ.Core 0.1
|
2022-11-23 13:40:03 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2021-10-25 19:37:44 +00:00
|
|
|
import StatusQ.Components 0.1
|
2021-10-01 15:58:36 +00:00
|
|
|
//TODO improve this!
|
2022-03-08 18:49:33 +00:00
|
|
|
import AppLayouts.Chat.stores 1.0
|
2020-09-29 08:41:27 +00:00
|
|
|
|
|
|
|
Popup {
|
2020-12-14 07:01:09 +00:00
|
|
|
id: root
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2022-02-14 23:27:23 +00:00
|
|
|
property var store
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2022-08-10 19:18:20 +00:00
|
|
|
signal stickerSelected(string hashId, string packId, string url)
|
2022-11-23 13:40:03 +00:00
|
|
|
|
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
// FIXME: move me to store
|
|
|
|
readonly property int installedPacksCount: root.store.stickersModuleInst.numInstalledStickerPacks
|
|
|
|
readonly property var recentStickers: root.store.stickersModuleInst.recent
|
|
|
|
readonly property var stickerPackList: store.stickersModuleInst.stickerPacks
|
|
|
|
readonly property bool stickerPacksLoaded: store.stickersModuleInst.packsLoaded
|
|
|
|
readonly property bool stickerPacksLoadFailed: store.stickersModuleInst.packsLoadFailed
|
|
|
|
readonly property bool stickerPacksLoading: !stickerPacksLoaded && !stickerPacksLoadFailed
|
|
|
|
|
|
|
|
function loadStickers() {
|
|
|
|
store.stickersModuleInst.loadStickers()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enabled: !!d.recentStickers && !!d.stickerPackList
|
2020-12-04 12:14:18 +00:00
|
|
|
width: 360
|
|
|
|
height: 440
|
2020-09-29 08:41:27 +00:00
|
|
|
modal: false
|
|
|
|
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"
|
|
|
|
}
|
|
|
|
}
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2020-09-29 08:41:27 +00:00
|
|
|
onClosed: {
|
|
|
|
stickerMarket.visible = false
|
|
|
|
footerContent.visible = true
|
|
|
|
stickersContainer.visible = true
|
|
|
|
}
|
2022-11-23 13:40:03 +00:00
|
|
|
|
2022-02-25 18:15:35 +00:00
|
|
|
Connections {
|
|
|
|
target: mainModule
|
2022-09-27 21:26:26 +00:00
|
|
|
function onOnlineStatusChanged() {
|
2022-02-25 18:15:35 +00:00
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
2021-12-01 21:42:42 +00:00
|
|
|
|
2020-09-29 08:41:27 +00:00
|
|
|
contentItem: ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
StatusStickerMarket {
|
|
|
|
id: stickerMarket
|
|
|
|
visible: false
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
2022-02-14 23:27:23 +00:00
|
|
|
store: root.store
|
2022-11-23 13:40:03 +00:00
|
|
|
stickerPacks: d.stickerPackList
|
2021-12-08 21:20:43 +00:00
|
|
|
packId: stickerPackListView.selectedPackId
|
2020-09-29 08:41:27 +00:00
|
|
|
onInstallClicked: {
|
2022-12-30 20:26:46 +00:00
|
|
|
//starts async task
|
2021-11-25 17:12:19 +00:00
|
|
|
stickersModule.install(packId)
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
onUninstallClicked: {
|
2021-11-25 17:12:19 +00:00
|
|
|
stickersModule.uninstall(packId)
|
2022-11-23 13:40:03 +00:00
|
|
|
stickerGrid.model = d.recentStickers
|
2022-12-01 10:24:25 +00:00
|
|
|
btnHistory.clicked(null)
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
onBackClicked: {
|
|
|
|
stickerMarket.visible = false
|
|
|
|
footerContent.visible = true
|
|
|
|
stickersContainer.visible = true
|
|
|
|
}
|
2021-11-23 13:59:49 +00:00
|
|
|
|
2022-12-30 20:26:46 +00:00
|
|
|
Connections {
|
|
|
|
target: root.store.stickersModuleInst
|
|
|
|
function onStickerPackInstalled(packId) {
|
|
|
|
const idx = stickersModule.stickerPacks.findIndexById(packId, false);
|
|
|
|
if (idx === -1) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
stickersModule.stickerPacks.findStickersById(packId)
|
|
|
|
stickerGrid.model = stickersModule.stickerPacks.getFoundStickers()
|
|
|
|
stickerPackListView.itemAt(idx).clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 13:59:49 +00:00
|
|
|
Loader {
|
|
|
|
id: marketLoader
|
|
|
|
anchors.centerIn: parent
|
2022-11-23 13:40:03 +00:00
|
|
|
active: d.stickerPacksLoading
|
|
|
|
sourceComponent: loadingImageComponent
|
2021-11-23 13:59:49 +00:00
|
|
|
}
|
2022-11-23 13:46:02 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: failedToLoadStickersInfo
|
|
|
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
visible: d.stickerPacksLoadFailed
|
|
|
|
|
|
|
|
StatusBaseText {
|
|
|
|
text: qsTr("Failed to load stickers")
|
|
|
|
color: Theme.palette.dangerColor1
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
objectName: "stickersPopupRetryButton"
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
text: qsTr("Try again")
|
|
|
|
|
|
|
|
onClicked: d.loadStickers()
|
|
|
|
}
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: stickersContainer
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: 4
|
|
|
|
Layout.rightMargin: 4
|
|
|
|
Layout.topMargin: 4
|
|
|
|
Layout.bottomMargin: 0
|
|
|
|
Layout.alignment: Qt.AlignTop | Qt.AlignLeft
|
|
|
|
Layout.preferredHeight: 400 - 4
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: noStickerPacks
|
|
|
|
anchors.fill: parent
|
2022-11-23 13:40:03 +00:00
|
|
|
visible: d.installedPacksCount == 0 || stickersModule.recent.rowCount() === 0
|
2020-09-29 08:41:27 +00:00
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgNoStickers
|
2020-12-14 07:01:09 +00:00
|
|
|
visible: lblNoStickersYet.visible || lblNoRecentStickers.visible
|
2020-09-29 08:41:27 +00:00
|
|
|
width: 56
|
|
|
|
height: 56
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 134
|
2021-09-28 15:04:06 +00:00
|
|
|
source: Style.svg("stickers_sad_icon")
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: noStickersContainer
|
|
|
|
width: parent.width
|
|
|
|
height: 22
|
|
|
|
anchors.top: imgNoStickers.bottom
|
|
|
|
anchors.topMargin: 8
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: lblNoStickersYet
|
2022-11-23 13:40:03 +00:00
|
|
|
visible: d.installedPacksCount === 0
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
font.pixelSize: 15
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("You don't have any stickers yet")
|
2020-09-29 08:41:27 +00:00
|
|
|
lineHeight: 22
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: lblNoRecentStickers
|
2021-11-25 17:12:19 +00:00
|
|
|
visible: stickerPackListView.selectedPackId === -1 && stickersModule.recent.rowCount() === 0 && !lblNoStickersYet.visible
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
font.pixelSize: 15
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Recently used stickers will appear here")
|
2020-09-29 08:41:27 +00:00
|
|
|
lineHeight: 22
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-23 13:40:03 +00:00
|
|
|
StatusButton {
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "stickersPopupGetStickersButton"
|
2020-12-14 07:01:09 +00:00
|
|
|
visible: lblNoStickersYet.visible
|
2022-04-04 11:26:30 +00:00
|
|
|
text: qsTr("Get Stickers")
|
2020-09-29 08:41:27 +00:00
|
|
|
anchors.top: noStickersContainer.bottom
|
|
|
|
anchors.topMargin: Style.current.padding
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
onClicked: {
|
|
|
|
stickersContainer.visible = false
|
|
|
|
stickerMarket.visible = true
|
|
|
|
footerContent.visible = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusStickerList {
|
|
|
|
id: stickerGrid
|
2022-08-11 19:16:59 +00:00
|
|
|
objectName: "statusStickerPopupStickerGrid"
|
2022-11-23 13:40:03 +00:00
|
|
|
model: d.recentStickers
|
2021-12-08 21:20:43 +00:00
|
|
|
packId: stickerPackListView.selectedPackId
|
2020-09-29 08:41:27 +00:00
|
|
|
onStickerClicked: {
|
2022-08-10 19:18:20 +00:00
|
|
|
root.stickerSelected(hash, packId, url)
|
2020-12-14 07:01:09 +00:00
|
|
|
root.close()
|
|
|
|
}
|
|
|
|
}
|
2021-02-09 13:57:53 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: loadingImageComponent
|
2021-04-26 10:25:01 +00:00
|
|
|
StatusLoadingIndicator {
|
2021-02-09 13:57:53 +00:00
|
|
|
width: 50
|
|
|
|
height: 50
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
2021-02-09 13:57:53 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: loadingGrid
|
2022-11-23 13:40:03 +00:00
|
|
|
active: d.stickerPacksLoading
|
2021-02-09 13:57:53 +00:00
|
|
|
sourceComponent: loadingImageComponent
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 18:59:04 +00:00
|
|
|
RowLayout {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: footerContent
|
|
|
|
Layout.fillWidth: true
|
2023-01-09 18:59:04 +00:00
|
|
|
Layout.rightMargin: Style.current.padding / 2
|
|
|
|
Layout.leftMargin: Style.current.padding / 2
|
2022-04-11 16:17:42 +00:00
|
|
|
spacing: Style.current.padding / 2
|
2020-09-29 08:41:27 +00:00
|
|
|
|
2022-11-23 13:40:03 +00:00
|
|
|
StatusFlatRoundButton {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: btnAddStickerPack
|
2022-08-10 07:51:04 +00:00
|
|
|
implicitHeight: 40
|
2022-04-11 16:17:42 +00:00
|
|
|
implicitWidth: 24
|
2021-10-25 19:37:44 +00:00
|
|
|
icon.name: "add"
|
2022-11-23 13:40:03 +00:00
|
|
|
type: StatusFlatRoundButton.Type.Tertiary
|
2022-04-11 16:17:42 +00:00
|
|
|
color: "transparent"
|
2022-11-23 13:40:03 +00:00
|
|
|
state: d.stickerPacksLoading ? "default" : "pending"
|
2020-09-29 08:41:27 +00:00
|
|
|
onClicked: {
|
|
|
|
stickersContainer.visible = false
|
|
|
|
stickerMarket.visible = true
|
|
|
|
footerContent.visible = false
|
|
|
|
}
|
|
|
|
}
|
2022-04-11 16:17:42 +00:00
|
|
|
|
2022-11-23 13:40:03 +00:00
|
|
|
StatusTabBarIconButton {
|
2020-09-29 08:41:27 +00:00
|
|
|
id: btnHistory
|
2022-04-11 16:17:42 +00:00
|
|
|
icon.name: "time"
|
|
|
|
highlighted: true
|
2020-09-29 08:41:27 +00:00
|
|
|
onClicked: {
|
2022-04-11 16:17:42 +00:00
|
|
|
highlighted = true
|
2020-09-29 08:41:27 +00:00
|
|
|
stickerPackListView.selectedPackId = -1
|
2022-11-23 13:40:03 +00:00
|
|
|
stickerGrid.model = d.recentStickers
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-13 12:29:38 +00:00
|
|
|
StatusScrollView {
|
2022-08-10 07:51:04 +00:00
|
|
|
height: 40
|
2023-01-09 18:59:04 +00:00
|
|
|
Layout.fillWidth: true
|
2023-01-26 08:41:07 +00:00
|
|
|
Layout.fillHeight: true
|
2023-01-09 18:59:04 +00:00
|
|
|
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
|
2022-04-11 16:17:42 +00:00
|
|
|
|
2020-11-27 20:51:52 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: Style.current.padding
|
2022-07-20 14:54:30 +00:00
|
|
|
|
2020-11-27 20:51:52 +00:00
|
|
|
Repeater {
|
|
|
|
id: stickerPackListView
|
|
|
|
property int selectedPackId: -1
|
2022-11-23 13:40:03 +00:00
|
|
|
model: d.stickerPackList
|
|
|
|
visible: d.stickerPacksLoaded
|
2020-09-29 08:41:27 +00:00
|
|
|
|
2020-11-27 20:51:52 +00:00
|
|
|
delegate: StatusStickerPackIconWithIndicator {
|
|
|
|
id: packIconWithIndicator
|
|
|
|
visible: installed
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
selected: stickerPackListView.selectedPackId === packId
|
2022-02-14 23:27:23 +00:00
|
|
|
source: thumbnail
|
2020-11-27 20:51:52 +00:00
|
|
|
Layout.preferredHeight: height
|
|
|
|
Layout.preferredWidth: width
|
|
|
|
onClicked: {
|
2022-04-11 16:17:42 +00:00
|
|
|
btnHistory.highlighted = false
|
2020-11-27 20:51:52 +00:00
|
|
|
stickerPackListView.selectedPackId = packId
|
|
|
|
stickerGrid.model = stickers
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
2020-12-14 07:01:09 +00:00
|
|
|
Repeater {
|
|
|
|
id: loadingStickerPackListView
|
2022-11-23 13:40:03 +00:00
|
|
|
model: d.stickerPacksLoading ? 7 : 0
|
2020-12-14 07:01:09 +00:00
|
|
|
|
|
|
|
delegate: Rectangle {
|
|
|
|
width: 24
|
|
|
|
height: 24
|
|
|
|
Layout.preferredHeight: height
|
|
|
|
Layout.preferredWidth: width
|
|
|
|
radius: width / 2
|
|
|
|
color: Style.current.backgroundHover
|
|
|
|
}
|
|
|
|
}
|
2022-08-10 07:51:04 +00:00
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-09-29 08:41:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|