2021-08-06 02:45:47 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2021-08-06 02:45:47 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import ".."
|
|
|
|
import "../components"
|
2021-08-06 04:28:56 +03:00
|
|
|
import Qt.labs.platform 1.1
|
2021-08-06 02:45:47 +03:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
|
|
|
import QtQuick.Layouts 1.12
|
|
|
|
import im.nheko 1.0
|
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: win
|
|
|
|
|
|
|
|
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3)
|
|
|
|
property SingleImagePackModel imagePack
|
|
|
|
property int currentImageIndex: -1
|
|
|
|
readonly property int stickerDim: 128
|
|
|
|
readonly property int stickerDimPad: 128 + Nheko.paddingSmall
|
|
|
|
|
|
|
|
title: qsTr("Editing image pack")
|
|
|
|
height: 600
|
|
|
|
width: 600
|
|
|
|
palette: Nheko.colors
|
|
|
|
color: Nheko.colors.base
|
|
|
|
modality: Qt.WindowModal
|
2021-08-19 17:55:54 +03:00
|
|
|
flags: Qt.Dialog | Qt.WindowCloseButtonHint | Qt.WindowTitleHint
|
2021-08-06 02:45:47 +03:00
|
|
|
|
|
|
|
AdaptiveLayout {
|
|
|
|
id: adaptiveView
|
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
singlePageMode: false
|
|
|
|
pageIndex: 0
|
|
|
|
|
|
|
|
AdaptiveLayoutElement {
|
|
|
|
id: packlistC
|
|
|
|
|
|
|
|
visible: Settings.groupView
|
|
|
|
minimumWidth: 200
|
|
|
|
collapsedWidth: 200
|
|
|
|
preferredWidth: 300
|
|
|
|
maximumWidth: 300
|
|
|
|
clip: true
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
//required property bool isEmote
|
|
|
|
//required property bool isSticker
|
|
|
|
|
|
|
|
model: imagePack
|
|
|
|
|
|
|
|
ScrollHelper {
|
|
|
|
flickable: parent
|
|
|
|
anchors.fill: parent
|
|
|
|
enabled: !Settings.mobileMode
|
|
|
|
}
|
|
|
|
|
|
|
|
header: AvatarListTile {
|
|
|
|
title: imagePack.packname
|
|
|
|
avatarUrl: imagePack.avatarUrl
|
2021-09-07 04:14:45 +03:00
|
|
|
roomid: imagePack.statekey
|
2021-08-06 02:45:47 +03:00
|
|
|
subtitle: imagePack.statekey
|
|
|
|
index: -1
|
|
|
|
selectedIndex: currentImageIndex
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
onSingleTapped: currentImageIndex = -1
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
height: parent.height - Nheko.paddingSmall * 2
|
|
|
|
width: 3
|
|
|
|
color: Nheko.colors.highlight
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-08-06 04:28:56 +03:00
|
|
|
footer: Button {
|
|
|
|
palette: Nheko.colors
|
|
|
|
onClicked: addFilesDialog.open()
|
|
|
|
width: ListView.view.width
|
|
|
|
text: qsTr("Add images")
|
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
id: addFilesDialog
|
|
|
|
|
|
|
|
folder: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
|
|
|
|
fileMode: FileDialog.OpenFiles
|
2021-12-13 08:18:30 +03:00
|
|
|
nameFilters: [qsTr("Images (*.png *.webp *.gif *.jpg *.jpeg)")]
|
|
|
|
title: qsTr("Select images for pack")
|
|
|
|
acceptLabel: qsTr("Add to pack")
|
2021-08-06 04:28:56 +03:00
|
|
|
onAccepted: imagePack.addStickers(files)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-08-06 02:45:47 +03:00
|
|
|
delegate: AvatarListTile {
|
|
|
|
id: packItem
|
|
|
|
|
|
|
|
property color background: Nheko.colors.window
|
|
|
|
property color importantText: Nheko.colors.text
|
|
|
|
property color unimportantText: Nheko.colors.buttonText
|
|
|
|
property color bubbleBackground: Nheko.colors.highlight
|
|
|
|
property color bubbleText: Nheko.colors.highlightedText
|
|
|
|
required property string shortCode
|
|
|
|
required property string url
|
|
|
|
required property string body
|
|
|
|
|
|
|
|
title: shortCode
|
|
|
|
subtitle: body
|
|
|
|
avatarUrl: url
|
|
|
|
selectedIndex: currentImageIndex
|
|
|
|
crop: false
|
|
|
|
|
|
|
|
TapHandler {
|
|
|
|
onSingleTapped: currentImageIndex = index
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
AdaptiveLayoutElement {
|
|
|
|
id: packinfoC
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
color: Nheko.colors.window
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
visible: currentImageIndex == -1
|
|
|
|
enabled: visible
|
|
|
|
columns: 2
|
|
|
|
rowSpacing: Nheko.paddingLarge
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
url: imagePack.avatarUrl.replace("mxc://", "image://MxcImage/")
|
|
|
|
displayName: imagePack.packname
|
2021-09-07 04:14:45 +03:00
|
|
|
roomid: imagePack.statekey
|
2021-08-06 02:45:47 +03:00
|
|
|
height: 130
|
|
|
|
width: 130
|
|
|
|
crop: false
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
2021-12-13 08:00:32 +03:00
|
|
|
|
|
|
|
ImageButton {
|
|
|
|
hoverEnabled: true
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: qsTr("Change the overview image for this pack")
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.leftMargin: Nheko.paddingMedium
|
|
|
|
anchors.topMargin: Nheko.paddingMedium
|
|
|
|
image: ":/icons/icons/ui/edit.svg"
|
|
|
|
onClicked: addAvatarDialog.open()
|
|
|
|
|
|
|
|
FileDialog {
|
|
|
|
id: addAvatarDialog
|
|
|
|
|
|
|
|
folder: StandardPaths.writableLocation(StandardPaths.PicturesLocation)
|
|
|
|
fileMode: FileDialog.OpenFile
|
|
|
|
nameFilters: [qsTr("Overview Image (*.png *.webp *.jpg *.jpeg)")]
|
2021-12-13 08:18:30 +03:00
|
|
|
title: qsTr("Select overview image for pack")
|
2021-12-13 08:00:32 +03:00
|
|
|
onAccepted: imagePack.setAvatar(file)
|
|
|
|
}
|
|
|
|
}
|
2021-08-06 02:45:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
MatrixTextField {
|
2022-01-24 02:41:55 +03:00
|
|
|
id: statekeyField
|
|
|
|
|
2021-08-06 02:45:47 +03:00
|
|
|
visible: imagePack.roomid
|
|
|
|
Layout.fillWidth: true
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
label: qsTr("State key")
|
2021-08-06 02:45:47 +03:00
|
|
|
text: imagePack.statekey
|
|
|
|
onTextEdited: imagePack.statekey = text
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixTextField {
|
|
|
|
Layout.fillWidth: true
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
label: qsTr("Packname")
|
2021-08-06 02:45:47 +03:00
|
|
|
text: imagePack.packname
|
|
|
|
onTextEdited: imagePack.packname = text
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixTextField {
|
|
|
|
Layout.fillWidth: true
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
label: qsTr("Attribution")
|
2021-08-06 02:45:47 +03:00
|
|
|
text: imagePack.attribution
|
|
|
|
onTextEdited: imagePack.attribution = text
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixText {
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.margins: statekeyField.textPadding
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
font.letterSpacing: font.pixelSize * 0.02
|
2021-08-06 02:45:47 +03:00
|
|
|
text: qsTr("Use as Emoji")
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
checked: imagePack.isEmotePack
|
2022-01-09 02:28:03 +03:00
|
|
|
onCheckedChanged: imagePack.isEmotePack = checked
|
2021-08-06 02:45:47 +03:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixText {
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.margins: statekeyField.textPadding
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
font.letterSpacing: font.pixelSize * 0.02
|
2021-08-06 02:45:47 +03:00
|
|
|
text: qsTr("Use as Sticker")
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
checked: imagePack.isStickerPack
|
2022-01-09 02:28:03 +03:00
|
|
|
onCheckedChanged: imagePack.isStickerPack = checked
|
2021-08-06 02:45:47 +03:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GridLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
visible: currentImageIndex >= 0
|
|
|
|
enabled: visible
|
|
|
|
columns: 2
|
|
|
|
rowSpacing: Nheko.paddingLarge
|
|
|
|
|
|
|
|
Avatar {
|
|
|
|
Layout.columnSpan: 2
|
2022-03-09 22:15:37 +03:00
|
|
|
url: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.Url).replace("mxc://", "image://MxcImage/") + "?scale"
|
2021-08-06 02:45:47 +03:00
|
|
|
displayName: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.ShortCode)
|
2021-09-07 04:14:45 +03:00
|
|
|
roomid: displayName
|
2021-08-06 02:45:47 +03:00
|
|
|
height: 130
|
|
|
|
width: 130
|
|
|
|
crop: false
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixTextField {
|
|
|
|
Layout.fillWidth: true
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
label: qsTr("Shortcode")
|
2021-08-06 02:45:47 +03:00
|
|
|
text: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.ShortCode)
|
|
|
|
onTextEdited: imagePack.setData(imagePack.index(currentImageIndex, 0), text, SingleImagePackModel.ShortCode)
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixTextField {
|
2022-01-24 02:41:55 +03:00
|
|
|
id: bodyField
|
|
|
|
|
2021-08-06 02:45:47 +03:00
|
|
|
Layout.fillWidth: true
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.columnSpan: 2
|
|
|
|
label: qsTr("Body")
|
2021-08-06 02:45:47 +03:00
|
|
|
text: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.Body)
|
|
|
|
onTextEdited: imagePack.setData(imagePack.index(currentImageIndex, 0), text, SingleImagePackModel.Body)
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixText {
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.margins: bodyField.textPadding
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
font.letterSpacing: font.pixelSize * 0.02
|
2021-08-06 02:45:47 +03:00
|
|
|
text: qsTr("Use as Emoji")
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsEmote)
|
2022-01-09 02:28:03 +03:00
|
|
|
onCheckedChanged: imagePack.setData(imagePack.index(currentImageIndex, 0), checked, SingleImagePackModel.IsEmote)
|
2021-08-06 02:45:47 +03:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
}
|
|
|
|
|
|
|
|
MatrixText {
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.margins: bodyField.textPadding
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
font.letterSpacing: font.pixelSize * 0.02
|
2021-08-06 02:45:47 +03:00
|
|
|
text: qsTr("Use as Sticker")
|
|
|
|
}
|
|
|
|
|
|
|
|
ToggleButton {
|
|
|
|
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsSticker)
|
2022-01-09 02:28:03 +03:00
|
|
|
onCheckedChanged: imagePack.setData(imagePack.index(currentImageIndex, 0), checked, SingleImagePackModel.IsSticker)
|
2021-08-06 02:45:47 +03:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
}
|
|
|
|
|
2021-08-29 18:22:49 +03:00
|
|
|
MatrixText {
|
2022-01-24 02:41:55 +03:00
|
|
|
Layout.margins: bodyField.textPadding
|
|
|
|
font.weight: Font.DemiBold
|
|
|
|
font.letterSpacing: font.pixelSize * 0.02
|
2021-08-29 18:22:49 +03:00
|
|
|
text: qsTr("Remove from pack")
|
|
|
|
}
|
|
|
|
|
|
|
|
Button {
|
|
|
|
text: qsTr("Remove")
|
|
|
|
onClicked: {
|
|
|
|
let temp = currentImageIndex;
|
|
|
|
currentImageIndex = -1;
|
|
|
|
imagePack.remove(temp);
|
|
|
|
}
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
}
|
|
|
|
|
2021-08-06 02:45:47 +03:00
|
|
|
Item {
|
|
|
|
Layout.columnSpan: 2
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
footer: DialogButtonBox {
|
|
|
|
id: buttons
|
|
|
|
|
2022-03-11 14:53:23 +03:00
|
|
|
standardButtons: DialogButtonBox.Save | DialogButtonBox.Cancel
|
|
|
|
onAccepted: {
|
|
|
|
imagePack.save();
|
|
|
|
win.close();
|
2021-08-06 02:45:47 +03:00
|
|
|
}
|
2022-03-11 14:53:23 +03:00
|
|
|
onRejected: win.close()
|
2021-08-06 02:45:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|