From deb3cf183a804fbaedc229636aaeded47dc146ac Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Sun, 23 Feb 2020 11:59:24 +0100 Subject: [PATCH] - Fix bug on search box - Add QML debug capability --- CHANGELOG.md | 1 + CMakeLists.txt | 1 + src/app/main.cpp | 6 ++++++ ui/modules/Common/Form/SearchBox.qml | 20 +++++++++++++++++-- .../Common/Menus/DropDownDynamicMenu.qml | 3 ++- ui/modules/Common/Popup/Popup.qml | 3 ++- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fbaca50c..aeeb17877 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Play a sound when DTMF is sent. - Do not use `:` separator when a file is saved on Windows. - Avoid mark as read on selected chat room if window is not active. +- Search box in main page will not reset its text when clicking on it ### Removed diff --git a/CMakeLists.txt b/CMakeLists.txt index 93a4df9b0..f43098f1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ else() # Build configuration set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG -DQT_NO_DEBUG") + set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG -DQT_QML_DEBUG -DQT_DECLARATIVE_DEBUG") if( WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_WINSOCKAPI_")#remove error from windows headers order diff --git a/src/app/main.cpp b/src/app/main.cpp index 12f8b8866..8813e1ca2 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -20,10 +20,16 @@ #include "AppController.hpp" #include +#ifdef QT_QML_DEBUG +#include +#endif // ============================================================================= int main (int argc, char *argv[]) { AppController controller(argc, argv); +#ifdef QT_QML_DEBUG + QQmlDebuggingEnabler enabler; +#endif //QLoggingCategory::setFilterRules("*.debug=true;qml=false"); App *app = controller.getApp(); if (app->isSecondary()) diff --git a/ui/modules/Common/Form/SearchBox.qml b/ui/modules/Common/Form/SearchBox.qml index 8f95f34e3..df611df7d 100644 --- a/ui/modules/Common/Form/SearchBox.qml +++ b/ui/modules/Common/Form/SearchBox.qml @@ -1,4 +1,5 @@ import QtQuick 2.7 +import QtQuick.Controls 2.2 as Controls import Common 1.0 import Utils 1.0 @@ -53,6 +54,7 @@ Item { model.setFilter(text) } + // --------------------------------------------------------------------------- implicitHeight: searchField.height @@ -73,12 +75,13 @@ Item { searchBox.enterPressed() searchBox.closeMenu() } - onActiveFocusChanged: { if (activeFocus && !_isOpen) { + searchBox.menuRequested() searchBox.openMenu() - } + }else if( !activeFocus) + searchBox.closeMenu() } onTextChanged: _filter(text) @@ -111,6 +114,19 @@ Item { value: searchBox.view.header ? ListView.OverlayHeader : ListView.InlineFooter } } + MouseArea + {// Just take hover events and set popup to do its automatic close if mouse is not inside field/popup area + anchors.fill: parent + onContainsMouseChanged: menu.popup.closePolicy=(containsMouse?Controls.Popup.NoAutoClose:Controls.Popup.CloseOnEscape | Controls.Popup.CloseOnPressOutside) + hoverEnabled:true + preventStealing: true + propagateComposedEvents:true + onPressed: mouse.accepted=false + onReleased: mouse.accepted=false + onClicked: mouse.accepted=false + onDoubleClicked: mouse.accepted=false + onPressAndHold: mouse.accepted=false + } // --------------------------------------------------------------------------- diff --git a/ui/modules/Common/Menus/DropDownDynamicMenu.qml b/ui/modules/Common/Menus/DropDownDynamicMenu.qml index 952bcd009..e2f3245b9 100644 --- a/ui/modules/Common/Menus/DropDownDynamicMenu.qml +++ b/ui/modules/Common/Menus/DropDownDynamicMenu.qml @@ -19,6 +19,7 @@ Item { property int maxMenuHeight default property alias _content: menuContent.data + property alias popup : popup // --------------------------------------------------------------------------- @@ -64,7 +65,7 @@ Item { // --------------------------------------------------------------------------- Popup { - id: popup + id: popup onOpened: menu.opened() onClosed: menu.closed() diff --git a/ui/modules/Common/Popup/Popup.qml b/ui/modules/Common/Popup/Popup.qml index d321a3a3f..0425c18a1 100644 --- a/ui/modules/Common/Popup/Popup.qml +++ b/ui/modules/Common/Popup/Popup.qml @@ -15,6 +15,7 @@ Item { property int relativeY: 0 default property alias _content: popup.contentItem + property alias closePolicy : popup.closePolicy // --------------------------------------------------------------------------- @@ -83,7 +84,7 @@ Item { } } - padding: 0 + padding: 0 Component.onCompleted: parent = Utils.getTopParent(this)