Commit e5afb073 authored by Edric Milaret's avatar Edric Milaret Committed by gerrit2

UI: add account state hint on main view

- This will do till we implement the more general error banner

Refs #74598

Change-Id: I337fdd6f602a03f36e779373a062fae30c854ba9
parent e0855a9e
......@@ -24,7 +24,6 @@
#include "audio/settings.h"
#include "personmodel.h"
#include "fallbackpersoncollection.h"
#include "accountmodel.h"
#include "categorizedcontactmodel.h"
#include "windowscontactbackend.h"
#include "historydelegate.h"
......@@ -62,6 +61,11 @@ CallWidget::CallWidget(QWidget *parent) :
connect(callModel_, SIGNAL(callStateChanged(Call*, Call::State)),
this, SLOT(callStateChanged(Call*, Call::State)));
connect(AccountModel::instance(),
SIGNAL(accountStateChanged(Account*,Account::RegistrationState)),
this,
SLOT(checkRegistrationState(Account*,Account::RegistrationState)));
connect(AccountModel::instance()
, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))
, this
......@@ -132,6 +136,47 @@ CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec
}
}
void
CallWidget::checkRegistrationState(Account *account,
Account::RegistrationState state)
{
Q_UNUSED(account);
QPixmap pm(20,20);
pm.fill();
QPainter p(&pm);
QPen pen(Qt::black, 2);
p.setPen(pen);
p.setRenderHint(QPainter::Antialiasing, true);
switch(state) {
case Account::RegistrationState::ERROR:
p.setBrush(Qt::red);
break;
case Account::RegistrationState::TRYING:
p.setBrush(Qt::yellow);
break;
case Account::RegistrationState::READY:
p.setBrush(Qt::green);
auto a_count = AccountModel::instance()->rowCount();
for (int i = 0; i < a_count; ++i) {
auto idx = AccountModel::instance()->index(i, 0);
auto stateAcc = idx.data(
static_cast<int>(Account::Role::RegistrationState));
if (stateAcc.value<Account::RegistrationState>()
!= Account::RegistrationState::READY) {
checkRegistrationState(nullptr,
stateAcc.value<Account::RegistrationState>());
return;
}
}
break;
}
p.drawEllipse(3, 3, 16, 16);
ui->accountStateHintLabel->setPixmap(pm);
ui->accountStateHintLabel->show();
}
void
CallWidget::findRingAccount()
{
......
......@@ -30,6 +30,7 @@
#include "callmodel.h"
#include "video/renderer.h"
#include "video/previewmanager.h"
#include "accountmodel.h"
#include "categorizedhistorymodel.h"
namespace Ui {
......@@ -67,6 +68,7 @@ private slots:
void addedCall(Call *call, Call *parent);
void callStateChanged(Call *call, Call::State previousState);
void findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec);
void checkRegistrationState(Account* account,Account::RegistrationState state);
private:
Ui::CallWidget *ui;
......
......@@ -20,25 +20,6 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="1" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="ringIdLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Your Ring ID:</string>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
......@@ -410,6 +391,49 @@
</layout>
</widget>
</item>
<item row="1" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_5" stretch="1,0,0">
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>10</number>
</property>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="ringIdLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Your Ring ID:</string>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="label_2">
<property name="text">
<string>State:</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="accountStateHintLabel">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment