mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-30 07:16:22 +00:00
feat(ui/views/App/Main/MainWindow): use a logic file
This commit is contained in:
parent
2069e990af
commit
2d8cf78839
4 changed files with 79 additions and 57 deletions
|
|
@ -324,6 +324,7 @@
|
||||||
<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/InviteFriends.qml</file>
|
<file>ui/views/App/Main/InviteFriends.qml</file>
|
||||||
|
<file>ui/views/App/Main/MainWindow.js</file>
|
||||||
<file>ui/views/App/Main/MainWindowMenuBar.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/ManageAccountsWindow.qml</file>
|
<file>ui/views/App/ManageAccountsWindow.qml</file>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
|
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
// Returns the username of a contact object or URI string.
|
// Returns the username of a contact object or URI string.
|
||||||
function getContactUsername (contact) {
|
function getContactUsername (contact) {
|
||||||
return Utils.isString(contact)
|
return Utils.isString(contact)
|
||||||
|
|
|
||||||
66
linphone-desktop/ui/views/App/Main/MainWindow.js
Normal file
66
linphone-desktop/ui/views/App/Main/MainWindow.js
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
// =============================================================================
|
||||||
|
// `MainWindow.qml` Logic.
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
.import QtQuick.Window 2.2 as Window
|
||||||
|
|
||||||
|
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
|
||||||
|
|
||||||
|
// =============================================================================
|
||||||
|
|
||||||
|
function lockView (info) {
|
||||||
|
window._lockedInfo = info
|
||||||
|
}
|
||||||
|
|
||||||
|
function unlockView () {
|
||||||
|
window._lockedInfo = undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
function setView (view, props) {
|
||||||
|
function apply (view, props) {
|
||||||
|
if (window.visibility === Window.Minimized) {
|
||||||
|
window.visibility = Window.AutomaticVisibility
|
||||||
|
} else {
|
||||||
|
window.setVisible(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
collapse.setCollapsed(true)
|
||||||
|
updateSelectedEntry(view, props)
|
||||||
|
window._currentView = view
|
||||||
|
contentLoader.setSource(view + '.qml', props || {})
|
||||||
|
}
|
||||||
|
|
||||||
|
var lockedInfo = window._lockedInfo
|
||||||
|
if (!lockedInfo) {
|
||||||
|
apply(view, props)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Utils.openConfirmDialog(window, {
|
||||||
|
descriptionText: lockedInfo.descriptionText,
|
||||||
|
exitHandler: function (status) {
|
||||||
|
if (status) {
|
||||||
|
unlockView()
|
||||||
|
apply(view, props)
|
||||||
|
} else {
|
||||||
|
updateSelectedEntry(window._currentView, props)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title: lockedInfo.title
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function updateSelectedEntry (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)
|
||||||
|
} else if (view === 'ContactEdit') {
|
||||||
|
menu.resetSelectedEntry()
|
||||||
|
timeline.resetSelectedEntry()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import QtQuick 2.7
|
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.Window 2.2
|
|
||||||
|
|
||||||
// Explicit import to support Toolbar.
|
// Explicit import to support Toolbar.
|
||||||
import QtQuick.Controls 1.4 as Controls1
|
import QtQuick.Controls 1.4 as Controls1
|
||||||
|
|
@ -12,6 +11,8 @@ import Utils 1.0
|
||||||
|
|
||||||
import App.Styles 1.0
|
import App.Styles 1.0
|
||||||
|
|
||||||
|
import 'MainWindow.js' as Logic
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
Controls1.ApplicationWindow {
|
Controls1.ApplicationWindow {
|
||||||
|
|
@ -23,64 +24,15 @@ Controls1.ApplicationWindow {
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
function lockView (info) {
|
function lockView (info) {
|
||||||
_lockedInfo = info
|
Logic.lockView(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
function unlockView () {
|
function unlockView () {
|
||||||
_lockedInfo = undefined
|
Logic.unlockView(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setView (view, props) {
|
function setView (view, props) {
|
||||||
if (!_lockedInfo) {
|
Logic.setView(view, props)
|
||||||
_setView(view, props)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Utils.openConfirmDialog(window, {
|
|
||||||
descriptionText: _lockedInfo.descriptionText,
|
|
||||||
exitHandler: function (status) {
|
|
||||||
if (status) {
|
|
||||||
unlockView()
|
|
||||||
_setView(view, props)
|
|
||||||
} else {
|
|
||||||
_updateSelectedEntry(_currentView, props)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
title: _lockedInfo.title
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
function _updateSelectedEntry (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)
|
|
||||||
} else if (view === 'ContactEdit') {
|
|
||||||
menu.resetSelectedEntry()
|
|
||||||
timeline.resetSelectedEntry()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function _forceView (view, props) {
|
|
||||||
collapse.setCollapsed(true)
|
|
||||||
|
|
||||||
_updateSelectedEntry(view, props)
|
|
||||||
_currentView = view
|
|
||||||
contentLoader.setSource(view + '.qml', props || {})
|
|
||||||
}
|
|
||||||
|
|
||||||
function _setView (view, props) {
|
|
||||||
if (window.visibility === Window.Minimized) {
|
|
||||||
window.visibility = Window.AutomaticVisibility
|
|
||||||
} else {
|
|
||||||
window.setVisible(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
_forceView(view, props)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
@ -105,10 +57,6 @@ Controls1.ApplicationWindow {
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
Component.onCompleted: Utils.setTimeout(window, 0, function () {
|
|
||||||
_forceView('Home')
|
|
||||||
})
|
|
||||||
|
|
||||||
onActiveFocusItemChanged: activeFocusItem == null && smartSearchBar.hideMenu()
|
onActiveFocusItemChanged: activeFocusItem == null && smartSearchBar.hideMenu()
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
@ -151,6 +99,8 @@ Controls1.ApplicationWindow {
|
||||||
target: window
|
target: window
|
||||||
targetHeight: MainWindowStyle.minimumHeight
|
targetHeight: MainWindowStyle.minimumHeight
|
||||||
visible: Qt.platform.os !== 'linux'
|
visible: Qt.platform.os !== 'linux'
|
||||||
|
|
||||||
|
Component.onCompleted: setCollapsed(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountStatus {
|
AccountStatus {
|
||||||
|
|
@ -193,6 +143,7 @@ Controls1.ApplicationWindow {
|
||||||
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')
|
||||||
|
|
@ -269,6 +220,8 @@ Controls1.ApplicationWindow {
|
||||||
|
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
source: 'Home.qml'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue