diff --git a/resources.qrc b/resources.qrc index 3be083616..bd49023b3 100644 --- a/resources.qrc +++ b/resources.qrc @@ -426,6 +426,7 @@ ui/views/App/Main/Dialogs/About.qml ui/views/App/Main/Dialogs/AuthenticationRequest.js ui/views/App/Main/Dialogs/AuthenticationRequest.qml + ui/views/App/Main/Dialogs/ManageAccount.js ui/views/App/Main/Dialogs/ManageAccounts.qml ui/views/App/Main/Home.qml ui/views/App/Main/InviteFriends.qml diff --git a/src/components/settings/AccountSettingsModel.cpp b/src/components/settings/AccountSettingsModel.cpp index f3698de9e..ce514ad85 100644 --- a/src/components/settings/AccountSettingsModel.cpp +++ b/src/components/settings/AccountSettingsModel.cpp @@ -362,6 +362,7 @@ QVariantList AccountSettingsModel::getAccounts () const { { QVariantMap account; account["sipAddress"] = Utils::coreStringToAppString(core->getPrimaryContactParsed()->asStringUriOnly()); + account["unreadMessageCount"] = core->getUnreadChatMessageCountFromLocal(core->getPrimaryContactParsed()); accounts << account; } @@ -369,6 +370,7 @@ QVariantList AccountSettingsModel::getAccounts () const { QVariantMap account; account["sipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asStringUriOnly()); account["proxyConfig"].setValue(proxyConfig); + account["unreadMessageCount"] = proxyConfig->getUnreadChatMessageCount(); accounts << account; } diff --git a/ui/modules/Common/Form/ComboBox.js b/ui/modules/Common/Form/ComboBox.js index 14fdc882a..4d881aba9 100644 --- a/ui/modules/Common/Form/ComboBox.js +++ b/ui/modules/Common/Form/ComboBox.js @@ -55,7 +55,7 @@ function getSelectedEntryText () { return '' } -function getEntryIcon (item) { +function getItemIcon (item) { var iconRole = comboBox.iconRole if (iconRole == null || iconRole.length === 0) { return '' diff --git a/ui/modules/Common/Form/ComboBox.qml b/ui/modules/Common/Form/ComboBox.qml index f112af834..f382416c8 100644 --- a/ui/modules/Common/Form/ComboBox.qml +++ b/ui/modules/Common/Form/ComboBox.qml @@ -87,7 +87,7 @@ Controls.ComboBox { container: comboBox flattenedModel: comboBox.textRole.length && (typeof modelData !== 'undefined' ? modelData : model) - itemIcon: Logic.getEntryIcon(item) + itemIcon: Logic.getItemIcon(item) width: comboBox.width } } diff --git a/ui/modules/Common/Form/CommonItemDelegate.qml b/ui/modules/Common/Form/CommonItemDelegate.qml index 8221d4648..176200096 100644 --- a/ui/modules/Common/Form/CommonItemDelegate.qml +++ b/ui/modules/Common/Form/CommonItemDelegate.qml @@ -14,6 +14,8 @@ Controls.ItemDelegate { property var flattenedModel property var itemIcon + default property alias _content: content.data + hoverEnabled: true background: Rectangle { @@ -64,7 +66,14 @@ Controls.ItemDelegate { pointSize: CommonItemDelegateStyle.contentItem.text.pointSize } - text: item.flattenedModel[textRole] || modelData + text: item.flattenedModel[container.textRole] || modelData + } + + Item { + id: content + + Layout.preferredWidth: CommonItemDelegateStyle.contentItem.iconSize + Layout.preferredHeight: CommonItemDelegateStyle.contentItem.iconSize } } } diff --git a/ui/modules/Common/Form/ListItemSelector.js b/ui/modules/Common/Form/ListItemSelector.js index 038486407..9d25c7d42 100644 --- a/ui/modules/Common/Form/ListItemSelector.js +++ b/ui/modules/Common/Form/ListItemSelector.js @@ -6,7 +6,7 @@ // ============================================================================= -function getEntryIcon (item) { +function getItemIcon (item) { var iconRole = view.iconRole if (iconRole == null || iconRole.length === 0) { return '' diff --git a/ui/modules/Common/Form/ListItemSelector.qml b/ui/modules/Common/Form/ListItemSelector.qml index dc5ae27c5..228540f99 100644 --- a/ui/modules/Common/Form/ListItemSelector.qml +++ b/ui/modules/Common/Form/ListItemSelector.qml @@ -33,7 +33,7 @@ ScrollableListViewField { container: view flattenedModel: view.textRole.length && (typeof modelData !== 'undefined' ? modelData : model) - itemIcon: Logic.getEntryIcon(item) + itemIcon: Logic.getItemIcon(item) width: parent.width onClicked: activated(index) diff --git a/ui/modules/Common/qmldir b/ui/modules/Common/qmldir index 5d748dcbe..bb3ae4d55 100644 --- a/ui/modules/Common/qmldir +++ b/ui/modules/Common/qmldir @@ -20,6 +20,7 @@ ActionButton 1.0 Form/ActionButton.qml ActionSwitch 1.0 Form/ActionSwitch.qml CheckBoxText 1.0 Form/CheckBoxText.qml ComboBox 1.0 Form/ComboBox.qml +CommonItemDelegate 1.0 Form/CommonItemDelegate.qml DroppableTextArea 1.0 Form/DroppableTextArea.qml ListForm 1.0 Form/ListForm.qml ListItemSelector 1.0 Form/ListItemSelector.qml diff --git a/ui/views/App/Main/Dialogs/ManageAccount.js b/ui/views/App/Main/Dialogs/ManageAccount.js new file mode 100644 index 000000000..622925c4e --- /dev/null +++ b/ui/views/App/Main/Dialogs/ManageAccount.js @@ -0,0 +1,15 @@ +// ============================================================================= +// `ManageAccount.qml` Logic. +// ============================================================================= + +function getItemIcon (data) { + var proxyConfig = data.proxyConfig + if (!proxyConfig) { + return '' + } + + var description = AccountSettingsModel.getProxyConfigDescription(proxyConfig) + return description.registerEnabled && description.registrationState !== AccountSettingsModel.RegistrationStateRegistered + ? 'generic_error' + : '' +} diff --git a/ui/views/App/Main/Dialogs/ManageAccounts.qml b/ui/views/App/Main/Dialogs/ManageAccounts.qml index 162e16553..c336b98b0 100644 --- a/ui/views/App/Main/Dialogs/ManageAccounts.qml +++ b/ui/views/App/Main/Dialogs/ManageAccounts.qml @@ -6,6 +6,8 @@ import Utils 1.0 import App.Styles 1.0 +import 'ManageAccount.js' as Logic + // ============================================================================= DialogPlus { @@ -53,29 +55,39 @@ DialogPlus { FormGroup { label: qsTr('selectAccountLabel') - ListItemSelector { + ScrollableListViewField { width: parent.width height: ManageAccountsStyle.accountSelector.height - currentIndex: Utils.findIndex(AccountSettingsModel.accounts, function (account) { - return account.sipAddress === AccountSettingsModel.sipAddress - }) + radius: 0 - model: AccountSettingsModel.accounts - iconRole: (function (data) { - var proxyConfig = data.proxyConfig - if (!proxyConfig) { - return '' + ScrollableListView { + id: view + + property string textRole: 'sipAddress' // Used by delegate. + + anchors.fill: parent + currentIndex: Utils.findIndex(AccountSettingsModel.accounts, function (account) { + return account.sipAddress === AccountSettingsModel.sipAddress + }) + model: AccountSettingsModel.accounts + + delegate: CommonItemDelegate { + id: item + + container: view + flattenedModel: modelData + itemIcon: Logic.getItemIcon(flattenedModel) + width: parent.width + + onClicked: AccountSettingsModel.setDefaultProxyConfig(flattenedModel.proxyConfig) + + MessageCounter { + anchors.fill: parent + count: flattenedModel.unreadMessageCount + } } - - var description = AccountSettingsModel.getProxyConfigDescription(proxyConfig) - return description.registerEnabled && description.registrationState !== AccountSettingsModel.RegistrationStateRegistered - ? 'generic_error' - : '' - }) - textRole: 'sipAddress' - - onActivated: AccountSettingsModel.setDefaultProxyConfig(model[index].proxyConfig) + } } } }