Port EmoticonEditorPage to FormCard
This commit is contained in:
@@ -8,11 +8,11 @@ import Qt.labs.platform 1.1
|
|||||||
import QtQuick.Window 2.15
|
import QtQuick.Window 2.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
|
||||||
|
|
||||||
required property string description
|
required property string description
|
||||||
@@ -24,124 +24,111 @@ Kirigami.ScrollablePage {
|
|||||||
property bool newEmoticon: false
|
property bool newEmoticon: false
|
||||||
required property var emoticonType
|
required property var emoticonType
|
||||||
|
|
||||||
topPadding: 0
|
|
||||||
leftPadding: 0
|
|
||||||
rightPadding: 0
|
|
||||||
|
|
||||||
title: emoticonType === EmoticonFormCard.Stickers ? (newEmoticon ? i18nc("@title", "Add Sticker") : i18nc("@title", "Edit Sticker"))
|
title: emoticonType === EmoticonFormCard.Stickers ? (newEmoticon ? i18nc("@title", "Add Sticker") : i18nc("@title", "Edit Sticker"))
|
||||||
: (newEmoticon ? i18nc("@title", "Add Emoji") : i18nc("@title", "Edit Emoji"))
|
: (newEmoticon ? i18nc("@title", "Add Emoji") : i18nc("@title", "Edit Emoji"))
|
||||||
|
|
||||||
ColumnLayout {
|
FormCard.FormHeader {
|
||||||
spacing: 0
|
title: emoticonType === EmoticonFormCard.Stickers ? i18n("Sticker") : i18n("Emoji")
|
||||||
MobileForm.FormHeader {
|
}
|
||||||
Layout.fillWidth: true
|
FormCard.FormCard {
|
||||||
title: emoticonType === EmoticonFormCard.Stickers ? i18n("Sticker") : i18n("Emoji")
|
FormCard.AbstractFormDelegate {
|
||||||
}
|
background: Item {}
|
||||||
MobileForm.FormCard {
|
contentItem: RowLayout {
|
||||||
Layout.fillWidth: true
|
Item {
|
||||||
contentItem: ColumnLayout {
|
|
||||||
spacing: 0
|
|
||||||
MobileForm.AbstractFormDelegate {
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
background: Item {}
|
}
|
||||||
contentItem: RowLayout {
|
Image {
|
||||||
Item {
|
id: image
|
||||||
Layout.fillWidth: true
|
Layout.alignment: Qt.AlignRight
|
||||||
}
|
source: root.url
|
||||||
Image {
|
sourceSize.width: Kirigami.Units.gridUnit * 4
|
||||||
id: image
|
sourceSize.height: Kirigami.Units.gridUnit * 4
|
||||||
Layout.alignment: Qt.AlignRight
|
width: Kirigami.Units.gridUnit * 4
|
||||||
source: root.url
|
height: Kirigami.Units.gridUnit * 4
|
||||||
sourceSize.width: Kirigami.Units.gridUnit * 4
|
|
||||||
sourceSize.height: Kirigami.Units.gridUnit * 4
|
|
||||||
width: Kirigami.Units.gridUnit * 4
|
|
||||||
height: Kirigami.Units.gridUnit * 4
|
|
||||||
|
|
||||||
Kirigami.Icon {
|
Kirigami.Icon {
|
||||||
source: emoticonType === EmoticonFormCard.Stickers ? "stickers" : "preferences-desktop-emoticons"
|
source: emoticonType === EmoticonFormCard.Stickers ? "stickers" : "preferences-desktop-emoticons"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: parent.status !== Image.Ready
|
visible: parent.status !== Image.Ready
|
||||||
|
}
|
||||||
|
|
||||||
|
QQC2.Button {
|
||||||
|
icon.name: "edit-entry"
|
||||||
|
anchors.right: parent.right
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
onClicked: mouseArea.clicked()
|
||||||
|
text: image.source != "" ? i18n("Change Image") : i18n("Set Image")
|
||||||
|
QQC2.ToolTip.text: text
|
||||||
|
QQC2.ToolTip.visible: hovered
|
||||||
|
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
||||||
|
display: QQC2.Button.IconOnly
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: mouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
property var fileDialog: null;
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (fileDialog != null) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QQC2.Button {
|
fileDialog = openFileDialog.createObject(QQC2.ApplicationWindow.Overlay)
|
||||||
icon.name: "edit-entry"
|
fileDialog.chosen.connect(function(receivedSource) {
|
||||||
anchors.right: parent.right
|
mouseArea.fileDialog = null;
|
||||||
anchors.bottom: parent.bottom
|
if (!receivedSource) {
|
||||||
onClicked: mouseArea.clicked()
|
return;
|
||||||
text: image.source != "" ? i18n("Change Image") : i18n("Set Image")
|
|
||||||
QQC2.ToolTip.text: text
|
|
||||||
QQC2.ToolTip.visible: hovered
|
|
||||||
QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay
|
|
||||||
display: QQC2.Button.IconOnly
|
|
||||||
}
|
|
||||||
|
|
||||||
MouseArea {
|
|
||||||
id: mouseArea
|
|
||||||
anchors.fill: parent
|
|
||||||
property var fileDialog: null;
|
|
||||||
cursorShape: Qt.PointingHandCursor
|
|
||||||
|
|
||||||
onClicked: {
|
|
||||||
if (fileDialog != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fileDialog = openFileDialog.createObject(QQC2.ApplicationWindow.Overlay)
|
|
||||||
fileDialog.chosen.connect(function(receivedSource) {
|
|
||||||
mouseArea.fileDialog = null;
|
|
||||||
if (!receivedSource) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parent.source = receivedSource;
|
|
||||||
});
|
|
||||||
fileDialog.onRejected.connect(function() {
|
|
||||||
mouseArea.fileDialog = null;
|
|
||||||
});
|
|
||||||
fileDialog.open();
|
|
||||||
}
|
}
|
||||||
}
|
parent.source = receivedSource;
|
||||||
}
|
});
|
||||||
Item {
|
fileDialog.onRejected.connect(function() {
|
||||||
Layout.fillWidth: true
|
mouseArea.fileDialog = null;
|
||||||
|
});
|
||||||
|
fileDialog.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MobileForm.FormTextFieldDelegate {
|
Item {
|
||||||
id: shortcode
|
Layout.fillWidth: true
|
||||||
label: i18n("Shortcode:")
|
|
||||||
text: root.shortcode
|
|
||||||
}
|
|
||||||
MobileForm.FormTextFieldDelegate {
|
|
||||||
id: description
|
|
||||||
label: i18n("Description:")
|
|
||||||
text: root.description
|
|
||||||
}
|
|
||||||
MobileForm.FormButtonDelegate {
|
|
||||||
id: save
|
|
||||||
text: i18n("Save")
|
|
||||||
icon.name: "document-save"
|
|
||||||
enabled: !root.newEmoticon || (image.source && shortcode.text && description.text)
|
|
||||||
onClicked: {
|
|
||||||
if (root.newEmoticon) {
|
|
||||||
model.addEmoticon(image.source, shortcode.text, description.text, emoticonType === EmoticonFormCard.Stickers ? "sticker" : "emoticon")
|
|
||||||
} else {
|
|
||||||
if (description.text !== root.description) {
|
|
||||||
root.model.setEmoticonBody(proxyModel.mapToSource(proxyModel.index(model.index, 0)).row, description.text)
|
|
||||||
}
|
|
||||||
if (shortcode.text !== root.shortcode) {
|
|
||||||
root.model.setEmoticonShortcode(proxyModel.mapToSource(proxyModel.index(model.index, 0)).row, shortcode.text)
|
|
||||||
}
|
|
||||||
if (image.source + "" !== root.url) {
|
|
||||||
root.model.setEmoticonImage(proxyModel.mapToSource(proxyModel.index(model.index, 0)).row, image.source)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
root.closeDialog()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FormCard.FormTextFieldDelegate {
|
||||||
|
id: shortcode
|
||||||
|
label: i18n("Shortcode:")
|
||||||
|
text: root.shortcode
|
||||||
|
}
|
||||||
|
FormCard.FormTextFieldDelegate {
|
||||||
|
id: description
|
||||||
|
label: i18n("Description:")
|
||||||
|
text: root.description
|
||||||
|
}
|
||||||
|
FormCard.FormButtonDelegate {
|
||||||
|
id: save
|
||||||
|
text: i18n("Save")
|
||||||
|
icon.name: "document-save"
|
||||||
|
enabled: !root.newEmoticon || (image.source && shortcode.text && description.text)
|
||||||
|
onClicked: {
|
||||||
|
if (root.newEmoticon) {
|
||||||
|
model.addEmoticon(image.source, shortcode.text, description.text, emoticonType === EmoticonFormCard.Stickers ? "sticker" : "emoticon")
|
||||||
|
} else {
|
||||||
|
if (description.text !== root.description) {
|
||||||
|
root.model.setEmoticonBody(proxyModel.mapToSource(proxyModel.index(model.index, 0)).row, description.text)
|
||||||
|
}
|
||||||
|
if (shortcode.text !== root.shortcode) {
|
||||||
|
root.model.setEmoticonShortcode(proxyModel.mapToSource(proxyModel.index(model.index, 0)).row, shortcode.text)
|
||||||
|
}
|
||||||
|
if (image.source + "" !== root.url) {
|
||||||
|
root.model.setEmoticonImage(proxyModel.mapToSource(proxyModel.index(model.index, 0)).row, image.source)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
root.closeDialog()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Component {
|
property Component openFileDialog: Component {
|
||||||
id: openFileDialog
|
id: openFileDialog
|
||||||
|
|
||||||
OpenFileDialog {
|
OpenFileDialog {
|
||||||
|
|||||||
Reference in New Issue
Block a user