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")
if (component.status == Component.Ready) {
var quickSwitch = component.createObject(timelineRoot);
quickSwitch.open(); quickSwitch.open();
destroyOnClosed(quickSwitch); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
dialog.show(); dialog.show();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
dialog.show(); dialog.show();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"roomSettings": settings, "roomSettings": settings,
"editingModel": editingModel "editingModel": editingModel
}); });
dialog.show(); dialog.show();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
dialog.show(); dialog.show();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var quickSwitch = component.createObject(timelineRoot);
quickSwitch.open(); quickSwitch.open();
destroyOnClosed(quickSwitch); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot);
dialog.open(); dialog.open();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot);
dialog.show(); dialog.show();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {"summary": summary});
dialog.show(); dialog.show();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var packSet = component.createObject(timelineRoot, {
"room": room, "room": room,
"packlist": packlist "packlist": packlist
}); });
packSet.show(); packSet.show();
destroyOnClose(packSet); 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")
if (component.status == Component.Ready) {
var membersDialog = component.createObject(timelineRoot, {
"members": members, "members": members,
"room": room "room": room
}); });
membersDialog.show(); membersDialog.show();
destroyOnClose(membersDialog); 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")
if (component.status == Component.Ready) {
var roomSettings = component.createObject(timelineRoot, {
"roomSettings": settings "roomSettings": settings
}); });
roomSettings.show(); roomSettings.show();
destroyOnClose(roomSettings); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, { var dialog = component.createObject(timelineRoot, {
"roomId": Rooms.currentRoom.roomId, "roomId": Rooms.currentRoom.roomId,
"plainRoomName": Rooms.currentRoom.plainRoomName, "plainRoomName": Rooms.currentRoom.plainRoomName,
"invitees": invitees "invitees": invitees
}); });
if (component.status != Component.Ready) {
console.log("Failed to create component: " + component.errorString());
}
dialog.show(); dialog.show();
destroyOnClose(dialog); destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"roomId": roomid, "roomId": roomid,
"reason": reason "reason": reason
}); });
dialog.open(); dialog.open();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"room": room, "room": room,
"eventId": eventId, "eventId": eventId,
"url": url, "url": url,
"originalWidth": originalWidth ?? 0, "originalWidth": originalWidth ?? 0,
"proportionalHeight": proportionalHeight ?? 0 "proportionalHeight": proportionalHeight ?? 0
}); }
);
dialog.showFullScreen(); dialog.showFullScreen();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot);
dialog.open(); dialog.open();
destroyOnClose(dialog); 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")
if (component.status == Component.Ready) {
var dialog = component.createObject(timelineRoot, {
"rawMessage": rawMessage "rawMessage": rawMessage
}); });
dialog.show(); dialog.show();
timelineRoot.destroyOnClose(dialog); timelineRoot.destroyOnClose(dialog);
} else {
console.error("Failed to create component: " + component.errorString());
}
} }
function onConfetti() function onConfetti()