Display an iteractive icon to search bars for cleaning request.

Add a close button on date time picker to cancel it.
This commit is contained in:
Julien Wadel 2022-08-22 14:04:40 +02:00
parent be933995f3
commit d3d7c667b9
10 changed files with 123 additions and 128 deletions

View file

@ -47,6 +47,7 @@ DialogPlus {
? dateTimeTitle
: timeTitle
: timeTitle
showCloseCross: true
// ---------------------------------------------------------------------------
RowLayout{
anchors.fill: parent

View file

@ -9,123 +9,121 @@ import Common.Styles 1.0
// =============================================================================
Controls.TextField {
id: textField
// ---------------------------------------------------------------------------
property alias icon: icon.icon
property alias iconSize: icon.iconSize
property bool isMandatory: false
property alias overwriteColor: icon.overwriteColor
property string error: ''
property var tools
property QtObject textFieldStyle : TextFieldStyle.normal
property bool showWhenEmpty: true
onTextFieldStyleChanged: if( !textFieldStyle) textFieldStyle = TextFieldStyle.normal
signal iconClicked()
// ---------------------------------------------------------------------------
background: Rectangle {
border {
color: textField.error.length > 0
? textFieldStyle.background.border.color.error
: (
textField.activeFocus && !textField.readOnly
? textFieldStyle.background.border.color.selected
: textFieldStyle.background.border.color.normal
)
width: textFieldStyle.background.border.width
}
color: textField.readOnly
? textFieldStyle.background.color.readOnly
: textFieldStyle.background.color.normal
implicitHeight: textFieldStyle.background.height
implicitWidth: textFieldStyle.background.width
radius: textFieldStyle.background.radius
MouseArea {
anchors.right: parent.right
height: parent.height
cursorShape: Qt.ArrowCursor
implicitWidth: tools ? tools.width : 0
Rectangle {
id: toolsContainer
border {
color: textField.error.length > 0
? textFieldStyle.background.border.color.error
: textFieldStyle.background.border.color.normal
width: textFieldStyle.background.border.width
}
anchors.fill: parent
color: background.color
data: tools || []
}
}
}
color: textField.readOnly ? textFieldStyle.text.readOnly : textFieldStyle.text.normal
font.pointSize: textFieldStyle.text.pointSize
rightPadding: textFieldStyle.text.rightPadding + toolsContainer.width + (icon.visible ? icon.iconSize + 10: 0)
selectByMouse: true
// ---------------------------------------------------------------------------
Icon {
id: icon
anchors {
right: parent.right
rightMargin: 10
verticalCenter: parent.verticalCenter
}
iconSize: parent.contentHeight
visible: showWhenEmpty && !parent.text || !showWhenEmpty && parent.text
Text{
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 5
textFormat: Text.RichText
text : '<span style="color:red">*</span>'
color: textFieldStyle.background.mandatory.color
font.pointSize: textFieldStyle.background.mandatory.pointSize
visible: textField.isMandatory
id: textField
// ---------------------------------------------------------------------------
property alias icon: icon.icon
property alias iconSize: icon.iconSize
property bool isMandatory: false
property alias overwriteColor: icon.overwriteColor
property string error: ''
property var tools
property QtObject textFieldStyle : TextFieldStyle.normal
onTextFieldStyleChanged: if( !textFieldStyle) textFieldStyle = TextFieldStyle.normal
// ---------------------------------------------------------------------------
background: Rectangle {
border {
color: textField.error.length > 0
? textFieldStyle.background.border.color.error
: (
textField.activeFocus && !textField.readOnly
? textFieldStyle.background.border.color.selected
: textFieldStyle.background.border.color.normal
)
width: textFieldStyle.background.border.width
}
color: textField.readOnly
? textFieldStyle.background.color.readOnly
: textFieldStyle.background.color.normal
implicitHeight: textFieldStyle.background.height
implicitWidth: textFieldStyle.background.width
radius: textFieldStyle.background.radius
MouseArea {
anchors.right: parent.right
height: parent.height
cursorShape: Qt.ArrowCursor
implicitWidth: tools ? tools.width : 0
Rectangle {
id: toolsContainer
border {
color: textField.error.length > 0
? textFieldStyle.background.border.color.error
: textFieldStyle.background.border.color.normal
width: textFieldStyle.background.border.width
}
anchors.fill: parent
color: background.color
data: tools || []
}
}
}
color: textField.readOnly ? textFieldStyle.text.readOnly : textFieldStyle.text.normal
font.pointSize: textFieldStyle.text.pointSize
rightPadding: textFieldStyle.text.rightPadding + toolsContainer.width + (icon.visible ? icon.iconSize + 10: 0)
selectByMouse: true
// ---------------------------------------------------------------------------
Icon {
id: icon
anchors {
right: parent.right
rightMargin: 10
verticalCenter: parent.verticalCenter
}
iconSize: parent.contentHeight
visible: icon.icon != ''
Text{
anchors.right: parent.right
anchors.top: parent.top
anchors.topMargin: 5
textFormat: Text.RichText
text : '<span style="color:red">*</span>'
color: textFieldStyle.background.mandatory.color
font.pointSize: textFieldStyle.background.mandatory.pointSize
visible: textField.isMandatory
}
MouseArea{
anchors.fill: parent
onClicked: textField.text = ''
}
}
bottomPadding: (statusItem.visible?statusItem.implicitHeight:2)
TextEdit{
id:statusItem
selectByMouse: true
readOnly:true
color: textFieldStyle.background.border.color.error
width:parent.width
anchors.bottom:parent.bottom
anchors.bottomMargin: 2
anchors.right:parent.right
anchors.rightMargin:10 + toolsContainer.width
horizontalAlignment:Text.AlignRight
verticalAlignment: Text.AlignVCenter
wrapMode: TextEdit.WordWrap
font {
italic: true
pointSize: textFieldStyle.text.pointSize
}
visible:error!= ''
text:error
}
MouseArea{
anchors.fill: parent
onClicked: textField.iconClicked()
}
}
bottomPadding: (statusItem.visible?statusItem.implicitHeight:2)
TextEdit{
id:statusItem
selectByMouse: true
readOnly:true
color: textFieldStyle.background.border.color.error
width:parent.width
anchors.bottom:parent.bottom
anchors.bottomMargin: 2
anchors.right:parent.right
anchors.rightMargin:10 + toolsContainer.width
horizontalAlignment:Text.AlignRight
verticalAlignment: Text.AlignVCenter
wrapMode: TextEdit.WordWrap
font {
italic: true
pointSize: textFieldStyle.text.pointSize
}
visible:error!= ''
text:error
}
Keys.onPressed:{
if( event.key == Qt.Key_Escape)
focus = false

View file

@ -76,7 +76,7 @@ Item {
TextField {
id: searchField
icon: 'search_custom'
icon: text == '' ? SearchBoxStyle.searchIcon : SearchBoxStyle.cancelIcon
overwriteColor: SearchBoxStyle.iconColor
iconSize: height
readOnly: !searchBox.enabled

View file

@ -8,4 +8,6 @@ QtObject {
property string sectionName: 'SearchBox'
property color shadowColor: ColorsList.add(sectionName+'_shadow', 'l').color
property color iconColor: ColorsList.add(sectionName+'_icon', 'c').color
property string searchIcon: 'search_custom'
property string cancelIcon: 'close_custom'
}

View file

@ -333,7 +333,7 @@ Rectangle {
anchors.topMargin: 5
anchors.bottomMargin: 5
width: parent.width - 14
icon: 'search_custom'
icon: text == '' ? 'search_custom' : 'close_custom'
iconSize: 30
overwriteColor: TimelineStyle.searchField.color
//: 'Search in the list' : ths is a placeholder when searching something in the timeline list

View file

@ -46,7 +46,7 @@ DialogPlus {
Layout.fillWidth: true
icon: 'search_custom'
icon: text == '' ? 'search_custom' : 'close_custom'
overwriteColor: CallSipAddressStyle.searchField.color
onTextChanged: sipAddressesModel.setFilter(text)

View file

@ -68,7 +68,7 @@ DialogPlus {
Layout.fillWidth: true
icon: 'search_custom'
icon: text == '' ? 'search_custom' : 'close_custom'
overwriteColor: CallTransferStyle.searchField.color
onTextChanged: sipAddressesModel.setFilter(text)

View file

@ -78,7 +78,7 @@ DialogPlus {
Layout.fillWidth: true
icon: 'search_custom'
icon: text == '' ? 'search_custom' : 'close_custom'
overwriteColor: ConferenceManagerStyle.searchField.color
onTextChanged: conferenceHelperModel.setFilter(text)

View file

@ -306,7 +306,6 @@ DialogPlus {
}
text: conferenceManager.conferenceInfoModel ? conferenceManager.conferenceInfoModel.dateTime.toLocaleDateString(scheduleForm.locale, Qt.ISODate) : ''
icon: 'drop_down_custom'
showWhenEmpty: false
MouseArea{
anchors.fill: parent
onClicked: {
@ -331,7 +330,6 @@ DialogPlus {
text: conferenceManager.conferenceInfoModel? conferenceManager.conferenceInfoModel.dateTime.toLocaleTimeString(scheduleForm.locale, 'hh:mm') : ''
icon: 'drop_down_custom'
showWhenEmpty: false
onEditingFinished: if(rightStackView.currentItemType === 2) {
rightStackView.currentItemType = 0
rightStackView.pop()

View file

@ -575,16 +575,12 @@ ColumnLayout {
margins: 0
}
width: parent.width-14
icon: 'close_custom'
icon: text != '' ? 'close_custom' : 'search_custom'
overwriteColor: ConversationStyle.filters.iconColor
showWhenEmpty: false
//: 'Search in messages' : this is a placeholder when searching something in the timeline list
placeholderText: qsTr('searchMessagesPlaceholder')
onTextChanged: searchDelay.restart()
onIconClicked: {
searchView.text = ''
}
font.pointSize: ConversationStyle.filters.pointSize
Timer{