Add room upgrade button
Add button to upgrade the room if the user has a high enough power level and the room is not at the highest available version.
This commit is contained in:
@@ -94,6 +94,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
|||||||
connect(this, &Room::changed, this, [this] {
|
connect(this, &Room::changed, this, [this] {
|
||||||
Q_EMIT canEncryptRoomChanged();
|
Q_EMIT canEncryptRoomChanged();
|
||||||
});
|
});
|
||||||
|
connect(connection, &Connection::capabilitiesLoaded, this, &NeoChatRoom::maxRoomVersionChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
|
void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
|
||||||
@@ -1370,3 +1371,14 @@ void NeoChatRoom::setCanonicalAlias(const QString &newAlias)
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NeoChatRoom::maxRoomVersion() const
|
||||||
|
{
|
||||||
|
int maxVersion = 0;
|
||||||
|
for (auto roomVersion : connection()->availableRoomVersions()) {
|
||||||
|
if (roomVersion.id.toInt() > maxVersion) {
|
||||||
|
maxVersion = roomVersion.id.toInt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return maxVersion;
|
||||||
|
}
|
||||||
|
|||||||
@@ -65,6 +65,13 @@ class NeoChatRoom : public Quotient::Room
|
|||||||
Q_PROPERTY(QString chatBoxAttachmentPath READ chatBoxAttachmentPath WRITE setChatBoxAttachmentPath NOTIFY chatBoxAttachmentPathChanged)
|
Q_PROPERTY(QString chatBoxAttachmentPath READ chatBoxAttachmentPath WRITE setChatBoxAttachmentPath NOTIFY chatBoxAttachmentPathChanged)
|
||||||
Q_PROPERTY(bool canEncryptRoom READ canEncryptRoom NOTIFY canEncryptRoomChanged)
|
Q_PROPERTY(bool canEncryptRoom READ canEncryptRoom NOTIFY canEncryptRoomChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the maximum room version that the server supports.
|
||||||
|
*
|
||||||
|
* Only returns main integer room versions (i.e. no msc room versions).
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(int maxRoomVersion READ maxRoomVersion NOTIFY maxRoomVersionChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum MessageType {
|
enum MessageType {
|
||||||
Positive,
|
Positive,
|
||||||
@@ -223,6 +230,8 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int maxRoomVersion() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSet<const Quotient::RoomEvent *> highlights;
|
QSet<const Quotient::RoomEvent *> highlights;
|
||||||
|
|
||||||
@@ -274,6 +283,7 @@ Q_SIGNALS:
|
|||||||
void canEncryptRoomChanged();
|
void canEncryptRoomChanged();
|
||||||
void joinRuleChanged();
|
void joinRuleChanged();
|
||||||
void historyVisibilityChanged();
|
void historyVisibilityChanged();
|
||||||
|
void maxRoomVersionChanged();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void uploadFile(const QUrl &url, const QString &body = QString());
|
void uploadFile(const QUrl &url, const QString &body = QString());
|
||||||
|
|||||||
@@ -126,6 +126,25 @@ Kirigami.ScrollablePage {
|
|||||||
MobileForm.FormTextDelegate {
|
MobileForm.FormTextDelegate {
|
||||||
text: i18n("Room version")
|
text: i18n("Room version")
|
||||||
description: room.version
|
description: room.version
|
||||||
|
|
||||||
|
contentItem.children: QQC2.Button {
|
||||||
|
visible: room.canSwitchVersions()
|
||||||
|
enabled: room.version < room.maxRoomVersion
|
||||||
|
text: i18n("Upgrade Room")
|
||||||
|
icon.name: "arrow-up-double"
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
if (room.canSwitchVersions()) {
|
||||||
|
roomUpgradeSheet.currentRoomVersion = room.version
|
||||||
|
roomUpgradeSheet.open()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QQC2.ToolTip {
|
||||||
|
text: text
|
||||||
|
delay: Kirigami.Units.toolTipDelay
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -264,6 +283,30 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
OpenFileDialog {}
|
OpenFileDialog {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Kirigami.OverlaySheet {
|
||||||
|
id: roomUpgradeSheet
|
||||||
|
|
||||||
|
property var currentRoomVersion
|
||||||
|
|
||||||
|
title: i18n("Upgrade the Room")
|
||||||
|
Kirigami.FormLayout {
|
||||||
|
QQC2.SpinBox {
|
||||||
|
id: spinBox
|
||||||
|
Kirigami.FormData.label: i18n("Select new version")
|
||||||
|
from: room.version
|
||||||
|
to: room.maxRoomVersion
|
||||||
|
value: room.version
|
||||||
|
}
|
||||||
|
QQC2.Button {
|
||||||
|
text: i18n("Confirm")
|
||||||
|
onClicked: {
|
||||||
|
room.switchVersion(spinBox.value)
|
||||||
|
roomUpgradeSheet.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user