mirror of https://github.com/Nheko-Reborn/nheko
commit
11f9a9d044
@ -0,0 +1,133 @@ |
||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors |
||||
// |
||||
// SPDX-License-Identifier: GPL-3.0-or-later |
||||
|
||||
import ".." |
||||
import QtQuick 2.15 |
||||
import QtQuick.Controls 2.15 |
||||
import QtQuick.Layouts 1.15 |
||||
import im.nheko 1.0 |
||||
|
||||
Rectangle { |
||||
id: tile |
||||
|
||||
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 |
||||
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3) |
||||
required property string avatarUrl |
||||
required property string title |
||||
required property string subtitle |
||||
required property int index |
||||
required property int selectedIndex |
||||
property bool crop: true |
||||
|
||||
color: background |
||||
height: avatarSize + 2 * Nheko.paddingMedium |
||||
width: ListView.view.width |
||||
state: "normal" |
||||
states: [ |
||||
State { |
||||
name: "highlight" |
||||
when: hovered.hovered && !(index == selectedIndex) |
||||
|
||||
PropertyChanges { |
||||
target: tile |
||||
background: Nheko.colors.dark |
||||
importantText: Nheko.colors.brightText |
||||
unimportantText: Nheko.colors.brightText |
||||
bubbleBackground: Nheko.colors.highlight |
||||
bubbleText: Nheko.colors.highlightedText |
||||
} |
||||
|
||||
}, |
||||
State { |
||||
name: "selected" |
||||
when: index == selectedIndex |
||||
|
||||
PropertyChanges { |
||||
target: tile |
||||
background: Nheko.colors.highlight |
||||
importantText: Nheko.colors.highlightedText |
||||
unimportantText: Nheko.colors.highlightedText |
||||
bubbleBackground: Nheko.colors.highlightedText |
||||
bubbleText: Nheko.colors.highlight |
||||
} |
||||
|
||||
} |
||||
] |
||||
|
||||
HoverHandler { |
||||
id: hovered |
||||
} |
||||
|
||||
RowLayout { |
||||
spacing: Nheko.paddingMedium |
||||
anchors.fill: parent |
||||
anchors.margins: Nheko.paddingMedium |
||||
|
||||
Avatar { |
||||
id: avatar |
||||
|
||||
enabled: false |
||||
Layout.alignment: Qt.AlignVCenter |
||||
height: avatarSize |
||||
width: avatarSize |
||||
url: tile.avatarUrl.replace("mxc://", "image://MxcImage/") |
||||
displayName: title |
||||
crop: tile.crop |
||||
} |
||||
|
||||
ColumnLayout { |
||||
id: textContent |
||||
|
||||
Layout.alignment: Qt.AlignLeft |
||||
Layout.fillWidth: true |
||||
Layout.minimumWidth: 100 |
||||
width: parent.width - avatar.width |
||||
Layout.preferredWidth: parent.width - avatar.width |
||||
spacing: Nheko.paddingSmall |
||||
|
||||
RowLayout { |
||||
Layout.fillWidth: true |
||||
spacing: 0 |
||||
|
||||
ElidedLabel { |
||||
Layout.alignment: Qt.AlignBottom |
||||
color: tile.importantText |
||||
elideWidth: textContent.width - Nheko.paddingMedium |
||||
fullText: title |
||||
textFormat: Text.PlainText |
||||
} |
||||
|
||||
Item { |
||||
Layout.fillWidth: true |
||||
} |
||||
|
||||
} |
||||
|
||||
RowLayout { |
||||
Layout.fillWidth: true |
||||
spacing: 0 |
||||
|
||||
ElidedLabel { |
||||
color: tile.unimportantText |
||||
font.pixelSize: fontMetrics.font.pixelSize * 0.9 |
||||
elideWidth: textContent.width - Nheko.paddingSmall |
||||
fullText: subtitle |
||||
textFormat: Text.PlainText |
||||
} |
||||
|
||||
Item { |
||||
Layout.fillWidth: true |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,301 @@ |
||||
// SPDX-FileCopyrightText: 2021 Nheko Contributors |
||||
// |
||||
// SPDX-License-Identifier: GPL-3.0-or-later |
||||
|
||||
import ".." |
||||
import "../components" |
||||
import Qt.labs.platform 1.1 |
||||
import QtQuick 2.12 |
||||
import QtQuick.Controls 2.12 |
||||
import QtQuick.Layouts 1.12 |
||||
import im.nheko 1.0 |
||||
|
||||
ApplicationWindow { |
||||
//Component.onCompleted: Nheko.reparent(win) |
||||
|
||||
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 |
||||
flags: Qt.Dialog | Qt.WindowCloseButtonHint |
||||
|
||||
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 |
||||
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 |
||||
} |
||||
|
||||
} |
||||
|
||||
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 |
||||
nameFilters: [qsTr("Stickers (*.png *.webp)")] |
||||
onAccepted: imagePack.addStickers(files) |
||||
} |
||||
|
||||
} |
||||
|
||||
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 |
||||
height: 130 |
||||
width: 130 |
||||
crop: false |
||||
Layout.alignment: Qt.AlignHCenter |
||||
} |
||||
|
||||
MatrixText { |
||||
visible: imagePack.roomid |
||||
text: qsTr("State key") |
||||
} |
||||
|
||||
MatrixTextField { |
||||
visible: imagePack.roomid |
||||
Layout.fillWidth: true |
||||
text: imagePack.statekey |
||||
onTextEdited: imagePack.statekey = text |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Packname") |
||||
} |
||||
|
||||
MatrixTextField { |
||||
Layout.fillWidth: true |
||||
text: imagePack.packname |
||||
onTextEdited: imagePack.packname = text |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Attrbution") |
||||
} |
||||
|
||||
MatrixTextField { |
||||
Layout.fillWidth: true |
||||
text: imagePack.attribution |
||||
onTextEdited: imagePack.attribution = text |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Use as Emoji") |
||||
} |
||||
|
||||
ToggleButton { |
||||
checked: imagePack.isEmotePack |
||||
onClicked: imagePack.isEmotePack = checked |
||||
Layout.alignment: Qt.AlignRight |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Use as Sticker") |
||||
} |
||||
|
||||
ToggleButton { |
||||
checked: imagePack.isStickerPack |
||||
onClicked: imagePack.isStickerPack = checked |
||||
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 |
||||
url: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.Url).replace("mxc://", "image://MxcImage/") |
||||
displayName: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.ShortCode) |
||||
height: 130 |
||||
width: 130 |
||||
crop: false |
||||
Layout.alignment: Qt.AlignHCenter |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Shortcode") |
||||
} |
||||
|
||||
MatrixTextField { |
||||
Layout.fillWidth: true |
||||
text: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.ShortCode) |
||||
onTextEdited: imagePack.setData(imagePack.index(currentImageIndex, 0), text, SingleImagePackModel.ShortCode) |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Body") |
||||
} |
||||
|
||||
MatrixTextField { |
||||
Layout.fillWidth: true |
||||
text: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.Body) |
||||
onTextEdited: imagePack.setData(imagePack.index(currentImageIndex, 0), text, SingleImagePackModel.Body) |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Use as Emoji") |
||||
} |
||||
|
||||
ToggleButton { |
||||
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsEmote) |
||||
onClicked: imagePack.setData(imagePack.index(currentImageIndex, 0), checked, SingleImagePackModel.IsEmote) |
||||
Layout.alignment: Qt.AlignRight |
||||
} |
||||
|
||||
MatrixText { |
||||
text: qsTr("Use as Sticker") |
||||
} |
||||
|
||||
ToggleButton { |
||||
checked: imagePack.data(imagePack.index(currentImageIndex, 0), SingleImagePackModel.IsSticker) |
||||
onClicked: imagePack.setData(imagePack.index(currentImageIndex, 0), checked, SingleImagePackModel.IsSticker) |
||||
Layout.alignment: Qt.AlignRight |
||||
} |
||||
|
||||
Item { |
||||
Layout.columnSpan: 2 |
||||
Layout.fillHeight: true |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
|
||||
footer: DialogButtonBox { |
||||
id: buttons |
||||
|
||||
Button { |
||||
text: qsTr("Cancel") |
||||
DialogButtonBox.buttonRole: DialogButtonBox.DestructiveRole |
||||
onClicked: win.close() |
||||
} |
||||
|
||||
Button { |
||||
text: qsTr("Save") |
||||
DialogButtonBox.buttonRole: DialogButtonBox.ApplyRole |
||||
onClicked: { |
||||
imagePack.save(); |
||||
win.close(); |
||||
} |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
Loading…
Reference in new issue