2021-05-14 16:23:32 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
2022-01-01 06:57:53 +03:00
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
2023-01-02 06:25:33 +03:00
|
|
|
// SPDX-FileCopyrightText: 2023 Nheko Contributors
|
2021-05-14 16:23:32 +03:00
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
import "./delegates"
|
|
|
|
import "./device-verification"
|
2021-07-21 14:37:57 +03:00
|
|
|
import "./dialogs"
|
2021-05-14 16:23:32 +03:00
|
|
|
import "./emoji"
|
2022-01-09 08:56:02 +03:00
|
|
|
import "./pages"
|
2021-05-14 16:23:32 +03:00
|
|
|
import "./voip"
|
2022-01-30 21:14:33 +03:00
|
|
|
import "./ui"
|
2021-05-14 16:23:32 +03:00
|
|
|
import Qt.labs.platform 1.1 as Platform
|
2021-08-04 03:27:50 +03:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
2021-05-14 16:23:32 +03:00
|
|
|
import QtQuick.Layouts 1.3
|
2021-08-04 03:27:50 +03:00
|
|
|
import QtQuick.Window 2.15
|
2021-05-14 16:23:32 +03:00
|
|
|
import im.nheko 1.0
|
|
|
|
import im.nheko.EmojiModel 1.0
|
|
|
|
|
2022-01-12 21:09:46 +03:00
|
|
|
Pane {
|
2021-05-14 16:23:32 +03:00
|
|
|
id: timelineRoot
|
|
|
|
|
|
|
|
palette: Nheko.colors
|
2022-01-12 21:09:46 +03:00
|
|
|
background: null
|
|
|
|
padding: 0
|
2021-05-14 16:23:32 +03:00
|
|
|
|
|
|
|
FontMetrics {
|
|
|
|
id: fontMetrics
|
|
|
|
}
|
|
|
|
|
2022-07-01 01:41:50 +03:00
|
|
|
RoomDirectoryModel {
|
|
|
|
id: publicRooms
|
|
|
|
}
|
|
|
|
|
2022-12-13 08:28:57 +03:00
|
|
|
UserDirectoryModel {
|
|
|
|
id: userDirectory
|
|
|
|
}
|
|
|
|
|
2022-02-21 07:01:01 +03:00
|
|
|
//Timer {
|
|
|
|
// onTriggered: gc()
|
|
|
|
// interval: 1000
|
|
|
|
// running: true
|
|
|
|
// repeat: true
|
|
|
|
//}
|
|
|
|
|
2021-05-14 16:23:32 +03:00
|
|
|
EmojiPicker {
|
|
|
|
id: emojiPopup
|
|
|
|
|
|
|
|
colors: palette
|
|
|
|
model: TimelineManager.completerFor("allemoji", "")
|
|
|
|
}
|
|
|
|
|
2022-07-08 18:28:28 +03:00
|
|
|
function showAliasEditor(settings) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/AliasEditor.qml").createObject(timelineRoot, {
|
2022-07-08 18:28:28 +03:00
|
|
|
"roomSettings": settings
|
|
|
|
});
|
|
|
|
dialog.show();
|
|
|
|
destroyOnClose(dialog);
|
|
|
|
}
|
|
|
|
|
|
|
|
function showPLEditor(settings) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/PowerLevelEditor.qml").createObject(timelineRoot, {
|
2022-07-08 18:28:28 +03:00
|
|
|
"roomSettings": settings
|
|
|
|
});
|
|
|
|
dialog.show();
|
|
|
|
destroyOnClose(dialog);
|
|
|
|
}
|
2022-05-27 17:31:54 +03:00
|
|
|
|
2022-09-28 03:09:04 +03:00
|
|
|
function showSpacePLApplyPrompt(settings, editingModel) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/PowerLevelSpacesApplyDialog.qml").createObject(timelineRoot, {
|
2022-09-28 03:09:04 +03:00
|
|
|
"roomSettings": settings,
|
|
|
|
"editingModel": editingModel
|
|
|
|
});
|
|
|
|
dialog.show();
|
|
|
|
destroyOnClose(dialog);
|
|
|
|
}
|
|
|
|
|
2022-09-19 22:39:37 +03:00
|
|
|
function showAllowedRoomsEditor(settings) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/AllowedRoomsSettingsDialog.qml").createObject(timelineRoot, {
|
2022-09-19 22:39:37 +03:00
|
|
|
"roomSettings": settings
|
|
|
|
});
|
|
|
|
dialog.show();
|
|
|
|
destroyOnClose(dialog);
|
|
|
|
}
|
|
|
|
|
2021-07-24 01:11:33 +03:00
|
|
|
Component {
|
|
|
|
id: readReceiptsDialog
|
|
|
|
|
|
|
|
ReadReceipts {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-01-24 02:41:55 +03:00
|
|
|
Shortcut {
|
|
|
|
sequence: StandardKey.Quit
|
|
|
|
onActivated: Qt.quit()
|
|
|
|
}
|
|
|
|
|
2021-05-14 16:23:32 +03:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+K"
|
|
|
|
onActivated: {
|
2022-10-01 15:47:42 +03:00
|
|
|
var quickSwitch = Qt.createComponent("qrc:/qml/QuickSwitcher.qml").createObject(timelineRoot);
|
2021-05-14 16:23:32 +03:00
|
|
|
quickSwitch.open();
|
2022-03-01 03:59:06 +03:00
|
|
|
destroyOnClosed(quickSwitch);
|
2021-05-14 16:23:32 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-11 15:00:00 +03:00
|
|
|
Shortcut {
|
2021-12-22 04:45:25 +03:00
|
|
|
// Add alternative shortcut, because sometimes Alt+A is stolen by the TextEdit
|
|
|
|
sequences: ["Alt+A", "Ctrl+Shift+A"]
|
2021-09-11 15:00:00 +03:00
|
|
|
onActivated: Rooms.nextRoomWithActivity()
|
|
|
|
}
|
|
|
|
|
2021-05-29 00:25:57 +03:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+Down"
|
2021-05-30 14:22:11 +03:00
|
|
|
onActivated: Rooms.nextRoom()
|
2021-05-29 00:25:57 +03:00
|
|
|
}
|
2021-05-30 14:22:11 +03:00
|
|
|
|
2021-05-29 00:25:57 +03:00
|
|
|
Shortcut {
|
|
|
|
sequence: "Ctrl+Up"
|
2021-05-30 14:22:11 +03:00
|
|
|
onActivated: Rooms.previousRoom()
|
2021-05-29 00:25:57 +03:00
|
|
|
}
|
|
|
|
|
2021-09-30 03:15:25 +03:00
|
|
|
Connections {
|
|
|
|
function onOpenLogoutDialog() {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/LogoutDialog.qml").createObject(timelineRoot);
|
2021-09-30 03:15:25 +03:00
|
|
|
dialog.open();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(dialog);
|
2021-09-30 03:15:25 +03:00
|
|
|
}
|
|
|
|
|
2021-09-25 04:32:06 +03:00
|
|
|
function onOpenJoinRoomDialog() {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/JoinRoomDialog.qml").createObject(timelineRoot);
|
2021-09-25 04:32:06 +03:00
|
|
|
dialog.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(dialog);
|
2021-09-25 04:32:06 +03:00
|
|
|
}
|
|
|
|
|
2022-08-05 22:44:40 +03:00
|
|
|
function onShowRoomJoinPrompt(summary) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/ConfirmJoinRoomDialog.qml").createObject(timelineRoot, {"summary": summary});
|
2022-08-05 22:44:40 +03:00
|
|
|
dialog.show();
|
|
|
|
destroyOnClose(dialog);
|
|
|
|
}
|
|
|
|
|
2021-09-30 03:15:25 +03:00
|
|
|
target: Nheko
|
|
|
|
}
|
|
|
|
|
2021-05-14 16:23:32 +03:00
|
|
|
Connections {
|
2021-07-27 23:35:38 +03:00
|
|
|
function onNewDeviceVerificationRequest(flow) {
|
2022-10-01 15:47:42 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/device-verification/DeviceVerification.qml").createObject(timelineRoot, {
|
2021-05-14 16:23:32 +03:00
|
|
|
"flow": flow
|
|
|
|
});
|
|
|
|
dialog.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(dialog);
|
2021-05-14 16:23:32 +03:00
|
|
|
}
|
2021-07-27 23:35:38 +03:00
|
|
|
|
2021-10-15 03:44:48 +03:00
|
|
|
target: VerificationManager
|
|
|
|
}
|
|
|
|
|
2022-02-21 07:01:01 +03:00
|
|
|
function destroyOnClose(obj) {
|
2022-03-10 22:42:12 +03:00
|
|
|
if (obj.closing != undefined) obj.closing.connect(() => obj.destroy(1000));
|
|
|
|
else if (obj.aboutToHide != undefined) obj.aboutToHide.connect(() => obj.destroy(1000));
|
2022-02-21 07:01:01 +03:00
|
|
|
}
|
|
|
|
|
2022-03-01 03:59:06 +03:00
|
|
|
function destroyOnClosed(obj) {
|
2022-03-10 22:42:12 +03:00
|
|
|
obj.aboutToHide.connect(() => obj.destroy(1000));
|
2022-03-01 03:59:06 +03:00
|
|
|
}
|
|
|
|
|
2021-10-15 03:44:48 +03:00
|
|
|
Connections {
|
2021-07-27 23:35:38 +03:00
|
|
|
function onOpenProfile(profile) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var userProfile = Qt.createComponent("qrc:/qml/dialogs/UserProfile.qml").createObject(timelineRoot, {
|
2021-05-14 16:23:32 +03:00
|
|
|
"profile": profile
|
|
|
|
});
|
|
|
|
userProfile.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(userProfile);
|
2021-05-14 16:23:32 +03:00
|
|
|
}
|
2021-07-27 23:35:38 +03:00
|
|
|
|
2021-12-14 01:25:42 +03:00
|
|
|
function onShowImagePackSettings(room, packlist) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var packSet = Qt.createComponent("qrc:/qml/dialogs/ImagePackSettingsDialog.qml").createObject(timelineRoot, {
|
2021-12-14 01:25:42 +03:00
|
|
|
"room": room,
|
2021-07-21 14:37:57 +03:00
|
|
|
"packlist": packlist
|
|
|
|
});
|
|
|
|
packSet.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(packSet);
|
2021-07-21 14:37:57 +03:00
|
|
|
}
|
2021-05-14 16:23:32 +03:00
|
|
|
|
2021-08-14 00:58:26 +03:00
|
|
|
function onOpenRoomMembersDialog(members, room) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var membersDialog = Qt.createComponent("qrc:/qml/dialogs/RoomMembers.qml").createObject(timelineRoot, {
|
2021-06-11 03:13:12 +03:00
|
|
|
"members": members,
|
2021-08-14 00:58:26 +03:00
|
|
|
"room": room
|
2021-06-11 03:13:12 +03:00
|
|
|
});
|
|
|
|
membersDialog.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(membersDialog);
|
2021-06-11 03:13:12 +03:00
|
|
|
}
|
2021-07-27 23:35:38 +03:00
|
|
|
|
|
|
|
function onOpenRoomSettingsDialog(settings) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var roomSettings = Qt.createComponent("qrc:/qml/dialogs/RoomSettings.qml").createObject(timelineRoot, {
|
2021-06-11 03:13:12 +03:00
|
|
|
"roomSettings": settings
|
|
|
|
});
|
|
|
|
roomSettings.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(roomSettings);
|
2021-06-11 03:13:12 +03:00
|
|
|
}
|
2021-07-27 23:35:38 +03:00
|
|
|
|
|
|
|
function onOpenInviteUsersDialog(invitees) {
|
2023-01-04 03:53:18 +03:00
|
|
|
var component = Qt.createComponent("qrc:/qml/dialogs/InviteDialog.qml")
|
|
|
|
var dialog = component.createObject(timelineRoot, {
|
2021-07-17 23:16:18 +03:00
|
|
|
"roomId": Rooms.currentRoom.roomId,
|
2021-07-21 02:17:20 +03:00
|
|
|
"plainRoomName": Rooms.currentRoom.plainRoomName,
|
2021-07-18 01:23:21 +03:00
|
|
|
"invitees": invitees
|
2021-07-17 23:16:18 +03:00
|
|
|
});
|
2023-01-04 03:53:18 +03:00
|
|
|
if (component.status != Component.Ready) {
|
|
|
|
console.log("Failed to create component: " + component.errorString());
|
|
|
|
}
|
2021-06-11 03:13:12 +03:00
|
|
|
dialog.show();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(dialog);
|
2021-06-11 03:13:12 +03:00
|
|
|
}
|
2021-07-27 23:35:38 +03:00
|
|
|
|
2022-03-31 00:38:38 +03:00
|
|
|
function onOpenLeaveRoomDialog(roomid, reason) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/LeaveRoomDialog.qml").createObject(timelineRoot, {
|
2022-03-31 00:38:38 +03:00
|
|
|
"roomId": roomid,
|
|
|
|
"reason": reason
|
2021-11-04 01:01:36 +03:00
|
|
|
});
|
2021-09-24 04:18:48 +03:00
|
|
|
dialog.open();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(dialog);
|
2021-09-24 04:18:48 +03:00
|
|
|
}
|
|
|
|
|
2022-05-10 04:19:53 +03:00
|
|
|
function onShowImageOverlay(room, eventId, url, originalWidth, proportionalHeight) {
|
2022-10-01 03:28:02 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/dialogs/ImageOverlay.qml").createObject(timelineRoot, {
|
2022-01-02 23:46:29 +03:00
|
|
|
"room": room,
|
|
|
|
"eventId": eventId,
|
2022-04-10 05:10:32 +03:00
|
|
|
"url": url,
|
|
|
|
"originalWidth": originalWidth ?? 0,
|
|
|
|
"proportionalHeight": proportionalHeight ?? 0
|
2022-01-02 23:46:29 +03:00
|
|
|
});
|
2022-05-10 04:19:53 +03:00
|
|
|
|
2022-01-02 23:46:29 +03:00
|
|
|
dialog.showFullScreen();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(dialog);
|
2022-01-02 23:46:29 +03:00
|
|
|
}
|
|
|
|
|
2021-07-27 23:35:38 +03:00
|
|
|
target: TimelineManager
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
function onNewInviteState() {
|
|
|
|
if (CallManager.haveCallInvite && Settings.mobileMode) {
|
2022-10-01 15:47:42 +03:00
|
|
|
var dialog = Qt.createComponent("qrc:/qml/voip/CallInvite.qml").createObject(timelineRoot);
|
2021-07-27 23:35:38 +03:00
|
|
|
dialog.open();
|
2022-02-21 07:01:01 +03:00
|
|
|
destroyOnClose(dialog);
|
2021-07-27 23:35:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
target: CallManager
|
2021-06-11 03:13:12 +03:00
|
|
|
}
|
|
|
|
|
2021-09-18 01:21:14 +03:00
|
|
|
SelfVerificationCheck {
|
|
|
|
}
|
|
|
|
|
|
|
|
InputDialog {
|
|
|
|
id: uiaPassPrompt
|
|
|
|
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
title: UIA.title
|
|
|
|
prompt: qsTr("Please enter your login password to continue:")
|
|
|
|
onAccepted: (t) => {
|
|
|
|
return UIA.continuePassword(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-03 20:36:12 +03:00
|
|
|
InputDialog {
|
|
|
|
id: uiaEmailPrompt
|
|
|
|
|
|
|
|
title: UIA.title
|
|
|
|
prompt: qsTr("Please enter a valid email address to continue:")
|
|
|
|
onAccepted: (t) => {
|
|
|
|
return UIA.continueEmail(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PhoneNumberInputDialog {
|
|
|
|
id: uiaPhoneNumberPrompt
|
|
|
|
|
|
|
|
title: UIA.title
|
|
|
|
prompt: qsTr("Please enter a valid phone number to continue:")
|
|
|
|
onAccepted: (p, t) => {
|
|
|
|
return UIA.continuePhoneNumber(p, t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InputDialog {
|
|
|
|
id: uiaTokenPrompt
|
|
|
|
|
|
|
|
title: UIA.title
|
2022-09-30 07:23:39 +03:00
|
|
|
prompt: qsTr("Please enter the token which has been sent to you:")
|
2021-11-03 20:36:12 +03:00
|
|
|
onAccepted: (t) => {
|
|
|
|
return UIA.submit3pidToken(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform.MessageDialog {
|
|
|
|
id: uiaErrorDialog
|
|
|
|
|
|
|
|
buttons: Platform.MessageDialog.Ok
|
|
|
|
}
|
|
|
|
|
|
|
|
Platform.MessageDialog {
|
|
|
|
id: uiaConfirmationLinkDialog
|
|
|
|
|
|
|
|
buttons: Platform.MessageDialog.Ok
|
|
|
|
text: qsTr("Wait for the confirmation link to arrive, then continue.")
|
|
|
|
onAccepted: UIA.continue3pidReceived()
|
|
|
|
}
|
|
|
|
|
2021-09-18 01:21:14 +03:00
|
|
|
Connections {
|
|
|
|
function onPassword() {
|
|
|
|
console.log("UIA: password needed");
|
|
|
|
uiaPassPrompt.show();
|
|
|
|
}
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-03 20:36:12 +03:00
|
|
|
function onEmail() {
|
|
|
|
uiaEmailPrompt.show();
|
|
|
|
}
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-03 20:36:12 +03:00
|
|
|
function onPhoneNumber() {
|
|
|
|
uiaPhoneNumberPrompt.show();
|
|
|
|
}
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-03 20:36:12 +03:00
|
|
|
function onPrompt3pidToken() {
|
|
|
|
uiaTokenPrompt.show();
|
|
|
|
}
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-03 20:36:12 +03:00
|
|
|
function onConfirm3pidToken() {
|
|
|
|
uiaConfirmationLinkDialog.open();
|
|
|
|
}
|
2021-11-04 01:01:36 +03:00
|
|
|
|
2021-11-03 20:36:12 +03:00
|
|
|
function onError(msg) {
|
|
|
|
uiaErrorDialog.text = msg;
|
|
|
|
uiaErrorDialog.open();
|
|
|
|
}
|
2021-09-18 01:21:14 +03:00
|
|
|
|
|
|
|
target: UIA
|
|
|
|
}
|
|
|
|
|
2022-01-09 02:28:03 +03:00
|
|
|
StackView {
|
|
|
|
id: mainWindow
|
|
|
|
|
2021-05-14 16:23:32 +03:00
|
|
|
anchors.fill: parent
|
2022-01-24 02:41:55 +03:00
|
|
|
initialItem: welcomePage
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: welcomePage
|
|
|
|
|
|
|
|
WelcomePage {
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
2021-05-14 16:23:32 +03:00
|
|
|
}
|
|
|
|
|
2022-01-12 21:09:46 +03:00
|
|
|
Component {
|
|
|
|
id: chatPage
|
|
|
|
|
|
|
|
ChatPage {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-24 02:41:55 +03:00
|
|
|
Component {
|
|
|
|
id: loginPage
|
|
|
|
|
|
|
|
LoginPage {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-28 17:24:56 +03:00
|
|
|
Component {
|
|
|
|
id: registerPage
|
|
|
|
|
2022-01-29 19:30:56 +03:00
|
|
|
RegisterPage {
|
2022-01-28 17:24:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-01 03:28:02 +03:00
|
|
|
Component {
|
|
|
|
id: userSettingsPage
|
|
|
|
|
|
|
|
UserSettingsPage {
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-01-30 21:14:33 +03:00
|
|
|
Snackbar { id: snackbar }
|
|
|
|
|
2022-01-12 21:09:46 +03:00
|
|
|
Connections {
|
|
|
|
function onSwitchToChatPage() {
|
2022-01-24 02:41:55 +03:00
|
|
|
mainWindow.replace(null, chatPage);
|
|
|
|
}
|
|
|
|
function onSwitchToLoginPage(error) {
|
|
|
|
mainWindow.replace(welcomePage, {}, loginPage, {"error": error}, StackView.PopTransition);
|
2022-01-12 21:09:46 +03:00
|
|
|
}
|
2022-01-30 21:14:33 +03:00
|
|
|
function onShowNotification(msg) {
|
|
|
|
snackbar.showNotification(msg);
|
|
|
|
console.log("New snack: " + msg);
|
|
|
|
}
|
2022-01-12 21:09:46 +03:00
|
|
|
target: MainWindow
|
|
|
|
}
|
|
|
|
|
2021-05-14 16:23:32 +03:00
|
|
|
}
|