Add UI to set a custom display name for specific rooms
This is the same functionality that /myroomnick does, but it's now exposed in a much more accessible place in the UI. A new page to the room settings is added to configure your profile in the room. It's currently limited to a display name.
This commit is contained in:
@@ -542,6 +542,8 @@ if(ANDROID)
|
||||
"edit-delete"
|
||||
"user-home-symbolic"
|
||||
"pin-symbolic"
|
||||
"kt-restore-defaults-symbolic"
|
||||
"user-symbolic"
|
||||
)
|
||||
ecm_add_android_apk(neochat-app ANDROID_DIR ${CMAKE_SOURCE_DIR}/android)
|
||||
else()
|
||||
|
||||
@@ -43,4 +43,5 @@ ecm_add_qml_module(settings GENERATE_PLUGIN_SOURCE
|
||||
ImportKeysDialog.qml
|
||||
ExportKeysDialog.qml
|
||||
RoomSortParameterDialog.qml
|
||||
RoomProfile.qml
|
||||
)
|
||||
|
||||
61
src/settings/RoomProfile.qml
Normal file
61
src/settings/RoomProfile.qml
Normal file
@@ -0,0 +1,61 @@
|
||||
// SPDX-FileCopyrightText: 2025 Joshua Goins <josh@redstrate.com>
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls as QQC2
|
||||
import QtQuick.Layouts
|
||||
|
||||
import org.kde.kirigami as Kirigami
|
||||
import org.kde.kirigamiaddons.formcard as FormCard
|
||||
import org.kde.kitemmodels
|
||||
|
||||
import org.kde.neochat
|
||||
|
||||
FormCard.FormCardPage {
|
||||
id: root
|
||||
|
||||
property NeoChatRoom room
|
||||
|
||||
title: i18nc('@title:window', 'Profile')
|
||||
|
||||
function setDisplayName(): void {
|
||||
root.room.connection.localUser.rename(displayNameDelegate.text, root.room);
|
||||
}
|
||||
|
||||
FormCard.FormCard {
|
||||
Layout.topMargin: Kirigami.Units.largeSpacing * 4
|
||||
|
||||
FormCard.FormTextDelegate {
|
||||
id: noticeLabel
|
||||
text: i18nc("@info", "Customize your profile only for this room.")
|
||||
}
|
||||
FormCard.FormDelegateSeparator {
|
||||
above: noticeLabel
|
||||
below: displayNameDelegate
|
||||
}
|
||||
FormCard.FormTextFieldDelegate {
|
||||
id: displayNameDelegate
|
||||
label: i18nc("@label:textbox", "Display Name")
|
||||
text: root.room.member(root.room.connection.localUserId).displayName
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormCard {
|
||||
Layout.topMargin: Kirigami.Units.largeSpacing * 2
|
||||
|
||||
FormCard.FormButtonDelegate {
|
||||
icon.name: "document-save-symbolic"
|
||||
text: i18nc("@action:button Save profile", "Save")
|
||||
onClicked: root.setDisplayName()
|
||||
}
|
||||
FormCard.FormDelegateSeparator {}
|
||||
FormCard.FormButtonDelegate {
|
||||
icon.name: "kt-restore-defaults-symbolic"
|
||||
text: i18nc("@action:button", "Reset to Default")
|
||||
onClicked: {
|
||||
displayNameDelegate.text = root.room.connection.localUser.displayName;
|
||||
root.setDisplayName();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +78,17 @@ KirigamiSettings.ConfigurationView {
|
||||
room: root._room
|
||||
};
|
||||
}
|
||||
},
|
||||
KirigamiSettings.ConfigurationModule {
|
||||
moduleId: "profile"
|
||||
text: i18nc("@title", "Profile")
|
||||
icon.name: "user-symbolic"
|
||||
page: () => Qt.createComponent("org.kde.neochat.settings", "RoomProfile")
|
||||
initialProperties: () => {
|
||||
return {
|
||||
room: root._room
|
||||
};
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user