mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Merge pull request #1374 from Nheko-Reborn/private_images
Blur images properly
This commit is contained in:
commit
4372742bc1
5 changed files with 105 additions and 40 deletions
|
@ -126,6 +126,7 @@ Rectangle {
|
||||||
TimelineView {
|
TimelineView {
|
||||||
id: timeline
|
id: timeline
|
||||||
|
|
||||||
|
privacyScreen: privacyScreen
|
||||||
showBackButton: adaptiveView.singlePageMode
|
showBackButton: adaptiveView.singlePageMode
|
||||||
room: Rooms.currentRoom
|
room: Rooms.currentRoom
|
||||||
roomPreview: Rooms.currentRoomPreview.roomid ? Rooms.currentRoomPreview : null
|
roomPreview: Rooms.currentRoomPreview.roomid ? Rooms.currentRoomPreview : null
|
||||||
|
@ -138,6 +139,8 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivacyScreen {
|
PrivacyScreen {
|
||||||
|
id: privacyScreen
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: Settings.privacyScreen
|
visible: Settings.privacyScreen
|
||||||
screenTimeout: Settings.privacyScreenTimeout
|
screenTimeout: Settings.privacyScreenTimeout
|
||||||
|
|
|
@ -10,6 +10,7 @@ import im.nheko 1.0
|
||||||
Item {
|
Item {
|
||||||
id: privacyScreen
|
id: privacyScreen
|
||||||
|
|
||||||
|
readonly property bool active: Settings.privacyScreen && screenSaver.state === "Visible"
|
||||||
property var timelineRoot
|
property var timelineRoot
|
||||||
property int screenTimeout
|
property int screenTimeout
|
||||||
|
|
||||||
|
@ -59,7 +60,6 @@ Item {
|
||||||
target: screenSaver
|
target: screenSaver
|
||||||
opacity: 1
|
opacity: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
State {
|
State {
|
||||||
name: "Invisible"
|
name: "Invisible"
|
||||||
|
@ -73,34 +73,13 @@ Item {
|
||||||
target: screenSaver
|
target: screenSaver
|
||||||
visible: false
|
visible: false
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
transitions: [
|
transitions: [
|
||||||
Transition {
|
|
||||||
from: "Visible"
|
|
||||||
to: "Invisible"
|
|
||||||
|
|
||||||
SequentialAnimation {
|
|
||||||
NumberAnimation {
|
|
||||||
target: screenSaver
|
|
||||||
property: "opacity"
|
|
||||||
duration: 250
|
|
||||||
easing.type: Easing.InQuad
|
|
||||||
}
|
|
||||||
|
|
||||||
NumberAnimation {
|
|
||||||
target: screenSaver
|
|
||||||
property: "visible"
|
|
||||||
duration: 0
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
Transition {
|
Transition {
|
||||||
from: "Invisible"
|
from: "Invisible"
|
||||||
to: "Visible"
|
to: "Visible"
|
||||||
|
reversible: true
|
||||||
|
|
||||||
SequentialAnimation {
|
SequentialAnimation {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
@ -112,8 +91,8 @@ Item {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
target: screenSaver
|
target: screenSaver
|
||||||
property: "opacity"
|
property: "opacity"
|
||||||
duration: 500
|
duration: 300
|
||||||
easing.type: Easing.InQuad
|
easing.type: Easing.Linear
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,17 +108,21 @@ Page {
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineView {
|
TimelineView {
|
||||||
id: timelineView
|
id: timeline
|
||||||
|
|
||||||
|
privacyScreen: privacyScreen
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
room: roomWindowW.room
|
room: roomWindowW.room
|
||||||
roomPreview: roomWindowW.roomPreview.roomid ? roomWindowW.roomPreview : null
|
roomPreview: roomWindowW.roomPreview.roomid ? roomWindowW.roomPreview : null
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivacyScreen {
|
PrivacyScreen {
|
||||||
|
id: privacyScreen
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
visible: Settings.privacyScreen
|
visible: Settings.privacyScreen
|
||||||
screenTimeout: Settings.privacyScreenTimeout
|
screenTimeout: Settings.privacyScreenTimeout
|
||||||
timelineRoot: timelineView
|
timelineRoot: timeline
|
||||||
windowTarget: roomWindowW
|
windowTarget: roomWindowW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ Item {
|
||||||
property var roomPreview: null
|
property var roomPreview: null
|
||||||
property bool showBackButton: false
|
property bool showBackButton: false
|
||||||
property bool shouldEffectsRun: false
|
property bool shouldEffectsRun: false
|
||||||
|
required property PrivacyScreen privacyScreen
|
||||||
clip: true
|
clip: true
|
||||||
|
|
||||||
onRoomChanged: if (room != null) room.triggerSpecialEffects()
|
onRoomChanged: if (room != null) room.triggerSpecialEffects()
|
||||||
|
|
|
@ -26,21 +26,88 @@ AbstractButton {
|
||||||
height: width*proportionalHeight
|
height: width*proportionalHeight
|
||||||
hoverEnabled: true
|
hoverEnabled: true
|
||||||
|
|
||||||
|
state: (img.status != Image.Ready || timeline.privacyScreen.active) ? "BlurhashVisible" : "ImageVisible"
|
||||||
|
states: [
|
||||||
|
State {
|
||||||
|
name: "BlurhashVisible"
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
target: blurhash_
|
||||||
|
opacity: (img.status != Image.Ready) || (timeline.privacyScreen.active && blurhash) ? 1 : 0
|
||||||
|
visible: (img.status != Image.Ready) || (timeline.privacyScreen.active && blurhash)
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
target: img
|
||||||
|
opacity: 0
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
target: mxcimage
|
||||||
|
opacity: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
State {
|
||||||
|
name: "ImageVisible"
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
target: blurhash_
|
||||||
|
opacity: 0
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
target: img
|
||||||
|
opacity: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyChanges {
|
||||||
|
target: mxcimage
|
||||||
|
opacity: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
transitions: [
|
||||||
|
Transition {
|
||||||
|
from: "ImageVisible"
|
||||||
|
to: "BlurhashVisible"
|
||||||
|
reversible: true
|
||||||
|
|
||||||
|
SequentialAnimation {
|
||||||
|
PropertyAction {
|
||||||
|
target: blurhash_
|
||||||
|
property: "visible"
|
||||||
|
}
|
||||||
|
|
||||||
|
ParallelAnimation {
|
||||||
|
NumberAnimation {
|
||||||
|
target: blurhash_
|
||||||
|
property: "opacity"
|
||||||
|
duration: 300
|
||||||
|
easing.type: Easing.Linear
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberAnimation {
|
||||||
|
target: img
|
||||||
|
property: "opacity"
|
||||||
|
duration: 300
|
||||||
|
easing.type: Easing.Linear
|
||||||
|
}
|
||||||
|
|
||||||
|
NumberAnimation {
|
||||||
|
target: mxcimage
|
||||||
|
property: "opacity"
|
||||||
|
duration: 300
|
||||||
|
easing.type: Easing.Linear
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
property int metadataWidth
|
property int metadataWidth
|
||||||
property bool fitsMetadata: (parent.width - width) > metadataWidth+4
|
property bool fitsMetadata: (parent.width - width) > metadataWidth+4
|
||||||
|
|
||||||
Image {
|
|
||||||
id: blurhash_
|
|
||||||
|
|
||||||
anchors.fill: parent
|
|
||||||
visible: img.status != Image.Ready
|
|
||||||
source: blurhash ? ("image://blurhash/" + blurhash) : ("image://colorimage/:/icons/icons/ui/image-failed.svg?" + Nheko.colors.buttonText)
|
|
||||||
asynchronous: true
|
|
||||||
fillMode: Image.PreserveAspectFit
|
|
||||||
sourceSize.width: parent.width * Screen.devicePixelRatio
|
|
||||||
sourceSize.height: parent.height * Screen.devicePixelRatio
|
|
||||||
}
|
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
id: img
|
id: img
|
||||||
|
|
||||||
|
@ -66,7 +133,18 @@ AbstractButton {
|
||||||
eventId: parent.eventId
|
eventId: parent.eventId
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked :Settings.openImageExternal ? room.openMedia(eventId) : TimelineManager.openImageOverlay(room, url, eventId, originalWidth, proportionalHeight);
|
Image {
|
||||||
|
id: blurhash_
|
||||||
|
|
||||||
|
anchors.fill: parent
|
||||||
|
source: blurhash ? ("image://blurhash/" + blurhash) : ("image://colorimage/:/icons/icons/ui/image-failed.svg?" + Nheko.colors.buttonText)
|
||||||
|
asynchronous: true
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
sourceSize.width: parent.width * Screen.devicePixelRatio
|
||||||
|
sourceSize.height: parent.height * Screen.devicePixelRatio
|
||||||
|
}
|
||||||
|
|
||||||
|
onClicked: Settings.openImageExternal ? room.openMedia(eventId) : TimelineManager.openImageOverlay(room, url, eventId, originalWidth, proportionalHeight);
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: overlay
|
id: overlay
|
||||||
|
|
Loading…
Reference in a new issue