Load components on demand

This commit is contained in:
Nicolas Werner 2022-10-01 02:28:02 +02:00
parent 570d7b8b30
commit 2a7c6f2d86
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
2 changed files with 27 additions and 168 deletions

View File

@ -91,7 +91,7 @@ Rectangle {
anchors.margins: 8 anchors.margins: 8
anchors.top: parent.top anchors.top: parent.top
hoverEnabled: true hoverEnabled: true
buttonTextColor: room ? TimelineManager.userColor(room.thread, Nheko.colors.base) : undefined buttonTextColor: room ? TimelineManager.userColor(room.thread, Nheko.colors.base) : Nheko.colors.buttonText
image: ":/icons/icons/ui/dismiss_thread.svg" image: ":/icons/icons/ui/dismiss_thread.svg"
width: 22 width: 22
height: 22 height: 22

View File

@ -47,46 +47,24 @@ Pane {
model: TimelineManager.completerFor("allemoji", "") model: TimelineManager.completerFor("allemoji", "")
} }
Component {
id: userProfileComponent
UserProfile {
}
}
function showAliasEditor(settings) { function showAliasEditor(settings) {
var dialog = aliasEditor.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/AliasEditor.qml").createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
dialog.show(); dialog.show();
destroyOnClose(dialog); destroyOnClose(dialog);
} }
Component {
id: aliasEditor
AliasEditor {
}
}
function showPLEditor(settings) { function showPLEditor(settings) {
var dialog = plEditor.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/PowerLevelEditor.qml").createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
dialog.show(); dialog.show();
destroyOnClose(dialog); destroyOnClose(dialog);
} }
Component {
id: plApplyPrompt
PowerLevelSpacesApplyDialog {
}
}
function showSpacePLApplyPrompt(settings, editingModel) { function showSpacePLApplyPrompt(settings, editingModel) {
var dialog = plApplyPrompt.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/PowerLevelSpacesApplyDialog.qml").createObject(timelineRoot, {
"roomSettings": settings, "roomSettings": settings,
"editingModel": editingModel "editingModel": editingModel
}); });
@ -94,86 +72,14 @@ Pane {
destroyOnClose(dialog); destroyOnClose(dialog);
} }
Component {
id: plEditor
PowerLevelEditor {
}
}
Component {
id: roomSettingsComponent
RoomSettings {
}
}
Component {
id: allowedRoomSettingsComponent
AllowedRoomsSettingsDialog {
}
}
function showAllowedRoomsEditor(settings) { function showAllowedRoomsEditor(settings) {
var dialog = allowedRoomSettingsComponent.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/AllowedRoomsSettingsDialog.qml").createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
dialog.show(); dialog.show();
destroyOnClose(dialog); destroyOnClose(dialog);
} }
Component {
id: roomMembersComponent
RoomMembers {
}
}
Component {
id: mobileCallInviteDialog
CallInvite {
}
}
Component {
id: quickSwitcherComponent
QuickSwitcher {
}
}
Component {
id: deviceVerificationDialog
DeviceVerification {
}
}
Component {
id: inviteDialog
InviteDialog {
}
}
Component {
id: packSettingsComponent
ImagePackSettingsDialog {
}
}
Component { Component {
id: readReceiptsDialog id: readReceiptsDialog
@ -182,62 +88,6 @@ Pane {
} }
Component {
id: rawMessageDialog
RawMessageDialog {
}
}
Component {
id: logoutDialog
LogoutDialog {
}
}
Component {
id: joinRoomDialog
JoinRoomDialog {
}
}
Component {
id: confirmJoinRoomDialog
ConfirmJoinRoomDialog {
}
}
Component {
id: leaveRoomComponent
LeaveRoomDialog {
}
}
Component {
id: imageOverlay
ImageOverlay {
}
}
Component {
id: userSettingsPage
UserSettingsPage {
}
}
Shortcut { Shortcut {
sequence: StandardKey.Quit sequence: StandardKey.Quit
onActivated: Qt.quit() onActivated: Qt.quit()
@ -246,7 +96,7 @@ Pane {
Shortcut { Shortcut {
sequence: "Ctrl+K" sequence: "Ctrl+K"
onActivated: { onActivated: {
var quickSwitch = quickSwitcherComponent.createObject(timelineRoot); var quickSwitch = Qt.createComponent("qrc:/qml/dialogs/QuickSwitcher.qml").createObject(timelineRoot);
quickSwitch.open(); quickSwitch.open();
destroyOnClosed(quickSwitch); destroyOnClosed(quickSwitch);
} }
@ -270,19 +120,19 @@ Pane {
Connections { Connections {
function onOpenLogoutDialog() { function onOpenLogoutDialog() {
var dialog = logoutDialog.createObject(timelineRoot); var dialog = Qt.createComponent("qrc:/qml/dialogs/LogoutDialog.qml").createObject(timelineRoot);
dialog.open(); dialog.open();
destroyOnClose(dialog); destroyOnClose(dialog);
} }
function onOpenJoinRoomDialog() { function onOpenJoinRoomDialog() {
var dialog = joinRoomDialog.createObject(timelineRoot); var dialog = Qt.createComponent("qrc:/qml/dialogs/JoinRoomDialog.qml").createObject(timelineRoot);
dialog.show(); dialog.show();
destroyOnClose(dialog); destroyOnClose(dialog);
} }
function onShowRoomJoinPrompt(summary) { function onShowRoomJoinPrompt(summary) {
var dialog = confirmJoinRoomDialog.createObject(timelineRoot, {"summary": summary}); var dialog = Qt.createComponent("qrc:/qml/dialogs/ConfirmJoinRoomDialog.qml").createObject(timelineRoot, {"summary": summary});
dialog.show(); dialog.show();
destroyOnClose(dialog); destroyOnClose(dialog);
} }
@ -292,7 +142,7 @@ Pane {
Connections { Connections {
function onNewDeviceVerificationRequest(flow) { function onNewDeviceVerificationRequest(flow) {
var dialog = deviceVerificationDialog.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/DeviceVerification.qml").createObject(timelineRoot, {
"flow": flow "flow": flow
}); });
dialog.show(); dialog.show();
@ -313,7 +163,7 @@ Pane {
Connections { Connections {
function onOpenProfile(profile) { function onOpenProfile(profile) {
var userProfile = userProfileComponent.createObject(timelineRoot, { var userProfile = Qt.createComponent("qrc:/qml/dialogs/UserProfile.qml").createObject(timelineRoot, {
"profile": profile "profile": profile
}); });
userProfile.show(); userProfile.show();
@ -321,7 +171,7 @@ Pane {
} }
function onShowImagePackSettings(room, packlist) { function onShowImagePackSettings(room, packlist) {
var packSet = packSettingsComponent.createObject(timelineRoot, { var packSet = Qt.createComponent("qrc:/qml/dialogs/ImagePackSettingsDialog.qml").createObject(timelineRoot, {
"room": room, "room": room,
"packlist": packlist "packlist": packlist
}); });
@ -330,7 +180,7 @@ Pane {
} }
function onOpenRoomMembersDialog(members, room) { function onOpenRoomMembersDialog(members, room) {
var membersDialog = roomMembersComponent.createObject(timelineRoot, { var membersDialog = Qt.createComponent("qrc:/qml/dialogs/RoomMembers.qml").createObject(timelineRoot, {
"members": members, "members": members,
"room": room "room": room
}); });
@ -339,7 +189,7 @@ Pane {
} }
function onOpenRoomSettingsDialog(settings) { function onOpenRoomSettingsDialog(settings) {
var roomSettings = roomSettingsComponent.createObject(timelineRoot, { var roomSettings = Qt.createComponent("qrc:/qml/dialogs/RoomSettings.qml").createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
roomSettings.show(); roomSettings.show();
@ -347,7 +197,7 @@ Pane {
} }
function onOpenInviteUsersDialog(invitees) { function onOpenInviteUsersDialog(invitees) {
var dialog = inviteDialog.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml").createObject(timelineRoot, {
"roomId": Rooms.currentRoom.roomId, "roomId": Rooms.currentRoom.roomId,
"plainRoomName": Rooms.currentRoom.plainRoomName, "plainRoomName": Rooms.currentRoom.plainRoomName,
"invitees": invitees "invitees": invitees
@ -357,7 +207,7 @@ Pane {
} }
function onOpenLeaveRoomDialog(roomid, reason) { function onOpenLeaveRoomDialog(roomid, reason) {
var dialog = leaveRoomComponent.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/LeaveRoomDialog.qml").createObject(timelineRoot, {
"roomId": roomid, "roomId": roomid,
"reason": reason "reason": reason
}); });
@ -366,7 +216,7 @@ Pane {
} }
function onShowImageOverlay(room, eventId, url, originalWidth, proportionalHeight) { function onShowImageOverlay(room, eventId, url, originalWidth, proportionalHeight) {
var dialog = imageOverlay.createObject(timelineRoot, { var dialog = Qt.createComponent("qrc:/qml/dialogs/ImageOverlay.qml").createObject(timelineRoot, {
"room": room, "room": room,
"eventId": eventId, "eventId": eventId,
"url": url, "url": url,
@ -384,7 +234,7 @@ Pane {
Connections { Connections {
function onNewInviteState() { function onNewInviteState() {
if (CallManager.haveCallInvite && Settings.mobileMode) { if (CallManager.haveCallInvite && Settings.mobileMode) {
var dialog = mobileCallInviteDialog.createObject(timelineRoot); var dialog = Qt.createComponent("qrc:/qml/dialogs/CallInvite.qml").createObject(timelineRoot);
dialog.open(); dialog.open();
destroyOnClose(dialog); destroyOnClose(dialog);
} }
@ -516,6 +366,15 @@ Pane {
} }
} }
Component {
id: userSettingsPage
UserSettingsPage {
}
}
Snackbar { id: snackbar } Snackbar { id: snackbar }
Connections { Connections {