From a1184fe1ce4791ac1b6a408636db2fa50843c507 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 15 Feb 2017 11:44:02 +0100 Subject: [PATCH] feat(app): reuse last Window component in `MainWindow` AND USE A WORKAROUND TO DEAL WITH A FILE STYLE BULLSHIT on `Chat` component --- linphone-desktop/resources.qrc | 1 - .../ui/modules/Linphone/Chat/Chat.qml | 10 +- .../ui/modules/Linphone/Styles/ChatStyle.qml | 2 - .../ui/views/App/Main/MainWindow.qml | 257 ++++++++---------- .../ui/views/App/Main/MainWindowMenuBar.qml | 11 - 5 files changed, 128 insertions(+), 153 deletions(-) delete mode 100644 linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index cbc418946..98990302a 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -303,7 +303,6 @@ ui/views/App/Main/Contacts.qml ui/views/App/Main/Conversation.qml ui/views/App/Main/Home.qml - ui/views/App/Main/MainWindowMenuBar.qml ui/views/App/Main/MainWindow.qml ui/views/App/ManageAccounts.qml ui/views/App/qmldir diff --git a/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml b/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml index 9d8703a4b..642f08ab0 100644 --- a/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml @@ -12,6 +12,12 @@ import Utils 1.0 ColumnLayout { 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 var _contactObserver: SipAddressesModel.getContactObserver(proxyModel.sipAddress) @@ -25,7 +31,7 @@ ColumnLayout { Rectangle { anchors.fill: parent - color: ChatStyle.color + color: _backgroundColor } ScrollableListView { @@ -176,7 +182,7 @@ ColumnLayout { ChatStyle.entry.message.extraContent.leftMargin + ChatStyle.entry.message.outgoing.sendIconSize } - color: ChatStyle.color + color: _backgroundColor implicitHeight: layout.height + ChatStyle.entry.bottomMargin // ----------------------------------------------------------------------- diff --git a/linphone-desktop/ui/modules/Linphone/Styles/ChatStyle.qml b/linphone-desktop/ui/modules/Linphone/Styles/ChatStyle.qml index 26cdbc253..45664b64c 100644 --- a/linphone-desktop/ui/modules/Linphone/Styles/ChatStyle.qml +++ b/linphone-desktop/ui/modules/Linphone/Styles/ChatStyle.qml @@ -6,8 +6,6 @@ import Common 1.0 // ============================================================================= QtObject { - property color color: Colors.k - property QtObject sectionHeading: QtObject { property int padding: 5 property int bottomMargin: 20 diff --git a/linphone-desktop/ui/views/App/Main/MainWindow.qml b/linphone-desktop/ui/views/App/Main/MainWindow.qml index 8105f0539..94311d681 100644 --- a/linphone-desktop/ui/views/App/Main/MainWindow.qml +++ b/linphone-desktop/ui/views/App/Main/MainWindow.qml @@ -2,8 +2,6 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import QtQuick.Layouts 1.3 -import QtQuick.Controls 1.4 as Controls1 - import Common 1.0 import Linphone 1.0 import Utils 1.0 @@ -12,7 +10,7 @@ import App.Styles 1.0 // ============================================================================= -Controls1.ApplicationWindow { +ApplicationWindow { id: window property string _currentView: '' @@ -64,7 +62,7 @@ Controls1.ApplicationWindow { } function _setView (view, props) { - window.setVisible(true) + window.show() window.requestActivate() collapse.setCollapsed(true) @@ -86,160 +84,145 @@ Controls1.ApplicationWindow { onActiveFocusItemChanged: activeFocusItem == null && smartSearchBar.hideMenu() // --------------------------------------------------------------------------- - // Menu bar. + // Toolbar properties. // --------------------------------------------------------------------------- - menuBar: MainWindowMenuBar {} - - - ColumnLayout { - anchors.fill: parent - spacing: 0 - - // ------------------------------------------------------------------------- - // Toolbar properties. - // ------------------------------------------------------------------------- - - ToolBar { - background: MainWindowStyle.toolBar.background - Layout.preferredHeight: MainWindowStyle.toolBar.height - Layout.fillWidth: true - - RowLayout { - anchors { - fill: parent - leftMargin: MainWindowStyle.toolBar.leftMargin - rightMargin: MainWindowStyle.toolBar.rightMargin - } - spacing: MainWindowStyle.toolBar.spacing - - Collapse { - id: collapse - - Layout.fillHeight: parent.height - target: window - targetHeight: MainWindowStyle.minimumHeight - } - - AccountStatus { - id: accountStatus - - Layout.fillHeight: parent.height - Layout.preferredWidth: MainWindowStyle.accountStatus.width - - account: AccountSettingsModel - - TooltipArea { - text: AccountSettingsModel.sipAddress - } - - onClicked: Utils.openWindow('ManageAccounts', window) - } - - Column { - width: MainWindowStyle.autoAnswerStatus.width - - Icon { - 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 - } - } - - SmartSearchBar { - id: smartSearchBar - - Layout.fillWidth: true - entryHeight: MainWindowStyle.searchBox.entryHeight - maxMenuHeight: MainWindowStyle.searchBox.maxHeight - placeholderText: qsTr('mainSearchBarPlaceholder') - - model: SmartSearchBarModel {} - - onAddContact: window.setView('ContactEdit', { - sipAddress: sipAddress - }) - - onLaunchCall: CallsListModel.launchAudioCall(sipAddress) - onLaunchChat: window.setView('Conversation', { - sipAddress: sipAddress - }) - - onLaunchVideoCall: CallsListModel.launchVideoCall(sipAddress) - - onEntryClicked: window.setView(entry.contact ? 'ContactEdit' : 'Conversation', { - sipAddress: entry.sipAddress - }) - } - } - } - - // ------------------------------------------------------------------------- - // Content. - // ------------------------------------------------------------------------- + header: ToolBar { + background: MainWindowStyle.toolBar.background + height: MainWindowStyle.toolBar.height RowLayout { - Layout.fillHeight: true - Layout.fillWidth: true + anchors { + fill: parent + leftMargin: MainWindowStyle.toolBar.leftMargin + rightMargin: MainWindowStyle.toolBar.rightMargin + } + spacing: MainWindowStyle.toolBar.spacing - spacing: 0 + Collapse { + id: collapse - // Main menu. - ColumnLayout { - Layout.fillHeight: true - Layout.maximumWidth: MainWindowStyle.menu.width - Layout.preferredWidth: MainWindowStyle.menu.width - spacing: 0 + Layout.fillHeight: parent.height + target: window + targetHeight: MainWindowStyle.minimumHeight + } - Menu { - id: menu + AccountStatus { + id: accountStatus - entryHeight: MainWindowStyle.menu.entryHeight - entryWidth: MainWindowStyle.menu.width + Layout.fillHeight: parent.height + Layout.preferredWidth: MainWindowStyle.accountStatus.width - entries: [{ - entryName: qsTr('homeEntry'), - icon: 'home' - }, { - entryName: qsTr('contactsEntry'), - icon: 'contact' - }] + account: AccountSettingsModel - onEntrySelected: !entry ? setView('Home') : setView('Contacts') + TooltipArea { + text: AccountSettingsModel.sipAddress } - // History. - Timeline { - id: timeline + onClicked: Utils.openWindow('ManageAccounts', window) + } - Layout.fillHeight: true - Layout.fillWidth: true - model: TimelineModel + Column { + width: MainWindowStyle.autoAnswerStatus.width - onEntrySelected: setView('Conversation', { sipAddress: entry }) + Icon { + 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 } } - // Main content. - Loader { - id: contentLoader + SmartSearchBar { + id: smartSearchBar - Layout.fillHeight: true Layout.fillWidth: true + entryHeight: MainWindowStyle.searchBox.entryHeight + maxMenuHeight: MainWindowStyle.searchBox.maxHeight + placeholderText: qsTr('mainSearchBarPlaceholder') - Component.onCompleted: setView('Home') + model: SmartSearchBarModel {} + + onAddContact: window.setView('ContactEdit', { + sipAddress: sipAddress + }) + + onLaunchCall: CallsListModel.launchAudioCall(sipAddress) + onLaunchChat: window.setView('Conversation', { + sipAddress: sipAddress + }) + + onLaunchVideoCall: CallsListModel.launchVideoCall(sipAddress) + + onEntryClicked: window.setView(entry.contact ? 'ContactEdit' : 'Conversation', { + sipAddress: entry.sipAddress + }) } } } + + // --------------------------------------------------------------------------- + // Content. + // --------------------------------------------------------------------------- + + RowLayout { + anchors.fill: parent + spacing: 0 + + // Main menu. + ColumnLayout { + 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: [{ + entryName: qsTr('homeEntry'), + icon: 'home' + }, { + entryName: qsTr('contactsEntry'), + icon: 'contact' + }] + + onEntrySelected: !entry ? setView('Home') : setView('Contacts') + } + + // History. + Timeline { + id: timeline + + Layout.fillHeight: true + Layout.fillWidth: true + model: TimelineModel + + onEntrySelected: setView('Conversation', { sipAddress: entry }) + } + } + + // Main content. + Loader { + id: contentLoader + + Layout.fillHeight: true + Layout.fillWidth: true + + Component.onCompleted: setView('Home') + } + } } diff --git a/linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml b/linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml deleted file mode 100644 index 69260e63a..000000000 --- a/linphone-desktop/ui/views/App/Main/MainWindowMenuBar.qml +++ /dev/null @@ -1,11 +0,0 @@ - - import QtQuick.Controls 1.4 -MenuBar { - - Menu { - title: "File" - MenuItem { text: "Open..." } - MenuItem { text: "Close" } - } - -}