From a8b159b98a042d4b1aaf0ef7b15b1770dabb0ef3 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Tue, 16 Oct 2018 08:16:54 +0800 Subject: [PATCH] Use AutoTextField. Fix #81. --- imports/Spectral/Component/AutoTextField.qml | 6 ++++ .../Component/Timeline/MessageDelegate.qml | 24 ++++++++++++---- .../TimelineImage.qml} | 0 .../TimelineLabel.qml} | 2 +- imports/Spectral/Component/qmldir | 4 +-- imports/Spectral/Menu/MessageContextMenu.qml | 10 ------- imports/Spectral/Page/LoginForm.ui.qml | 6 ++-- imports/Spectral/Page/Room.qml | 1 + .../Spectral/Page/SettingAccountDelegate.qml | 9 ++---- imports/Spectral/Panel/RoomDrawer.qml | 8 ++---- .../Spectral/Panel/RoomListPanelForm.ui.qml | 2 +- imports/Spectral/Panel/RoomPanelForm.ui.qml | 2 +- .../RoomPanelInputField.qml} | 0 qml/main.qml | 8 +++--- res.qrc | 28 +++++++++++++++++-- 15 files changed, 67 insertions(+), 43 deletions(-) create mode 100644 imports/Spectral/Component/AutoTextField.qml rename imports/Spectral/Component/{AutoImage.qml => Timeline/TimelineImage.qml} (100%) rename imports/Spectral/Component/{AutoLabel.qml => Timeline/TimelineLabel.qml} (83%) rename imports/Spectral/{Component/AutoTextArea.qml => Panel/RoomPanelInputField.qml} (100%) diff --git a/imports/Spectral/Component/AutoTextField.qml b/imports/Spectral/Component/AutoTextField.qml new file mode 100644 index 0000000..8bd6bac --- /dev/null +++ b/imports/Spectral/Component/AutoTextField.qml @@ -0,0 +1,6 @@ +import QtQuick 2.9 +import QtQuick.Controls 2.2 + +TextField { + selectByMouse: true +} diff --git a/imports/Spectral/Component/Timeline/MessageDelegate.qml b/imports/Spectral/Component/Timeline/MessageDelegate.qml index 70237b3..db6eea7 100644 --- a/imports/Spectral/Component/Timeline/MessageDelegate.qml +++ b/imports/Spectral/Component/Timeline/MessageDelegate.qml @@ -60,7 +60,7 @@ RowLayout { spacing: 0 - AutoLabel { + TimelineLabel { id: authorLabel visible: messageRow.avatarVisible @@ -71,6 +71,7 @@ RowLayout { MouseArea { anchors.fill: parent + cursorShape: Qt.PointingHandCursor onClicked: inputField.insert(inputField.cursorPosition, author.displayName) } } @@ -123,7 +124,7 @@ RowLayout { spacing: 4 - AutoLabel { + TimelineLabel { visible: userMarker.length > 5 text: userMarker.length - 5 + "+" coloredBackground: highlighted @@ -140,10 +141,21 @@ RowLayout { hint: modelData.displayName image: modelData.avatar + + MouseArea { + anchors.fill: parent + + cursorShape: Qt.PointingHandCursor + + onClicked: { + readMarkerDialog.listModel = userMarker + readMarkerDialog.open() + } + } } } - AutoLabel { + TimelineLabel { id: timeLabel visible: Math.abs(time - aboveTime) > 600000 || index == 0 @@ -164,7 +176,7 @@ RowLayout { id: downloadable - AutoImage { + TimelineImage { z: -4 id: messageImage @@ -185,7 +197,7 @@ RowLayout { Component { id: fileComponent - AutoLabel { + TimelineLabel { Layout.fillWidth: true id: downloadDelegate @@ -207,7 +219,7 @@ RowLayout { Component { id: audioComponent - AutoLabel { + TimelineLabel { id: downloadDelegate text: content.info.duration / 1000 + '"' diff --git a/imports/Spectral/Component/AutoImage.qml b/imports/Spectral/Component/Timeline/TimelineImage.qml similarity index 100% rename from imports/Spectral/Component/AutoImage.qml rename to imports/Spectral/Component/Timeline/TimelineImage.qml diff --git a/imports/Spectral/Component/AutoLabel.qml b/imports/Spectral/Component/Timeline/TimelineLabel.qml similarity index 83% rename from imports/Spectral/Component/AutoLabel.qml rename to imports/Spectral/Component/Timeline/TimelineLabel.qml index 4774210..f64751f 100644 --- a/imports/Spectral/Component/AutoLabel.qml +++ b/imports/Spectral/Component/Timeline/TimelineLabel.qml @@ -11,7 +11,7 @@ Label { wrapMode: Label.Wrap linkColor: coloredBackground ? "white" : Material.accent - textFormat: MSettings.richText ? Text.RichText : Text.StyledText + textFormat: Text.RichText onLinkActivated: Qt.openUrlExternally(link) } diff --git a/imports/Spectral/Component/qmldir b/imports/Spectral/Component/qmldir index a9bbe45..e70c3b1 100644 --- a/imports/Spectral/Component/qmldir +++ b/imports/Spectral/Component/qmldir @@ -2,8 +2,6 @@ module Spectral.Component AutoMouseArea 2.0 AutoMouseArea.qml MaterialIcon 2.0 MaterialIcon.qml SideNavButton 2.0 SideNavButton.qml -AutoImage 2.0 AutoImage.qml -AutoLabel 2.0 AutoLabel.qml -AutoTextArea 2.0 AutoTextArea.qml ScrollHelper 2.0 ScrollHelper.qml AutoListView 2.0 AutoListView.qml +AutoTextField 2.0 AutoTextField.qml diff --git a/imports/Spectral/Menu/MessageContextMenu.qml b/imports/Spectral/Menu/MessageContextMenu.qml index b9486c4..277f7bd 100644 --- a/imports/Spectral/Menu/MessageContextMenu.qml +++ b/imports/Spectral/Menu/MessageContextMenu.qml @@ -18,16 +18,6 @@ Menu { sourceDialog.open() } } - MenuItem { - visible: model && model.userMarker.length > 0 - height: visible ? undefined : 0 - text: "View Receipts" - - onTriggered: { - readMarkerDialog.listModel = model.userMarker - readMarkerDialog.open() - } - } MenuItem { visible: isFile height: visible ? undefined : 0 diff --git a/imports/Spectral/Page/LoginForm.ui.qml b/imports/Spectral/Page/LoginForm.ui.qml index 7d5014e..2099ebf 100644 --- a/imports/Spectral/Page/LoginForm.ui.qml +++ b/imports/Spectral/Page/LoginForm.ui.qml @@ -71,7 +71,7 @@ Page { id: mainCol - TextField { + AutoTextField { Layout.fillWidth: true id: serverField @@ -92,7 +92,7 @@ Page { } } - TextField { + AutoTextField { Layout.fillWidth: true id: usernameField @@ -112,7 +112,7 @@ Page { } } - TextField { + AutoTextField { Layout.fillWidth: true id: passwordField diff --git a/imports/Spectral/Page/Room.qml b/imports/Spectral/Page/Room.qml index bd55905..ffdd3a7 100644 --- a/imports/Spectral/Page/Room.qml +++ b/imports/Spectral/Page/Room.qml @@ -2,4 +2,5 @@ import QtQuick 2.9 RoomForm { roomListModel.onNewMessage: if (!window.active) spectralController.showMessage(roomName, content, icon) + roomListModel.onRoomAdded: if (room) room.getPreviousContent(5) } diff --git a/imports/Spectral/Page/SettingAccountDelegate.qml b/imports/Spectral/Page/SettingAccountDelegate.qml index a59b1ee..42d52d3 100644 --- a/imports/Spectral/Page/SettingAccountDelegate.qml +++ b/imports/Spectral/Page/SettingAccountDelegate.qml @@ -83,11 +83,10 @@ Column { Label { text: "Homeserver:" } - TextField { + AutoTextField { Layout.fillWidth: true text: connection.homeserver - selectByMouse: true readOnly: true } } @@ -100,11 +99,10 @@ Column { Label { text: "Device ID:" } - TextField { + AutoTextField { Layout.fillWidth: true text: connection.deviceId - selectByMouse: true readOnly: true } } @@ -117,11 +115,10 @@ Column { Label { text: "Access Token:" } - TextField { + AutoTextField { Layout.fillWidth: true text: connection.accessToken - selectByMouse: true readOnly: true } } diff --git a/imports/Spectral/Panel/RoomDrawer.qml b/imports/Spectral/Panel/RoomDrawer.qml index 26dc036..5136c9c 100644 --- a/imports/Spectral/Panel/RoomDrawer.qml +++ b/imports/Spectral/Panel/RoomDrawer.qml @@ -63,12 +63,11 @@ Drawer { RowLayout { Layout.fillWidth: true - TextField { + AutoTextField { Layout.fillWidth: true id: roomNameField text: room && room.name ? room.name : "" - selectByMouse: true } ItemDelegate { @@ -84,13 +83,12 @@ Drawer { RowLayout { Layout.fillWidth: true - TextField { + AutoTextField { Layout.fillWidth: true id: roomTopicField text: room && room.topic ? room.topic : "" - selectByMouse: true } ItemDelegate { @@ -196,7 +194,7 @@ Drawer { modal: true standardButtons: Dialog.Ok | Dialog.Cancel - contentItem: TextField { + contentItem: AutoTextField { id: inviteUserDialogTextField placeholderText: "@bot:matrix.org" } diff --git a/imports/Spectral/Panel/RoomListPanelForm.ui.qml b/imports/Spectral/Panel/RoomListPanelForm.ui.qml index 60ef9b3..a7a2767 100644 --- a/imports/Spectral/Panel/RoomListPanelForm.ui.qml +++ b/imports/Spectral/Panel/RoomListPanelForm.ui.qml @@ -35,7 +35,7 @@ Rectangle { anchors.fill: parent spacing: 0 - TextField { + AutoTextField { Layout.fillWidth: true Layout.preferredHeight: 40 Layout.margins: 12 diff --git a/imports/Spectral/Panel/RoomPanelForm.ui.qml b/imports/Spectral/Panel/RoomPanelForm.ui.qml index 2256ea0..e1bf3d8 100644 --- a/imports/Spectral/Panel/RoomPanelForm.ui.qml +++ b/imports/Spectral/Panel/RoomPanelForm.ui.qml @@ -312,7 +312,7 @@ Item { clip: true - AutoTextArea { + RoomPanelInputField { id: inputField } } diff --git a/imports/Spectral/Component/AutoTextArea.qml b/imports/Spectral/Panel/RoomPanelInputField.qml similarity index 100% rename from imports/Spectral/Component/AutoTextArea.qml rename to imports/Spectral/Panel/RoomPanelInputField.qml diff --git a/qml/main.qml b/qml/main.qml index 1251aa5..93c8fbb 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -236,14 +236,14 @@ ApplicationWindow { standardButtons: Dialog.Ok | Dialog.Cancel contentItem: Column { - TextField { + AutoTextField { width: parent.width id: addRoomDialogNameTextField placeholderText: "Name" } - TextField { + AutoTextField { width: parent.width id: addRoomDialogTopicTextField @@ -274,7 +274,7 @@ ApplicationWindow { modal: true standardButtons: Dialog.Ok | Dialog.Cancel - contentItem: TextField { + contentItem: AutoTextField { id: joinRoomDialogTextField placeholderText: "#matrix:matrix.org" } @@ -301,7 +301,7 @@ ApplicationWindow { modal: true standardButtons: Dialog.Ok | Dialog.Cancel - contentItem: TextField { + contentItem: AutoTextField { id: directChatDialogTextField placeholderText: "@bot:matrix.org" } diff --git a/res.qrc b/res.qrc index 66b41dd..cdf22d6 100644 --- a/res.qrc +++ b/res.qrc @@ -48,10 +48,32 @@ imports/Spectral/Panel/RoomPanelForm.ui.qml imports/Spectral/Panel/RoomHeader.qml imports/Spectral/Panel/RoomListDelegate.qml - imports/Spectral/Component/AutoImage.qml - imports/Spectral/Component/AutoLabel.qml - imports/Spectral/Component/AutoTextArea.qml imports/Spectral/Component/ScrollHelper.qml imports/Spectral/Component/AutoListView.qml + imports/Spectral/Component/Timeline/TimelineImage.qml + imports/Spectral/Component/Timeline/TimelineLabel.qml + imports/Spectral/Panel/RoomPanelInputField.qml + src/accountlistmodel.cpp + src/accountlistmodel.h + src/controller.cpp + src/controller.h + src/emojimodel.cpp + src/emojimodel.h + src/imageitem.cpp + src/imageitem.h + src/imageprovider.cpp + src/imageprovider.h + src/main.cpp + src/messageeventmodel.cpp + src/messageeventmodel.h + src/roomlistmodel.cpp + src/roomlistmodel.h + src/spectralroom.cpp + src/spectralroom.h + src/spectraluser.cpp + src/spectraluser.h + src/userlistmodel.cpp + src/userlistmodel.h + imports/Spectral/Component/AutoTextField.qml