linphone-desktop/ui/views/App/Main/MainWindow.js
2018-08-22 14:31:58 +02:00

119 lines
2.9 KiB
JavaScript

// =============================================================================
// `MainWindow.qml` Logic.
// =============================================================================
.import Linphone 1.0 as Linphone
.import QtQuick.Window 2.2 as Window
.import 'qrc:/ui/scripts/Utils/utils.js' as Utils
// =============================================================================
function handleActiveFocusItemChanged (activeFocusItem) {
var smartSearchBar = window._smartSearchBar
if (activeFocusItem == null && smartSearchBar) {
smartSearchBar.closeMenu()
}
}
function handleClosing (close) {
if (Linphone.SettingsModel.exitOnClose) {
Qt.quit()
return
}
if (Qt.platform.os === 'osx') {
close.accepted = false
window.showMinimized()
}
}
// -----------------------------------------------------------------------------
function lockView (info) {
window._lockedInfo = info
}
function unlockView () {
window._lockedInfo = undefined
}
function setView (view, props) {
function apply (view, props) {
Linphone.App.smartShowWindow(window)
var item = mainLoader.item
updateSelectedEntry(view, props)
window._currentView = view
item.contentLoader.setSource(view + '.qml', props || {})
}
var lockedInfo = window._lockedInfo
if (!lockedInfo) {
apply(view, props)
return
}
window.attachVirtualWindow(Utils.buildDialogUri('ConfirmDialog'), {
descriptionText: lockedInfo.descriptionText,
}, function (status) {
if (status) {
unlockView()
apply(view, props)
} else {
updateSelectedEntry(window._currentView, props)
}
})
}
// -----------------------------------------------------------------------------
function openConferenceManager () {
var App = Linphone.App
var callsWindow = App.getCallsWindow()
App.smartShowWindow(callsWindow)
callsWindow.openConferenceManager()
}
function manageAccounts () {
window.attachVirtualWindow(Qt.resolvedUrl('Dialogs/ManageAccounts.qml'))
}
// -----------------------------------------------------------------------------
function updateSelectedEntry (view, props) {
var item = mainLoader.item
var menu = item.menu
var timeline = item.timeline
if (view === 'Home') {
item.homeEntry.select()
timeline.resetSelectedEntry()
} else if (view === 'Contacts') {
item.contactsEntry.select()
timeline.resetSelectedEntry()
} else {
menu.resetSelectedEntry()
if (view === 'Conversation') {
timeline.setSelectedEntry(props.peerAddress, props.localAddress)
} else if (view === 'ContactEdit') {
timeline.resetSelectedEntry()
}
}
}
// -----------------------------------------------------------------------------
function handleAuthenticationRequested (authInfo, realm, sipAddress, userId) {
window.attachVirtualWindow(Qt.resolvedUrl('Dialogs/AuthenticationRequest.qml'), {
authInfo: authInfo,
realm: realm,
sipAddress: sipAddress,
userId: userId
})
}