Commit 68ccd50f authored by Ronan Abhamon's avatar Ronan Abhamon

fix(app): remove usage of Collapse in V1

parent 97ba2e3b
...@@ -216,7 +216,6 @@ ...@@ -216,7 +216,6 @@
<file>ui/modules/Common/Form/Fields/ScrollableListViewField.qml</file> <file>ui/modules/Common/Form/Fields/ScrollableListViewField.qml</file>
<file>ui/modules/Common/Form/Fields/TextAreaField.qml</file> <file>ui/modules/Common/Form/Fields/TextAreaField.qml</file>
<file>ui/modules/Common/Form/Fields/TextField.qml</file> <file>ui/modules/Common/Form/Fields/TextField.qml</file>
<file>ui/modules/Common/Form/+linux/SearchBox.qml</file>
<file>ui/modules/Common/Form/ListForm.js</file> <file>ui/modules/Common/Form/ListForm.js</file>
<file>ui/modules/Common/Form/ListForm.qml</file> <file>ui/modules/Common/Form/ListForm.qml</file>
<file>ui/modules/Common/Form/Placements/FormEmptyLine.qml</file> <file>ui/modules/Common/Form/Placements/FormEmptyLine.qml</file>
...@@ -247,7 +246,6 @@ ...@@ -247,7 +246,6 @@
<file>ui/modules/Common/Menus/MenuItem.qml</file> <file>ui/modules/Common/Menus/MenuItem.qml</file>
<file>ui/modules/Common/Menus/Menu.qml</file> <file>ui/modules/Common/Menus/Menu.qml</file>
<file>ui/modules/Common/Misc/Borders.qml</file> <file>ui/modules/Common/Misc/Borders.qml</file>
<file>ui/modules/Common/Misc/Collapse.qml</file>
<file>ui/modules/Common/Misc/ForceScrollBar.qml</file> <file>ui/modules/Common/Misc/ForceScrollBar.qml</file>
<file>ui/modules/Common/Misc/Paned.qml</file> <file>ui/modules/Common/Misc/Paned.qml</file>
<file>ui/modules/Common/Popup/DesktopPopup.qml</file> <file>ui/modules/Common/Popup/DesktopPopup.qml</file>
...@@ -286,7 +284,6 @@ ...@@ -286,7 +284,6 @@
<file>ui/modules/Common/Styles/Menus/DropDownStaticMenuStyle.qml</file> <file>ui/modules/Common/Styles/Menus/DropDownStaticMenuStyle.qml</file>
<file>ui/modules/Common/Styles/Menus/MenuItemStyle.qml</file> <file>ui/modules/Common/Styles/Menus/MenuItemStyle.qml</file>
<file>ui/modules/Common/Styles/Menus/MenuStyle.qml</file> <file>ui/modules/Common/Styles/Menus/MenuStyle.qml</file>
<file>ui/modules/Common/Styles/Misc/CollapseStyle.qml</file>
<file>ui/modules/Common/Styles/Misc/ForceScrollBarStyle.qml</file> <file>ui/modules/Common/Styles/Misc/ForceScrollBarStyle.qml</file>
<file>ui/modules/Common/Styles/Misc/PanedStyle.qml</file> <file>ui/modules/Common/Styles/Misc/PanedStyle.qml</file>
<file>ui/modules/Common/Styles/Popup/PopupStyle.qml</file> <file>ui/modules/Common/Styles/Popup/PopupStyle.qml</file>
...@@ -324,8 +321,8 @@ ...@@ -324,8 +321,8 @@
<file>ui/modules/Linphone/Contact/Contact.qml</file> <file>ui/modules/Linphone/Contact/Contact.qml</file>
<file>ui/modules/Linphone/Contact/MessagesCounter.qml</file> <file>ui/modules/Linphone/Contact/MessagesCounter.qml</file>
<file>ui/modules/Linphone/Menus/SipAddressesMenu.qml</file> <file>ui/modules/Linphone/Menus/SipAddressesMenu.qml</file>
<file>ui/modules/Linphone/Notifications/Notification.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationNewVersionAvailable.qml</file> <file>ui/modules/Linphone/Notifications/NotificationNewVersionAvailable.qml</file>
<file>ui/modules/Linphone/Notifications/Notification.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationReceivedCall.qml</file> <file>ui/modules/Linphone/Notifications/NotificationReceivedCall.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml</file> <file>ui/modules/Linphone/Notifications/NotificationReceivedFileMessage.qml</file>
<file>ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml</file> <file>ui/modules/Linphone/Notifications/NotificationReceivedMessage.qml</file>
......
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()
}
}
}
]
}
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Window 2.2
import Common 1.0 import Common 1.0
import Utils 1.0 import Utils 1.0
// ============================================================================= // =============================================================================
// A reusable search input which display a entries model in a menu. // Specific GNU/Linux version of `SearchBox` component.
// Each entry can be filtered with the search input.
// ============================================================================= // =============================================================================
Item { Item {
...@@ -57,21 +55,12 @@ Item { ...@@ -57,21 +55,12 @@ Item {
model.setFilter(text) 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 implicitHeight: searchField.height
Item { Item {
implicitHeight: searchField.height implicitHeight: searchField.height + menu.height
width: parent.width width: parent.width
TextField { TextField {
...@@ -94,49 +83,21 @@ Item { ...@@ -94,49 +83,21 @@ Item {
} }
onTextChanged: _filter(text) onTextChanged: _filter(text)
InvertedMouseArea {
anchors.fill: parent
enabled: searchBox._isOpen
onPressed: searchBox.closeMenu()
}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
Connections { DropDownDynamicMenu {
target: searchBox.Window.window id: menu
onHeightChanged: _handleCoords()
onWidthChanged: _handleCoords()
onXChanged: _handleCoords() relativeTo: searchField
onYChanged: _handleCoords() relativeY: searchField.height
onVisibilityChanged: _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
// Wrap the search box menu in a window.
DesktopPopup {
id: desktopPopup
requestActivate: true
onVisibleChanged: !visible && searchBox.closeMenu()
DropDownDynamicMenu { onClosed: searchBox.closeMenu()
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()
}
} }
Binding { Binding {
...@@ -167,7 +128,6 @@ Item { ...@@ -167,7 +128,6 @@ Item {
ScriptAction { ScriptAction {
script: { script: {
menu.open() menu.open()
desktopPopup.open()
searchBox.menuOpened() searchBox.menuOpened()
} }
...@@ -182,7 +142,6 @@ Item { ...@@ -182,7 +142,6 @@ Item {
script: { script: {
menu.close() menu.close()
searchField.focus = false searchField.focus = false
desktopPopup.close()
searchBox.menuClosed() searchBox.menuClosed()
} }
......
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)
}
}
}
}
pragma Singleton
import QtQuick 2.7
// =============================================================================
QtObject {
property int animationDuration: 200
property int iconSize: 14
}
...@@ -45,7 +45,6 @@ singleton DropDownStaticMenuStyle 1.0 Menus/DropDownStaticMenuStyle.qml ...@@ -45,7 +45,6 @@ singleton DropDownStaticMenuStyle 1.0 Menus/DropDownStaticMenuStyle.qml
singleton MenuItemStyle 1.0 Menus/MenuItemStyle.qml singleton MenuItemStyle 1.0 Menus/MenuItemStyle.qml
singleton MenuStyle 1.0 Menus/MenuStyle.qml singleton MenuStyle 1.0 Menus/MenuStyle.qml
singleton CollapseStyle 1.0 Misc/CollapseStyle.qml
singleton ForceScrollBarStyle 1.0 Misc/ForceScrollBarStyle.qml singleton ForceScrollBarStyle 1.0 Misc/ForceScrollBarStyle.qml
singleton PanedStyle 1.0 Misc/PanedStyle.qml singleton PanedStyle 1.0 Misc/PanedStyle.qml
......
...@@ -69,7 +69,6 @@ Menu 1.0 Menus/Menu.qml ...@@ -69,7 +69,6 @@ Menu 1.0 Menus/Menu.qml
MenuItem 1.0 Menus/MenuItem.qml MenuItem 1.0 Menus/MenuItem.qml
Borders 1.0 Misc/Borders.qml Borders 1.0 Misc/Borders.qml
Collapse 1.0 Misc/Collapse.qml
ForceScrollBar 1.0 Misc/ForceScrollBar.qml ForceScrollBar 1.0 Misc/ForceScrollBar.qml
Paned 1.0 Misc/Paned.qml Paned 1.0 Misc/Paned.qml
......
...@@ -40,7 +40,6 @@ function setView (view, props) { ...@@ -40,7 +40,6 @@ function setView (view, props) {
var item = mainLoader.item var item = mainLoader.item
item.collapse.setCollapsed(true)
updateSelectedEntry(view, props) updateSelectedEntry(view, props)
window._currentView = view window._currentView = view
item.contentLoader.setSource(view + '.qml', props || {}) item.contentLoader.setSource(view + '.qml', props || {})
......
...@@ -36,8 +36,7 @@ ApplicationWindow { ...@@ -36,8 +36,7 @@ ApplicationWindow {
// Window properties. // Window properties.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
maximumHeight: MainWindowStyle.toolBar.height minimumHeight: MainWindowStyle.minimumHeight
minimumHeight: MainWindowStyle.toolBar.height
minimumWidth: MainWindowStyle.minimumWidth minimumWidth: MainWindowStyle.minimumWidth
width: MainWindowStyle.width width: MainWindowStyle.width
...@@ -70,7 +69,6 @@ ApplicationWindow { ...@@ -70,7 +69,6 @@ ApplicationWindow {
sourceComponent: ColumnLayout { sourceComponent: ColumnLayout {
// Workaround to get these properties in `MainWindow.js`. // Workaround to get these properties in `MainWindow.js`.
readonly property alias collapse: collapse
readonly property alias contentLoader: contentLoader readonly property alias contentLoader: contentLoader
readonly property alias menu: menu readonly property alias menu: menu
readonly property alias timeline: timeline readonly property alias timeline: timeline
...@@ -101,17 +99,6 @@ ApplicationWindow { ...@@ -101,17 +99,6 @@ ApplicationWindow {
} }
spacing: MainWindowStyle.toolBar.spacing 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 { AccountStatus {
id: accountStatus id: accountStatus
...@@ -251,8 +238,6 @@ ApplicationWindow { ...@@ -251,8 +238,6 @@ ApplicationWindow {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
visible: collapse.collapsed ? 1.0 : 0
source: 'Home.qml' source: 'Home.qml'
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment