From d46e517e3aad9f9daca5f54805101a5ea4826b69 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 13 Dec 2021 23:25:42 +0100 Subject: [PATCH] Only show room pack button, when you can actually create one --- resources/qml/Root.qml | 3 ++- resources/qml/dialogs/ImagePackSettingsDialog.qml | 2 ++ src/timeline/TimelineViewManager.cpp | 3 ++- src/timeline/TimelineViewManager.h | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml index f6b26041..2d4f9923 100644 --- a/resources/qml/Root.qml +++ b/resources/qml/Root.qml @@ -192,8 +192,9 @@ Page { userProfile.show(); } - function onShowImagePackSettings(packlist) { + function onShowImagePackSettings(room, packlist) { var packSet = packSettingsComponent.createObject(timelineRoot, { + "room": room, "packlist": packlist }); packSet.show(); diff --git a/resources/qml/dialogs/ImagePackSettingsDialog.qml b/resources/qml/dialogs/ImagePackSettingsDialog.qml index 2bad7ff9..6a1dfa88 100644 --- a/resources/qml/dialogs/ImagePackSettingsDialog.qml +++ b/resources/qml/dialogs/ImagePackSettingsDialog.qml @@ -12,6 +12,7 @@ import im.nheko 1.0 ApplicationWindow { id: win + property Room room property ImagePackListModel packlist property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3) property SingleImagePackModel currentPack: packlist.packAt(currentPackIndex) @@ -85,6 +86,7 @@ ApplicationWindow { dialog.show(); } width: packlistC.width + visible: room.permissions.canChange(MtxEvent.ImagePackInRoom) text: qsTr("New room pack") } diff --git a/src/timeline/TimelineViewManager.cpp b/src/timeline/TimelineViewManager.cpp index 3bc246b9..9303ee40 100644 --- a/src/timeline/TimelineViewManager.cpp +++ b/src/timeline/TimelineViewManager.cpp @@ -418,7 +418,8 @@ TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId) void TimelineViewManager::openImagePackSettings(QString roomid) { - emit showImagePackSettings(new ImagePackListModel(roomid.toStdString(), this)); + auto room = rooms_->getRoomById(roomid).get(); + emit showImagePackSettings(room, new ImagePackListModel(roomid.toStdString(), this)); } void diff --git a/src/timeline/TimelineViewManager.h b/src/timeline/TimelineViewManager.h index a4b49829..c282cc93 100644 --- a/src/timeline/TimelineViewManager.h +++ b/src/timeline/TimelineViewManager.h @@ -91,7 +91,7 @@ signals: void openRoomSettingsDialog(RoomSettings *settings); void openInviteUsersDialog(InviteesModel *invitees); void openProfile(UserProfile *profile); - void showImagePackSettings(ImagePackListModel *packlist); + void showImagePackSettings(TimelineModel *room, ImagePackListModel *packlist); void openLeaveRoomDialog(QString roomid); public slots: