diff --git a/assets/languages/de.ts b/assets/languages/de.ts index df3a0526f..3ed85ad3f 100644 --- a/assets/languages/de.ts +++ b/assets/languages/de.ts @@ -1218,6 +1218,14 @@ Klicken Sie hier: <a href="%1">%1</a> conferenceEnabledLabel + + contactsTitle + + + + contactsEnabledLabel + + SettingsNetwork diff --git a/assets/languages/en.ts b/assets/languages/en.ts index 8aae36c8a..852ae27c6 100644 --- a/assets/languages/en.ts +++ b/assets/languages/en.ts @@ -1220,6 +1220,14 @@ your friend's SIP address or username. conferenceEnabledLabel Enable conference + + contactsTitle + Contacts + + + contactsEnabledLabel + Enable contacts + SettingsNetwork diff --git a/assets/languages/fr_FR.ts b/assets/languages/fr_FR.ts index 6f8e3427f..5101ec883 100644 --- a/assets/languages/fr_FR.ts +++ b/assets/languages/fr_FR.ts @@ -1218,6 +1218,14 @@ Cliquez ici : <a href="%1">%1</a> conferenceEnabledLabel Activer la conférence + + contactsTitle + Contacts + + + contactsEnabledLabel + Activer les contacts + SettingsNetwork diff --git a/assets/languages/ja.ts b/assets/languages/ja.ts index 337c05466..f62a6777b 100644 --- a/assets/languages/ja.ts +++ b/assets/languages/ja.ts @@ -1215,6 +1215,14 @@ conferenceEnabledLabel + + contactsTitle + + + + contactsEnabledLabel + + SettingsNetwork diff --git a/assets/languages/lt.ts b/assets/languages/lt.ts index e6a685635..f24d3b2e5 100644 --- a/assets/languages/lt.ts +++ b/assets/languages/lt.ts @@ -1220,6 +1220,14 @@ Tiesiog, įveskite savo draugo SIP adresą ar naudotojo vardą. conferenceEnabledLabel + + contactsTitle + + + + contactsEnabledLabel + + SettingsNetwork diff --git a/assets/languages/pt_BR.ts b/assets/languages/pt_BR.ts index 5e4918a5c..89a8d3be2 100644 --- a/assets/languages/pt_BR.ts +++ b/assets/languages/pt_BR.ts @@ -1220,6 +1220,14 @@ o endereço SIP ou nome de usuário do seu amigo. conferenceEnabledLabel + + contactsTitle + + + + contactsEnabledLabel + + SettingsNetwork diff --git a/assets/languages/ru.ts b/assets/languages/ru.ts index 899812494..56ca5abf8 100644 --- a/assets/languages/ru.ts +++ b/assets/languages/ru.ts @@ -1218,6 +1218,14 @@ conferenceEnabledLabel + + contactsTitle + + + + contactsEnabledLabel + + SettingsNetwork diff --git a/assets/languages/sv.ts b/assets/languages/sv.ts index b847fb70f..a3127dcea 100644 --- a/assets/languages/sv.ts +++ b/assets/languages/sv.ts @@ -1217,6 +1217,14 @@ Klicka här: <a href="%1">%1</a> conferenceEnabledLabel + + contactsTitle + + + + contactsEnabledLabel + + SettingsNetwork diff --git a/assets/languages/tr.ts b/assets/languages/tr.ts index 05784b186..c1f9cded7 100644 --- a/assets/languages/tr.ts +++ b/assets/languages/tr.ts @@ -1220,6 +1220,14 @@ arkadaşınızın SIP adresini veya kullanıcı adını girin. conferenceEnabledLabel + + contactsTitle + + + + contactsEnabledLabel + + SettingsNetwork diff --git a/resources.qrc b/resources.qrc index 1edae91b2..dbab42029 100644 --- a/resources.qrc +++ b/resources.qrc @@ -248,6 +248,7 @@ ui/modules/Common/Image/Icon.qml ui/modules/Common/Image/RoundedImage.qml ui/modules/Common/Indicators/VuMeter.qml + ui/modules/Common/Menus/ApplicationMenuEntry.qml ui/modules/Common/Menus/ApplicationMenu.qml ui/modules/Common/Menus/DropDownDynamicMenu.qml ui/modules/Common/Menus/DropDownStaticMenuEntry.qml diff --git a/src/components/settings/SettingsModel.cpp b/src/components/settings/SettingsModel.cpp index 4738520f9..727cd3b83 100644 --- a/src/components/settings/SettingsModel.cpp +++ b/src/components/settings/SettingsModel.cpp @@ -423,6 +423,17 @@ void SettingsModel::setLimeState (LimeState state) { emit limeStateChanged(state); } +// ----------------------------------------------------------------------------- + +bool SettingsModel::getContactsEnabled () const { + return !!mConfig->getInt(UiSection, "contacts_enabled", 1); +} + +void SettingsModel::setContactsEnabled (bool status) { + mConfig->setInt(UiSection, "contacts_enabled", status); + emit contactsEnabledChanged(status); +} + // ============================================================================= // Network. // ============================================================================= diff --git a/src/components/settings/SettingsModel.hpp b/src/components/settings/SettingsModel.hpp index d946d2698..251864d52 100644 --- a/src/components/settings/SettingsModel.hpp +++ b/src/components/settings/SettingsModel.hpp @@ -86,6 +86,8 @@ class SettingsModel : public QObject { Q_PROPERTY(MediaEncryption mediaEncryption READ getMediaEncryption WRITE setMediaEncryption NOTIFY mediaEncryptionChanged); Q_PROPERTY(LimeState limeState READ getLimeState WRITE setLimeState NOTIFY limeStateChanged); + Q_PROPERTY(bool contactsEnabled READ getContactsEnabled WRITE setContactsEnabled NOTIFY contactsEnabledChanged); + // Network. ------------------------------------------------------------------ Q_PROPERTY(bool useSipInfoForDtmfs READ getUseSipInfoForDtmfs WRITE setUseSipInfoForDtmfs NOTIFY dtmfsProtocolChanged); @@ -243,6 +245,9 @@ public: LimeState getLimeState () const; void setLimeState (LimeState state); + bool getContactsEnabled () const; + void setContactsEnabled (bool status); + // Network. ------------------------------------------------------------------ bool getUseSipInfoForDtmfs () const; @@ -395,6 +400,8 @@ signals: void mediaEncryptionChanged (MediaEncryption encryption); void limeStateChanged (LimeState state); + void contactsEnabledChanged (bool status); + // Network. ------------------------------------------------------------------ void dtmfsProtocolChanged (); diff --git a/ui/modules/Common/Menus/ApplicationMenu.qml b/ui/modules/Common/Menus/ApplicationMenu.qml index 83288a9f8..2fee739b6 100644 --- a/ui/modules/Common/Menus/ApplicationMenu.qml +++ b/ui/modules/Common/Menus/ApplicationMenu.qml @@ -1,7 +1,6 @@ import QtQuick 2.7 import QtQuick.Layouts 1.3 -import Common 1.0 import Common.Styles 1.0 // ============================================================================= @@ -13,24 +12,19 @@ Rectangle { // --------------------------------------------------------------------------- + property var defaultSelectedEntry: null + property int entryHeight property int entryWidth - property var entries - property int _selectedEntry: 0 + property var _selected: defaultSelectedEntry + + default property alias _content: content.data // --------------------------------------------------------------------------- - signal entrySelected (int entry) - - // --------------------------------------------------------------------------- - - function setSelectedEntry (entry) { - _selectedEntry = entry - } - function resetSelectedEntry () { - _selectedEntry = -1 + _selected = null } // --------------------------------------------------------------------------- @@ -39,84 +33,10 @@ Rectangle { implicitHeight: content.height width: entryWidth - ColumnLayout { + Column { id: content - anchors.centerIn: parent + width: parent.width spacing: ApplicationMenuStyle.spacing - - Repeater { - model: entries - - Rectangle { - color: mouseArea.pressed - ? ApplicationMenuStyle.entry.color.pressed - : (_selectedEntry === index - ? ApplicationMenuStyle.entry.color.selected - : (mouseArea.containsMouse - ? ApplicationMenuStyle.entry.color.hovered - : ApplicationMenuStyle.entry.color.normal - ) - ) - height: menu.entryHeight - width: menu.entryWidth - - RowLayout { - anchors { - left: parent.left - leftMargin: ApplicationMenuStyle.entry.leftMargin - right: parent.right - rightMargin: ApplicationMenuStyle.entry.rightMargin - verticalCenter: parent.verticalCenter - } - - spacing: ApplicationMenuStyle.entry.spacing - - Icon { - icon: modelData.icon + ( - _selectedEntry === index - ? '_selected' - : '_normal' - ) - iconSize: ApplicationMenuStyle.entry.iconSize - } - - Text { - Layout.fillWidth: true - color: _selectedEntry === index - ? ApplicationMenuStyle.entry.text.color.selected - : ApplicationMenuStyle.entry.text.color.normal - font.pointSize: ApplicationMenuStyle.entry.text.pointSize - height: parent.height - text: modelData.entryName - verticalAlignment: Text.AlignVCenter - } - } - - Rectangle { - anchors { - left: parent.left - } - - height: parent.height - color: _selectedEntry === index - ? ApplicationMenuStyle.entry.indicator.color - : 'transparent' - width: ApplicationMenuStyle.entry.indicator.width - } - - MouseArea { - id: mouseArea - - anchors.fill: parent - hoverEnabled: true - - onClicked: { - _selectedEntry = index - entrySelected(index) - } - } - } - } } } diff --git a/ui/modules/Common/Menus/ApplicationMenuEntry.qml b/ui/modules/Common/Menus/ApplicationMenuEntry.qml new file mode 100644 index 000000000..e3c3fab7a --- /dev/null +++ b/ui/modules/Common/Menus/ApplicationMenuEntry.qml @@ -0,0 +1,101 @@ +import QtQuick 2.7 +import QtQuick.Layouts 1.3 + +import Common 1.0 +import Common.Styles 1.0 + +// ============================================================================= + +Rectangle { + id: entry + + // --------------------------------------------------------------------------- + + property string icon + property alias name: text.text + + readonly property bool isSelected: parent.parent._selected === this + + // --------------------------------------------------------------------------- + + signal selected + + // --------------------------------------------------------------------------- + + function select () { + var menu = parent.parent + if (menu._selected !== this) { + menu._selected = this + selected() + } + } + + // --------------------------------------------------------------------------- + + color: mouseArea.pressed + ? ApplicationMenuStyle.entry.color.pressed + : (isSelected + ? ApplicationMenuStyle.entry.color.selected + : (mouseArea.containsMouse + ? ApplicationMenuStyle.entry.color.hovered + : ApplicationMenuStyle.entry.color.normal + ) + ) + height: parent.parent.entryHeight + width: parent.parent.entryWidth + + RowLayout { + anchors { + left: parent.left + leftMargin: ApplicationMenuStyle.entry.leftMargin + right: parent.right + rightMargin: ApplicationMenuStyle.entry.rightMargin + verticalCenter: parent.verticalCenter + } + + spacing: ApplicationMenuStyle.entry.spacing + + Icon { + icon: entry.icon + ( + entry.isSelected + ? '_selected' + : '_normal' + ) + iconSize: ApplicationMenuStyle.entry.iconSize + } + + Text { + id: text + + Layout.fillWidth: true + color: entry.isSelected + ? ApplicationMenuStyle.entry.text.color.selected + : ApplicationMenuStyle.entry.text.color.normal + font.pointSize: ApplicationMenuStyle.entry.text.pointSize + height: parent.height + text: entry.name + verticalAlignment: Text.AlignVCenter + } + } + + Rectangle { + anchors { + left: parent.left + } + + height: parent.height + color: entry.isSelected + ? ApplicationMenuStyle.entry.indicator.color + : 'transparent' + width: ApplicationMenuStyle.entry.indicator.width + } + + MouseArea { + id: mouseArea + + anchors.fill: parent + hoverEnabled: true + + onClicked: entry.select() + } +} diff --git a/ui/modules/Common/qmldir b/ui/modules/Common/qmldir index 78f93994f..1a3bab8e3 100644 --- a/ui/modules/Common/qmldir +++ b/ui/modules/Common/qmldir @@ -62,6 +62,7 @@ RoundedImage 1.0 Image/RoundedImage.qml VuMeter 1.0 Indicators/VuMeter.qml ApplicationMenu 1.0 Menus/ApplicationMenu.qml +ApplicationMenuEntry 1.0 Menus/ApplicationMenuEntry.qml DropDownDynamicMenu 1.0 Menus/DropDownDynamicMenu.qml DropDownStaticMenu 1.0 Menus/DropDownStaticMenu.qml DropDownStaticMenuEntry 1.0 Menus/DropDownStaticMenuEntry.qml diff --git a/ui/views/App/Main/Conversation.qml b/ui/views/App/Main/Conversation.qml index c1184e785..0b8b249ee 100644 --- a/ui/views/App/Main/Conversation.qml +++ b/ui/views/App/Main/Conversation.qml @@ -92,6 +92,7 @@ ColumnLayout { ActionButton { icon: Logic.getEditIcon() iconSize: ConversationStyle.bar.actions.edit.iconSize + visible: SettingsModel.contactsEnabled onClicked: window.setView('ContactEdit', { sipAddress: conversation.sipAddress diff --git a/ui/views/App/Main/MainWindow.js b/ui/views/App/Main/MainWindow.js index 91dbb43a7..6e3dcadb9 100644 --- a/ui/views/App/Main/MainWindow.js +++ b/ui/views/App/Main/MainWindow.js @@ -90,8 +90,11 @@ function updateSelectedEntry (view, props) { var menu = item.menu var timeline = item.timeline - if (view === 'Home' || view === 'Contacts') { - menu.setSelectedEntry(view === 'Home' ? 0 : 1) + if (view === 'Home') { + item.homeEntry.select() + timeline.resetSelectedEntry() + } else if (view === 'Contacts') { + item.contactsEntry.select() timeline.resetSelectedEntry() } else if (view === 'Conversation') { menu.resetSelectedEntry() diff --git a/ui/views/App/Main/MainWindow.qml b/ui/views/App/Main/MainWindow.qml index 3e91041c2..12259c3c5 100644 --- a/ui/views/App/Main/MainWindow.qml +++ b/ui/views/App/Main/MainWindow.qml @@ -68,8 +68,11 @@ ApplicationWindow { sourceComponent: ColumnLayout { // Workaround to get these properties in `MainWindow.js`. + readonly property alias contactsEntry: contactsEntry readonly property alias contentLoader: contentLoader + readonly property alias homeEntry: homeEntry readonly property alias menu: menu + readonly property alias timeline: timeline spacing: 0 @@ -143,7 +146,9 @@ ApplicationWindow { sipAddress: sipAddress }) - onEntryClicked: window.setView(entry.contact ? 'ContactEdit' : 'Conversation', { + onEntryClicked: window.setView(entry.contact && SettingsModel.contactsEnabled + ? 'ContactEdit' + : 'Conversation', { sipAddress: entry.sipAddress }) @@ -201,18 +206,29 @@ ApplicationWindow { ApplicationMenu { id: menu + defaultSelectedEntry: homeEntry + entryHeight: MainWindowStyle.menu.height entryWidth: MainWindowStyle.menu.width - entries: [{ - entryName: qsTr('homeEntry'), - icon: 'home' - }, { - entryName: qsTr('contactsEntry'), - icon: 'contact' - }] + ApplicationMenuEntry { + id: homeEntry - onEntrySelected: !entry ? setView('Home') : setView('Contacts') + icon: 'home' + name: qsTr('homeEntry') + + onSelected: setView('Home') + } + + ApplicationMenuEntry { + id: contactsEntry + + icon: 'contact' + name: qsTr('contactsEntry') + visible: SettingsModel.contactsEnabled + + onSelected: setView('Contacts') + } } // History. diff --git a/ui/views/App/Settings/SettingsCallsChat.qml b/ui/views/App/Settings/SettingsCallsChat.qml index 2e4b340dd..6a3615f72 100644 --- a/ui/views/App/Settings/SettingsCallsChat.qml +++ b/ui/views/App/Settings/SettingsCallsChat.qml @@ -219,5 +219,23 @@ TabContainer { } } } + + Form { + title: qsTr('contactsTitle') + visible: SettingsModel.developerSettingsEnabled + width: parent.width + + FormLine { + FormGroup { + label: qsTr('contactsEnabledLabel') + + Switch { + checked: SettingsModel.contactsEnabled + + onClicked: SettingsModel.contactsEnabled = !checked + } + } + } + } } }