Commit ed0b2805 authored by Edric Milaret's avatar Edric Milaret

smartlist: implement smart list view

- remove mainbar
- reconnect search/call bar
- add welcome screen
- add smartlist delegate
- use PeopleProxy
- clean and guard (WIN32) code
- remove state label

Issue: #81177
Change-Id: I0cbeb1bf754124ca6bb83acab50f1e7fd0f19e0a
parent 24c15d76
......@@ -6,7 +6,9 @@
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg winextras xml
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets svg xml
win32: QT += winextras
VERSION = 0.3.0
GIT_VERSION = $$system(git --git-dir $$PWD/.git --work-tree $$PWD describe --always --tags)
......@@ -35,7 +37,6 @@ SOURCES += main.cpp\
configurationwidget.cpp \
navstack.cpp \
navbar.cpp \
mainbar.cpp \
navwidget.cpp \
accountdetails.cpp \
aboutdialog.cpp \
......@@ -55,14 +56,14 @@ SOURCES += main.cpp\
contactpicker.cpp \
contactmethodpicker.cpp \
globalsystemtray.cpp \
transferdialog.cpp
transferdialog.cpp \
smartlistdelegate.cpp
HEADERS += mainwindow.h \
callwidget.h \
configurationwidget.h \
navstack.h \
navbar.h \
mainbar.h \
navwidget.h \
accountdetails.h \
aboutdialog.h \
......@@ -83,13 +84,13 @@ HEADERS += mainwindow.h \
contactmethodpicker.h \
settingskey.h \
globalsystemtray.h \
transferdialog.h
transferdialog.h \
smartlistdelegate.h
FORMS += mainwindow.ui \
callwidget.ui \
configurationwidget.ui \
navbar.ui \
mainbar.ui \
accountdetails.ui \
aboutdialog.ui \
wizarddialog.ui \
......
......@@ -25,9 +25,6 @@ AboutDialog::AboutDialog(QWidget *parent) :
{
ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint);
this->setFixedSize(this->width(),this->height());
ui->creditsWidget->hide();
ui->clientVersionLabel->setText(
......@@ -77,9 +74,3 @@ AboutDialog::on_creditsButton_clicked(bool checked)
ui->creditsWidget->setVisible(checked);
ui->aboutWidget->setVisible(!checked);
}
void
AboutDialog::on_toolButton_clicked()
{
this->close();
}
......@@ -36,7 +36,6 @@ public:
private slots:
void on_aboutButton_toggled(bool checked);
void on_creditsButton_clicked(bool checked);
void on_toolButton_clicked();
private:
Ui::AboutDialog *ui;
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>674</width>
<height>565</height>
<height>555</height>
</rect>
</property>
<property name="sizePolicy">
......@@ -439,7 +439,7 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,0,0,0">
<property name="topMargin">
<number>0</number>
</property>
......@@ -492,23 +492,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton">
<property name="text">
<string>X</string>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/close.png</normaloff>:/images/close.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>30</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item alignment="Qt::AlignHCenter">
......@@ -537,7 +520,10 @@
<number>0</number>
</property>
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="clientVersionLabel">
......@@ -684,7 +670,10 @@ Ring is a secured and distributed communication software.</string>
<widget class="QWidget" name="creditsWidget" native="true">
<layout class="QVBoxLayout" name="creditsLayout">
<property name="topMargin">
<number>1</number>
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextBrowser" name="creditsBrowser">
......
......@@ -157,6 +157,8 @@ AccountDetails::setAccount(Account* currentAccount) {
currentAccount_ = currentAccount;
ui->lrcfg_username->setReadOnly(currentAccount_->protocol() == Account::Protocol::RING);
codecModel_ = currentAccount->codecModel();
ui->typeValueLabel->setText(currentAccount_->protocolModel()->
......
......@@ -56,7 +56,7 @@
<x>0</x>
<y>0</y>
<width>746</width>
<height>645</height>
<height>646</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_12">
......@@ -360,12 +360,18 @@
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lrcfg_username">
<property name="enabled">
<bool>true</bool>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
......@@ -626,7 +632,7 @@
<x>0</x>
<y>0</y>
<width>733</width>
<height>685</height>
<height>665</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_11">
......@@ -1192,7 +1198,7 @@
<x>0</x>
<y>0</y>
<width>746</width>
<height>645</height>
<height>646</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
......
......@@ -32,7 +32,7 @@ AccountStateDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
initStyleOption(&opt, index);
if (index.column() == 0) {
auto name = index.model()->data(index, Qt::DisplayRole).toString();
opt.text = "";
opt.text = QString();
QStyle *style = opt.widget ? opt.widget->style() : QApplication::style();
style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, opt.widget);
auto rect = opt.rect;
......
......@@ -36,22 +36,26 @@
#include "media/text.h"
#include "media/recording.h"
#include "media/textrecording.h"
#include "recentmodel.h"
#include "wizarddialog.h"
#include "windowscontactbackend.h"
#include "contactpicker.h"
#include "contactmethodpicker.h"
#include "globalsystemtray.h"
#include "historydelegate.h"
#include "contactdelegate.h"
#include "smartlistdelegate.h"
CallWidget::CallWidget(QWidget *parent) :
NavWidget(Main ,parent),
NavWidget(END ,parent),
ui(new Ui::CallWidget),
menu_(new QMenu())
{
ui->setupUi(this);
ui->callInvite->setVisible(false);
ui->videoWidget->setVisible(false);
setActualCall(nullptr);
videoRenderer_ = nullptr;
......@@ -65,6 +69,10 @@ CallWidget::CallWidget(QWidget *parent) :
ui->spinnerLabel->setMovie(spinner_);
}
QPixmap logo(":/images/logo-ring-standard-coul.png");
ui->ringLogo->setPixmap(logo.scaledToHeight(100, Qt::SmoothTransformation));
ui->ringLogo->setAlignment(Qt::AlignHCenter);
try {
callModel_ = CallModel::instance();
......@@ -75,18 +83,19 @@ 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
, SLOT(findRingAccount(QModelIndex, QModelIndex, QVector<int>)));
ui->callList->setModel(callModel_);
ui->callList->setSelectionModel(callModel_->selectionModel());
ui->smartList->setModel(RecentModel::instance()->peopleProxy());
connect(ui->smartList->selectionModel(),
SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
this,
SLOT(smartListSelectionChanged(QItemSelection,QItemSelection)));
smartListDelegate_ = new SmartListDelegate();
ui->smartList->setItemDelegate(smartListDelegate_);
ui->smartList->setHeaderHidden(true);
PersonModel::instance()->
addCollection<WindowsContactBackend>(LoadOptions::FORCE_ENABLED);
......@@ -139,8 +148,6 @@ CallWidget::CallWidget(QWidget *parent) :
}
});
ui->sortComboBox->setModel(CategorizedHistoryModel::SortedProxy::instance()->categoryModel());
findRingAccount();
} catch (...) {
......@@ -153,7 +160,6 @@ CallWidget::~CallWidget()
delete ui;
delete spinner_;
delete menu_;
delete historyDelegate_;
delete contactDelegate_;
}
......@@ -171,8 +177,7 @@ CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec
auto protocol = idx.data(static_cast<int>(Account::Role::Proto));
if ((Account::Protocol)protocol.toUInt() == Account::Protocol::RING) {
auto username = idx.data(static_cast<int>(Account::Role::Username));
ui->ringIdLabel->setText(
QString(tr("Your RingID: %1", "%1 is the RingID")).arg(username.toString()));
ui->ringIdLabel->setText(username.toString());
found = true;
return;
}
......@@ -182,51 +187,6 @@ 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;
default:
break;
}
p.drawEllipse(3, 3, 16, 16);
ui->accountStateHintLabel->setPixmap(pm);
ui->accountStateHintLabel->show();
}
void
CallWidget::findRingAccount()
{
......@@ -241,13 +201,13 @@ CallWidget::findRingAccount()
if (account->displayName().isEmpty())
account->displayName() = account->alias();
auto username = account->username();
ui->ringIdLabel->setText(
QString(tr("Your RingID: %1", "%1 is the RingID")).arg(username));
ui->ringIdLabel->setText(username);
found = true;
return;
}
}
if (!found) {
ui->ringIdLabel->setText(tr("NO RING ACCOUNT FOUND"));
WizardDialog *wizardDialog = new WizardDialog();
wizardDialog->exec();
delete wizardDialog;
......@@ -265,6 +225,7 @@ CallWidget::callIncoming(Call *call)
if (!call->account()->isAutoAnswer()) {
ui->callLabel->setText(QString(tr("Call from %1", "%1 is the name of the caller"))
.arg(call->formattedName()));
ui->stackedWidget->setCurrentWidget(ui->callInvitePage);
ui->callInvite->setVisible(true);
ui->callInvite->raise();
}
......@@ -277,6 +238,7 @@ CallWidget::on_acceptButton_clicked()
if (actualCall_ != nullptr)
actualCall_->performAction(Call::Action::ACCEPT);
ui->callInvite->setVisible(false);
ui->stackedWidget->setCurrentWidget(ui->videoPage);
}
void
......@@ -287,6 +249,7 @@ CallWidget::on_refuseButton_clicked()
actualCall_->performAction(Call::Action::REFUSE);
setActualCall(nullptr);
ui->callInvite->setVisible(false);
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
}
void
......@@ -296,6 +259,7 @@ CallWidget::addedCall(Call* call, Call* parent)
if (call->direction() == Call::Direction::OUTGOING) {
displaySpinner(true);
setActualCall(call);
ui->stackedWidget->setCurrentWidget(ui->callInvitePage);
}
}
......@@ -305,42 +269,29 @@ CallWidget::callStateChanged(Call* call, Call::State previousState)
Q_UNUSED(previousState)
if (call == nullptr)
return;
ui->callList->setCurrentIndex(callModel_->getIndex(actualCall_));
//Force update of smartList
ui->smartList->setFocus();
if (call->state() == Call::State::OVER
|| call->state() == Call::State::ERROR
|| call->state() == Call::State::FAILURE
|| call->state() == Call::State::ABORTED) {
setActualCall(nullptr);
ui->instantMessagingWidget->setMediaText(nullptr);
ui->videoWidget->hide();
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
displaySpinner(false);
auto onHoldCall = callModel_->getActiveCalls().first();
if (onHoldCall != nullptr && onHoldCall->state() == Call::State::HOLD) {
setActualCall(onHoldCall);
onHoldCall->performAction(Call::Action::HOLD);
}
//TODO : Link this so that recentModel get selected correctly
// auto onHoldCall = callModel_->getActiveCalls().first();
// if (onHoldCall != nullptr && onHoldCall->state() == Call::State::HOLD) {
// setActualCall(onHoldCall);
// onHoldCall->performAction(Call::Action::HOLD);
// }
} else if (call->state() == Call::State::CURRENT) {
displaySpinner(false);
ui->videoWidget->show();
ui->instantMessagingWidget->setMediaText(actualCall_);
ui->stackedWidget->setCurrentWidget(ui->videoPage);
}
ui->callStateLabel->setText(QString(tr("Call State: %1", "%1 is the state of the call"))
.arg(call->toHumanStateName()));
}
void
CallWidget::on_callList_activated(const QModelIndex &index)
{
Call *callSelected = callModel_->getCall(index);
if (actualCall_ != nullptr) {
if (callSelected == actualCall_)
return;
ui->videoWidget->hide();
actualCall_->performAction(Call::Action::HOLD);
}
setActualCall(callSelected);
actualCall_->performAction(Call::Action::HOLD);
ui->videoWidget->show();
}
void
......@@ -371,9 +322,10 @@ CallWidget::on_contactView_doubleClicked(const QModelIndex &index)
uri = dlg.getSelected();
}
if (uri) {
auto outCall = CallModel::instance()->dialingCall(person->formattedName());
outCall->setDialNumber(uri);
auto outCall = CallModel::instance()->dialingCall(uri);
outCall->performAction(Call::Action::ACCEPT);
ui->mainTabMenu->setCurrentIndex(0);
ui->smartList->setFocus();
}
}
}
......@@ -386,9 +338,10 @@ CallWidget::on_historyList_doubleClicked(const QModelIndex &index)
auto number = index.data(static_cast<int>(Call::Role::ContactMethod)).value<ContactMethod*>();
if (number) {
auto outCall = CallModel::instance()->dialingCall();
outCall->setDialNumber(number);
auto outCall = CallModel::instance()->dialingCall(number);
outCall->performAction(Call::Action::ACCEPT);
ui->mainTabMenu->setCurrentIndex(0);
ui->smartList->setFocus();
}
}
......@@ -396,16 +349,8 @@ void
CallWidget::setActualCall(Call* value)
{
actualCall_ = value;
}
void
CallWidget::on_sortComboBox_currentIndexChanged(int index)
{
auto idx = CategorizedHistoryModel::SortedProxy::instance()->
categoryModel()->index(index, 0);
CategorizedHistoryModel::SortedProxy::instance()->categorySelectionModel()->
setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect);
ui->historyList->setModel(CategorizedHistoryModel::SortedProxy::instance()->model());
if (value)
CallModel::instance()->selectCall(value);
}
void
......@@ -416,8 +361,94 @@ CallWidget::displaySpinner(bool display)
display ? ui->spinnerLabel->movie()->start() : ui->spinnerLabel->movie()->stop();
}
void CallWidget::on_cancelButton_clicked()
void
CallWidget::on_cancelButton_clicked()
{
if (actualCall_)
actualCall_->performAction(Call::Action::REFUSE);
}
void
CallWidget::on_smartList_doubleClicked(const QModelIndex &index)
{
auto realIndex = RecentModel::instance()->peopleProxy()->mapToSource(index);
if (RecentModel::instance()->hasActiveCall(realIndex))
return;
ContactMethod* m = nullptr;
if (auto cm = realIndex.data((int)Call::Role::ContactMethod).value<ContactMethod*>()) {
m = cm;
} else {
if (auto person = realIndex.data((int)Person::Role::Object).value<Person*>()) {
m = person->phoneNumbers().first();
}
}
if (m && !RecentModel::instance()->index(0, 0, realIndex).isValid()) {
Call* c = CallModel::instance()->dialingCall(m);
c->performAction(Call::Action::ACCEPT);
}
}
void
CallWidget::smartListSelectionChanged(const QItemSelection &newSel, const QItemSelection &oldSel) {
Q_UNUSED(oldSel)
auto newIdx = newSel.indexes().first();
if (newIdx.parent().isValid())
return;
auto newIdxCall = RecentModel::instance()->getActiveCall(RecentModel::instance()->peopleProxy()->mapToSource(newIdx));
if (newIdxCall == actualCall_)
return;
if (actualCall_ != nullptr) {
actualCall_->performAction(Call::Action::HOLD);
}
if (newIdxCall) {
newIdxCall->performAction(Call::Action::HOLD);
setActualCall(newIdxCall);
ui->stackedWidget->setCurrentWidget(ui->videoPage);
} else {
setActualCall(nullptr);
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
}
}
void
CallWidget::placeCall()
{
if (ui->searchEdit->text().isEmpty())
return;
Call* c = CallModel::instance()->dialingCall(PhoneDirectoryModel::instance()->getNumber(ui->searchEdit->text()));
c->performAction(Call::Action::ACCEPT);
ui->searchEdit->clear();
}
void
CallWidget::on_searchEdit_returnPressed()
{
placeCall();
}
void
CallWidget::on_settingsButton_clicked()
{
emit NavigationRequested(ScreenEnum::ConfScreen);
}
void
CallWidget::on_contactButton_clicked(bool checked)
{
if (checked)
ui->historicButton->setChecked(false);
ui->mainTabMenu->setCurrentIndex(checked ? 1 : 0);
}
void
CallWidget::on_historicButton_clicked(bool checked)
{
if (checked)
ui->contactButton->setChecked(false);
ui->mainTabMenu->setCurrentIndex(checked ? 2 : 0);
}
......@@ -27,8 +27,6 @@
#include "navwidget.h"
#include "instantmessagingwidget.h"
#include "historydelegate.h"
#include "contactdelegate.h"
#include "callmodel.h"
#include "video/renderer.h"
......@@ -36,6 +34,10 @@
#include "accountmodel.h"
#include "categorizedhistorymodel.h"
class ContactDelegate;
class HistoryDelegate;
class SmartListDelegate;
namespace Ui {
class CallWidget;
}
......@@ -54,18 +56,20 @@ private slots:
void on_acceptButton_clicked();
void on_refuseButton_clicked();
void on_contactView_doubleClicked(const QModelIndex &index);
void on_cancelButton_clicked();
void on_smartList_doubleClicked(const QModelIndex &index);
void on_searchEdit_returnPressed();
void on_settingsButton_clicked();
void on_historyList_doubleClicked(const QModelIndex &index);
void on_sortComboBox_currentIndexChanged(int index);
void on_callList_activated(const QModelIndex &index);
void on_contactButton_clicked(bool checked);