Only show room pack button, when you can actually create one

This commit is contained in:
Nicolas Werner 2021-12-13 23:25:42 +01:00
parent a0699f5247
commit d46e517e3a
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
4 changed files with 7 additions and 3 deletions

View File

@ -192,8 +192,9 @@ Page {
userProfile.show(); userProfile.show();
} }
function onShowImagePackSettings(packlist) { function onShowImagePackSettings(room, packlist) {
var packSet = packSettingsComponent.createObject(timelineRoot, { var packSet = packSettingsComponent.createObject(timelineRoot, {
"room": room,
"packlist": packlist "packlist": packlist
}); });
packSet.show(); packSet.show();

View File

@ -12,6 +12,7 @@ import im.nheko 1.0
ApplicationWindow { ApplicationWindow {
id: win id: win
property Room room
property ImagePackListModel packlist property ImagePackListModel packlist
property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3) property int avatarSize: Math.ceil(fontMetrics.lineSpacing * 2.3)
property SingleImagePackModel currentPack: packlist.packAt(currentPackIndex) property SingleImagePackModel currentPack: packlist.packAt(currentPackIndex)
@ -85,6 +86,7 @@ ApplicationWindow {
dialog.show(); dialog.show();
} }
width: packlistC.width width: packlistC.width
visible: room.permissions.canChange(MtxEvent.ImagePackInRoom)
text: qsTr("New room pack") text: qsTr("New room pack")
} }

View File

@ -418,7 +418,8 @@ TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId)
void void
TimelineViewManager::openImagePackSettings(QString roomid) 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 void

View File

@ -91,7 +91,7 @@ signals:
void openRoomSettingsDialog(RoomSettings *settings); void openRoomSettingsDialog(RoomSettings *settings);
void openInviteUsersDialog(InviteesModel *invitees); void openInviteUsersDialog(InviteesModel *invitees);
void openProfile(UserProfile *profile); void openProfile(UserProfile *profile);
void showImagePackSettings(ImagePackListModel *packlist); void showImagePackSettings(TimelineModel *room, ImagePackListModel *packlist);
void openLeaveRoomDialog(QString roomid); void openLeaveRoomDialog(QString roomid);
public slots: public slots: