Port EmoticonsPage to FormCard
This commit is contained in:
@@ -6,12 +6,12 @@ import QtQuick.Controls 2.15 as QQC2
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
import org.kde.kirigami 2.19 as Kirigami
|
import org.kde.kirigami 2.19 as Kirigami
|
||||||
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
|
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||||
|
|
||||||
import org.kde.neochat 1.0
|
import org.kde.neochat 1.0
|
||||||
|
|
||||||
MobileForm.FormCard {
|
FormCard.FormCard {
|
||||||
id: emoticonFormCard
|
id: root
|
||||||
|
|
||||||
enum EmoticonType {
|
enum EmoticonType {
|
||||||
Emojis,
|
Emojis,
|
||||||
@@ -20,102 +20,98 @@ MobileForm.FormCard {
|
|||||||
|
|
||||||
property var emoticonType
|
property var emoticonType
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Flow {
|
||||||
contentItem: ColumnLayout {
|
id: stickerFlow
|
||||||
spacing: 0
|
Layout.fillWidth: true
|
||||||
Flow {
|
Repeater {
|
||||||
id: stickerFlow
|
model: EmoticonFilterModel {
|
||||||
Layout.fillWidth: true
|
id: emoticonFilterModel
|
||||||
Repeater {
|
sourceModel: AccountEmoticonModel {
|
||||||
model: EmoticonFilterModel {
|
id: stickerModel
|
||||||
id: emoticonFilterModel
|
connection: Controller.activeConnection
|
||||||
sourceModel: AccountEmoticonModel {
|
|
||||||
id: stickerModel
|
|
||||||
connection: Controller.activeConnection
|
|
||||||
}
|
|
||||||
showStickers: emoticonFormCard.emoticonType === EmoticonFormCard.Stickers
|
|
||||||
showEmojis: emoticonFormCard.emoticonType === EmoticonFormCard.Emojis
|
|
||||||
}
|
|
||||||
|
|
||||||
delegate: MobileForm.AbstractFormDelegate {
|
|
||||||
id: stickerDelegate
|
|
||||||
|
|
||||||
width: stickerFlow.width / 4
|
|
||||||
height: width
|
|
||||||
|
|
||||||
onClicked: pageSettingStack.pushDialogLayer(emoticonEditorPage, {
|
|
||||||
description: model.body ?? "",
|
|
||||||
index: model.index,
|
|
||||||
url: model.url,
|
|
||||||
shortcode: model.shortcode,
|
|
||||||
model: stickerModel,
|
|
||||||
proxyModel: emoticonFilterModel,
|
|
||||||
emoticonType: emoticonFormCard.emoticonType
|
|
||||||
}, {
|
|
||||||
title: emoticonFormCard.emoticonType === EmoticonFormCard.Emojis ? i18nc("@title", "Edit Emoji") : i18nc("@title", "Edit Sticker")
|
|
||||||
});
|
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
|
||||||
Image {
|
|
||||||
source: model.url
|
|
||||||
Layout.fillWidth: true
|
|
||||||
sourceSize.height: parent.width * 0.8
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
autoTransform: true
|
|
||||||
Kirigami.Icon {
|
|
||||||
source: emoticonFormCard.emoticonType === EmoticonFormCard.Emojis ? "preferences-desktop-emoticons" : "stickers"
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: parent.status !== Image.Ready
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QQC2.Label {
|
|
||||||
id: descriptionLabel
|
|
||||||
text: model.body ?? i18nc("As in 'This sticker/emoji has no description'", "No Description")
|
|
||||||
horizontalAlignment: Qt.AlignHCenter
|
|
||||||
Layout.fillWidth: true
|
|
||||||
wrapMode: Text.Wrap
|
|
||||||
maximumLineCount: 2
|
|
||||||
elide: Text.ElideRight
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QQC2.Button {
|
|
||||||
icon.name: "edit-delete"
|
|
||||||
anchors.top: parent.top
|
|
||||||
anchors.right: parent.right
|
|
||||||
anchors.margins: Kirigami.Units.smallSpacing
|
|
||||||
z: 2
|
|
||||||
onClicked: stickerModel.deleteEmoticon(emoticonFilterModel.mapToSource(emoticonFilterModel.index(model.index, 0)).row)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
showStickers: root.emoticonType === EmoticonFormCard.Stickers
|
||||||
|
showEmojis: root.emoticonType === EmoticonFormCard.Emojis
|
||||||
}
|
}
|
||||||
MobileForm.AbstractFormDelegate {
|
|
||||||
|
delegate: FormCard.AbstractFormDelegate {
|
||||||
|
id: stickerDelegate
|
||||||
|
|
||||||
width: stickerFlow.width / 4
|
width: stickerFlow.width / 4
|
||||||
height: width
|
height: width
|
||||||
|
|
||||||
onClicked: pageSettingStack.pushDialogLayer(emoticonEditorPage, {
|
onClicked: pageStack.pushDialogLayer(emoticonEditorPage, {
|
||||||
description: "",
|
description: model.body ?? "",
|
||||||
index: -1,
|
index: model.index,
|
||||||
url: "",
|
url: model.url,
|
||||||
shortcode: "",
|
shortcode: model.shortcode,
|
||||||
model: stickerModel,
|
model: stickerModel,
|
||||||
proxyModel: emoticonFilterModel,
|
proxyModel: emoticonFilterModel,
|
||||||
newEmoticon: true,
|
emoticonType: root.emoticonType
|
||||||
emoticonType: emoticonFormCard.emoticonType
|
|
||||||
}, {
|
}, {
|
||||||
title: emoticonFormCard.emoticonType === EmoticonFormCard.Emojis ? i18nc("@title", "Add Emoji") : i18nc("@title", "Add Sticker")
|
title: root.emoticonType === EmoticonFormCard.Emojis ? i18nc("@title", "Edit Emoji") : i18nc("@title", "Edit Sticker")
|
||||||
});
|
});
|
||||||
|
|
||||||
contentItem: ColumnLayout {
|
contentItem: ColumnLayout {
|
||||||
spacing: 0
|
Image {
|
||||||
Kirigami.Icon {
|
source: model.url
|
||||||
source: "list-add"
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
sourceSize.height: parent.width * 0.8
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
autoTransform: true
|
||||||
|
Kirigami.Icon {
|
||||||
|
source: root.emoticonType === EmoticonFormCard.Emojis ? "preferences-desktop-emoticons" : "stickers"
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: parent.status !== Image.Ready
|
||||||
|
}
|
||||||
}
|
}
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
text: emoticonFormCard.emoticonType === EmoticonFormCard.Emojis ? i18n("Add Emoji") : i18n("Add Sticker")
|
id: descriptionLabel
|
||||||
|
text: model.body ?? i18nc("As in 'This sticker/emoji has no description'", "No Description")
|
||||||
horizontalAlignment: Qt.AlignHCenter
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
wrapMode: Text.Wrap
|
||||||
|
maximumLineCount: 2
|
||||||
|
elide: Text.ElideRight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QQC2.Button {
|
||||||
|
icon.name: "edit-delete"
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.margins: Kirigami.Units.smallSpacing
|
||||||
|
z: 2
|
||||||
|
onClicked: stickerModel.deleteEmoticon(emoticonFilterModel.mapToSource(emoticonFilterModel.index(model.index, 0)).row)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FormCard.AbstractFormDelegate {
|
||||||
|
width: stickerFlow.width / 4
|
||||||
|
height: width
|
||||||
|
|
||||||
|
onClicked: pageStack.pushDialogLayer(emoticonEditorPage, {
|
||||||
|
description: "",
|
||||||
|
index: -1,
|
||||||
|
url: "",
|
||||||
|
shortcode: "",
|
||||||
|
model: stickerModel,
|
||||||
|
proxyModel: emoticonFilterModel,
|
||||||
|
newEmoticon: true,
|
||||||
|
emoticonType: root.emoticonType
|
||||||
|
}, {
|
||||||
|
title: root.emoticonType === EmoticonFormCard.Emojis ? i18nc("@title", "Add Emoji") : i18nc("@title", "Add Sticker")
|
||||||
|
});
|
||||||
|
contentItem: ColumnLayout {
|
||||||
|
spacing: 0
|
||||||
|
Kirigami.Icon {
|
||||||
|
source: "list-add"
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
|
QQC2.Label {
|
||||||
|
text: root.emoticonType === EmoticonFormCard.Emojis ? i18n("Add Emoji") : i18n("Add Sticker")
|
||||||
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
|
Layout.fillWidth: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,37 +5,31 @@ import QtQuick 2.15
|
|||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
|
|
||||||
import org.kde.kirigami 2.19 as Kirigami
|
import org.kde.kirigami 2.19 as Kirigami
|
||||||
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
|
import org.kde.kirigamiaddons.formcard 1.0 as FormCard
|
||||||
|
|
||||||
import org.kde.neochat 1.0
|
import org.kde.neochat 1.0
|
||||||
|
|
||||||
Kirigami.ScrollablePage {
|
FormCard.FormCardPage {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
title: emoticonType === EmoticonFormCard.Emojis ? i18n("Emojis") : i18n("Stickers")
|
title: i18nc("@title", "Stickers & Emojis")
|
||||||
topPadding: 0
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
|
|
||||||
ColumnLayout {
|
FormCard.FormHeader {
|
||||||
spacing: 0
|
title: i18n("Emojis")
|
||||||
MobileForm.FormHeader {
|
}
|
||||||
Layout.fillWidth: true
|
EmoticonFormCard {
|
||||||
title: i18n("Emojis")
|
emoticonType: EmoticonFormCard.Emojis
|
||||||
}
|
|
||||||
EmoticonFormCard {
|
|
||||||
emoticonType: EmoticonFormCard.Emojis
|
|
||||||
}
|
|
||||||
MobileForm.FormHeader {
|
|
||||||
Layout.fillWidth: true
|
|
||||||
title: i18n("Stickers")
|
|
||||||
}
|
|
||||||
EmoticonFormCard {
|
|
||||||
emoticonType: EmoticonFormCard.Stickers
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Component {
|
FormCard.FormHeader {
|
||||||
|
title: i18n("Stickers")
|
||||||
|
}
|
||||||
|
EmoticonFormCard {
|
||||||
|
emoticonType: EmoticonFormCard.Stickers
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
property Component emoticonEditorPage: Component {
|
||||||
id: emoticonEditorPage
|
id: emoticonEditorPage
|
||||||
EmoticonEditorPage {}
|
EmoticonEditorPage {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user