1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-09-10 03:53:23 +02:00

misc: refactor account change

- UI sensitive to currentAccountId property, remove getCurrAccId from UtilsAdapter
- centralize signals / functions at MainView and avoid unnecessary propagation between modules
- name revision (avoid syntax such as "needTo" or "slot..")

Gitlab: #85
Gitlab: #86

Change-Id: Ie4060df4b64990bdd3f412d0e491080a4cd20092
This commit is contained in:
ababi 2020-09-23 12:54:48 +02:00 committed by Andreas Traczyk
parent 5d4e69ef09
commit a737855426
15 changed files with 37 additions and 88 deletions

View file

@ -42,11 +42,6 @@ ApplicationWindow {
}
}
function slotNewAccountAdded() {
if(mainViewLoader.newAddedAccountIndex !== -1)
mainViewLoader.item.newAccountAdded(mainViewLoader.newAddedAccountIndex)
}
function startAccountMigration(){
return accountMigrationDialog.startAccountMigrationOfTopStack()
}
@ -105,13 +100,8 @@ ApplicationWindow {
onNeedToShowMainViewWindow: {
mainViewLoader.newAddedAccountIndex = accountIndex
if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml") {
mainViewLoader.loaded.disconnect(slotNewAccountAdded)
mainViewLoader.loaded.connect(slotNewAccountAdded)
if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml")
mainViewLoader.setSource("qrc:/src/mainview/MainView.qml")
} else {
slotNewAccountAdded()
}
wizardView.close()
}

View file

@ -71,7 +71,7 @@ BaseDialog {
var success = false
if (path.length > 0) {
success = AccountAdapter.exportToFile(
UtilsAdapter.getCurrAccId(),
AccountAdapter.currentAccountId,
path,
currentPasswordEdit.text)
}
@ -82,7 +82,7 @@ BaseDialog {
function savePasswordQML() {
var success = false
success = AccountAdapter.savePassword(
UtilsAdapter.getCurrAccId(),
AccountAdapter.currentAccountId,
currentPasswordEdit.text,
passwordEdit.text)
if (success) {

View file

@ -58,6 +58,18 @@ Window {
signal closeApp
signal noAccountIsAvailable
property string currentAccountId: AccountAdapter.currentAccountId
onCurrentAccountIdChanged: {
var index = UtilsAdapter.getCurrAccList().indexOf(currentAccountId)
mainViewWindowSidePanel.refreshAccountComboBox(index)
if (inSettingsView) {
settingsView.accountListChanged()
settingsView.setSelected(settingsView.selectedMenu, true)
} else if (currentAccountIsCalling()) {
setCallStackView()
}
}
function showWelcomeView() {
mainViewWindowSidePanel.deselectConversationSmartList()
if (communicationPageMessageWebView.visible || callStackView.visible) {
@ -121,8 +133,8 @@ Window {
}
}
function newAccountAdded(index) {
AccountAdapter.accountChanged(index)
function startWizard() {
mainViewStackLayout.currentIndex = 1
}
function currentAccountIsCalling() {
@ -311,23 +323,6 @@ Window {
toggleSettingsView()
}
onAccountChanged: {
mainViewWindowSidePanel.deselectConversationSmartList()
AccountAdapter.accountChanged(index)
if (inSettingsView) {
settingsView.slotAccountListChanged()
settingsView.setSelected(settingsView.selectedMenu, true)
} else if (currentAccountIsCalling()) {
setCallStackView()
}
}
onNewAccountButtonClicked: {
mainViewWindowSidePanel.needToAddNewAccount()
}
Component.onCompleted: {
AccountAdapter.setQmlObject(this)
}
@ -370,14 +365,6 @@ Window {
Layout.fillHeight: true
onNeedToShowMainViewWindow: {
mainViewLoader.newAddedAccountIndex = accountIndex
if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml") {
mainViewLoader.loaded.disconnect(slotNewAccountAdded)
mainViewLoader.loaded.connect(slotNewAccountAdded)
mainViewLoader.setSource("qrc:/src/mainview/MainView.qml")
} else {
slotNewAccountAdded()
}
mainViewStackLayout.currentIndex = 0
}
@ -438,12 +425,11 @@ Window {
id: mainViewWindowSidePanel
onConversationSmartListNeedToAccessMessageWebView: {
communicationPageMessageWebView.headerUserAliasLabelText = currentUserAlias
communicationPageMessageWebView.headerUserUserNameLabelText = currentUserDisplayName
callStackView.needToCloseInCallConversationAndPotentialWindow()
callStackView.responsibleAccountId = UtilsAdapter.getCurrAccId()
callStackView.responsibleAccountId = AccountAdapter.currentAccountId
callStackView.responsibleConvUid = currentUID
callStackView.updateCorrespondingUI()
@ -511,10 +497,6 @@ Window {
mainViewWindowSidePanel.forceReselectConversationSmartListCurrentIndex()
}
onNeedToAddNewAccount: {
mainViewStackLayout.currentIndex = 1
}
Connections {
target: ConversationsAdapter
@ -747,7 +729,7 @@ Window {
Shortcut {
sequence: "Ctrl+Shift+N"
context: Qt.ApplicationShortcut
onActivated: mainViewWindowSidePanel.needToAddNewAccount()
onActivated: startWizard()
}
KeyBoardShortcutTable {

View file

@ -27,8 +27,6 @@ import "../../commoncomponents"
ComboBox {
id: root
signal accountChanged(int index)
signal newAccountButtonClicked
signal settingBtnClicked
// Reset accountListModel.
@ -280,14 +278,6 @@ ComboBox {
comboBoxPopup.close() :
comboBoxPopup.open()
}
onAccountNeedToChange: {
root.accountChanged(index)
}
onNewAccountButtonClicked: {
root.newAccountButtonClicked()
}
}
Shortcut {

View file

@ -20,6 +20,7 @@ import QtQuick 2.14
import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14
import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents"
@ -28,9 +29,6 @@ Popup {
property bool toogleUpdatePopupHeight: false
signal accountNeedToChange(int index)
signal newAccountButtonClicked
y: accountComboBox.height - 1
implicitWidth: accountComboBox.width - 1
@ -143,7 +141,7 @@ Popup {
itemCoboBackground.color = JamiTheme.releaseColor
currentIndex = index
comboBoxPopup.close()
comboBoxPopup.accountNeedToChange(index)
AccountAdapter.accountChanged(index)
}
onEntered: {
itemCoboBackground.color = JamiTheme.hoverColor
@ -169,7 +167,7 @@ Popup {
onClicked: {
comboBoxPopup.close()
comboBoxPopup.newAccountButtonClicked()
mainViewWindow.startWizard()
}
}

View file

@ -114,7 +114,7 @@ ListView {
context: Qt.ApplicationShortcut
enabled: root.visible
onActivated: {
UtilsAdapter.clearConversationHistory(UtilsAdapter.getCurrAccId(),
UtilsAdapter.clearConversationHistory(AccountAdapter.currentAccountId,
UtilsAdapter.getCurrConvId())
}
}
@ -133,7 +133,7 @@ ListView {
context: Qt.ApplicationShortcut
enabled: root.visible
onActivated: {
UtilsAdapter.removeConversation(UtilsAdapter.getCurrAccId(),
UtilsAdapter.removeConversation(AccountAdapter.currentAccountId,
UtilsAdapter.getCurrConvId(),
false)
}

View file

@ -170,7 +170,7 @@ ItemDelegate {
}
onDoubleClicked: {
if (!InCall) {
ConversationsAdapter.selectConversation(UtilsAdapter.getCurrAccId(),
ConversationsAdapter.selectConversation(AccountAdapter.currentAccountId,
UID,
false)
CallAdapter.placeCall()
@ -188,7 +188,7 @@ ItemDelegate {
mouse.x, mouse.y)
smartListContextMenu.x = relativeMousePos.x
smartListContextMenu.y = relativeMousePos.y
smartListContextMenu.responsibleAccountId = UtilsAdapter.getCurrAccId()
smartListContextMenu.responsibleAccountId = AccountAdapter.currentAccountId
smartListContextMenu.responsibleConvUid = UID
smartListContextMenu.contactType = ContactType
userProfile.responsibleConvUid = UID

View file

@ -33,16 +33,8 @@ Rectangle {
property int pendingRequestCount: 0
property int totalUnreadMessagesCount: 0
property string currentAccountId: AccountAdapter.currentAccountId
onCurrentAccountIdChanged: {
var index = UtilsAdapter.getCurrAccList().indexOf(currentAccountId)
refreshAccountComboBox(index)
}
signal conversationSmartListNeedToAccessMessageWebView(string currentUserDisplayName, string currentUserAlias, string currentUID, bool callStackViewShouldShow, bool isAudioOnly, int callState)
signal needToUpdateConversationForAddedContact
signal needToAddNewAccount
// Hack -> force redraw.
function forceReselectConversationSmartListCurrentIndex() {

View file

@ -96,7 +96,7 @@ Rectangle {
target: LRCInstance
function onAccountListChanged() {
slotAccountListChanged()
accountListChanged()
}
}
@ -111,7 +111,7 @@ Rectangle {
settingsViewWindowNeedToShowNewWizardWindow()
}
function slotAccountListChanged() {
function accountListChanged() {
var accountList = AccountAdapter.model.getAccountList()
if(accountList.length === 0)
return

View file

@ -163,7 +163,8 @@ Rectangle {
return
} else {
if (exportPath.length > 0) {
var isSuccessful = AccountAdapter.model.exportToFile(UtilsAdapter.getCurrAccId(), exportPath,"")
var isSuccessful = AccountAdapter.model.exportToFile(AccountAdapter.currentAccountId,
exportPath, "")
var title = isSuccessful ? qsTr("Success") : qsTr("Error")
var info = isSuccessful ? JamiStrings.backupSuccessful : JamiStrings.backupFailed
@ -218,7 +219,8 @@ Rectangle {
labelText: JamiStrings.enableAccount
fontPointSize: JamiTheme.headerFontSize
onSwitchToggled: AccountAdapter.model.setAccountEnabled(UtilsAdapter.getCurrAccId(), checked)
onSwitchToggled: AccountAdapter.model.setAccountEnabled(
AccountAdapter.currentAccountId, checked)
}
AccountProfile {

View file

@ -54,7 +54,8 @@ BaseDialog {
}
function slotExportOnRing(){
AccountAdapter.model.exportOnRing(UtilsAdapter.getCurrAccId(),passwordEdit.text)
AccountAdapter.model.exportOnRing(AccountAdapter.currentAccountId,
passwordEdit.text)
}
Timer{

View file

@ -53,7 +53,8 @@ BaseDialog {
function slotStartNameRegistration() {
var password = passwordEdit.text
AccountAdapter.model.registerName(UtilsAdapter.getCurrAccId(), password, registerdName)
AccountAdapter.model.registerName(AccountAdapter.currentAccountId,
password, registerdName)
}
function startSpinner() {

View file

@ -175,12 +175,6 @@ UtilsAdapter::removeConversation(const QString& accountId, const QString& uid, b
LRCInstance::getAccountInfo(accountId).conversationModel->removeConversation(uid, banContact);
}
const QString
UtilsAdapter::getCurrAccId()
{
return LRCInstance::getCurrAccId();
}
const QString
UtilsAdapter::getCurrConvId()
{

View file

@ -55,7 +55,6 @@ public:
Q_INVOKABLE const QString getBestName(const QString& accountId, const QString& uid);
Q_INVOKABLE QString getBestId(const QString& accountId);
Q_INVOKABLE const QString getBestId(const QString& accountId, const QString& uid);
Q_INVOKABLE const QString getCurrAccId();
Q_INVOKABLE const QString getCurrConvId();
Q_INVOKABLE void makePermanentCurrentConv();
Q_INVOKABLE const QStringList getCurrAccList();

View file

@ -269,7 +269,7 @@ Rectangle {
} else {
if (folderDir.length > 0) {
AccountAdapter.exportToFile(
UtilsAdapter.getCurrAccId(),
AccountAdapter.currentAccountId,
UtilsAdapter.getAbsPath(folderDir))
}
}