Port to explicit connect syntax

Also fix a lot of warnings.
pull/662/head
Nicolas Werner 3 years ago
parent 6222ae88ce
commit d955444dc1
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 1
      resources/qml/ChatPage.qml
  2. 6
      resources/qml/ForwardCompleter.qml
  3. 4
      resources/qml/MatrixText.qml
  4. 35
      resources/qml/MessageInput.qml
  5. 26
      resources/qml/MessageView.qml
  6. 5
      resources/qml/PrivacyScreen.qml
  7. 6
      resources/qml/QuickSwitcher.qml
  8. 7
      resources/qml/RoomList.qml
  9. 43
      resources/qml/Root.qml
  10. 5
      resources/qml/UserProfile.qml
  11. 5
      resources/qml/delegates/PlayableMediaMessage.qml
  12. 5
      resources/qml/voip/CallInvite.qml
  13. 10
      src/Logging.cpp

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

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

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

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

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

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

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

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

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

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

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

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

@ -30,19 +30,11 @@ qmlMessageHandler(QtMsgType type, const QMessageLogContext &context, const QStri
const char *function = context.function ? context.function : ""; const char *function = context.function ? context.function : "";
if ( 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 // 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 // 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 // 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! // 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.")) || 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>) { ... }")))
return; return;
switch (type) { switch (type) {

Loading…
Cancel
Save