status-desktop/ui/imports/shared/status/StatusChatInputImageArea.qml

89 lines
2.6 KiB
QML
Raw Normal View History

import QtQuick 2.13
import QtGraphicalEffects 1.13
import QtQuick.Controls 2.13
import utils 1.0
import shared 1.0
import shared.controls.chat 1.0
import shared.panels 1.0
Row {
id: imageArea
spacing: Style.current.halfPadding
signal imageRemoved(int index)
signal imageClicked(var chatImage)
property bool leftTail: true
property alias imageSource: rptImages.model
Repeater {
id: rptImages
feat: Add settings card to control link previews settings in chat input This commit adds the link preview settings card in the chat input area and connects the settings to the controller. Not included in this commit: Backend for the preserving the settings, syncing the settings and enforcing the settings on the backend side. Whenever an url is detected in the chat input area, the link preview settings card is presented. This card enables the user to choose one of the following options: 1. `Show for this message` - All the link previews in the current message will be loaded without asking again. The current message can be defined as the message currently typed/pasted in the chat input. Deleting or sending the current content is resetting this setting and the link preview settings card will be presented again when a new url is detected. 2. `Always show previews` - All the link previews will be loaded automatically. The link preview settings card will not be presented again (in the current state, this settings is enabled for the lifetime of the controller. This will change once the settings are preserved and synced) 3. `Never show previews` - No link preview will be loaded. Same as the `Always show previews` option, this will be preserved for the lifetime of the controller for now. 4. Dismiss (x button) - The link preview settings card will be dismissed. It will be loaded again when a new link preview is detected The same options can be loaded as a context menu on the link preview card. Changes: 1. Adding `LinkPreviewSettingsCard` 2. Adding the settings context menu to `LinkPreviewSettingsCard` and `LinkPreviewMiniCard` 3. Connect settings events to the nim controller 4. Adding the controller logic for settings change 5. Adding the link preview dismiss settings flag to the preserverd properties and use it as a condition to load the settings. 6. Adding/Updating corresponding storybook pages
2023-10-09 08:45:16 +00:00
Item {
height: chatImage.height
width: chatImage.width
Image {
id: chatImage
anchors.left: parent.left
anchors.bottom: parent.bottom
width: 64
height: 64
fillMode: Image.PreserveAspectCrop
mipmap: true
smooth: false
antialiasing: true
cache: false
source: modelData
layer.enabled: true
layer.effect: CalloutOpacityMask {
width: parent.width
height: parent.height
leftTail: imageArea.leftTail
}
}
MouseArea {
id: mouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: imageClicked(chatImage)
}
RoundButton {
id: closeBtn
width: 24
height: 24
padding: 0
anchors.right: chatImage.right
anchors.rightMargin: -width / 3
anchors.top: chatImage.top
anchors.topMargin: -height / 3
hoverEnabled: false
opacity: mouseArea.containsMouse || buttonMouseArea.containsMouse ? 1 : 0
contentItem: SVGImage {
source: Style.svg( !buttonMouseArea.containsMouse ? "close-filled" : "close-filled-hovered")
width: closeBtn.width
height: closeBtn.height
}
background: Rectangle {
color: "transparent"
}
onClicked: {
imageArea.imageRemoved(index)
}
MouseArea {
id: buttonMouseArea
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled: true
onClicked: closeBtn.clicked()
}
}
}
}
}