fix: make text selectable, limit text input content width and execute actions onEnter

This commit is contained in:
Richard Ramos 2020-06-15 12:24:21 -04:00 committed by Iuri Matias
parent b842925ba4
commit b0a8bc3368
13 changed files with 92 additions and 188 deletions

View File

@ -51,16 +51,18 @@ Rectangle {
TextField { TextField {
id: txtData id: txtData
text: "" text: ""
leftPadding: 0
padding: 0 padding: 0
font.pixelSize: 14 font.pixelSize: 14
placeholderText: qsTr("Type a message...") placeholderText: qsTr("Type a message...")
anchors.right: chatSendBtn.left anchors.right: chatSendBtn.left
anchors.rightMargin: 16 anchors.rightMargin: 16
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: 24 anchors.topMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 24 leftPadding: 24
selectByMouse: true
Keys.onEnterPressed: { Keys.onEnterPressed: {
chatsModel.sendMessage(txtData.text) chatsModel.sendMessage(txtData.text)
txtData.text = "" txtData.text = ""
@ -73,15 +75,6 @@ Rectangle {
color: "#00000000" color: "#00000000"
} }
} }
MouseArea {
id: mouseArea1
anchors.rightMargin: 50
anchors.fill: parent
onClicked: {
txtData.forceActiveFocus(Qt.MouseFocusReason)
}
}
} }
} }
/*##^## /*##^##

View File

@ -10,7 +10,7 @@ import "./ContactsColumn"
Item { Item {
property alias chatGroupsListViewCount: channelList.channelListCount property alias chatGroupsListViewCount: channelList.channelListCount
property alias searchStr: searchBox.searchStr property alias searchStr: searchBox.text
id: contactsColumn id: contactsColumn
width: 300 width: 300
@ -38,9 +38,16 @@ Item {
SearchBox { SearchBox {
id: searchBox id: searchBox
anchors.top: parent.top
anchors.topMargin: 59
anchors.right: addChat.left
anchors.rightMargin: Theme.padding
anchors.left: parent.left
anchors.leftMargin: Theme.padding
} }
AddChat { AddChat {
id: "addChat"
} }
StackLayout { StackLayout {

View File

@ -13,7 +13,6 @@ Item {
ListView { ListView {
id: chatGroupsListView id: chatGroupsListView
anchors.topMargin: 24
anchors.fill: parent anchors.fill: parent
model: chatsModel.chats model: chatsModel.chats
delegate: Channel {} delegate: Channel {}

View File

@ -1,49 +0,0 @@
import QtQuick 2.3
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import Qt.labs.platform 1.1
import "../../../../shared"
import "../../../../imports"
Rectangle {
property alias searchStr: searchText.text
id: searchBox
height: 36
color: Theme.grey
anchors.top: parent.top
anchors.topMargin: 59
radius: 8
anchors.right: parent.right
anchors.rightMargin: 65
anchors.left: parent.left
anchors.leftMargin: 16
TextField {
id: searchText
placeholderText: qsTr("Search")
anchors.left: parent.left
anchors.leftMargin: 32
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 12
background: Rectangle {
color: "#00000000"
}
}
Image {
id: image4
anchors.left: parent.left
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
fillMode: Image.PreserveAspectFit
source: "../../../img/search.svg"
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
searchText.forceActiveFocus(Qt.MouseFocusReason)
}
}
}

View File

@ -1,3 +1,2 @@
EmptyView 1.0 EmptyView.qml EmptyView 1.0 EmptyView.qml
ChannelList 1.0 ChannelList.qml ChannelList 1.0 ChannelList.qml
SearchBox 1.0 SearchBox.qml

View File

@ -6,6 +6,13 @@ import "../../../../shared"
import "./" import "./"
ModalPopup { ModalPopup {
function doJoin(){
if(chatKey.text === "") return;
chatsModel.joinChat(chatKey.text, Constants.chatTypeOneToOne);
popup.close();
}
id: popup id: popup
title: qsTr("New chat") title: qsTr("New chat")
@ -14,39 +21,13 @@ ModalPopup {
chatKey.forceActiveFocus(Qt.MouseFocusReason) chatKey.forceActiveFocus(Qt.MouseFocusReason)
} }
Rectangle { Input {
id: chatKeyBox id: chatKey
height: 44 placeholderText: qsTr("Enter ENS username or chat key")
color: Theme.grey Keys.onEnterPressed: doJoin()
anchors.top: parent.top Keys.onReturnPressed: doJoin()
radius: 8
anchors.right: parent.right
anchors.left: parent.left
TextField {
id: chatKey
placeholderText: qsTr("Enter ENS username or chat key")
anchors.left: parent.left
anchors.leftMargin: 16
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 15
background: Rectangle {
color: "#00000000"
}
width: chatKeyBox.width - 32
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked : {
chatKey.forceActiveFocus(Qt.MouseFocusReason)
}
}
} }
footer: Button { footer: Button {
width: 44 width: 44
height: 44 height: 44
@ -62,11 +43,7 @@ ModalPopup {
id: btnMAnewChat id: btnMAnewChat
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.fill: parent anchors.fill: parent
onClicked : { onClicked : doJoin()
if(chatKey.text === "") return;
chatsModel.joinChat(chatKey.text, Constants.chatTypeOneToOne);
popup.close();
}
} }
} }
} }

View File

@ -7,6 +7,14 @@ import "./"
ModalPopup { ModalPopup {
function doJoin() {
if(channelName.text === "") return;
chatsModel.joinChat(channelName.text, Constants.chatTypePublic);
popup.close();
}
id: popup id: popup
title: qsTr("Join public chat") title: qsTr("Join public chat")
@ -30,45 +38,16 @@ ModalPopup {
} }
} }
Rectangle { Input {
id: channelNameBox id: channelName
height: 44
color: Theme.grey
anchors.top: description.bottom anchors.top: description.bottom
radius: 8 anchors.topMargin: Theme.padding
anchors.right: parent.right placeholderText: qsTr("chat-name")
anchors.left: parent.left Keys.onEnterPressed: doJoin()
Keys.onReturnPressed: doJoin()
TextField { icon: "../../../img/hash.svg"
id: channelName
placeholderText: qsTr("chat-name")
anchors.left: parent.left
anchors.leftMargin: 32
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 15
background: Rectangle {
color: "#00000000"
}
width: channelNameBox.width - 32
}
Image {
id: image4
anchors.left: parent.left
anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter
fillMode: Image.PreserveAspectFit
source: "../../../img/hash.svg"
}
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked : {
channelName.forceActiveFocus(Qt.MouseFocusReason)
}
}
} }
RowLayout { RowLayout {
id: row id: row
@ -78,7 +57,7 @@ ModalPopup {
anchors.rightMargin: 65 anchors.rightMargin: 65
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 65 anchors.leftMargin: 65
anchors.top: channelNameBox.bottom anchors.top: channelName.bottom
anchors.topMargin: 37 anchors.topMargin: 37
Flow { Flow {
@ -120,12 +99,7 @@ ModalPopup {
id: btnMAJoinChat id: btnMAJoinChat
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
anchors.fill: parent anchors.fill: parent
onClicked : { onClicked : doJoin()
if(channelName.text === "") return;
chatsModel.joinChat(channelName.text, Constants.chatTypePublic);
popup.close();
}
}
} }
}
} }

View File

@ -6,6 +6,11 @@ import "../../../../shared"
import "./" import "./"
Popup { Popup {
function doRename(){
chatsModel.renameGroup(groupName.text)
popup.close();
}
id: popup id: popup
modal: true modal: true
@ -42,44 +47,27 @@ Popup {
anchors.bottomMargin: Theme.padding anchors.bottomMargin: Theme.padding
} }
Rectangle { Input {
id: groupNameBox id: groupName
height: 44
color: Theme.grey
anchors.top: groupTitleLabel.bottom anchors.top: groupTitleLabel.bottom
radius: 8 anchors.topMargin: 7
anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: Theme.padding anchors.leftMargin: Theme.padding
anchors.right: parent.right
anchors.rightMargin: Theme.padding anchors.rightMargin: Theme.padding
anchors.topMargin: 7 placeholderText: qsTr("Group Name")
Keys.onEnterPressed: doRename()
TextField { Keys.onReturnPressed: doRename()
id: groupName
placeholderText: qsTr("Group Name")
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 15
background: Rectangle {
color: "#00000000"
}
width: groupNameBox.width - 32
selectByMouse: true
}
} }
StyledButton { StyledButton {
id: saveBtn id: saveBtn
anchors.top: groupNameBox.bottom anchors.top: groupName.bottom
anchors.topMargin: 22 anchors.topMargin: 22
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Theme.padding anchors.rightMargin: Theme.padding
label: qsTr("Save") label: qsTr("Save")
onClicked : { onClicked : doRename()
chatsModel.renameGroup(groupName.text)
popup.close();
}
} }
} }
} }

View File

@ -56,8 +56,9 @@ Item {
SearchBox { SearchBox {
id: searchBox id: searchBox
customHeight: 36
fontPixelSize: 12
anchors.top: modalBody.top anchors.top: modalBody.top
anchors.topMargin: 0
} }
ListView { ListView {
@ -79,7 +80,7 @@ Item {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 10 anchors.leftMargin: 10
width: parent.width width: parent.width
property bool isVisible: searchBox.searchStr == "" || name.toLowerCase().includes(searchBox.searchStr.toLowerCase()) || symbol.toLowerCase().includes(searchBox.searchStr.toLowerCase()) property bool isVisible: searchBox.text == "" || name.toLowerCase().includes(searchBox.text.toLowerCase()) || symbol.toLowerCase().includes(searchBox.text.toLowerCase())
visible: isVisible && symbol !== "" ? true : false visible: isVisible && symbol !== "" ? true : false
height: isVisible && symbol !== "" ? 40 : 0 height: isVisible && symbol !== "" ? 40 : 0

View File

@ -64,7 +64,6 @@ DISTFILES += \
app/AppLayouts/Chat/ContactsColumn/Channel.qml \ app/AppLayouts/Chat/ContactsColumn/Channel.qml \
app/AppLayouts/Chat/ContactsColumn/ChannelList.qml \ app/AppLayouts/Chat/ContactsColumn/ChannelList.qml \
app/AppLayouts/Chat/ContactsColumn/EmptyView.qml \ app/AppLayouts/Chat/ContactsColumn/EmptyView.qml \
app/AppLayouts/Chat/ContactsColumn/SearchBox.qml \
app/AppLayouts/Chat/ContactsColumn/qmldir \ app/AppLayouts/Chat/ContactsColumn/qmldir \
app/AppLayouts/Chat/components/PublicChatPopup.qml \ app/AppLayouts/Chat/components/PublicChatPopup.qml \
app/AppLayouts/Chat/components/PrivateChatPopup.qml \ app/AppLayouts/Chat/components/PrivateChatPopup.qml \
@ -174,6 +173,7 @@ DISTFILES += \
shared/ModalPopup.qml \ shared/ModalPopup.qml \
shared/PopupMenu.qml \ shared/PopupMenu.qml \
shared/RoundImage.qml \ shared/RoundImage.qml \
shared/SearchBox.qml \
shared/Select.qml \ shared/Select.qml \
shared/Separator.qml \ shared/Separator.qml \
shared/StatusTabButton.qml \ shared/StatusTabButton.qml \

View File

@ -14,12 +14,16 @@ Item {
property color bgColor: Theme.grey property color bgColor: Theme.grey
// property url icon: "../app/img/hash.svg" // property url icon: "../app/img/hash.svg"
property url icon: "" property url icon: ""
property int iconHeight: 24
property int iconWidth: 24
readonly property bool hasIcon: icon.toString() !== "" readonly property bool hasIcon: icon.toString() !== ""
readonly property var forceActiveFocus: function () { readonly property var forceActiveFocus: function () {
inputValue.forceActiveFocus(Qt.MouseFocusReason) inputValue.forceActiveFocus(Qt.MouseFocusReason)
} }
readonly property int labelMargin: 7 readonly property int labelMargin: 7
property int customHeight: 44 property int customHeight: 44
property int fontPixelSize: 15
id: inputBox id: inputBox
height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0) height: inputRectangle.height + (hasLabel ? inputLabel.height + labelMargin : 0)
@ -47,16 +51,22 @@ Item {
anchors.topMargin: inputBox.hasLabel ? inputBox.labelMargin : 0 anchors.topMargin: inputBox.hasLabel ? inputBox.labelMargin : 0
anchors.right: parent.right anchors.right: parent.right
anchors.left: parent.left anchors.left: parent.left
TextField { TextField {
id: inputValue id: inputValue
visible: !inputBox.isTextArea && !inputBox.isSelect visible: !inputBox.isTextArea && !inputBox.isSelect
placeholderText: inputBox.placeholderText placeholderText: inputBox.placeholderText
text: inputBox.text text: inputBox.text
anchors.top: parent.top
anchors.topMargin: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
anchors.right: parent.right
anchors.rightMargin: parent.rightMargin
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: inputBox.hasIcon ? 36 : Theme.padding anchors.leftMargin: 0
anchors.verticalCenter: parent.verticalCenter leftPadding: inputBox.hasIcon ? 36 : Theme.padding
font.pixelSize: 15 selectByMouse: true
font.pixelSize: fontPixelSize
background: Rectangle { background: Rectangle {
color: "#00000000" color: "#00000000"
} }
@ -64,8 +74,8 @@ Item {
Image { Image {
id: iconImg id: iconImg
sourceSize.height: 24 sourceSize.height: iconHeight
sourceSize.width: 24 sourceSize.width: iconWidth
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 10 anchors.leftMargin: 10
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -73,14 +83,6 @@ Item {
source: inputBox.icon source: inputBox.icon
} }
} }
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
inputValue.forceActiveFocus(Qt.MouseFocusReason)
}
}
} }
/*##^## /*##^##

12
ui/shared/SearchBox.qml Normal file
View File

@ -0,0 +1,12 @@
import QtQuick 2.3
import "../imports"
Input {
id: searchBox
placeholderText: qsTr("Search")
icon: "../app/img/search.svg"
iconWidth: 17
iconHeight: 17
customHeight: 36
fontPixelSize: 12
}

View File

@ -6,6 +6,7 @@ Separator 1.0 Separator.qml
StatusTabButton 1.0 StatusTabButton.qml StatusTabButton 1.0 StatusTabButton.qml
TextWithLabel 1.0 TextWithLabel.qml TextWithLabel 1.0 TextWithLabel.qml
Input 1.0 Input.qml Input 1.0 Input.qml
SearchBox 1.0 SearchBox.qml
Select 1.0 Select.qml Select 1.0 Select.qml
StyledTextArea 1.0 StyledTextArea.qml StyledTextArea 1.0 StyledTextArea.qml
RoundImage 1.0 RoundImage.qml RoundImage 1.0 RoundImage.qml