mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-22 22:28:08 +00:00
feat(ui/views/App/MainWindow/ContactEdit): use a custom transparent text input
This commit is contained in:
parent
93c88e8a09
commit
30c2c8cd12
12 changed files with 78 additions and 55 deletions
|
|
@ -141,9 +141,9 @@
|
|||
<file>ui/modules/Common/Form/SmallButton.qml</file>
|
||||
<file>ui/modules/Common/Form/TextButtonA.qml</file>
|
||||
<file>ui/modules/Common/Form/TextButtonB.qml</file>
|
||||
<file>ui/modules/Common/Form/TextEdit.qml</file>
|
||||
<file>ui/modules/Common/Form/TextField.qml</file>
|
||||
<file>ui/modules/Common/Form/TransparentComboBox.qml</file>
|
||||
<file>ui/modules/Common/Form/TransparentTextInput.qml</file>
|
||||
<file>ui/modules/Common/Image/Icon.qml</file>
|
||||
<file>ui/modules/Common/Image/RoundedImage.qml</file>
|
||||
<file>ui/modules/Common/InvertedMouseArea.qml</file>
|
||||
|
|
@ -171,9 +171,9 @@
|
|||
<file>ui/modules/Common/Styles/Form/SmallButtonStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Form/TextButtonAStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Form/TextButtonBStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Form/TextEditStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Form/TextFieldStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Form/TransparentComboBoxStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Form/TransparentTextInputStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Menu/ActionMenuStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/Menu/MenuStyle.qml</file>
|
||||
<file>ui/modules/Common/Styles/PanedStyle.qml</file>
|
||||
|
|
|
|||
|
|
@ -109,14 +109,14 @@ RowLayout {
|
|||
visible: model.count > 0
|
||||
|
||||
delegate: Item {
|
||||
implicitHeight: textEdit.height
|
||||
implicitHeight: textInput.height
|
||||
width: parent.width
|
||||
|
||||
TextEdit {
|
||||
id: textEdit
|
||||
TransparentTextInput {
|
||||
id: textInput
|
||||
|
||||
text: $value
|
||||
width: 300
|
||||
width: parent.width
|
||||
height: ListFormStyle.lineHeight
|
||||
|
||||
onEditingFinished: _handleEditionFinished(index, text)
|
||||
|
|
@ -131,7 +131,7 @@ RowLayout {
|
|||
// So, I choose to run a callback executed after this
|
||||
// internal event.
|
||||
Utils.setTimeout(listForm, 0, function () {
|
||||
textEdit.forceActiveFocus()
|
||||
textInput.forceActiveFocus()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ Item {
|
|||
Rectangle {
|
||||
anchors.fill: flick
|
||||
color: textEdit.activeFocus && !textEdit.readOnly
|
||||
? TextEditStyle.backgroundColor.focused
|
||||
: TextEditStyle.backgroundColor.normal
|
||||
? TransparentTextInputStyle.backgroundColor.focused
|
||||
: 'transparent'
|
||||
|
||||
InvertedMouseArea {
|
||||
anchors.fill: parent
|
||||
|
|
@ -64,8 +64,8 @@ Item {
|
|||
id: textEdit
|
||||
|
||||
color: activeFocus && !readOnly
|
||||
? TextEditStyle.textColor.focused
|
||||
: TextEditStyle.textColor.normal
|
||||
? TransparentTextInputStyle.textColor.focused
|
||||
: TransparentTextInputStyle.textColor.normal
|
||||
selectByMouse: true
|
||||
width: flick.width
|
||||
wrapMode: Text.Wrap
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
import QtQuick 2.7
|
||||
|
||||
import Common 1.0
|
||||
import Common.Styles 1.0
|
||||
|
||||
// ===================================================================
|
||||
|
||||
TextInput {
|
||||
id: textEdit
|
||||
|
||||
clip: true
|
||||
color: activeFocus && !readOnly
|
||||
? TextEditStyle.textColor.focused
|
||||
: TextEditStyle.textColor.normal
|
||||
padding: ListFormStyle.value.text.padding
|
||||
selectByMouse: true
|
||||
verticalAlignment: TextEdit.AlignVCenter
|
||||
|
||||
Keys.onEscapePressed: focus = false
|
||||
Keys.onReturnPressed: focus = false
|
||||
|
||||
InvertedMouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: textEdit.activeFocus
|
||||
onPressed: textEdit.focus = false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: textEdit
|
||||
color: textEdit.activeFocus && !readOnly
|
||||
? TextEditStyle.backgroundColor.focused
|
||||
: TextEditStyle.backgroundColor.normal
|
||||
z: -1
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ import QtQuick.Controls 2.0 as Controls
|
|||
import Common 1.0
|
||||
import Common.Styles 1.0
|
||||
|
||||
// ===================================================================
|
||||
// A classic TextInput which supports an icon attribute.
|
||||
// ===================================================================
|
||||
|
||||
Controls.TextField {
|
||||
|
|
|
|||
57
tests/ui/modules/Common/Form/TransparentTextInput.qml
Normal file
57
tests/ui/modules/Common/Form/TransparentTextInput.qml
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
import QtQuick 2.7
|
||||
|
||||
import Common 1.0
|
||||
import Common.Styles 1.0
|
||||
|
||||
// ===================================================================
|
||||
|
||||
Item {
|
||||
property alias color: textInput.color
|
||||
property alias font: textInput.font
|
||||
property alias readOnly: textInput.readOnly
|
||||
property alias text: textInput.text
|
||||
property int padding: TransparentTextInputStyle.padding
|
||||
|
||||
signal editingFinished
|
||||
|
||||
// -----------------------------------------------------------------
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: textInput.activeFocus && !readOnly
|
||||
? TransparentTextInputStyle.backgroundColor
|
||||
: // No Style constant, see component name.
|
||||
// It's a `transparent` TextInput.
|
||||
'transparent'
|
||||
z: -1
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: textInput
|
||||
|
||||
anchors.centerIn: parent
|
||||
height: parent.height - parent.padding * 2
|
||||
width: parent.width - parent.padding * 2
|
||||
|
||||
clip: true
|
||||
color: activeFocus && !readOnly
|
||||
? TransparentTextInputStyle.textColor.focused
|
||||
: TransparentTextInputStyle.textColor.normal
|
||||
selectByMouse: true
|
||||
verticalAlignment: TextInput.AlignVCenter
|
||||
|
||||
Keys.onEscapePressed: focus = false
|
||||
Keys.onReturnPressed: focus = false
|
||||
|
||||
onEditingFinished: {
|
||||
cursorPosition = 0
|
||||
parent.editingFinished()
|
||||
}
|
||||
|
||||
InvertedMouseArea {
|
||||
anchors.fill: parent
|
||||
enabled: textInput.activeFocus
|
||||
onPressed: textInput.focus = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,7 +6,7 @@ import Common 1.0
|
|||
// ===================================================================
|
||||
|
||||
QtObject {
|
||||
property int lineHeight: 30
|
||||
property int lineHeight: 35
|
||||
|
||||
property QtObject value: QtObject {
|
||||
property QtObject placeholder: QtObject {
|
||||
|
|
|
|||
|
|
@ -6,13 +6,11 @@ import Common 1.0
|
|||
// ===================================================================
|
||||
|
||||
QtObject {
|
||||
property QtObject backgroundColor: QtObject {
|
||||
property color focused: Colors.q
|
||||
property color normal: Colors.a
|
||||
}
|
||||
property color backgroundColor: Colors.q
|
||||
property int padding: 10
|
||||
|
||||
property QtObject textColor: QtObject {
|
||||
property color focused: Colors.l
|
||||
property color focused: Colors.l
|
||||
property color normal: Colors.r
|
||||
}
|
||||
}
|
||||
|
|
@ -22,9 +22,9 @@ singleton ListFormStyle 1.0 Form/ListFormStyle.qml
|
|||
singleton SmallButtonStyle 1.0 Form/SmallButtonStyle.qml
|
||||
singleton TextButtonAStyle 1.0 Form/TextButtonAStyle.qml
|
||||
singleton TextButtonBStyle 1.0 Form/TextButtonBStyle.qml
|
||||
singleton TextEditStyle 1.0 Form/TextEditStyle.qml
|
||||
singleton TextFieldStyle 1.0 Form/TextFieldStyle.qml
|
||||
singleton TransparentComboBoxStyle 1.0 Form/TransparentComboBoxStyle.qml
|
||||
singleton TransparentTextInputStyle 1.0 Form/TransparentTextInputStyle.qml
|
||||
|
||||
singleton ActionMenuStyle 1.0 Menu/ActionMenuStyle.qml
|
||||
singleton MenuStyle 1.0 Menu/MenuStyle.qml
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ ListForm 1.0 Form/ListForm.qml
|
|||
ScrollableTextEdit 1.0 Form/ScrollableTextEdit.qml
|
||||
TextButtonA 1.0 Form/TextButtonA.qml
|
||||
TextButtonB 1.0 Form/TextButtonB.qml
|
||||
TextEdit 1.0 Form/TextEdit.qml
|
||||
TextField 1.0 Form/TextField.qml
|
||||
TransparentComboBox 1.0 Form/TransparentComboBox.qml
|
||||
TransparentTextInput 1.0 Form/TransparentTextInput.qml
|
||||
|
||||
# Image
|
||||
Icon 1.0 Image/Icon.qml
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ Item {
|
|||
// See http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop
|
||||
// and http://doc.qt.io/qt-5/richtext-html-subset.html
|
||||
textFormat: Text.RichText // To supports links and imgs.
|
||||
wrapMode: TextEdit.Wrap
|
||||
|
||||
onHoveredLinkChanged: _handleHoveredLink(hoveredLink)
|
||||
onLinkActivated: Qt.openUrlExternally(link)
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ ColumnLayout {
|
|||
}
|
||||
}
|
||||
|
||||
ScrollableTextEdit {
|
||||
TransparentTextInput {
|
||||
id: editUsername
|
||||
|
||||
Layout.fillWidth: true
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue