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 @@ ...@@ -190,6 +190,14 @@
<source>locality</source> <source>locality</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>abortEditionTitle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>abortEditionDescriptionText</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Contacts</name> <name>Contacts</name>
......
...@@ -178,6 +178,14 @@ ...@@ -178,6 +178,14 @@
<source>locality</source> <source>locality</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>abortEditionTitle</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>abortEditionDescriptionText</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Contacts</name> <name>Contacts</name>
......
...@@ -105,11 +105,11 @@ function getTopParent (object, useFakeParent) { ...@@ -105,11 +105,11 @@ function getTopParent (object, useFakeParent) {
function openConfirmDialog (parent, options) { function openConfirmDialog (parent, options) {
return openWindow( return openWindow(
'import QtQuick 2.7;' + 'import QtQuick 2.7;' +
'import Common 1.0;' + 'import Common 1.0;' +
'ConfirmDialog {' + 'ConfirmDialog {' +
'descriptionText: \'' + escapeQuotes(options.descriptionText) + '\';' + 'descriptionText: \'' + escapeQuotes(options.descriptionText) + '\';' +
'title: \'' + escapeQuotes(options.title) + '\'' + 'title: \'' + escapeQuotes(options.title) + '\'' +
'}', '}',
parent, { parent, {
isString: true, isString: true,
exitHandler: options.exitHandler exitHandler: options.exitHandler
......
...@@ -25,11 +25,17 @@ ColumnLayout { ...@@ -25,11 +25,17 @@ ColumnLayout {
function _editContact () { function _editContact () {
_contact.startEdit() _contact.startEdit()
_edition = true _edition = true
window.lockView({
title: qsTr('abortEditionTitle'),
descriptionText: qsTr('abortEditionDescriptionText')
})
} }
function _save () { function _save () {
if (_contact) { if (_contact) {
_contact.endEdit() _contact.endEdit()
window.unlockView()
} else { } else {
_contact = ContactsListModel.addContact(_vcard) _contact = ContactsListModel.addContact(_vcard)
} }
...@@ -41,6 +47,7 @@ ColumnLayout { ...@@ -41,6 +47,7 @@ ColumnLayout {
if (_contact) { if (_contact) {
_contact.abortEdit() _contact.abortEdit()
_edition = false _edition = false
window.unlockView()
} else { } else {
window.setView('Contacts') window.setView('Contacts')
} }
......
...@@ -13,20 +13,62 @@ import App.Styles 1.0 ...@@ -13,20 +13,62 @@ import App.Styles 1.0
ApplicationWindow { ApplicationWindow {
id: window id: window
property string _currentView: ''
property var _lockedInfo
// ---------------------------------------------------------------------------
function lockView (info) {
_lockedInfo = info
}
function unlockView () {
_lockedInfo = undefined
}
function setView (view, props) { 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') { if (view === 'Home' || view === 'Contacts') {
menu.setSelectedEntry(view === 'Home' ? 0 : 1) menu.setSelectedEntry(view === 'Home' ? 0 : 1)
timeline.resetSelectedEntry() timeline.resetSelectedEntry()
} else if (view === 'Conversation') { } else if (view === 'Conversation') {
menu.resetSelectedEntry() menu.resetSelectedEntry()
timeline.setSelectedEntry(props.sipAddress) timeline.setSelectedEntry(props.sipAddress)
} else if (view === 'ContactEdit') {
menu.resetSelectedEntry()
timeline.resetSelectedEntry()
} }
contentLoader.setSource(view + '.qml', props || {})
} }
function ensureCollapsed () { function _setView (view, props) {
collapse.setCollapsed(true) _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