Use AutoTextField.

Fix #81.
This commit is contained in:
Black Hat 2018-10-16 08:16:54 +08:00
parent bead3ed36b
commit a8b159b98a
15 changed files with 67 additions and 43 deletions

View File

@ -0,0 +1,6 @@
import QtQuick 2.9
import QtQuick.Controls 2.2
TextField {
selectByMouse: true
}

View File

@ -60,7 +60,7 @@ RowLayout {
spacing: 0 spacing: 0
AutoLabel { TimelineLabel {
id: authorLabel id: authorLabel
visible: messageRow.avatarVisible visible: messageRow.avatarVisible
@ -71,6 +71,7 @@ RowLayout {
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: inputField.insert(inputField.cursorPosition, author.displayName) onClicked: inputField.insert(inputField.cursorPosition, author.displayName)
} }
} }
@ -123,7 +124,7 @@ RowLayout {
spacing: 4 spacing: 4
AutoLabel { TimelineLabel {
visible: userMarker.length > 5 visible: userMarker.length > 5
text: userMarker.length - 5 + "+" text: userMarker.length - 5 + "+"
coloredBackground: highlighted coloredBackground: highlighted
@ -140,10 +141,21 @@ RowLayout {
hint: modelData.displayName hint: modelData.displayName
image: modelData.avatar image: modelData.avatar
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: {
readMarkerDialog.listModel = userMarker
readMarkerDialog.open()
}
}
} }
} }
AutoLabel { TimelineLabel {
id: timeLabel id: timeLabel
visible: Math.abs(time - aboveTime) > 600000 || index == 0 visible: Math.abs(time - aboveTime) > 600000 || index == 0
@ -164,7 +176,7 @@ RowLayout {
id: downloadable id: downloadable
AutoImage { TimelineImage {
z: -4 z: -4
id: messageImage id: messageImage
@ -185,7 +197,7 @@ RowLayout {
Component { Component {
id: fileComponent id: fileComponent
AutoLabel { TimelineLabel {
Layout.fillWidth: true Layout.fillWidth: true
id: downloadDelegate id: downloadDelegate
@ -207,7 +219,7 @@ RowLayout {
Component { Component {
id: audioComponent id: audioComponent
AutoLabel { TimelineLabel {
id: downloadDelegate id: downloadDelegate
text: content.info.duration / 1000 + '"' text: content.info.duration / 1000 + '"'

View File

@ -11,7 +11,7 @@ Label {
wrapMode: Label.Wrap wrapMode: Label.Wrap
linkColor: coloredBackground ? "white" : Material.accent linkColor: coloredBackground ? "white" : Material.accent
textFormat: MSettings.richText ? Text.RichText : Text.StyledText textFormat: Text.RichText
onLinkActivated: Qt.openUrlExternally(link) onLinkActivated: Qt.openUrlExternally(link)
} }

View File

@ -2,8 +2,6 @@ module Spectral.Component
AutoMouseArea 2.0 AutoMouseArea.qml AutoMouseArea 2.0 AutoMouseArea.qml
MaterialIcon 2.0 MaterialIcon.qml MaterialIcon 2.0 MaterialIcon.qml
SideNavButton 2.0 SideNavButton.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 ScrollHelper 2.0 ScrollHelper.qml
AutoListView 2.0 AutoListView.qml AutoListView 2.0 AutoListView.qml
AutoTextField 2.0 AutoTextField.qml

View File

@ -18,16 +18,6 @@ Menu {
sourceDialog.open() sourceDialog.open()
} }
} }
MenuItem {
visible: model && model.userMarker.length > 0
height: visible ? undefined : 0
text: "View Receipts"
onTriggered: {
readMarkerDialog.listModel = model.userMarker
readMarkerDialog.open()
}
}
MenuItem { MenuItem {
visible: isFile visible: isFile
height: visible ? undefined : 0 height: visible ? undefined : 0

View File

@ -71,7 +71,7 @@ Page {
id: mainCol id: mainCol
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
id: serverField id: serverField
@ -92,7 +92,7 @@ Page {
} }
} }
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
id: usernameField id: usernameField
@ -112,7 +112,7 @@ Page {
} }
} }
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
id: passwordField id: passwordField

View File

@ -2,4 +2,5 @@ import QtQuick 2.9
RoomForm { RoomForm {
roomListModel.onNewMessage: if (!window.active) spectralController.showMessage(roomName, content, icon) roomListModel.onNewMessage: if (!window.active) spectralController.showMessage(roomName, content, icon)
roomListModel.onRoomAdded: if (room) room.getPreviousContent(5)
} }

View File

@ -83,11 +83,10 @@ Column {
Label { Label {
text: "Homeserver:" text: "Homeserver:"
} }
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
text: connection.homeserver text: connection.homeserver
selectByMouse: true
readOnly: true readOnly: true
} }
} }
@ -100,11 +99,10 @@ Column {
Label { Label {
text: "Device ID:" text: "Device ID:"
} }
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
text: connection.deviceId text: connection.deviceId
selectByMouse: true
readOnly: true readOnly: true
} }
} }
@ -117,11 +115,10 @@ Column {
Label { Label {
text: "Access Token:" text: "Access Token:"
} }
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
text: connection.accessToken text: connection.accessToken
selectByMouse: true
readOnly: true readOnly: true
} }
} }

View File

@ -63,12 +63,11 @@ Drawer {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
id: roomNameField id: roomNameField
text: room && room.name ? room.name : "" text: room && room.name ? room.name : ""
selectByMouse: true
} }
ItemDelegate { ItemDelegate {
@ -84,13 +83,12 @@ Drawer {
RowLayout { RowLayout {
Layout.fillWidth: true Layout.fillWidth: true
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
id: roomTopicField id: roomTopicField
text: room && room.topic ? room.topic : "" text: room && room.topic ? room.topic : ""
selectByMouse: true
} }
ItemDelegate { ItemDelegate {
@ -196,7 +194,7 @@ Drawer {
modal: true modal: true
standardButtons: Dialog.Ok | Dialog.Cancel standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: TextField { contentItem: AutoTextField {
id: inviteUserDialogTextField id: inviteUserDialogTextField
placeholderText: "@bot:matrix.org" placeholderText: "@bot:matrix.org"
} }

View File

@ -35,7 +35,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
spacing: 0 spacing: 0
TextField { AutoTextField {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 40 Layout.preferredHeight: 40
Layout.margins: 12 Layout.margins: 12

View File

@ -312,7 +312,7 @@ Item {
clip: true clip: true
AutoTextArea { RoomPanelInputField {
id: inputField id: inputField
} }
} }

View File

@ -236,14 +236,14 @@ ApplicationWindow {
standardButtons: Dialog.Ok | Dialog.Cancel standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: Column { contentItem: Column {
TextField { AutoTextField {
width: parent.width width: parent.width
id: addRoomDialogNameTextField id: addRoomDialogNameTextField
placeholderText: "Name" placeholderText: "Name"
} }
TextField { AutoTextField {
width: parent.width width: parent.width
id: addRoomDialogTopicTextField id: addRoomDialogTopicTextField
@ -274,7 +274,7 @@ ApplicationWindow {
modal: true modal: true
standardButtons: Dialog.Ok | Dialog.Cancel standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: TextField { contentItem: AutoTextField {
id: joinRoomDialogTextField id: joinRoomDialogTextField
placeholderText: "#matrix:matrix.org" placeholderText: "#matrix:matrix.org"
} }
@ -301,7 +301,7 @@ ApplicationWindow {
modal: true modal: true
standardButtons: Dialog.Ok | Dialog.Cancel standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: TextField { contentItem: AutoTextField {
id: directChatDialogTextField id: directChatDialogTextField
placeholderText: "@bot:matrix.org" placeholderText: "@bot:matrix.org"
} }

28
res.qrc
View File

@ -48,10 +48,32 @@
<file>imports/Spectral/Panel/RoomPanelForm.ui.qml</file> <file>imports/Spectral/Panel/RoomPanelForm.ui.qml</file>
<file>imports/Spectral/Panel/RoomHeader.qml</file> <file>imports/Spectral/Panel/RoomHeader.qml</file>
<file>imports/Spectral/Panel/RoomListDelegate.qml</file> <file>imports/Spectral/Panel/RoomListDelegate.qml</file>
<file>imports/Spectral/Component/AutoImage.qml</file>
<file>imports/Spectral/Component/AutoLabel.qml</file>
<file>imports/Spectral/Component/AutoTextArea.qml</file>
<file>imports/Spectral/Component/ScrollHelper.qml</file> <file>imports/Spectral/Component/ScrollHelper.qml</file>
<file>imports/Spectral/Component/AutoListView.qml</file> <file>imports/Spectral/Component/AutoListView.qml</file>
<file>imports/Spectral/Component/Timeline/TimelineImage.qml</file>
<file>imports/Spectral/Component/Timeline/TimelineLabel.qml</file>
<file>imports/Spectral/Panel/RoomPanelInputField.qml</file>
<file>src/accountlistmodel.cpp</file>
<file>src/accountlistmodel.h</file>
<file>src/controller.cpp</file>
<file>src/controller.h</file>
<file>src/emojimodel.cpp</file>
<file>src/emojimodel.h</file>
<file>src/imageitem.cpp</file>
<file>src/imageitem.h</file>
<file>src/imageprovider.cpp</file>
<file>src/imageprovider.h</file>
<file>src/main.cpp</file>
<file>src/messageeventmodel.cpp</file>
<file>src/messageeventmodel.h</file>
<file>src/roomlistmodel.cpp</file>
<file>src/roomlistmodel.h</file>
<file>src/spectralroom.cpp</file>
<file>src/spectralroom.h</file>
<file>src/spectraluser.cpp</file>
<file>src/spectraluser.h</file>
<file>src/userlistmodel.cpp</file>
<file>src/userlistmodel.h</file>
<file>imports/Spectral/Component/AutoTextField.qml</file>
</qresource> </qresource>
</RCC> </RCC>