mirror of https://github.com/Nheko-Reborn/nheko
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
473 lines
9.8 KiB
473 lines
9.8 KiB
4 years ago
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
||
3 years ago
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
||
4 years ago
|
//
|
||
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||
|
|
||
|
import "./delegates"
|
||
|
import "./device-verification"
|
||
3 years ago
|
import "./dialogs"
|
||
4 years ago
|
import "./emoji"
|
||
3 years ago
|
import "./pages"
|
||
4 years ago
|
import "./voip"
|
||
3 years ago
|
import "./ui"
|
||
4 years ago
|
import Qt.labs.platform 1.1 as Platform
|
||
3 years ago
|
import QtQuick 2.15
|
||
|
import QtQuick.Controls 2.15
|
||
4 years ago
|
import QtQuick.Layouts 1.3
|
||
3 years ago
|
import QtQuick.Window 2.15
|
||
4 years ago
|
import im.nheko 1.0
|
||
|
import im.nheko.EmojiModel 1.0
|
||
|
|
||
3 years ago
|
Pane {
|
||
4 years ago
|
id: timelineRoot
|
||
|
|
||
3 years ago
|
palette {
|
||
|
windowText: "#caccd1"
|
||
|
button: "white"
|
||
|
light: "#caccd1"
|
||
|
dark: "#3c464d"
|
||
|
mid: "#202228"
|
||
|
text: "#caccd1"
|
||
|
brightText: "#f4f5f8"
|
||
|
base: "#202228"
|
||
|
window: "#2d3139"
|
||
|
|
||
|
alternateBase: "#2d3139"
|
||
|
highlight: "#38a3d8"
|
||
|
highlightedText: "#f4f5f8"
|
||
3 years ago
|
toolTipBase: timelineRoot.palette.base
|
||
|
toolTipText: timelineRoot.palette.text
|
||
3 years ago
|
link: "#38a3d8"
|
||
|
buttonText: "#828284"
|
||
|
|
||
|
}
|
||
3 years ago
|
background: null
|
||
|
padding: 0
|
||
4 years ago
|
|
||
|
FontMetrics {
|
||
|
id: fontMetrics
|
||
|
}
|
||
|
|
||
3 years ago
|
//Timer {
|
||
|
// onTriggered: gc()
|
||
|
// interval: 1000
|
||
|
// running: true
|
||
|
// repeat: true
|
||
|
//}
|
||
|
|
||
4 years ago
|
EmojiPicker {
|
||
|
id: emojiPopup
|
||
|
|
||
|
colors: palette
|
||
|
model: TimelineManager.completerFor("allemoji", "")
|
||
|
}
|
||
|
|
||
|
Component {
|
||
|
id: userProfileComponent
|
||
|
|
||
|
UserProfile {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
Component {
|
||
|
id: roomSettingsComponent
|
||
|
|
||
|
RoomSettings {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: roomMembersComponent
|
||
|
|
||
|
RoomMembers {
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
|
|
||
4 years ago
|
Component {
|
||
|
id: mobileCallInviteDialog
|
||
|
|
||
|
CallInvite {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
Component {
|
||
|
id: quickSwitcherComponent
|
||
|
|
||
|
QuickSwitcher {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: deviceVerificationDialog
|
||
|
|
||
|
DeviceVerification {
|
||
|
}
|
||
|
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
Component {
|
||
|
id: inviteDialog
|
||
|
|
||
|
InviteDialog {
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: packSettingsComponent
|
||
|
|
||
|
ImagePackSettingsDialog {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: readReceiptsDialog
|
||
|
|
||
|
ReadReceipts {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: rawMessageDialog
|
||
|
|
||
|
RawMessageDialog {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: logoutDialog
|
||
|
|
||
|
LogoutDialog {
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: joinRoomDialog
|
||
|
|
||
|
JoinRoomDialog {
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: leaveRoomComponent
|
||
|
|
||
|
LeaveRoomDialog {
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: imageOverlay
|
||
|
|
||
|
ImageOverlay {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: userSettingsPage
|
||
|
|
||
|
UserSettingsPage {
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
3 years ago
|
Shortcut {
|
||
|
sequence: StandardKey.Quit
|
||
|
onActivated: Qt.quit()
|
||
|
}
|
||
|
|
||
4 years ago
|
Shortcut {
|
||
|
sequence: "Ctrl+K"
|
||
|
onActivated: {
|
||
|
var quickSwitch = quickSwitcherComponent.createObject(timelineRoot);
|
||
|
quickSwitch.open();
|
||
3 years ago
|
destroyOnClosed(quickSwitch);
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
Shortcut {
|
||
3 years ago
|
// Add alternative shortcut, because sometimes Alt+A is stolen by the TextEdit
|
||
|
sequences: ["Alt+A", "Ctrl+Shift+A"]
|
||
3 years ago
|
onActivated: Rooms.nextRoomWithActivity()
|
||
|
}
|
||
|
|
||
4 years ago
|
Shortcut {
|
||
|
sequence: "Ctrl+Down"
|
||
4 years ago
|
onActivated: Rooms.nextRoom()
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
4 years ago
|
Shortcut {
|
||
|
sequence: "Ctrl+Up"
|
||
4 years ago
|
onActivated: Rooms.previousRoom()
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
Connections {
|
||
|
function onOpenLogoutDialog() {
|
||
|
var dialog = logoutDialog.createObject(timelineRoot);
|
||
|
dialog.open();
|
||
3 years ago
|
destroyOnClose(dialog);
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
function onOpenJoinRoomDialog() {
|
||
|
var dialog = joinRoomDialog.createObject(timelineRoot);
|
||
|
dialog.show();
|
||
3 years ago
|
destroyOnClose(dialog);
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
target: Nheko
|
||
|
}
|
||
|
|
||
4 years ago
|
Connections {
|
||
3 years ago
|
function onNewDeviceVerificationRequest(flow) {
|
||
4 years ago
|
var dialog = deviceVerificationDialog.createObject(timelineRoot, {
|
||
|
"flow": flow
|
||
|
});
|
||
|
dialog.show();
|
||
3 years ago
|
destroyOnClose(dialog);
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
target: VerificationManager
|
||
|
}
|
||
|
|
||
3 years ago
|
function destroyOnClose(obj) {
|
||
3 years ago
|
if (obj.closing != undefined) obj.closing.connect(() => obj.destroy(1000));
|
||
|
else if (obj.aboutToHide != undefined) obj.aboutToHide.connect(() => obj.destroy(1000));
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
function destroyOnClosed(obj) {
|
||
3 years ago
|
obj.aboutToHide.connect(() => obj.destroy(1000));
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
Connections {
|
||
3 years ago
|
function onOpenProfile(profile) {
|
||
4 years ago
|
var userProfile = userProfileComponent.createObject(timelineRoot, {
|
||
|
"profile": profile
|
||
|
});
|
||
|
userProfile.show();
|
||
3 years ago
|
destroyOnClose(userProfile);
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function onShowImagePackSettings(room, packlist) {
|
||
3 years ago
|
var packSet = packSettingsComponent.createObject(timelineRoot, {
|
||
3 years ago
|
"room": room,
|
||
3 years ago
|
"packlist": packlist
|
||
|
});
|
||
|
packSet.show();
|
||
3 years ago
|
destroyOnClose(packSet);
|
||
3 years ago
|
}
|
||
4 years ago
|
|
||
3 years ago
|
function onOpenRoomMembersDialog(members, room) {
|
||
4 years ago
|
var membersDialog = roomMembersComponent.createObject(timelineRoot, {
|
||
|
"members": members,
|
||
3 years ago
|
"room": room
|
||
4 years ago
|
});
|
||
|
membersDialog.show();
|
||
3 years ago
|
destroyOnClose(membersDialog);
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
|
function onOpenRoomSettingsDialog(settings) {
|
||
4 years ago
|
var roomSettings = roomSettingsComponent.createObject(timelineRoot, {
|
||
|
"roomSettings": settings
|
||
|
});
|
||
|
roomSettings.show();
|
||
3 years ago
|
destroyOnClose(roomSettings);
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
|
function onOpenInviteUsersDialog(invitees) {
|
||
4 years ago
|
var dialog = inviteDialog.createObject(timelineRoot, {
|
||
3 years ago
|
"roomId": Rooms.currentRoom.roomId,
|
||
3 years ago
|
"plainRoomName": Rooms.currentRoom.plainRoomName,
|
||
3 years ago
|
"invitees": invitees
|
||
3 years ago
|
});
|
||
4 years ago
|
dialog.show();
|
||
3 years ago
|
destroyOnClose(dialog);
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function onOpenLeaveRoomDialog(roomid, reason) {
|
||
3 years ago
|
var dialog = leaveRoomComponent.createObject(timelineRoot, {
|
||
3 years ago
|
"roomId": roomid,
|
||
|
"reason": reason
|
||
3 years ago
|
});
|
||
3 years ago
|
dialog.open();
|
||
3 years ago
|
destroyOnClose(dialog);
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
function onShowImageOverlay(room, eventId, url, proportionalHeight, originalWidth) {
|
||
|
var dialog = imageOverlay.createObject(timelineRoot, {
|
||
|
"room": room,
|
||
|
"eventId": eventId,
|
||
3 years ago
|
"url": url,
|
||
|
"originalWidth": originalWidth ?? 0,
|
||
|
"proportionalHeight": proportionalHeight ?? 0
|
||
3 years ago
|
});
|
||
|
dialog.showFullScreen();
|
||
3 years ago
|
destroyOnClose(dialog);
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
target: TimelineManager
|
||
|
}
|
||
|
|
||
|
Connections {
|
||
|
function onNewInviteState() {
|
||
|
if (CallManager.haveCallInvite && Settings.mobileMode) {
|
||
3 years ago
|
var dialog = mobileCallInviteDialog.createObject(timelineRoot);
|
||
3 years ago
|
dialog.open();
|
||
3 years ago
|
destroyOnClose(dialog);
|
||
3 years ago
|
}
|
||
|
}
|
||
|
|
||
|
target: CallManager
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
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
|
||
|
prompt: qsTr("Please enter the token, which has been sent to you:")
|
||
|
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()
|
||
|
}
|
||
|
|
||
3 years ago
|
Connections {
|
||
|
function onPassword() {
|
||
|
console.log("UIA: password needed");
|
||
|
uiaPassPrompt.show();
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function onEmail() {
|
||
|
uiaEmailPrompt.show();
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function onPhoneNumber() {
|
||
|
uiaPhoneNumberPrompt.show();
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function onPrompt3pidToken() {
|
||
|
uiaTokenPrompt.show();
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function onConfirm3pidToken() {
|
||
|
uiaConfirmationLinkDialog.open();
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
function onError(msg) {
|
||
|
uiaErrorDialog.text = msg;
|
||
|
uiaErrorDialog.open();
|
||
|
}
|
||
3 years ago
|
|
||
|
target: UIA
|
||
|
}
|
||
|
|
||
3 years ago
|
StackView {
|
||
|
id: mainWindow
|
||
|
|
||
4 years ago
|
anchors.fill: parent
|
||
3 years ago
|
initialItem: welcomePage
|
||
|
}
|
||
|
|
||
|
Component {
|
||
|
id: welcomePage
|
||
|
|
||
|
WelcomePage {
|
||
3 years ago
|
}
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: chatPage
|
||
|
|
||
|
ChatPage {
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: loginPage
|
||
|
|
||
|
LoginPage {
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
Component {
|
||
|
id: registerPage
|
||
|
|
||
3 years ago
|
RegisterPage {
|
||
3 years ago
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
Snackbar { id: snackbar }
|
||
|
|
||
3 years ago
|
Connections {
|
||
|
function onSwitchToChatPage() {
|
||
3 years ago
|
mainWindow.replace(null, chatPage);
|
||
|
}
|
||
|
function onSwitchToLoginPage(error) {
|
||
|
mainWindow.replace(welcomePage, {}, loginPage, {"error": error}, StackView.PopTransition);
|
||
3 years ago
|
}
|
||
3 years ago
|
function onShowNotification(msg) {
|
||
|
snackbar.showNotification(msg);
|
||
|
console.log("New snack: " + msg);
|
||
|
}
|
||
3 years ago
|
target: MainWindow
|
||
|
}
|
||
|
|
||
4 years ago
|
}
|