Commit e6276c62 authored by Ronan Abhamon's avatar Ronan Abhamon

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
parent 01ba4d78
......@@ -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 || {})
}
// ---------------------------------------------------------------------------
......
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