mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(ui/views/App/MainWindow/MainWindow):
- add a lock feature of views - display a confirm dialog when lock is enabled and if the user try to change the view - `ContactEdit` use a lock on edition
This commit is contained in:
parent
01ba4d78eb
commit
e6276c6212
5 changed files with 72 additions and 7 deletions
|
|
@ -190,6 +190,14 @@
|
|||
<source>locality</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>abortEditionTitle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>abortEditionDescriptionText</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Contacts</name>
|
||||
|
|
|
|||
|
|
@ -178,6 +178,14 @@
|
|||
<source>locality</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>abortEditionTitle</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>abortEditionDescriptionText</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Contacts</name>
|
||||
|
|
|
|||
|
|
@ -105,11 +105,11 @@ function getTopParent (object, useFakeParent) {
|
|||
function openConfirmDialog (parent, options) {
|
||||
return openWindow(
|
||||
'import QtQuick 2.7;' +
|
||||
'import Common 1.0;' +
|
||||
'ConfirmDialog {' +
|
||||
'import Common 1.0;' +
|
||||
'ConfirmDialog {' +
|
||||
'descriptionText: \'' + escapeQuotes(options.descriptionText) + '\';' +
|
||||
'title: \'' + escapeQuotes(options.title) + '\'' +
|
||||
'}',
|
||||
'}',
|
||||
parent, {
|
||||
isString: true,
|
||||
exitHandler: options.exitHandler
|
||||
|
|
|
|||
|
|
@ -25,11 +25,17 @@ ColumnLayout {
|
|||
function _editContact () {
|
||||
_contact.startEdit()
|
||||
_edition = true
|
||||
|
||||
window.lockView({
|
||||
title: qsTr('abortEditionTitle'),
|
||||
descriptionText: qsTr('abortEditionDescriptionText')
|
||||
})
|
||||
}
|
||||
|
||||
function _save () {
|
||||
if (_contact) {
|
||||
_contact.endEdit()
|
||||
window.unlockView()
|
||||
} else {
|
||||
_contact = ContactsListModel.addContact(_vcard)
|
||||
}
|
||||
|
|
@ -41,6 +47,7 @@ ColumnLayout {
|
|||
if (_contact) {
|
||||
_contact.abortEdit()
|
||||
_edition = false
|
||||
window.unlockView()
|
||||
} else {
|
||||
window.setView('Contacts')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,20 +13,62 @@ import App.Styles 1.0
|
|||
ApplicationWindow {
|
||||
id: window
|
||||
|
||||
property string _currentView: ''
|
||||
property var _lockedInfo
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function lockView (info) {
|
||||
_lockedInfo = info
|
||||
}
|
||||
|
||||
function unlockView () {
|
||||
_lockedInfo = undefined
|
||||
}
|
||||
|
||||
function setView (view, props) {
|
||||
if (!_lockedInfo) {
|
||||
_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 ensureCollapsed () {
|
||||
collapse.setCollapsed(true)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
contentLoader.setSource(view + '.qml', props || {})
|
||||
}
|
||||
|
||||
function ensureCollapsed () {
|
||||
collapse.setCollapsed(true)
|
||||
function _setView (view, props) {
|
||||
_updateSelectedEntry(view, props)
|
||||
_currentView = view
|
||||
contentLoader.setSource(view + '.qml', props || {})
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue