mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-09-10 12:03:18 +02:00
switchToggled: use toggle() instead checked=value
This forces the settings to get the correct status. Also do some cleanup in currentaccount Change-Id: I0f1bff7e54d902b25afd3c95a804400c4e6b6b52 GitLab: #801
This commit is contained in:
parent
d7d29156db
commit
571ec9a2b4
4 changed files with 8 additions and 23 deletions
|
@ -41,21 +41,9 @@ CurrentAccount::CurrentAccount(LRCInstance* lrcInstance,
|
|||
}
|
||||
|
||||
void
|
||||
CurrentAccount::set_enabled(bool enabled, bool initialize)
|
||||
CurrentAccount::enableAccount(bool enabled)
|
||||
{
|
||||
if (enabled_ != enabled) {
|
||||
enabled_ = enabled;
|
||||
if (!initialize)
|
||||
lrcInstance_->accountModel().setAccountEnabled(lrcInstance_->get_currentAccountId(),
|
||||
enabled);
|
||||
Q_EMIT enabledChanged();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CurrentAccount::get_enabled()
|
||||
{
|
||||
return enabled_;
|
||||
lrcInstance_->accountModel().setAccountEnabled(lrcInstance_->get_currentAccountId(), enabled);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -120,7 +108,7 @@ CurrentAccount::updateData()
|
|||
set_status(accInfo.status);
|
||||
set_type(accInfo.profileInfo.type);
|
||||
|
||||
set_enabled(accInfo.enabled, true);
|
||||
set_enabled(accInfo.enabled);
|
||||
set_managerUri(accConfig.managerUri);
|
||||
set_keepAliveEnabled(accConfig.keepAliveEnabled, true);
|
||||
set_peerDiscovery(accConfig.peerDiscovery, true);
|
||||
|
|
|
@ -98,7 +98,6 @@ class CurrentAccount final : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
// Basic settings
|
||||
Q_PROPERTY(bool enabled READ get_enabled WRITE set_enabled NOTIFY enabledChanged);
|
||||
|
||||
QML_RO_PROPERTY(QString, id)
|
||||
QML_RO_PROPERTY(QString, uri)
|
||||
|
@ -108,6 +107,7 @@ class CurrentAccount final : public QObject
|
|||
QML_RO_PROPERTY(QString, bestName)
|
||||
QML_RO_PROPERTY(QString, managerUri)
|
||||
QML_RO_PROPERTY(bool, hasAvatarSet)
|
||||
QML_PROPERTY(bool, enabled)
|
||||
QML_RO_PROPERTY(lrc::api::account::Status, status)
|
||||
QML_RO_PROPERTY(lrc::api::profile::Type, type)
|
||||
|
||||
|
@ -198,17 +198,15 @@ public:
|
|||
QObject* parent = nullptr);
|
||||
~CurrentAccount() = default;
|
||||
|
||||
void set_enabled(bool enabled = false, bool initialize = false);
|
||||
bool get_enabled();
|
||||
|
||||
void set_isAllModeratorsEnabled(bool enabled, bool initialize = false);
|
||||
bool get_isAllModeratorsEnabled();
|
||||
|
||||
void set_isLocalModeratorsEnabled(bool enabled, bool initialize = false);
|
||||
bool get_isLocalModeratorsEnabled();
|
||||
|
||||
Q_INVOKABLE void enableAccount(bool enabled);
|
||||
|
||||
Q_SIGNALS:
|
||||
void enabledChanged();
|
||||
void isAllModeratorsEnabledChanged();
|
||||
void isLocalModeratorsEnabledChanged();
|
||||
|
||||
|
@ -217,7 +215,6 @@ private Q_SLOTS:
|
|||
void onAccountUpdated(const QString& id);
|
||||
|
||||
private:
|
||||
bool enabled_;
|
||||
bool isAllModeratorsEnabled_;
|
||||
bool isLocalModeratorsEnabled_;
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ Rectangle {
|
|||
|
||||
checked: CurrentAccount.enabled
|
||||
|
||||
onSwitchToggled: CurrentAccount.enabled = checked
|
||||
onSwitchToggled: CurrentAccount.enableAccount(checked)
|
||||
}
|
||||
|
||||
AccountProfile {
|
||||
|
|
|
@ -76,7 +76,7 @@ RowLayout {
|
|||
enabled: parent.visible
|
||||
onTapped: function onTapped(eventPoint) {
|
||||
// switchToggled should be emitted as onToggled is not called (because it's only called if the user click on the switch)
|
||||
switchOfLayout.checked = !switchOfLayout.checked
|
||||
switchOfLayout.toggle()
|
||||
switchToggled()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue