diff --git a/Linphone/core/account/AccountList.cpp b/Linphone/core/account/AccountList.cpp index 09f3b6a7c..66d4c0845 100644 --- a/Linphone/core/account/AccountList.cpp +++ b/Linphone/core/account/AccountList.cpp @@ -60,7 +60,7 @@ void AccountList::setSelf(QSharedPointer me) { QSharedPointer defaultAccountCore; for (auto it : linphoneAccounts) { auto model = AccountCore::create(it); - if (it == defaultAccount) defaultAccountCore = AccountCore::create(defaultAccount); + if (it == defaultAccount) defaultAccountCore = model; accounts->push_back(model); } mModelConnection->invokeToCore([this, accounts, defaultAccountCore, isInitialization]() { @@ -76,8 +76,10 @@ void AccountList::setSelf(QSharedPointer me) { mModelConnection->makeConnectToModel( &CoreModel::defaultAccountChanged, [this](const std::shared_ptr &core, const std::shared_ptr &account) { - if (account) { - auto model = AccountCore::create(account); + if (account && account->getParams()->getIdentityAddress()) { + auto address = + Utils::coreStringToAppString(account->getParams()->getIdentityAddress()->asStringUriOnly()); + auto model = findAccountByAddress(address); mModelConnection->invokeToCore([this, model]() { setDefaultAccount(model); }); } else mModelConnection->invokeToCore([this]() { setDefaultAccount(nullptr); }); }); @@ -104,12 +106,10 @@ void AccountList::setDefaultAccount(QSharedPointer account) { } } -AccountGui *AccountList::findAccountByAddress(const QString &address) { - for (auto &item : mList) { - if (auto isAccount = item.objectCast()) { - if (isAccount->getIdentityAddress() == address) { - return new AccountGui(isAccount); - } +QSharedPointer AccountList::findAccountByAddress(const QString &address) { + for (auto &item : getSharedList()) { + if (item->getIdentityAddress() == address) { + return item; } } return nullptr; diff --git a/Linphone/core/account/AccountList.hpp b/Linphone/core/account/AccountList.hpp index c32a78d00..0b0f3068c 100644 --- a/Linphone/core/account/AccountList.hpp +++ b/Linphone/core/account/AccountList.hpp @@ -43,7 +43,7 @@ public: AccountGui *getDefaultAccount() const; QSharedPointer getDefaultAccountCore() const; void setDefaultAccount(QSharedPointer account); - AccountGui *findAccountByAddress(const QString &address); + QSharedPointer findAccountByAddress(const QString &address); AccountGui *firstAccount(); bool getHaveAccount() const; diff --git a/Linphone/core/account/AccountProxy.cpp b/Linphone/core/account/AccountProxy.cpp index 388b7d4ed..5cd9de3bb 100644 --- a/Linphone/core/account/AccountProxy.cpp +++ b/Linphone/core/account/AccountProxy.cpp @@ -39,9 +39,6 @@ AccountGui *AccountProxy::getDefaultAccount() { return new AccountGui(mDefaultAccount); } -void AccountProxy::setDefaultAccount(AccountGui *account) { -} - // Reset the default account to let UI build its new object if needed. void AccountProxy::resetDefaultAccount() { mDefaultAccount = nullptr; @@ -50,7 +47,7 @@ void AccountProxy::resetDefaultAccount() { AccountGui *AccountProxy::findAccountByAddress(const QString &address) { auto model = getListModel(); - if (model) return model->findAccountByAddress(address); + if (model) return new AccountGui(model->findAccountByAddress(address)); else return nullptr; } diff --git a/Linphone/core/account/AccountProxy.hpp b/Linphone/core/account/AccountProxy.hpp index e3fcf9171..078453470 100644 --- a/Linphone/core/account/AccountProxy.hpp +++ b/Linphone/core/account/AccountProxy.hpp @@ -31,7 +31,7 @@ class AccountProxy : public LimitProxy { Q_OBJECT - Q_PROPERTY(AccountGui *defaultAccount READ getDefaultAccount WRITE setDefaultAccount NOTIFY defaultAccountChanged) + Q_PROPERTY(AccountGui *defaultAccount READ getDefaultAccount NOTIFY defaultAccountChanged) Q_PROPERTY(bool haveAccount READ getHaveAccount NOTIFY haveAccountChanged) Q_PROPERTY(bool isInitialized READ isInitialized NOTIFY initializedChanged) @@ -41,9 +41,8 @@ public: AccountProxy(QObject *parent = Q_NULLPTR); ~AccountProxy(); - AccountGui *getDefaultAccount(); // Get a new object from List or give the stored one. - void setDefaultAccount(AccountGui *account); // TODO - void resetDefaultAccount(); // Reset the default account to let UI build its new object if needed. + AccountGui *getDefaultAccount(); // Get a new object from List or give the stored one. + void resetDefaultAccount(); // Reset the default account to let UI build its new object if needed. Q_INVOKABLE AccountGui *findAccountByAddress(const QString &address); Q_INVOKABLE AccountGui *firstAccount(); diff --git a/Linphone/view/Control/Button/PopupButton.qml b/Linphone/view/Control/Button/PopupButton.qml index 90c5939a4..2730334a3 100644 --- a/Linphone/view/Control/Button/PopupButton.qml +++ b/Linphone/view/Control/Button/PopupButton.qml @@ -27,13 +27,54 @@ Button { function open() { popup.open() } + + function isFocusable(item){ + return item.activeFocusOnTab + } + function getPreviousItem(index){ + return _getPreviousItem(popup.contentItem instanceof FocusScope ? popup.contentItem.children[0] : popup.contentItem, index) + } + function getNextItem(index){ + return _getNextItem(popup.contentItem instanceof FocusScope ? popup.contentItem.children[0] : popup.contentItem, index) + } + + function _getPreviousItem(content, index){ + if(content.visibleChildren.length == 0) return null + --index + while(index >= 0){ + if( isFocusable(content.children[index]) && content.children[index].visible) return content.children[index] + --index + } + return _getPreviousItem(content, content.children.length) + } + function _getNextItem(content, index){ + ++index + while(index < content.children.length){ + if( isFocusable(content.children[index]) && content.children[index].visible) return content.children[index] + ++index + } + return _getNextItem(content, -1) + } Keys.onPressed: (event) => { - if(popup.checked && event.key == Qt.Key_Escape){ - mainItem.close() + if(mainItem.checked){ + if( event.key == Qt.Key_Escape || event.key == Qt.Key_Left || event.key == Qt.Key_Space){ + mainItem.close() + mainItem.forceActiveFocus() + event.accepted = true + }else if(event.key == Qt.Key_Up){ + getPreviousItem(0).forceActiveFocus() + event.accepted = true + }else if(event.key == Qt.Key_Tab || event.key == Qt.Key_Down){ + getNextItem(-1).forceActiveFocus() + event.accepted = true + } + }else if(event.key == Qt.Key_Space){ + mainItem.open() event.accepted = true } } + background: Item { anchors.fill: mainItem Rectangle { @@ -84,16 +125,17 @@ Button { if( y < mainItem.height && y + popupHeight > 0){ x += mainItem.width } - popup.contentItem.forceActiveFocus() } + onHeightChanged: Qt.callLater(updatePosition) onWidthChanged: Qt.callLater(updatePosition) + onVisibleChanged: Qt.callLater(updatePosition) + Connections{ target: mainItem.Window function onHeightChanged(){ Qt.callLater(popup.updatePosition)} function onWidthChanged(){ Qt.callLater(popup.updatePosition)} } - onVisibleChanged: Qt.callLater(updatePosition) background: Item { anchors.fill: parent diff --git a/Linphone/view/Page/Layout/Main/MainLayout.qml b/Linphone/view/Page/Layout/Main/MainLayout.qml index 5f1c09653..ca4633c73 100644 --- a/Linphone/view/Page/Layout/Main/MainLayout.qml +++ b/Linphone/view/Page/Layout/Main/MainLayout.qml @@ -371,46 +371,28 @@ Item { implicitHeight: settingsButtons.implicitHeight implicitWidth: settingsButtons.implicitWidth Keys.onPressed: (event)=> { - if (event.key == Qt.Key_Left || event.key == Qt.Key_Escape) { - settingsMenuButton.popup.close() + if (event.key == Qt.Key_Left || event.key == Qt.Key_Escape) { + settingsMenuButton.popup.close() event.accepted = true; } } + ColumnLayout { id: settingsButtons + spacing: 16 * DefaultStyle.dp anchors.fill: parent - spacing: 16 * DefaultStyle.dp - - function getPreviousItem(index){ - if(visibleChildren.length == 0) return null - --index - while(index >= 0){ - if( index!= 4 && children[index].visible) return children[index] - --index - } - return getPreviousItem(children.length) - } - function getNextItem(index){ - ++index - while(index < children.length){ - if( index!= 4 && children[index].visible) return children[index] - ++index - } - return getNextItem(-1) - } IconLabelButton { id: accountButton Layout.preferredHeight: 32 * DefaultStyle.dp Layout.fillWidth: true visible: !SettingsCpp.hideAccountSettings - focus: visible iconSize: 32 * DefaultStyle.dp text: qsTr("Mon compte") iconSource: AppIcons.manageProfile onClicked: openAccountSettings(accountProxy.defaultAccount ? accountProxy.defaultAccount : accountProxy.firstAccount()) - KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(0) : null - KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(0) : null + KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem(0) : null + KeyNavigation.down: visibleChildren.length != 0 ? settingsMenuButton.getNextItem(0) : null } IconLabelButton { id: dndButton @@ -423,51 +405,47 @@ Item { settingsMenuButton.popup.close() SettingsCpp.dnd = !SettingsCpp.dnd } - KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(0) : null - KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(0) : null + KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem(1) : null + KeyNavigation.down: visibleChildren.length != 0 ? settingsMenuButton.getNextItem(1) : null } IconLabelButton { id: settingsButton Layout.preferredHeight: 32 * DefaultStyle.dp Layout.fillWidth: true visible: !SettingsCpp.hideSettings - focus: !accountButton.visible && visible iconSize: 32 * DefaultStyle.dp text: qsTr("Paramètres") iconSource: AppIcons.settings onClicked: openContextualMenuComponent(settingsPageComponent) - KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(1) : null - KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(1) : null + KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem(2) : null + KeyNavigation.down: visibleChildren.length != 0 ? settingsMenuButton.getNextItem(2) : null } IconLabelButton { id: recordsButton Layout.preferredHeight: 32 * DefaultStyle.dp Layout.fillWidth: true visible: !SettingsCpp.disableCallRecordings - focus: !accountButton.visible && !settingsButton.visible && visible iconSize: 32 * DefaultStyle.dp text: qsTr("Enregistrements") iconSource: AppIcons.micro - KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(2) : null - KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(2) : null + KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem(3) : null + KeyNavigation.down: visibleChildren.length != 0 ? settingsMenuButton.getNextItem(3) : null } IconLabelButton { id: helpButton Layout.preferredHeight: 32 * DefaultStyle.dp Layout.fillWidth: true iconSize: 32 * DefaultStyle.dp - focus: !accountButton.visible && !settingsButton.visible && !recordsButton.visible text: qsTr("Aide") iconSource: AppIcons.question onClicked: openContextualMenuComponent(helpPageComponent) - KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(3) : null - KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(3) : null + KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem(4) : null + KeyNavigation.down: visibleChildren.length != 0 ? settingsMenuButton.getNextItem(4) : null } IconLabelButton { id: quitButton Layout.preferredHeight: 32 * DefaultStyle.dp Layout.fillWidth: true - focus: !accountButton.visible && !settingsButton.visible && visible iconSize: 32 * DefaultStyle.dp text: qsTr("Quitter Linphone") iconSource: AppIcons.power @@ -484,8 +462,8 @@ Item { } ) } - KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(4) : null - KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(4) : null + KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem(5) : null + KeyNavigation.down: visibleChildren.length != 0 ? settingsMenuButton.getNextItem(5) : null } Rectangle { Layout.fillWidth: true @@ -502,8 +480,8 @@ Item { text: qsTr("Ajouter un compte") iconSource: AppIcons.plusCircle onClicked: mainItem.addAccountRequest() - KeyNavigation.up: visibleChildren.length != 0 ? settingsButtons.getPreviousItem(5) : null - KeyNavigation.down: visibleChildren.length != 0 ? settingsButtons.getNextItem(5) : null + KeyNavigation.up: visibleChildren.length != 0 ? settingsMenuButton.getPreviousItem(7) : null + KeyNavigation.down: visibleChildren.length != 0 ? settingsMenuButton.getNextItem(7) : null } } } diff --git a/Linphone/view/Page/Main/Account/AccountListView.qml b/Linphone/view/Page/Main/Account/AccountListView.qml index 86408b0c6..ff8a2463f 100644 --- a/Linphone/view/Page/Main/Account/AccountListView.qml +++ b/Linphone/view/Page/Main/Account/AccountListView.qml @@ -38,20 +38,21 @@ Item { Layout.fillWidth: true spacing: mainItem.spacing model: AccountProxy { + id: accountProxy sourceModel: AppCpp.accounts } delegate: Contact{ id: contactItem width: list.width account: modelData + property bool isSelected: modelData && accountProxy.defaultAccount && modelData.core === accountProxy.defaultAccount.core onAvatarClicked: fileDialog.open() onBackgroundClicked: { - list.currentIndex = index modelData.core.lSetDefaultAccount() } onEdit: editAccount(modelData) hoverEnabled: true - backgroundColor: list.currentIndex === index + backgroundColor: contactItem.isSelected ? DefaultStyle.grey_200 : hovered ? DefaultStyle.main2_100 diff --git a/external/linphone-sdk b/external/linphone-sdk index 3e3edec28..0383755cb 160000 --- a/external/linphone-sdk +++ b/external/linphone-sdk @@ -1 +1 @@ -Subproject commit 3e3edec2889317585d5267d764885b2c25806aeb +Subproject commit 0383755cb03b44baebadb523ff7e44c51d4bd404