print errors on failed dialog creation

Signed-off-by: Marcus Hoffmann <bubu@bubu1.eu>
This commit is contained in:
Marcus Hoffmann 2023-02-21 14:32:35 +01:00
parent 5d9895a38c
commit 7c08d88990
3 changed files with 195 additions and 101 deletions

View file

@ -470,11 +470,14 @@ Page {
function openUserProfile() { function openUserProfile() {
Nheko.updateUserProfile(); Nheko.updateUserProfile();
var userProfile = Qt.createComponent("qrc:/qml/dialogs/UserProfile.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/UserProfile.qml")
"profile": Nheko.currentUser if (component.status == Component.Ready) {
}); var userProfile = component.createObject(timelineRoot, {"profile": Nheko.currentUser});
userProfile.show(); userProfile.show();
timelineRoot.destroyOnClose(userProfile); timelineRoot.destroyOnClose(userProfile);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
@ -790,9 +793,14 @@ Page {
ToolTip.text: qsTr("Search rooms (Ctrl+K)") ToolTip.text: qsTr("Search rooms (Ctrl+K)")
Layout.margins: Nheko.paddingMedium Layout.margins: Nheko.paddingMedium
onClicked: { onClicked: {
var quickSwitch = Qt.createComponent("qrc:/qml/QuickSwitcher.qml").createObject(timelineRoot); var component = Qt.createComponent("qrc:/qml/QuickSwitcher.qml")
quickSwitch.open(); if (component.status == Component.Ready) {
destroyOnClosed(quickSwitch); var quickSwitch = component.createObject(timelineRoot);
quickSwitch.open();
destroyOnClosed(quickSwitch);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
} }

View file

@ -51,36 +51,57 @@ Pane {
} }
function showAliasEditor(settings) { function showAliasEditor(settings) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/AliasEditor.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/AliasEditor.qml")
"roomSettings": settings if (component.status == Component.Ready) {
}); var dialog = component.createObject(timelineRoot, {
dialog.show(); "roomSettings": settings
destroyOnClose(dialog); });
dialog.show();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function showPLEditor(settings) { function showPLEditor(settings) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/PowerLevelEditor.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/PowerLevelEditor.qml")
"roomSettings": settings if (component.status == Component.Ready) {
}); var dialog = component.createObject(timelineRoot, {
dialog.show(); "roomSettings": settings
destroyOnClose(dialog); });
dialog.show();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function showSpacePLApplyPrompt(settings, editingModel) { function showSpacePLApplyPrompt(settings, editingModel) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/PowerLevelSpacesApplyDialog.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/PowerLevelSpacesApplyDialog.qml")
"roomSettings": settings, if (component.status == Component.Ready) {
"editingModel": editingModel var dialog = component.createObject(timelineRoot, {
}); "roomSettings": settings,
dialog.show(); "editingModel": editingModel
destroyOnClose(dialog); });
dialog.show();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function showAllowedRoomsEditor(settings) { function showAllowedRoomsEditor(settings) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/AllowedRoomsSettingsDialog.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/AllowedRoomsSettingsDialog.qml")
"roomSettings": settings if (component.status == Component.Ready) {
}); var dialog = component.createObject(timelineRoot, {
dialog.show(); "roomSettings": settings
destroyOnClose(dialog); });
dialog.show();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
Component { Component {
@ -99,9 +120,14 @@ Pane {
Shortcut { Shortcut {
sequence: "Ctrl+K" sequence: "Ctrl+K"
onActivated: { onActivated: {
var quickSwitch = Qt.createComponent("qrc:/qml/QuickSwitcher.qml").createObject(timelineRoot); var component = Qt.createComponent("qrc:/qml/QuickSwitcher.qml")
quickSwitch.open(); if (component.status == Component.Ready) {
destroyOnClosed(quickSwitch); var quickSwitch = component.createObject(timelineRoot);
quickSwitch.open();
destroyOnClosed(quickSwitch);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
} }
@ -123,21 +149,36 @@ Pane {
Connections { Connections {
function onOpenLogoutDialog() { function onOpenLogoutDialog() {
var dialog = Qt.createComponent("qrc:/qml/dialogs/LogoutDialog.qml").createObject(timelineRoot); var component = Qt.createComponent("qrc:/qml/dialogs/LogoutDialog.qml")
dialog.open(); if (component.status == Component.Ready) {
destroyOnClose(dialog); var dialog = component.createObject(timelineRoot);
dialog.open();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onOpenJoinRoomDialog() { function onOpenJoinRoomDialog() {
var dialog = Qt.createComponent("qrc:/qml/dialogs/JoinRoomDialog.qml").createObject(timelineRoot); var component = Qt.createComponent("qrc:/qml/dialogs/JoinRoomDialog.qml")
dialog.show(); if (component.status == Component.Ready) {
destroyOnClose(dialog); var dialog = component.createObject(timelineRoot);
dialog.show();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onShowRoomJoinPrompt(summary) { function onShowRoomJoinPrompt(summary) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/ConfirmJoinRoomDialog.qml").createObject(timelineRoot, {"summary": summary}); var component = Qt.createComponent("qrc:/qml/dialogs/ConfirmJoinRoomDialog.qml")
dialog.show(); if (component.status == Component.Ready) {
destroyOnClose(dialog); var dialog = component.createObject(timelineRoot, {"summary": summary});
dialog.show();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
target: Nheko target: Nheko
@ -145,11 +186,14 @@ Pane {
Connections { Connections {
function onNewDeviceVerificationRequest(flow) { function onNewDeviceVerificationRequest(flow) {
var dialog = Qt.createComponent("qrc:/qml/device-verification/DeviceVerification.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/device-verification/DeviceVerification.qml")
"flow": flow if (component.status == Component.Ready) {
}); var dialog = component.createObject(timelineRoot, {"flow": flow});
dialog.show(); dialog.show();
destroyOnClose(dialog); destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
target: VerificationManager target: VerificationManager
@ -166,73 +210,105 @@ Pane {
Connections { Connections {
function onOpenProfile(profile) { function onOpenProfile(profile) {
var userProfile = Qt.createComponent("qrc:/qml/dialogs/UserProfile.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/UserProfile.qml")
"profile": profile if (component.status == Component.Ready) {
}); var userProfile = component.createObject(timelineRoot, {"profile": profile});
userProfile.show(); userProfile.show();
destroyOnClose(userProfile); destroyOnClose(userProfile);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onShowImagePackSettings(room, packlist) { function onShowImagePackSettings(room, packlist) {
var packSet = Qt.createComponent("qrc:/qml/dialogs/ImagePackSettingsDialog.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/ImagePackSettingsDialog.qml")
"room": room,
"packlist": packlist if (component.status == Component.Ready) {
}); var packSet = component.createObject(timelineRoot, {
packSet.show(); "room": room,
destroyOnClose(packSet); "packlist": packlist
});
packSet.show();
destroyOnClose(packSet);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onOpenRoomMembersDialog(members, room) { function onOpenRoomMembersDialog(members, room) {
var membersDialog = Qt.createComponent("qrc:/qml/dialogs/RoomMembers.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/RoomMembers.qml")
"members": members, if (component.status == Component.Ready) {
"room": room var membersDialog = component.createObject(timelineRoot, {
}); "members": members,
membersDialog.show(); "room": room
destroyOnClose(membersDialog); });
membersDialog.show();
destroyOnClose(membersDialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onOpenRoomSettingsDialog(settings) { function onOpenRoomSettingsDialog(settings) {
var roomSettings = Qt.createComponent("qrc:/qml/dialogs/RoomSettings.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/RoomSettings.qml")
"roomSettings": settings if (component.status == Component.Ready) {
}); var roomSettings = component.createObject(timelineRoot, {
roomSettings.show(); "roomSettings": settings
destroyOnClose(roomSettings); });
roomSettings.show();
destroyOnClose(roomSettings);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onOpenInviteUsersDialog(invitees) { function onOpenInviteUsersDialog(invitees) {
var component = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml") var component = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml")
var dialog = component.createObject(timelineRoot, { if (component.status == Component.Ready) {
"roomId": Rooms.currentRoom.roomId, var dialog = component.createObject(timelineRoot, {
"plainRoomName": Rooms.currentRoom.plainRoomName, "roomId": Rooms.currentRoom.roomId,
"invitees": invitees "plainRoomName": Rooms.currentRoom.plainRoomName,
}); "invitees": invitees
if (component.status != Component.Ready) { });
console.log("Failed to create component: " + component.errorString()); dialog.show();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
} }
dialog.show();
destroyOnClose(dialog);
} }
function onOpenLeaveRoomDialog(roomid, reason) { function onOpenLeaveRoomDialog(roomid, reason) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/LeaveRoomDialog.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/LeaveRoomDialog.qml")
"roomId": roomid, if (component.status == Component.Ready) {
"reason": reason var dialog = component.createObject(timelineRoot, {
}); "roomId": roomid,
dialog.open(); "reason": reason
destroyOnClose(dialog); });
dialog.open();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onShowImageOverlay(room, eventId, url, originalWidth, proportionalHeight) { function onShowImageOverlay(room, eventId, url, originalWidth, proportionalHeight) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/ImageOverlay.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/ImageOverlay.qml")
"room": room, if (component.status == Component.Ready) {
"eventId": eventId, var dialog = component.createObject(timelineRoot, {
"url": url, "room": room,
"originalWidth": originalWidth ?? 0, "eventId": eventId,
"proportionalHeight": proportionalHeight ?? 0 "url": url,
}); "originalWidth": originalWidth ?? 0,
"proportionalHeight": proportionalHeight ?? 0
dialog.showFullScreen(); }
destroyOnClose(dialog); );
dialog.showFullScreen();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
target: TimelineManager target: TimelineManager
@ -241,9 +317,14 @@ Pane {
Connections { Connections {
function onNewInviteState() { function onNewInviteState() {
if (CallManager.haveCallInvite && Settings.mobileMode) { if (CallManager.haveCallInvite && Settings.mobileMode) {
var dialog = Qt.createComponent("qrc:/qml/voip/CallInvite.qml").createObject(timelineRoot); var component = Qt.createComponent("qrc:/qml/voip/CallInvite.qml")
dialog.open(); if (component.status == Component.Ready) {
destroyOnClose(dialog); var dialog = component.createObject(timelineRoot);
dialog.open();
destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
} }

View file

@ -423,11 +423,16 @@ Item {
} }
function onShowRawMessageDialog(rawMessage) { function onShowRawMessageDialog(rawMessage) {
var dialog = Qt.createComponent("qrc:/qml/dialogs/RawMessageDialog.qml").createObject(timelineRoot, { var component = Qt.createComponent("qrc:/qml/dialogs/RawMessageDialog.qml")
"rawMessage": rawMessage if (component.status == Component.Ready) {
}); var dialog = component.createObject(timelineRoot, {
dialog.show(); "rawMessage": rawMessage
timelineRoot.destroyOnClose(dialog); });
dialog.show();
timelineRoot.destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onConfetti() function onConfetti()