summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2021-07-27 22:35:38 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2021-07-27 22:35:38 +0200
commitd955444dc18b2977d8b22e87b92c85bca90a623e (patch)
tree22086804e4d01f85583fc46f72350317ee626849
parentFix crash on invalid utf8 in decrypted events (diff)
downloadnheko-d955444dc18b2977d8b22e87b92c85bca90a623e.tar.xz
Port to explicit connect syntax
Also fix a lot of warnings.
-rw-r--r--resources/qml/ChatPage.qml1
-rw-r--r--resources/qml/ForwardCompleter.qml6
-rw-r--r--resources/qml/MatrixText.qml4
-rw-r--r--resources/qml/MessageInput.qml35
-rw-r--r--resources/qml/MessageView.qml26
-rw-r--r--resources/qml/PrivacyScreen.qml5
-rw-r--r--resources/qml/QuickSwitcher.qml6
-rw-r--r--resources/qml/RoomList.qml7
-rw-r--r--resources/qml/Root.qml43
-rw-r--r--resources/qml/UserProfile.qml5
-rw-r--r--resources/qml/delegates/PlayableMediaMessage.qml5
-rw-r--r--resources/qml/voip/CallInvite.qml5
-rw-r--r--src/Logging.cpp10
13 files changed, 96 insertions, 62 deletions
diff --git a/resources/qml/ChatPage.qml b/resources/qml/ChatPage.qml
index ae37187b..e56d7d46 100644
--- a/resources/qml/ChatPage.qml
+++ b/resources/qml/ChatPage.qml
@@ -56,6 +56,7 @@ Rectangle {
             RoomList {
                 id: roomlist
 
+                implicitHeight: chatPage.height
                 collapsed: parent.collapsed
             }
 
diff --git a/resources/qml/ForwardCompleter.qml b/resources/qml/ForwardCompleter.qml
index 127b59c2..525477cd 100644
--- a/resources/qml/ForwardCompleter.qml
+++ b/resources/qml/ForwardCompleter.qml
@@ -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
     }
 
diff --git a/resources/qml/MatrixText.qml b/resources/qml/MatrixText.qml
index 35e5f7e7..7253cbe6 100644
--- a/resources/qml/MatrixText.qml
+++ b/resources/qml/MatrixText.qml
@@ -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);
     }
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml
index 58d71a4e..8bc8ac62 100644
--- a/resources/qml/MessageInput.qml
+++ b/resources/qml/MessageInput.qml
@@ -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 {
diff --git a/resources/qml/MessageView.qml b/resources/qml/MessageView.qml
index 50cbd371..07feec8c 100644
--- a/resources/qml/MessageView.qml
+++ b/resources/qml/MessageView.qml
@@ -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
             }
 
         }
diff --git a/resources/qml/PrivacyScreen.qml b/resources/qml/PrivacyScreen.qml
index ca73cfd7..5f18a1ce 100644
--- a/resources/qml/PrivacyScreen.qml
+++ b/resources/qml/PrivacyScreen.qml
@@ -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 {
diff --git a/resources/qml/QuickSwitcher.qml b/resources/qml/QuickSwitcher.qml
index 8c4f47ca..61155acf 100644
--- a/resources/qml/QuickSwitcher.qml
+++ b/resources/qml/QuickSwitcher.qml
@@ -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
     }
 
diff --git a/resources/qml/RoomList.qml b/resources/qml/RoomList.qml
index 2be5fe92..a2e50fab 100644
--- a/resources/qml/RoomList.qml
+++ b/resources/qml/RoomList.qml
@@ -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
             }
diff --git a/resources/qml/Root.qml b/resources/qml/Root.qml
index 1793d9bc..e80ff764 100644
--- a/resources/qml/Root.qml
+++ b/resources/qml/Root.qml
@@ -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 {
diff --git a/resources/qml/UserProfile.qml b/resources/qml/UserProfile.qml
index 826d3165..d138060b 100644
--- a/resources/qml/UserProfile.qml
+++ b/resources/qml/UserProfile.qml
@@ -83,12 +83,13 @@ ApplicationWindow {
         }
 
         Connections {
-            target: profile
-            onDisplayError: {
+            function onDisplayError(errorMessage) {
                 errorText.text = errorMessage;
                 errorText.opacity = 1;
                 hideErrorAnimation.restart();
             }
+
+            target: profile
         }
 
         TextInput {
diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml
index fd764d52..73c74ec0 100644
--- a/resources/qml/delegates/PlayableMediaMessage.qml
+++ b/resources/qml/delegates/PlayableMediaMessage.qml
@@ -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
                 }
 
             }
diff --git a/resources/qml/voip/CallInvite.qml b/resources/qml/voip/CallInvite.qml
index 1b57976d..253fa25c 100644
--- a/resources/qml/voip/CallInvite.qml
+++ b/resources/qml/voip/CallInvite.qml
@@ -23,12 +23,13 @@ Popup {
     }
 
     Connections {
-        target: CallManager
-        onNewInviteState: {
+        function onNewInviteState() {
             if (!CallManager.haveCallInvite)
                 close();
 
         }
+
+        target: CallManager
     }
 
     ColumnLayout {
diff --git a/src/Logging.cpp b/src/Logging.cpp
index 642e8957..67bcaf7a 100644
--- a/src/Logging.cpp
+++ b/src/Logging.cpp
@@ -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) {