Port to explicit connect syntax

Also fix a lot of warnings.
This commit is contained in:
Nicolas Werner 2021-07-27 22:35:38 +02:00
parent 6222ae88ce
commit d955444dc1
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
13 changed files with 96 additions and 62 deletions

View File

@ -56,6 +56,7 @@ Rectangle {
RoomList {
id: roomlist
implicitHeight: chatPage.height
collapsed: parent.collapsed
}

View File

@ -109,15 +109,17 @@ Popup {
}
Connections {
onCompletionSelected: {
function onCompletionSelected(id) {
room.forwardMessage(messageContextMenu.eventId, id);
forwardMessagePopup.close();
}
onCountChanged: {
function onCountChanged() {
if (completerPopup.count > 0 && (completerPopup.currentIndex < 0 || completerPopup.currentIndex >= completerPopup.count))
completerPopup.currentIndex = 0;
}
target: completerPopup
}

View File

@ -18,8 +18,8 @@ TextEdit {
//enabled: selectByMouse
color: Nheko.colors.text
onLinkActivated: Nheko.openLink(link)
ToolTip.visible: hoveredLink
ToolTip.text: hoveredLink
ToolTip.visible: hoveredLink || false
ToolTip.text: hoveredLink || ""
Component.onCompleted: {
TimelineManager.fixImageRendering(r.textDocument, r);
}

View File

@ -261,18 +261,24 @@ Rectangle {
background: null
Connections {
onRoomChanged: {
function onRoomChanged() {
messageInput.clear();
messageInput.append(room.input.text());
if (room)
messageInput.append(room.input.text());
messageInput.completerTriggeredAt = -1;
popup.completerName = "";
messageInput.forceActiveFocus();
}
target: timelineView
}
Connections {
onCompletionClicked: messageInput.insertCompletion(completion)
function onCompletionClicked(completion) {
messageInput.insertCompletion(completion);
}
target: popup
}
@ -284,28 +290,39 @@ Rectangle {
}
Connections {
ignoreUnknownSignals: true
onInsertText: {
function onInsertText(text) {
messageInput.remove(messageInput.selectionStart, messageInput.selectionEnd);
messageInput.insert(messageInput.cursorPosition, text);
}
onTextChanged: {
function onTextChanged(newText) {
messageInput.text = newText;
messageInput.cursorPosition = newText.length;
}
ignoreUnknownSignals: true
target: room ? room.input : null
}
Connections {
function onReplyChanged() {
messageInput.forceActiveFocus();
}
function onEditChanged() {
messageInput.forceActiveFocus();
}
ignoreUnknownSignals: true
onReplyChanged: messageInput.forceActiveFocus()
onEditChanged: messageInput.forceActiveFocus()
target: room
}
Connections {
function onFocusInput() {
messageInput.forceActiveFocus();
}
target: TimelineManager
onFocusInput: messageInput.forceActiveFocus()
}
MouseArea {

View File

@ -200,15 +200,22 @@ ScrollView {
}
Connections {
function onFocusChanged() {
readTimer.running = TimelineManager.isWindowFocused;
}
target: TimelineManager
onFocusChanged: readTimer.running = TimelineManager.isWindowFocused
}
Timer {
id: readTimer
// force current read index to update
onTriggered: chat.model.setCurrentIndex(chat.model.currentIndex)
onTriggered: {
if (chat.model) {
chat.model.setCurrentIndex(chat.model.currentIndex);
}
}
interval: 1000
}
@ -265,11 +272,15 @@ ScrollView {
}
Connections {
target: chat.model
onRoomAvatarUrlChanged: {
function onRoomAvatarUrlChanged() {
messageUserAvatar.url = chat.model.avatarUrl(userId).replace("mxc://", "image://MxcImage/");
}
onScrollToIndex: chat.positionViewAtIndex(index, ListView.Visible)
function onScrollToIndex(index) {
chat.positionViewAtIndex(index, ListView.Visible);
}
target: chat.model
}
Label {
@ -467,12 +478,13 @@ ScrollView {
}
Connections {
target: chat
onMovementEnded: {
function onMovementEnded() {
if (y + height + 2 * chat.spacing > chat.contentY + chat.height && y < chat.contentY + chat.height)
chat.model.currentIndex = index;
}
target: chat
}
}

View File

@ -13,8 +13,7 @@ Item {
property int screenTimeout
Connections {
target: TimelineManager
onFocusChanged: {
function onFocusChanged() {
if (TimelineManager.isWindowFocused) {
screenSaverTimer.stop();
screenSaver.state = "Invisible";
@ -24,6 +23,8 @@ Item {
}
}
target: TimelineManager
}
Timer {

View File

@ -71,15 +71,17 @@ Popup {
}
Connections {
onCompletionSelected: {
function onCompletionSelected(id) {
Rooms.setCurrentRoom(id);
quickSwitcher.close();
}
onCountChanged: {
function onCountChanged() {
if (completerPopup.count > 0 && (completerPopup.currentIndex < 0 || completerPopup.currentIndex >= completerPopup.count))
completerPopup.currentIndex = 0;
}
target: completerPopup
}

View File

@ -32,11 +32,12 @@ Page {
}
Connections {
onActiveTimelineChanged: {
function onCurrentRoomChanged() {
roomlist.positionViewAtIndex(Rooms.roomidToIndex(Rooms.currentRoom.roomId), ListView.Contain);
console.log("Test" + Rooms.currentRoom.roomId + " " + Rooms.roomidToIndex(Rooms.currentRoom.roomId));
}
target: TimelineManager
target: Rooms
}
Platform.Menu {
@ -66,7 +67,7 @@ Page {
title: qsTr("Leave Room")
text: qsTr("Are you sure you want to leave this room?")
modality: Qt.Modal
modality: Qt.ApplicationModal
onAccepted: Rooms.leave(roomContextMenu.roomid)
buttons: Dialog.Ok | Dialog.Cancel
}

View File

@ -116,53 +116,43 @@ Page {
}
Connections {
target: TimelineManager
onNewDeviceVerificationRequest: {
function onNewDeviceVerificationRequest(flow) {
var dialog = deviceVerificationDialog.createObject(timelineRoot, {
"flow": flow
});
dialog.show();
}
onOpenProfile: {
function onOpenProfile(profile) {
var userProfile = userProfileComponent.createObject(timelineRoot, {
"profile": profile
});
userProfile.show();
}
onShowImagePackSettings: {
function onShowImagePackSettings(packlist) {
var packSet = packSettingsComponent.createObject(timelineRoot, {
"packlist": packlist
});
packSet.show();
}
}
Connections {
target: CallManager
onNewInviteState: {
if (CallManager.haveCallInvite && Settings.mobileMode) {
var dialog = mobileCallInviteDialog.createObject(msgView);
dialog.open();
}
}
}
Connections {
target: TimelineManager
onOpenRoomMembersDialog: {
function onOpenRoomMembersDialog(members) {
var membersDialog = roomMembersComponent.createObject(timelineRoot, {
"members": members,
"roomName": Rooms.currentRoom.roomName
});
membersDialog.show();
}
onOpenRoomSettingsDialog: {
function onOpenRoomSettingsDialog(settings) {
var roomSettings = roomSettingsComponent.createObject(timelineRoot, {
"roomSettings": settings
});
roomSettings.show();
}
onOpenInviteUsersDialog: {
function onOpenInviteUsersDialog(invitees) {
var dialog = inviteDialog.createObject(timelineRoot, {
"roomId": Rooms.currentRoom.roomId,
"plainRoomName": Rooms.currentRoom.plainRoomName,
@ -170,6 +160,19 @@ Page {
});
dialog.show();
}
target: TimelineManager
}
Connections {
function onNewInviteState() {
if (CallManager.haveCallInvite && Settings.mobileMode) {
var dialog = mobileCallInviteDialog.createObject(msgView);
dialog.open();
}
}
target: CallManager
}
ChatPage {

View File

@ -83,12 +83,13 @@ ApplicationWindow {
}
Connections {
target: profile
onDisplayError: {
function onDisplayError(errorMessage) {
errorText.text = errorMessage;
errorText.opacity = 1;
hideErrorAnimation.restart();
}
target: profile
}
TextInput {

View File

@ -185,8 +185,7 @@ Rectangle {
}
Connections {
target: room
onMediaCached: {
function onMediaCached(mxcUrl, cacheUrl) {
if (mxcUrl == url) {
media.source = cacheUrl;
button.state = "stopped";
@ -194,6 +193,8 @@ Rectangle {
}
console.log("media cached: " + mxcUrl + " at " + cacheUrl);
}
target: room
}
}

View File

@ -23,12 +23,13 @@ Popup {
}
Connections {
target: CallManager
onNewInviteState: {
function onNewInviteState() {
if (!CallManager.haveCallInvite)
close();
}
target: CallManager
}
ColumnLayout {

View File

@ -30,19 +30,11 @@ qmlMessageHandler(QtMsgType type, const QMessageLogContext &context, const QStri
const char *function = context.function ? context.function : "";
if (
// Surpress binding wrning for now, as we can't set restore mode to keep compat with
// qt 5.10
msg.contains(QStringLiteral(
"QML Binding: Not restoring previous value because restoreMode has not been set.")) ||
// The default style has the point size set. If you use pixel size anywhere, you get
// that warning, which is useless, since sometimes you need the pixel size to match the
// text to the size of the outer element for example. This is done in the avatar and
// without that you get one warning for every Avatar displayed, which is stupid!
msg.endsWith(QStringLiteral("Both point size and pixel size set. Using pixel size.")) ||
// The new syntax breaks rebinding on Qt < 5.15. Until we can drop that, we still need it.
msg.endsWith(QStringLiteral(
"QML Connections: Implicitly defined onFoo properties in Connections are "
"deprecated. Use this syntax instead: function onFoo(<arguments>) { ... }")))
msg.endsWith(QStringLiteral("Both point size and pixel size set. Using pixel size.")))
return;
switch (type) {