Commit a1184fe1 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): reuse last Window component in `MainWindow` AND USE A WORKAROUND TO...

feat(app): reuse last Window component in `MainWindow` AND USE A WORKAROUND TO DEAL WITH A FILE STYLE BULLSHIT on `Chat` component
parent e1d7b7bf
...@@ -303,7 +303,6 @@ ...@@ -303,7 +303,6 @@
<file>ui/views/App/Main/Contacts.qml</file> <file>ui/views/App/Main/Contacts.qml</file>
<file>ui/views/App/Main/Conversation.qml</file> <file>ui/views/App/Main/Conversation.qml</file>
<file>ui/views/App/Main/Home.qml</file> <file>ui/views/App/Main/Home.qml</file>
<file>ui/views/App/Main/MainWindowMenuBar.qml</file>
<file>ui/views/App/Main/MainWindow.qml</file> <file>ui/views/App/Main/MainWindow.qml</file>
<file>ui/views/App/ManageAccounts.qml</file> <file>ui/views/App/ManageAccounts.qml</file>
<file>ui/views/App/qmldir</file> <file>ui/views/App/qmldir</file>
......
...@@ -12,6 +12,12 @@ import Utils 1.0 ...@@ -12,6 +12,12 @@ import Utils 1.0
ColumnLayout { ColumnLayout {
property alias proxyModel: chat.model property alias proxyModel: chat.model
// Unable to use it in style file at this moment.
// A `TypeError: Cannot read property 'XXX' of undefined` is launched for many properties
// in the style file otherwise.
// Seems related to: https://bugreports.qt.io/browse/QTBUG-58648
property color _backgroundColor: 'white'
property bool _bindToEnd: false property bool _bindToEnd: false
property var _contactObserver: SipAddressesModel.getContactObserver(proxyModel.sipAddress) property var _contactObserver: SipAddressesModel.getContactObserver(proxyModel.sipAddress)
...@@ -25,7 +31,7 @@ ColumnLayout { ...@@ -25,7 +31,7 @@ ColumnLayout {
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent
color: ChatStyle.color color: _backgroundColor
} }
ScrollableListView { ScrollableListView {
...@@ -176,7 +182,7 @@ ColumnLayout { ...@@ -176,7 +182,7 @@ ColumnLayout {
ChatStyle.entry.message.extraContent.leftMargin + ChatStyle.entry.message.extraContent.leftMargin +
ChatStyle.entry.message.outgoing.sendIconSize ChatStyle.entry.message.outgoing.sendIconSize
} }
color: ChatStyle.color color: _backgroundColor
implicitHeight: layout.height + ChatStyle.entry.bottomMargin implicitHeight: layout.height + ChatStyle.entry.bottomMargin
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
......
...@@ -6,8 +6,6 @@ import Common 1.0 ...@@ -6,8 +6,6 @@ import Common 1.0
// ============================================================================= // =============================================================================
QtObject { QtObject {
property color color: Colors.k
property QtObject sectionHeading: QtObject { property QtObject sectionHeading: QtObject {
property int padding: 5 property int padding: 5
property int bottomMargin: 20 property int bottomMargin: 20
......
...@@ -2,8 +2,6 @@ import QtQuick 2.7 ...@@ -2,8 +2,6 @@ import QtQuick 2.7
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Controls 1.4 as Controls1
import Common 1.0 import Common 1.0
import Linphone 1.0 import Linphone 1.0
import Utils 1.0 import Utils 1.0
...@@ -12,7 +10,7 @@ import App.Styles 1.0 ...@@ -12,7 +10,7 @@ import App.Styles 1.0
// ============================================================================= // =============================================================================
Controls1.ApplicationWindow { ApplicationWindow {
id: window id: window
property string _currentView: '' property string _currentView: ''
...@@ -64,7 +62,7 @@ Controls1.ApplicationWindow { ...@@ -64,7 +62,7 @@ Controls1.ApplicationWindow {
} }
function _setView (view, props) { function _setView (view, props) {
window.setVisible(true) window.show()
window.requestActivate() window.requestActivate()
collapse.setCollapsed(true) collapse.setCollapsed(true)
...@@ -86,160 +84,145 @@ Controls1.ApplicationWindow { ...@@ -86,160 +84,145 @@ Controls1.ApplicationWindow {
onActiveFocusItemChanged: activeFocusItem == null && smartSearchBar.hideMenu() onActiveFocusItemChanged: activeFocusItem == null && smartSearchBar.hideMenu()
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Menu bar. // Toolbar properties.
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
menuBar: MainWindowMenuBar {} header: ToolBar {
background: MainWindowStyle.toolBar.background
height: MainWindowStyle.toolBar.height
RowLayout {
anchors {
fill: parent
leftMargin: MainWindowStyle.toolBar.leftMargin
rightMargin: MainWindowStyle.toolBar.rightMargin
}
spacing: MainWindowStyle.toolBar.spacing
ColumnLayout { Collapse {
anchors.fill: parent id: collapse
spacing: 0
// ------------------------------------------------------------------------- Layout.fillHeight: parent.height
// Toolbar properties. target: window
// ------------------------------------------------------------------------- targetHeight: MainWindowStyle.minimumHeight
}
ToolBar { AccountStatus {
background: MainWindowStyle.toolBar.background id: accountStatus
Layout.preferredHeight: MainWindowStyle.toolBar.height
Layout.fillWidth: true
RowLayout { Layout.fillHeight: parent.height
anchors { Layout.preferredWidth: MainWindowStyle.accountStatus.width
fill: parent
leftMargin: MainWindowStyle.toolBar.leftMargin
rightMargin: MainWindowStyle.toolBar.rightMargin
}
spacing: MainWindowStyle.toolBar.spacing
Collapse { account: AccountSettingsModel
id: collapse
Layout.fillHeight: parent.height TooltipArea {
target: window text: AccountSettingsModel.sipAddress
targetHeight: MainWindowStyle.minimumHeight
} }
AccountStatus { onClicked: Utils.openWindow('ManageAccounts', window)
id: accountStatus }
Layout.fillHeight: parent.height
Layout.preferredWidth: MainWindowStyle.accountStatus.width
account: AccountSettingsModel
TooltipArea { Column {
text: AccountSettingsModel.sipAddress width: MainWindowStyle.autoAnswerStatus.width
}
onClicked: Utils.openWindow('ManageAccounts', window) Icon {
icon: SettingsModel.autoAnswerStatus
? 'auto_answer'
: ''
iconSize: MainWindowStyle.autoAnswerStatus.iconSize
} }
Column { Text {
width: MainWindowStyle.autoAnswerStatus.width clip: true
font {
Icon { pointSize: MainWindowStyle.autoAnswerStatus.text.fontSize
icon: SettingsModel.autoAnswerStatus
? 'auto_answer'
: ''
iconSize: MainWindowStyle.autoAnswerStatus.iconSize
}
Text {
clip: true
font {
pointSize: MainWindowStyle.autoAnswerStatus.text.fontSize
}
text: qsTr('autoAnswerStatus')
width: parent.width
color: MainWindowStyle.autoAnswerStatus.text.color
} }
text: qsTr('autoAnswerStatus')
width: parent.width
color: MainWindowStyle.autoAnswerStatus.text.color
} }
}
SmartSearchBar { SmartSearchBar {
id: smartSearchBar id: smartSearchBar
Layout.fillWidth: true Layout.fillWidth: true
entryHeight: MainWindowStyle.searchBox.entryHeight entryHeight: MainWindowStyle.searchBox.entryHeight
maxMenuHeight: MainWindowStyle.searchBox.maxHeight maxMenuHeight: MainWindowStyle.searchBox.maxHeight
placeholderText: qsTr('mainSearchBarPlaceholder') placeholderText: qsTr('mainSearchBarPlaceholder')
model: SmartSearchBarModel {} model: SmartSearchBarModel {}
onAddContact: window.setView('ContactEdit', { onAddContact: window.setView('ContactEdit', {
sipAddress: sipAddress sipAddress: sipAddress
}) })
onLaunchCall: CallsListModel.launchAudioCall(sipAddress) onLaunchCall: CallsListModel.launchAudioCall(sipAddress)
onLaunchChat: window.setView('Conversation', { onLaunchChat: window.setView('Conversation', {
sipAddress: sipAddress sipAddress: sipAddress
}) })
onLaunchVideoCall: CallsListModel.launchVideoCall(sipAddress) onLaunchVideoCall: CallsListModel.launchVideoCall(sipAddress)
onEntryClicked: window.setView(entry.contact ? 'ContactEdit' : 'Conversation', { onEntryClicked: window.setView(entry.contact ? 'ContactEdit' : 'Conversation', {
sipAddress: entry.sipAddress sipAddress: entry.sipAddress
}) })
}
} }
} }
}
// ---------------------------------------------------------------------------
// Content.
// ---------------------------------------------------------------------------
// ------------------------------------------------------------------------- RowLayout {
// Content. anchors.fill: parent
// ------------------------------------------------------------------------- spacing: 0
RowLayout { // Main menu.
ColumnLayout {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.maximumWidth: MainWindowStyle.menu.width
Layout.preferredWidth: MainWindowStyle.menu.width
spacing: 0 spacing: 0
// Main menu. Menu {
ColumnLayout { id: menu
Layout.fillHeight: true
Layout.maximumWidth: MainWindowStyle.menu.width
Layout.preferredWidth: MainWindowStyle.menu.width
spacing: 0
Menu {
id: menu
entryHeight: MainWindowStyle.menu.entryHeight
entryWidth: MainWindowStyle.menu.width
entries: [{ entryHeight: MainWindowStyle.menu.entryHeight
entryName: qsTr('homeEntry'), entryWidth: MainWindowStyle.menu.width
icon: 'home'
}, {
entryName: qsTr('contactsEntry'),
icon: 'contact'
}]
onEntrySelected: !entry ? setView('Home') : setView('Contacts') entries: [{
} entryName: qsTr('homeEntry'),
icon: 'home'
// History. }, {
Timeline { entryName: qsTr('contactsEntry'),
id: timeline icon: 'contact'
}]
Layout.fillHeight: true
Layout.fillWidth: true
model: TimelineModel
onEntrySelected: setView('Conversation', { sipAddress: entry }) onEntrySelected: !entry ? setView('Home') : setView('Contacts')
}
} }
// Main content. // History.
Loader { Timeline {
id: contentLoader id: timeline
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
model: TimelineModel
Component.onCompleted: setView('Home') onEntrySelected: setView('Conversation', { sipAddress: entry })
} }
} }
// Main content.
Loader {
id: contentLoader
Layout.fillHeight: true
Layout.fillWidth: true
Component.onCompleted: setView('Home')
}
} }
} }
import QtQuick.Controls 1.4
MenuBar {
Menu {
title: "File"
MenuItem { text: "Open..." }
MenuItem { text: "Close" }
}
}
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