Commit 01ba4d78 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app):

  - many fixes
  - method `setView` of `MainWindow` update the menus/buttons of the interface.
  - ...
parent 05b99bf1
...@@ -3,9 +3,9 @@ import QtQuick 2.7 ...@@ -3,9 +3,9 @@ import QtQuick 2.7
import Common 1.0 import Common 1.0
import Common.Styles 1.0 import Common.Styles 1.0
// =================================================================== // =============================================================================
// A simple component to build collapsed item. // A simple component to build collapsed item.
// =================================================================== // =============================================================================
Item { Item {
id: collapse id: collapse
...@@ -17,13 +17,13 @@ Item { ...@@ -17,13 +17,13 @@ Item {
signal collapsed (bool collapsed) signal collapsed (bool collapsed)
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
function isCollapsed () { function setCollapsed (status) {
return _collapsed _collapsed = status
} }
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
implicitHeight: button.iconSize implicitHeight: button.iconSize
implicitWidth: button.iconSize implicitWidth: button.iconSize
...@@ -39,7 +39,7 @@ Item { ...@@ -39,7 +39,7 @@ Item {
onClicked: _collapsed = !_collapsed onClicked: _collapsed = !_collapsed
} }
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
states: State { states: State {
when: _collapsed when: _collapsed
......
...@@ -4,9 +4,9 @@ import QtQuick.Layouts 1.3 ...@@ -4,9 +4,9 @@ import QtQuick.Layouts 1.3
import Common 1.0 import Common 1.0
import Common.Styles 1.0 import Common.Styles 1.0
// =================================================================== // =============================================================================
// Responsive flat menu with visual indicators. // Responsive flat menu with visual indicators.
// =================================================================== // =============================================================================
Rectangle { Rectangle {
id: menu id: menu
...@@ -19,13 +19,17 @@ Rectangle { ...@@ -19,13 +19,17 @@ Rectangle {
signal entrySelected (int entry) signal entrySelected (int entry)
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
function setSelectedEntry (entry) {
_selectedEntry = entry
}
function resetSelectedEntry () { function resetSelectedEntry () {
_selectedEntry = -1 _selectedEntry = -1
} }
// ----------------------------------------------------------------- // ---------------------------------------------------------------------------
color: MenuStyle.backgroundColor color: MenuStyle.backgroundColor
implicitHeight: content.height implicitHeight: content.height
......
...@@ -13,9 +13,8 @@ SearchBox { ...@@ -13,9 +13,8 @@ SearchBox {
delegate: Rectangle { delegate: Rectangle {
id: searchBoxEntry id: searchBoxEntry
width: parent.width
height: searchBox.entryHeight height: searchBox.entryHeight
color: '#FFFFFF' width: parent.width
Rectangle { Rectangle {
id: indicator id: indicator
...@@ -85,13 +84,17 @@ SearchBox { ...@@ -85,13 +84,17 @@ SearchBox {
ActionButton { ActionButton {
icon: 'chat' icon: 'chat'
onClicked: window.setView('Conversation', { onClicked: {
searchBox.hideMenu()
window.ensureCollapsed()
window.setView('Conversation', {
sipAddress: $entry.sipAddress || $entry.vcard.sipAddresses[0] // FIXME: Display menu if many addresses. sipAddress: $entry.sipAddress || $entry.vcard.sipAddresses[0] // FIXME: Display menu if many addresses.
}) })
} }
} }
} }
} }
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
...@@ -17,7 +17,18 @@ ColumnLayout { ...@@ -17,7 +17,18 @@ ColumnLayout {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
function resetSelectedItem () { function setSelectedEntry (sipAddress) {
var n = model.rowCount()
for (var i = 0; i < n; i++) {
if (sipAddress === model.data(model.index(i, 0)).sipAddress) {
view.currentIndex = i
return
}
}
}
function resetSelectedEntry () {
view.currentIndex = -1 view.currentIndex = -1
} }
...@@ -25,12 +36,15 @@ ColumnLayout { ...@@ -25,12 +36,15 @@ ColumnLayout {
spacing: 0 spacing: 0
// ---------------------------------------------------------------------------
// Legend.
// ---------------------------------------------------------------------------
Rectangle { Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: TimelineStyle.legend.height Layout.preferredHeight: TimelineStyle.legend.height
color: TimelineStyle.legend.backgroundColor color: TimelineStyle.legend.backgroundColor
// Legend.
Row { Row {
anchors { anchors {
fill: parent fill: parent
...@@ -55,7 +69,10 @@ ColumnLayout { ...@@ -55,7 +69,10 @@ ColumnLayout {
} }
} }
// ---------------------------------------------------------------------------
// History. // History.
// ---------------------------------------------------------------------------
ScrollableListView { ScrollableListView {
id: view id: view
......
...@@ -57,8 +57,8 @@ ColumnLayout { ...@@ -57,8 +57,8 @@ ColumnLayout {
Layout.preferredHeight: ConversationStyle.bar.avatarSize Layout.preferredHeight: ConversationStyle.bar.avatarSize
Layout.preferredWidth: ConversationStyle.bar.avatarSize Layout.preferredWidth: ConversationStyle.bar.avatarSize
image: _contact.avatar image: _contact.vcard.avatar
presenceLevel: _contact.presenceLevel || Presence.White presenceLevel: _contact.presenceLevel || -1
username: LinphoneUtils.getContactUsername(_contact) username: LinphoneUtils.getContactUsername(_contact)
} }
......
...@@ -14,9 +14,21 @@ ApplicationWindow { ...@@ -14,9 +14,21 @@ ApplicationWindow {
id: window id: window
function setView (view, props) { function setView (view, props) {
if (view === 'Home' || view === 'Contacts') {
menu.setSelectedEntry(view === 'Home' ? 0 : 1)
timeline.resetSelectedEntry()
} else if (view === 'Conversation') {
menu.resetSelectedEntry()
timeline.setSelectedEntry(props.sipAddress)
}
contentLoader.setSource(view + '.qml', props || {}) contentLoader.setSource(view + '.qml', props || {})
} }
function ensureCollapsed () {
collapse.setCollapsed(true)
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Window properties. // Window properties.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
...@@ -46,6 +58,8 @@ ApplicationWindow { ...@@ -46,6 +58,8 @@ ApplicationWindow {
spacing: MainWindowStyle.toolBar.spacing spacing: MainWindowStyle.toolBar.spacing
Collapse { Collapse {
id: collapse
Layout.fillHeight: parent.height Layout.fillHeight: parent.height
target: window target: window
targetHeight: MainWindowStyle.minimumHeight targetHeight: MainWindowStyle.minimumHeight
...@@ -123,15 +137,7 @@ ApplicationWindow { ...@@ -123,15 +137,7 @@ ApplicationWindow {
icon: 'contact' icon: 'contact'
}] }]
onEntrySelected: { onEntrySelected: !entry ? setView('Home') : setView('Contacts')
timeline.resetSelectedItem()
if (entry === 0) {
setView('Home')
} else if (entry === 1) {
setView('Contacts')
}
}
} }
// History. // History.
...@@ -142,10 +148,7 @@ ApplicationWindow { ...@@ -142,10 +148,7 @@ ApplicationWindow {
Layout.fillWidth: true Layout.fillWidth: true
model: TimelineModel model: TimelineModel
onEntrySelected: { onEntrySelected: setView('Conversation', { sipAddress: entry })
menu.resetSelectedEntry()
setView('Conversation', { sipAddress: entry })
}
} }
} }
......
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