Skip to content
Snippets Groups Projects
Commit 266dd30e authored by Anthony Léonard's avatar Anthony Léonard Committed by Olivier SOLDANO
Browse files

display the selected account's RingID/username


This patch improves the way the client react to a modification
of the selected account.

From a UI point of view, the displayed Ring ID now depends
on the selected account in the combo box. Previously, it was
always set to the first enabled Ring account found in
AccountModel.

The old behavior is removed from findRingAccount() which now
only focus on looking if an account needs migration or if it
is needed to create one (at first launch).

Change-Id: If63a74eb320b8fc31064d87b04b5e062fc0cc10a
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent d47179c3
Branches
No related tags found
No related merge requests found
...@@ -98,11 +98,6 @@ CallWidget::CallWidget(QWidget* parent) : ...@@ -98,11 +98,6 @@ CallWidget::CallWidget(QWidget* parent) :
connect(callModel_, SIGNAL(callStateChanged(Call*, Call::State)), connect(callModel_, SIGNAL(callStateChanged(Call*, Call::State)),
this, SLOT(callStateChanged(Call*, Call::State))); this, SLOT(callStateChanged(Call*, Call::State)));
connect(&AccountModel::instance()
, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))
, this
, SLOT(findRingAccount(QModelIndex, QModelIndex, QVector<int>)));
RecentModel::instance().peopleProxy()->setFilterRole(static_cast<int>(Ring::Role::Name)); RecentModel::instance().peopleProxy()->setFilterRole(static_cast<int>(Ring::Role::Name));
RecentModel::instance().peopleProxy()->setFilterCaseSensitivity(Qt::CaseInsensitive); RecentModel::instance().peopleProxy()->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->smartList->setModel(RecentModel::instance().peopleProxy()); ui->smartList->setModel(RecentModel::instance().peopleProxy());
...@@ -291,33 +286,6 @@ CallWidget::setupSmartListMenu() ...@@ -291,33 +286,6 @@ CallWidget::setupSmartListMenu()
}); });
} }
void
CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec)
{
Q_UNUSED(idx1)
Q_UNUSED(idx2)
Q_UNUSED(vec)
auto a_count = AccountModel::instance().rowCount();
for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance().index(i, 0);
auto protocol = idx.data(static_cast<int>(Account::Role::Proto));
if (static_cast<Account::Protocol>(protocol.toUInt()) == Account::Protocol::RING) {
auto account = AccountModel::instance().getAccountByModelIndex(idx);
auto registeredName = account->registeredName();
auto username = idx.data(static_cast<int>(Account::Role::Username));
if (registeredName.isEmpty()) {
ui->ringIdLabel->setText(username.toString());
} else
ui->ringIdLabel->setText(registeredName);
setupQRCode(username.toString());
return;
}
}
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
}
void CallWidget::setupQRCode(QString ringID) void CallWidget::setupQRCode(QString ringID)
{ {
auto rcode = QRcode_encodeString(ringID.toStdString().c_str(), auto rcode = QRcode_encodeString(ringID.toStdString().c_str(),
...@@ -358,13 +326,14 @@ void CallWidget::setupQRCode(QString ringID) ...@@ -358,13 +326,14 @@ void CallWidget::setupQRCode(QString ringID)
void void
CallWidget::findRingAccount() CallWidget::findRingAccount()
{ {
ui->ringIdLabel->clear(); bool ringAccountFound = false;
auto a_count = AccountModel::instance().rowCount(); auto a_count = AccountModel::instance().rowCount();
for (int i = 0; i < a_count; ++i) { for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance().index(i, 0); auto idx = AccountModel::instance().index(i, 0);
auto protocol = idx.data(static_cast<int>(Account::Role::Proto)); auto protocol = idx.data(static_cast<int>(Account::Role::Proto));
if (static_cast<Account::Protocol>(protocol.toUInt()) == Account::Protocol::RING) { if (static_cast<Account::Protocol>(protocol.toUInt()) == Account::Protocol::RING) {
ringAccountFound = true;
auto account = AccountModel::instance().getAccountByModelIndex(idx); auto account = AccountModel::instance().getAccountByModelIndex(idx);
if (account->displayName().isEmpty()) if (account->displayName().isEmpty())
account->displayName() = account->alias(); account->displayName() = account->alias();
...@@ -372,16 +341,9 @@ CallWidget::findRingAccount() ...@@ -372,16 +341,9 @@ CallWidget::findRingAccount()
WizardDialog dlg(WizardDialog::MIGRATION, account); WizardDialog dlg(WizardDialog::MIGRATION, account);
dlg.exec(); dlg.exec();
} }
if (ui->ringIdLabel->text().isEmpty()) {
auto registeredName = account->registeredName();
ui->ringIdLabel->setText((registeredName.isEmpty())?account->username():registeredName);
setupQRCode(account->username());
}
} }
} }
if (!ringAccountFound) {
if (ui->ringIdLabel->text().isEmpty()) {
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
WizardDialog wizardDialog; WizardDialog wizardDialog;
wizardDialog.exec(); wizardDialog.exec();
} }
...@@ -718,6 +680,15 @@ CallWidget::selectedAccountChanged(const QModelIndex &current, const QModelIndex ...@@ -718,6 +680,15 @@ CallWidget::selectedAccountChanged(const QModelIndex &current, const QModelIndex
slidePage(ui->welcomePage); slidePage(ui->welcomePage);
} }
// We setup the ringIdLabel and the QRCode
auto protocol = ac->protocol();
if (protocol == Account::Protocol::RING) {
ui->ringIdLabel->setText((ac->registeredName().isEmpty())?ac->username():ac->registeredName());
setupQRCode(ac->username());
} else {
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
}
// Then, we update the pending CR list with those from the newly selected account // Then, we update the pending CR list with those from the newly selected account
if (disconnect(crListSelectionConnection_)) { if (disconnect(crListSelectionConnection_)) {
// The selection model must be deleted by the application (see QT doc). // The selection model must be deleted by the application (see QT doc).
......
...@@ -87,7 +87,6 @@ private slots: ...@@ -87,7 +87,6 @@ private slots:
private slots: private slots:
void callIncoming(Call* call); void callIncoming(Call* call);
void callStateChanged(Call* call, Call::State previousState); void callStateChanged(Call* call, Call::State previousState);
void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
void smartListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx); void smartListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
void contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx); void contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir); void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment