Improve room settings dialog.

This commit is contained in:
Black
2020-01-22 20:37:27 -08:00
parent 09090f81f4
commit 6af7befd11
3 changed files with 208 additions and 174 deletions

View File

@@ -15,7 +15,9 @@ Dialog {
readonly property bool canChangeCanonicalAlias: room.canSendState("m.room.canonical_alias") readonly property bool canChangeCanonicalAlias: room.canSendState("m.room.canonical_alias")
anchors.centerIn: parent anchors.centerIn: parent
width: 480 width: 480
height: window.height * 0.9
id: root id: root
@@ -85,108 +87,6 @@ Dialog {
} }
} }
Control {
Layout.fillWidth: true
visible: room.predecessorId && room.connection.room(room.predecessorId)
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)
root.close()
}
}
}
}
Control {
Layout.fillWidth: true
visible: room.successorId && room.connection.room(room.successorId)
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)
root.close()
}
}
}
}
Button { Button {
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
@@ -210,118 +110,231 @@ Dialog {
Layout.fillWidth: true Layout.fillWidth: true
} }
ColumnLayout { ScrollView {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true
RowLayout { id: scrollview
Layout.fillWidth: true
Label { clip: true
Layout.preferredWidth: 100
wrapMode: Label.Wrap ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
text: "Main Alias"
color: MPalette.lighter
}
ComboBox { ColumnLayout {
width: scrollview.width
Control {
Layout.fillWidth: true Layout.fillWidth: true
id: canonicalAliasComboBox visible: room.predecessorId && room.connection.room(room.predecessorId)
enabled: canChangeCanonicalAlias padding: 8
model: room.remoteAliases contentItem: RowLayout {
MaterialIcon {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
currentIndex: room.remoteAliases.indexOf(room.canonicalAlias) icon: "\ue8d4"
onCurrentIndexChanged: { }
if (room.canonicalAlias != room.remoteAliases[currentIndex]) {
room.setCanonicalAlias(room.remoteAliases[currentIndex]) ColumnLayout {
Layout.fillWidth: true
spacing: 0
Label {
Layout.fillWidth: true
font.bold: true
color: MPalette.foreground
text: "This room continues 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)
root.close()
}
} }
} }
} }
}
RowLayout { Control {
Layout.fillWidth: true
Label {
Layout.preferredWidth: 100
Layout.alignment: Qt.AlignTop
wrapMode: Label.Wrap
text: "Local Aliases"
color: MPalette.lighter
}
ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 0 visible: room.successorId && room.connection.room(room.successorId)
Repeater { padding: 8
model: room.localAliases
delegate: RowLayout { contentItem: RowLayout {
Layout.maximumWidth: parent.width MaterialIcon {
Layout.preferredWidth: 48
Layout.preferredHeight: 48
icon: "\ue8d4"
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Label { Label {
text: modelData Layout.fillWidth: true
font.pixelSize: 12 font.bold: true
color: MPalette.lighter color: MPalette.foreground
text: "This room has been replaced."
} }
MaterialIcon { Label {
icon: "\ue5cd" Layout.fillWidth: true
color: MPalette.lighter color: MPalette.lighter
font.pixelSize: 12 text: "The conversation continues here."
}
}
}
RippleEffect { background: Rectangle {
anchors.fill: parent color: MPalette.banner
circular: true RippleEffect {
anchors.fill: parent
onClicked: room.removeLocalAlias(modelData) onClicked: {
roomListForm.enteredRoom = spectralController.connection.room(room.successorId)
root.close()
}
}
}
}
RowLayout {
Layout.fillWidth: true
Label {
Layout.preferredWidth: 100
wrapMode: Label.Wrap
text: "Main Alias"
color: MPalette.lighter
}
ComboBox {
Layout.fillWidth: true
id: canonicalAliasComboBox
enabled: canChangeCanonicalAlias
model: room.remoteAliases
currentIndex: room.remoteAliases.indexOf(room.canonicalAlias)
onCurrentIndexChanged: {
if (room.canonicalAlias != room.remoteAliases[currentIndex]) {
room.setCanonicalAlias(room.remoteAliases[currentIndex])
}
}
}
}
RowLayout {
Layout.fillWidth: true
Label {
Layout.preferredWidth: 100
Layout.alignment: Qt.AlignTop
wrapMode: Label.Wrap
text: "Local Aliases"
color: MPalette.lighter
}
ColumnLayout {
Layout.fillWidth: true
spacing: 0
Repeater {
model: room.localAliases
delegate: RowLayout {
Layout.maximumWidth: parent.width
Label {
text: modelData
font.pixelSize: 12
color: MPalette.lighter
}
MaterialIcon {
icon: "\ue5cd"
color: MPalette.lighter
font.pixelSize: 12
RippleEffect {
anchors.fill: parent
circular: true
onClicked: room.removeLocalAlias(modelData)
}
} }
} }
} }
} }
} }
}
RowLayout { RowLayout {
Layout.fillWidth: true
Label {
Layout.preferredWidth: 100
Layout.alignment: Qt.AlignTop
wrapMode: Label.Wrap
text: "Remote Aliases"
color: MPalette.lighter
}
ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
spacing: 0 Label {
Layout.preferredWidth: 100
Layout.alignment: Qt.AlignTop
Repeater { wrapMode: Label.Wrap
model: { text: "Remote Aliases"
var localAliases = room.localAliases color: MPalette.lighter
var remoteAliases = room.remoteAliases }
return remoteAliases.filter(n => !localAliases.includes(n))
}
delegate: Label { ColumnLayout {
width: parent.width Layout.fillWidth: true
text: modelData spacing: 0
font.pixelSize: 12 Repeater {
color: MPalette.lighter model: {
var localAliases = room.localAliases
var remoteAliases = room.remoteAliases
return remoteAliases.filter(n => !localAliases.includes(n))
}
delegate: Label {
width: parent.width
text: modelData
font.pixelSize: 12
color: MPalette.lighter
}
} }
} }
} }

View File

@@ -106,6 +106,21 @@ void RoomListModel::connectRoomSignals(SpectralRoom* room) {
sender->displayname(), room->eventToString(*lastEvent), sender->displayname(), room->eventToString(*lastEvent),
room->avatar(128)); room->avatar(128));
}); });
connect(room, &Room::highlightCountChanged, this, [=] {
if (room->highlightCount() == 0)
return;
if (room->timelineSize() == 0)
return;
const RoomEvent* lastEvent = room->messageEvents().rbegin()->get();
if (lastEvent->isStateEvent())
return;
User* sender = room->user(lastEvent->senderId());
if (sender == room->localUser())
return;
emit newHighlight(room->id(), lastEvent->id(), room->displayName(),
sender->displayname(), room->eventToString(*lastEvent),
room->avatar(128));
});
connect(room, &Room::notificationCountChanged, this, connect(room, &Room::notificationCountChanged, this,
&RoomListModel::refreshNotificationCount); &RoomListModel::refreshNotificationCount);
} }

View File

@@ -89,6 +89,12 @@ class RoomListModel : public QAbstractListModel {
const QString& senderName, const QString& senderName,
const QString& text, const QString& text,
const QImage& icon); const QImage& icon);
void newHighlight(const QString& roomId,
const QString& eventId,
const QString& roomName,
const QString& senderName,
const QString& text,
const QImage& icon);
}; };
#endif // ROOMLISTMODEL_H #endif // ROOMLISTMODEL_H