From a944bf020b096e687e890440f264a4b0d58a9d95 Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Wed, 3 Jan 2018 16:35:51 +0100 Subject: [PATCH] Filter refactoring --- qml/pages/PageContactList.qml | 60 ++++++++++++++++++------------- qml/pages/PageDataboxSearch.qml | 62 ++++++++++++++++++-------------- qml/pages/PageMessageList.qml | 64 +++++++++++++++++++-------------- 3 files changed, 109 insertions(+), 77 deletions(-) diff --git a/qml/pages/PageContactList.qml b/qml/pages/PageContactList.qml index 59d64e81..7e981b66 100644 --- a/qml/pages/PageContactList.qml +++ b/qml/pages/PageContactList.qml @@ -95,40 +95,49 @@ Item { MouseArea { anchors.fill: parent onClicked: { - databoxList.anchors.top = filter.bottom - filter.visible = true + databoxList.anchors.top = filterBar.bottom + filterBar.visible = true filter.forceActiveFocus() + Qt.inputMethod.show() } } } } } // PageHeader - TextField { - id: filter + Rectangle { + id: filterBar visible: false z: 1 anchors.top: headerBar.bottom width: parent.width - placeholderText: qsTr("Set filter") - font.pointSize: defaultTextFont.font.pointSize - inputMethodHints: Qt.ImhNoPredictiveText - /* - * Using explicit top, left, ... padding because plain padding - * does not centre the text properly. - */ - topPadding: 8.0 - bottomPadding: 8.0 - leftPadding: 8.0 - rightPadding: 8.0 - /* TODO - remove background if used materials */ - background: Rectangle { - anchors.fill: parent - color: (filter.text.length == 0) ? datovkaPalette.alternateBase : + height: filter.height + color: (filter.text.length == 0) ? datovkaPalette.alternateBase : (databoxList.count > 0) ? "#afffaf" : "#ffafaf" - border.color: filter.activeFocus ? "#0066ff" : "#bdbebf" - } - onTextChanged: { - proxyDataboxModel.setFilterRegExpStr(filter.text) + border.color: filter.activeFocus ? "#0066ff" : "#bdbebf" + TextField { + id: filter + anchors.top: parent.top + width: parent.width - close.width + placeholderText: qsTr("Set filter") + font.pointSize: defaultTextFont.font.pointSize + inputMethodHints: Qt.ImhNoPredictiveText + /* + * Using explicit top, left, ... padding because plain padding + * does not centre the text properly. + */ + topPadding: 8.0 + bottomPadding: 8.0 + leftPadding: 8.0 + rightPadding: 8.0 + /* TODO - remove background if used materials */ + background: Rectangle { + anchors.fill: parent + color: "transparent" + border.color: "transparent" + } + onTextChanged: { + proxyDataboxModel.setFilterRegExpStr(filter.text) + } } Image { id: close @@ -139,13 +148,14 @@ Item { MouseArea { anchors.fill: parent onClicked: { - filter.visible = false + filterBar.visible = false filter.clear() databoxList.anchors.top = headerBar.bottom + Qt.inputMethod.hide() } } } - } + } // Rectangle Text { id: emptyList visible: false diff --git a/qml/pages/PageDataboxSearch.qml b/qml/pages/PageDataboxSearch.qml index 85b53e81..222b97ea 100644 --- a/qml/pages/PageDataboxSearch.qml +++ b/qml/pages/PageDataboxSearch.qml @@ -101,9 +101,10 @@ Item { MouseArea { anchors.fill: parent onClicked: { - databoxList.anchors.top = filter.bottom - filter.visible = true + databoxList.anchors.top = filterBar.bottom + filterBar.visible = true filter.forceActiveFocus() + Qt.inputMethod.show() } } } @@ -288,33 +289,40 @@ Item { } // Item } // Column } // Pane - TextField { - id: filter + Rectangle { + id: filterBar visible: false z: 1 anchors.top: searchPanel.bottom width: parent.width - placeholderText: qsTr("Set filter") - font.pointSize: defaultTextFont.font.pointSize - inputMethodHints: Qt.ImhNoPredictiveText - /* - * Using explicit top, left, ... padding because plain padding - * does not centre the text properly. - */ - topPadding: 8.0 - bottomPadding: 8.0 - leftPadding: 8.0 - rightPadding: 8.0 - /* TODO - remove background if used materials */ - background: Rectangle { - anchors.fill: parent - color: (filter.text.length == 0) ? datovkaPalette.alternateBase : + height: filter.height + color: (filter.text.length == 0) ? datovkaPalette.alternateBase : (databoxList.count > 0) ? "#afffaf" : "#ffafaf" - border.color: filter.activeFocus ? "#0066ff" : - "#bdbebf" - } - onTextChanged: { - proxyDataboxModel.setFilterRegExpStr(filter.text) + border.color: filter.activeFocus ? "#0066ff" : "#bdbebf" + TextField { + id: filter + anchors.top: parent.top + width: parent.width - close.width + placeholderText: qsTr("Set filter") + font.pointSize: defaultTextFont.font.pointSize + inputMethodHints: Qt.ImhNoPredictiveText + /* + * Using explicit top, left, ... padding because plain padding + * does not centre the text properly. + */ + topPadding: 8.0 + bottomPadding: 8.0 + leftPadding: 8.0 + rightPadding: 8.0 + /* TODO - remove background if used materials */ + background: Rectangle { + anchors.fill: parent + color: "transparent" + border.color: "transparent" + } + onTextChanged: { + proxyDataboxModel.setFilterRegExpStr(filter.text) + } } Image { id: close @@ -325,13 +333,14 @@ Item { MouseArea { anchors.fill: parent onClicked: { - filter.visible = false + filterBar.visible = false filter.clear() databoxList.anchors.top = searchPanel.bottom + Qt.inputMethod.hide() } } } - } + } // Rectangle Text { id: emptyList visible: false @@ -375,6 +384,7 @@ Item { statusBar.visible = false if (recipBoxModel == null) { + Qt.inputMethod.hide() pageView.push(pageDataboxDetail, { "pageView": pageView, "statusBar": statusBar, diff --git a/qml/pages/PageMessageList.qml b/qml/pages/PageMessageList.qml index d0da5b62..64571250 100644 --- a/qml/pages/PageMessageList.qml +++ b/qml/pages/PageMessageList.qml @@ -108,9 +108,10 @@ Component { MouseArea { anchors.fill: parent onClicked: { - messageList.anchors.top = filter.bottom - filter.visible = true + messageList.anchors.top = filterBar.bottom + filterBar.visible = true filter.forceActiveFocus() + Qt.inputMethod.show() } } } @@ -123,6 +124,7 @@ Component { anchors.fill: parent onClicked: { statusBar.visible = false + Qt.inputMethod.hide() pageView.push(pageMenuMessageList, { "pageView": pageView, "statusBar": statusBar, @@ -136,33 +138,40 @@ Component { } } } - TextField { - id: filter + Rectangle { + id: filterBar visible: false z: 1 anchors.top: headerBar.bottom width: parent.width - placeholderText: qsTr("Set filter") - font.pointSize: defaultTextFont.font.pointSize - inputMethodHints: Qt.ImhNoPredictiveText - /* - * Using explicit top, left, ... padding because plain padding - * does not centre the text properly. - */ - topPadding: 8.0 - bottomPadding: 8.0 - leftPadding: 8.0 - rightPadding: 8.0 - /* TODO - remove background if used materials */ - background: Rectangle { - anchors.fill: parent - color: (filter.text.length == 0) ? datovkaPalette.alternateBase : + height: filter.height + color: (filter.text.length == 0) ? datovkaPalette.alternateBase : (messageList.count > 0) ? "#afffaf" : "#ffafaf" - border.color: filter.activeFocus ? "#0066ff" : - "#bdbebf" - } - onTextChanged: { - proxyMessageModel.setFilterRegExpStr(filter.text) + border.color: filter.activeFocus ? "#0066ff" : "#bdbebf" + TextField { + id: filter + anchors.top: parent.top + width: parent.width - close.width + placeholderText: qsTr("Set filter") + font.pointSize: defaultTextFont.font.pointSize + inputMethodHints: Qt.ImhNoPredictiveText + /* + * Using explicit top, left, ... padding because plain padding + * does not centre the text properly. + */ + topPadding: 8.0 + bottomPadding: 8.0 + leftPadding: 8.0 + rightPadding: 8.0 + /* TODO - remove background if used materials */ + background: Rectangle { + anchors.fill: parent + color: "transparent" + border.color: "transparent" + } + onTextChanged: { + proxyMessageModel.setFilterRegExpStr(filter.text) + } } Image { id: close @@ -173,13 +182,14 @@ Component { MouseArea { anchors.fill: parent onClicked: { - filter.visible = false + filterBar.visible = false filter.clear() messageList.anchors.top = headerBar.bottom + Qt.inputMethod.hide() } } } - } + } // Rectangle Text { id: emptyList visible: false @@ -215,6 +225,7 @@ Component { } onMsgClicked: { statusBar.visible = false + Qt.inputMethod.hide() pageView.push(pageMessageDetail, { "pageView": pageView, "statusBar": statusBar, @@ -228,6 +239,7 @@ Component { } onMsgPressAndHold: { statusBar.visible = false + Qt.inputMethod.hide() /* Use message settings for received message only */ if (msgType == MessageType.TYPE_RECEIVED) { pageView.push(pageMenuMessage, { -- GitLab