Add basic room upgrade support.

Add full screen image view.
Fix a bug in image provider.
This commit is contained in:
Black Hat 2019-04-23 10:57:35 +08:00
parent 11ede88abc
commit 2565b8ba79
9 changed files with 177 additions and 6 deletions

View File

@ -36,8 +36,8 @@ Item {
visible: !realSource || image.status != Image.Ready
radius: height / 2
color: stringToColor(hint)
antialiasing: true
Label {
anchors.centerIn: parent

View File

@ -0,0 +1,41 @@
import QtQuick 2.12
import QtQuick.Controls 2.12
ApplicationWindow {
property url imageUrl
property int sourceWidth
property int sourceHeight
id: root
flags: Qt.FramelessWindowHint | Qt.WA_TranslucentBackground
visible: true
visibility: Qt.WindowFullScreen
title: "Image View - " + imageUrl
color: "#BB000000"
Image {
anchors.centerIn: parent
sourceSize.width: root.sourceWidth
sourceSize.height: root.sourceHeight
source: imageUrl
}
ItemDelegate {
anchors.top: parent.top
anchors.right: parent.right
width: 64
height: 64
contentItem: MaterialIcon {
icon: "\ue5cd"
color: "white"
}
onClicked: root.close()
}
}

View File

@ -85,8 +85,11 @@ ColumnLayout {
source: "image://mxc/" +
(content.info && content.info.thumbnail_info ?
content.thumbnailMediaId : content.mediaId)
sourceSize.width: messageListView.width * 0.6
sourceSize.height: messageListView.height
sourceSize.width: 720
sourceSize.height: 720
fillMode: Image.PreserveAspectCrop
layer.enabled: true
layer.effect: OpacityMask {
@ -97,6 +100,16 @@ ColumnLayout {
}
}
Component {
id: fullScreenImage
FullScreenImage {
imageUrl: "image://mxc/" + content.mediaId
sourceWidth: content.info.w
sourceHeight: content.info.h
}
}
Rectangle {
anchors.fill: parent
@ -113,6 +126,11 @@ ColumnLayout {
id: messageMouseArea
onPrimaryClicked: {
var window = fullScreenImage.createObject()
window.show()
}
onSecondaryClicked: messageContextMenu.popup()
Menu {
@ -126,16 +144,19 @@ ColumnLayout {
sourceDialog.open()
}
}
MenuItem {
text: "Open Externally"
onTriggered: downloadAndOpen()
}
MenuItem {
text: "Save As"
onTriggered: saveFileAs()
}
MenuItem {
text: "Reply"
@ -147,6 +168,7 @@ ColumnLayout {
roomPanelInput.focus()
}
}
MenuItem {
text: "Redact"

View File

@ -7,3 +7,4 @@ AutoListView 2.0 AutoListView.qml
AutoTextField 2.0 AutoTextField.qml
SplitView 2.0 SplitView.qml
Avatar 2.0 Avatar.qml
FullScreenImage 2.0 FullScreenImage.qml

View File

@ -271,6 +271,102 @@ Drawer {
}
}
Control {
Layout.fillWidth: true
visible: room ? room.predecessorId : false
padding: 8
contentItem: RowLayout {
MaterialIcon {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
icon: "\ue8d4"
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Label {
Layout.fillWidth: true
font.bold: true
color: MPalette.foreground
text: "This room is a continuation of another conversation."
}
Label {
Layout.fillWidth: true
color: MPalette.lighter
text: "Click here to see older messages."
}
}
}
background: Rectangle {
color: MPalette.banner
RippleEffect {
anchors.fill: parent
onClicked: roomListForm.enteredRoom = spectralController.connection.room(room.predecessorId)
}
}
}
Control {
Layout.fillWidth: true
visible: room ? room.successorId : false
padding: 8
contentItem: RowLayout {
MaterialIcon {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
icon: "\ue8d4"
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Label {
Layout.fillWidth: true
font.bold: true
color: MPalette.foreground
text: "This room has been replaced and is no longer active."
}
Label {
Layout.fillWidth: true
color: MPalette.lighter
text: "The conversation continues here."
}
}
}
background: Rectangle {
color: MPalette.banner
RippleEffect {
anchors.fill: parent
onClicked: roomListForm.enteredRoom = spectralController.connection.room(room.successorId)
}
}
}
MenuSeparator {
Layout.fillWidth: true
}

View File

@ -60,6 +60,9 @@ Item {
]
filters: [
ExpressionFilter {
expression: joinState != "upgraded"
},
RegExpFilter {
roleName: "name"
pattern: searchField.text
@ -272,7 +275,7 @@ Item {
}
Rectangle {
width: unreadCount > 0 ? 4 : 0
width: unreadCount >= 0 ? 4 : 0
height: parent.height
color: Material.accent

View File

@ -43,5 +43,6 @@
<file>imports/Spectral/Component/Avatar.qml</file>
<file>imports/Spectral/Setting/Palette.qml</file>
<file>imports/Spectral/Component/Timeline/FileDelegate.qml</file>
<file>imports/Spectral/Component/FullScreenImage.qml</file>
</qresource>
</RCC>

View File

@ -195,6 +195,11 @@ QVariant RoomListModel::data(const QModelIndex& index, int role) const {
return room->lastEvent();
if (role == LastActiveTimeRole)
return room->lastActiveTime();
if (role == JoinStateRole) {
if (!room->successorId().isEmpty())
return QStringLiteral("upgraded");
return toCString(room->joinState());
}
if (role == CurrentRoomRole)
return QVariant::fromValue(room);
return QVariant();
@ -231,6 +236,7 @@ QHash<int, QByteArray> RoomListModel::roleNames() const {
roles[HighlightCountRole] = "highlightCount";
roles[LastEventRole] = "lastEvent";
roles[LastActiveTimeRole] = "lastActiveTime";
roles[JoinStateRole] = "joinState";
roles[CurrentRoomRole] = "currentRoom";
return roles;
}

View File

@ -39,6 +39,7 @@ class RoomListModel : public QAbstractListModel {
HighlightCountRole,
LastEventRole,
LastActiveTimeRole,
JoinStateRole,
CurrentRoomRole,
};