From 68ccd50f2f8cc9e802a2b422225194da7ae8b90e Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 9 Jun 2017 09:26:26 +0200 Subject: [PATCH] fix(app): remove usage of Collapse in V1 --- linphone-desktop/resources.qrc | 5 +- .../modules/Common/Form/+linux/SearchBox.qml | 151 ------------------ .../ui/modules/Common/Form/SearchBox.qml | 61 ++----- .../ui/modules/Common/Misc/Collapse.qml | 98 ------------ .../Common/Styles/Misc/CollapseStyle.qml | 9 -- .../ui/modules/Common/Styles/qmldir | 1 - linphone-desktop/ui/modules/Common/qmldir | 1 - .../ui/views/App/Main/MainWindow.js | 1 - .../ui/views/App/Main/MainWindow.qml | 17 +- 9 files changed, 12 insertions(+), 332 deletions(-) delete mode 100644 linphone-desktop/ui/modules/Common/Form/+linux/SearchBox.qml delete mode 100644 linphone-desktop/ui/modules/Common/Misc/Collapse.qml delete mode 100644 linphone-desktop/ui/modules/Common/Styles/Misc/CollapseStyle.qml diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index c7e9f6ad0..f05a313ad 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -216,7 +216,6 @@ ui/modules/Common/Form/Fields/ScrollableListViewField.qml ui/modules/Common/Form/Fields/TextAreaField.qml ui/modules/Common/Form/Fields/TextField.qml - ui/modules/Common/Form/+linux/SearchBox.qml ui/modules/Common/Form/ListForm.js ui/modules/Common/Form/ListForm.qml ui/modules/Common/Form/Placements/FormEmptyLine.qml @@ -247,7 +246,6 @@ ui/modules/Common/Menus/MenuItem.qml ui/modules/Common/Menus/Menu.qml ui/modules/Common/Misc/Borders.qml - ui/modules/Common/Misc/Collapse.qml ui/modules/Common/Misc/ForceScrollBar.qml ui/modules/Common/Misc/Paned.qml ui/modules/Common/Popup/DesktopPopup.qml @@ -286,7 +284,6 @@ ui/modules/Common/Styles/Menus/DropDownStaticMenuStyle.qml ui/modules/Common/Styles/Menus/MenuItemStyle.qml ui/modules/Common/Styles/Menus/MenuStyle.qml - ui/modules/Common/Styles/Misc/CollapseStyle.qml ui/modules/Common/Styles/Misc/ForceScrollBarStyle.qml ui/modules/Common/Styles/Misc/PanedStyle.qml ui/modules/Common/Styles/Popup/PopupStyle.qml @@ -324,8 +321,8 @@ ui/modules/Linphone/Contact/Contact.qml ui/modules/Linphone/Contact/MessagesCounter.qml ui/modules/Linphone/Menus/SipAddressesMenu.qml - ui/modules/Linphone/Notifications/Notification.qml ui/modules/Linphone/Notifications/NotificationNewVersionAvailable.qml + ui/modules/Linphone/Notifications/Notification.qml ui/modules/Linphone/Notifications/NotificationReceivedCall.qml ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml diff --git a/linphone-desktop/ui/modules/Common/Form/+linux/SearchBox.qml b/linphone-desktop/ui/modules/Common/Form/+linux/SearchBox.qml deleted file mode 100644 index 84aeedda0..000000000 --- a/linphone-desktop/ui/modules/Common/Form/+linux/SearchBox.qml +++ /dev/null @@ -1,151 +0,0 @@ -import QtQuick 2.7 - -import Common 1.0 -import Utils 1.0 - -// ============================================================================= -// Specific GNU/Linux version of `SearchBox` component. -// ============================================================================= - -Item { - id: searchBox - - // --------------------------------------------------------------------------- - - readonly property alias filter: searchField.text - readonly property alias isOpen: searchBox._isOpen - readonly property var view: _content[0] - - property alias entryHeight: menu.entryHeight - property alias maxMenuHeight: menu.maxMenuHeight - property alias placeholderText: searchField.placeholderText - - default property alias _content: menu._content - - property bool _isOpen: false - - // --------------------------------------------------------------------------- - - signal menuClosed - signal menuOpened - signal menuRequested - signal enterPressed - - // --------------------------------------------------------------------------- - - function closeMenu () { - if (!_isOpen) { - return - } - - _isOpen = false - } - - function openMenu () { - if (_isOpen) { - return - } - - _isOpen = true - } - - function _filter (text) { - var model = searchBox.view.model - Utils.assert(model.setFilter != null, '`model.setFilter` must be defined.') - model.setFilter(text) - } - - // --------------------------------------------------------------------------- - - implicitHeight: searchField.height - - Item { - implicitHeight: searchField.height + menu.height - width: parent.width - - TextField { - id: searchField - - icon: 'search' - width: parent.width - - Keys.onEscapePressed: searchBox.closeMenu() - Keys.onReturnPressed: { - searchBox.closeMenu() - searchBox.enterPressed() - } - - onActiveFocusChanged: { - if (activeFocus && !_isOpen) { - searchBox.menuRequested() - searchBox.openMenu() - } - } - - onTextChanged: _filter(text) - } - - // ------------------------------------------------------------------------- - - DropDownDynamicMenu { - id: menu - - relativeTo: searchField - relativeY: searchField.height - - // If the menu is focused, the main window loses the active status. - // So It's necessary to map the keys events. - Keys.forwardTo: searchField - - onClosed: searchBox.closeMenu() - } - - Binding { - target: searchBox.view - property: 'width' - value: searchField.width - } - - Binding { - target: searchBox.view - property: 'headerPositioning' - value: searchBox.view.header ? ListView.OverlayHeader : ListView.InlineFooter - } - } - - // --------------------------------------------------------------------------- - - states: State { - name: 'opened' - when: _isOpen - } - - transitions: [ - Transition { - from: '' - to: 'opened' - - ScriptAction { - script: { - menu.open() - - searchBox.menuOpened() - } - } - }, - - Transition { - from: 'opened' - to: '' - - ScriptAction { - script: { - menu.close() - searchField.focus = false - - searchBox.menuClosed() - } - } - } - ] -} diff --git a/linphone-desktop/ui/modules/Common/Form/SearchBox.qml b/linphone-desktop/ui/modules/Common/Form/SearchBox.qml index 3fa7702cf..84aeedda0 100644 --- a/linphone-desktop/ui/modules/Common/Form/SearchBox.qml +++ b/linphone-desktop/ui/modules/Common/Form/SearchBox.qml @@ -1,12 +1,10 @@ import QtQuick 2.7 -import QtQuick.Window 2.2 import Common 1.0 import Utils 1.0 // ============================================================================= -// A reusable search input which display a entries model in a menu. -// Each entry can be filtered with the search input. +// Specific GNU/Linux version of `SearchBox` component. // ============================================================================= Item { @@ -57,21 +55,12 @@ Item { model.setFilter(text) } - function _handleCoords () { - searchBox.closeMenu() - - var point = searchBox.mapToItem(null, 0, searchBox.height) - - desktopPopup.popupX = window.x + point.x - desktopPopup.popupY = window.y + point.y - } - // --------------------------------------------------------------------------- implicitHeight: searchField.height Item { - implicitHeight: searchField.height + implicitHeight: searchField.height + menu.height width: parent.width TextField { @@ -94,49 +83,21 @@ Item { } onTextChanged: _filter(text) - - InvertedMouseArea { - anchors.fill: parent - enabled: searchBox._isOpen - - onPressed: searchBox.closeMenu() - } } // ------------------------------------------------------------------------- - Connections { - target: searchBox.Window.window + DropDownDynamicMenu { + id: menu - onHeightChanged: _handleCoords() - onWidthChanged: _handleCoords() + relativeTo: searchField + relativeY: searchField.height - onXChanged: _handleCoords() - onYChanged: _handleCoords() + // If the menu is focused, the main window loses the active status. + // So It's necessary to map the keys events. + Keys.forwardTo: searchField - onVisibilityChanged: _handleCoords() - } - - // Wrap the search box menu in a window. - DesktopPopup { - id: desktopPopup - - requestActivate: true - - onVisibleChanged: !visible && searchBox.closeMenu() - - DropDownDynamicMenu { - id: menu - - implicitHeight: searchBox.view.height - width: searchField.width - - // If the menu is focused, the main window loses the active status. - // So It's necessary to map the keys events. - Keys.forwardTo: searchField - - onClosed: searchBox.closeMenu() - } + onClosed: searchBox.closeMenu() } Binding { @@ -167,7 +128,6 @@ Item { ScriptAction { script: { menu.open() - desktopPopup.open() searchBox.menuOpened() } @@ -182,7 +142,6 @@ Item { script: { menu.close() searchField.focus = false - desktopPopup.close() searchBox.menuClosed() } diff --git a/linphone-desktop/ui/modules/Common/Misc/Collapse.qml b/linphone-desktop/ui/modules/Common/Misc/Collapse.qml deleted file mode 100644 index 9e349bd81..000000000 --- a/linphone-desktop/ui/modules/Common/Misc/Collapse.qml +++ /dev/null @@ -1,98 +0,0 @@ -import QtQuick 2.7 - -import Common 1.0 -import Common.Styles 1.0 -import Utils 1.0 - -// ============================================================================= -// A simple component to build collapsed item. -// ============================================================================= - -Item { - id: collapse - - // --------------------------------------------------------------------------- - - property var target - property int targetHeight - readonly property alias isCollapsed: collapse._collapsed - - property bool _collapsed: false - property var _savedHeight - - // --------------------------------------------------------------------------- - - signal collapsed (bool collapsed) - - // --------------------------------------------------------------------------- - - function setCollapsed (status) { - if (_collapsed === status) { - return - } - - _collapsed = status - - // Warning: Unable to use `PropertyChanges` because the change order is unknown. - // It exists a bug on Ubuntu if the `height` property is changed before `minimumHeight`. - if (_collapsed) { - _savedHeight = Utils.extractProperties(target, [ - 'height', - 'maximumHeight', - 'minimumHeight' - ]) - - target.minimumHeight = collapse.targetHeight - target.maximumHeight = Constants.sizeMax - target.height = collapse.targetHeight - } else { - target.minimumHeight = _savedHeight.minimumHeight - target.maximumHeight = _savedHeight.maximumHeight - target.height = _savedHeight.height - } - } - - // --------------------------------------------------------------------------- - - implicitHeight: button.iconSize - implicitWidth: button.iconSize - - property int savedHeight - - ActionButton { - id: button - - anchors.centerIn: parent - icon: 'collapse' - iconSize: CollapseStyle.iconSize - useStates: false - - onClicked: setCollapsed(!_collapsed) - } - - // --------------------------------------------------------------------------- - - states: State { - when: _collapsed - - PropertyChanges { - rotation: 180 - target: button - } - } - - transitions: Transition { - SequentialAnimation { - RotationAnimation { - direction: RotationAnimation.Clockwise - duration: CollapseStyle.animationDuration - property: 'rotation' - target: button - } - - ScriptAction { - script: collapsed(_collapsed) - } - } - } -} diff --git a/linphone-desktop/ui/modules/Common/Styles/Misc/CollapseStyle.qml b/linphone-desktop/ui/modules/Common/Styles/Misc/CollapseStyle.qml deleted file mode 100644 index 4ba3925d4..000000000 --- a/linphone-desktop/ui/modules/Common/Styles/Misc/CollapseStyle.qml +++ /dev/null @@ -1,9 +0,0 @@ -pragma Singleton -import QtQuick 2.7 - -// ============================================================================= - -QtObject { - property int animationDuration: 200 - property int iconSize: 14 -} diff --git a/linphone-desktop/ui/modules/Common/Styles/qmldir b/linphone-desktop/ui/modules/Common/Styles/qmldir index cb0349684..1e669f32a 100644 --- a/linphone-desktop/ui/modules/Common/Styles/qmldir +++ b/linphone-desktop/ui/modules/Common/Styles/qmldir @@ -45,7 +45,6 @@ singleton DropDownStaticMenuStyle 1.0 Menus/DropDownStaticMenuStyle.qml singleton MenuItemStyle 1.0 Menus/MenuItemStyle.qml singleton MenuStyle 1.0 Menus/MenuStyle.qml -singleton CollapseStyle 1.0 Misc/CollapseStyle.qml singleton ForceScrollBarStyle 1.0 Misc/ForceScrollBarStyle.qml singleton PanedStyle 1.0 Misc/PanedStyle.qml diff --git a/linphone-desktop/ui/modules/Common/qmldir b/linphone-desktop/ui/modules/Common/qmldir index c1d696efc..48aec2f44 100644 --- a/linphone-desktop/ui/modules/Common/qmldir +++ b/linphone-desktop/ui/modules/Common/qmldir @@ -69,7 +69,6 @@ Menu 1.0 Menus/Menu.qml MenuItem 1.0 Menus/MenuItem.qml Borders 1.0 Misc/Borders.qml -Collapse 1.0 Misc/Collapse.qml ForceScrollBar 1.0 Misc/ForceScrollBar.qml Paned 1.0 Misc/Paned.qml diff --git a/linphone-desktop/ui/views/App/Main/MainWindow.js b/linphone-desktop/ui/views/App/Main/MainWindow.js index ced0f31b4..a504fc208 100644 --- a/linphone-desktop/ui/views/App/Main/MainWindow.js +++ b/linphone-desktop/ui/views/App/Main/MainWindow.js @@ -40,7 +40,6 @@ function setView (view, props) { var item = mainLoader.item - item.collapse.setCollapsed(true) updateSelectedEntry(view, props) window._currentView = view item.contentLoader.setSource(view + '.qml', props || {}) diff --git a/linphone-desktop/ui/views/App/Main/MainWindow.qml b/linphone-desktop/ui/views/App/Main/MainWindow.qml index 7ad160427..05ef1ff25 100644 --- a/linphone-desktop/ui/views/App/Main/MainWindow.qml +++ b/linphone-desktop/ui/views/App/Main/MainWindow.qml @@ -36,8 +36,7 @@ ApplicationWindow { // Window properties. // --------------------------------------------------------------------------- - maximumHeight: MainWindowStyle.toolBar.height - minimumHeight: MainWindowStyle.toolBar.height + minimumHeight: MainWindowStyle.minimumHeight minimumWidth: MainWindowStyle.minimumWidth width: MainWindowStyle.width @@ -70,7 +69,6 @@ ApplicationWindow { sourceComponent: ColumnLayout { // Workaround to get these properties in `MainWindow.js`. - readonly property alias collapse: collapse readonly property alias contentLoader: contentLoader readonly property alias menu: menu readonly property alias timeline: timeline @@ -101,17 +99,6 @@ ApplicationWindow { } spacing: MainWindowStyle.toolBar.spacing - Collapse { - id: collapse - - Layout.fillHeight: parent.height - target: window - targetHeight: MainWindowStyle.minimumHeight - visible: Qt.platform.os !== 'linux' - - Component.onCompleted: setCollapsed(true) - } - AccountStatus { id: accountStatus @@ -251,8 +238,6 @@ ApplicationWindow { Layout.fillHeight: true Layout.fillWidth: true - visible: collapse.collapsed ? 1.0 : 0 - source: 'Home.qml' } }