Commit 8c136440 authored by Anthony Léonard's avatar Anthony Léonard Committed by Olivier SOLDANO

display vCard data in contact request view

The whole contact request view design has been modified to show every
informations contained in vCard that are useful for a user to decide
if he should or not trust somebody. It is also better looking than
the previous version.

Those informations are presented:
 * An embedded picture if any (with a fallback to the default one)
 * The profile name chosen by the sender of the request
 * The "best ID" which is the registered name or the RingID (in that
   order of priority)

This last information is a security measure to check the real identity
of the contact request sender.

Change-Id: Ibcb3e8667f91c8123b9016e6dfd72621bfb4f3f1
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent 2bcdfd70
......@@ -92,8 +92,6 @@ CallWidget::CallWidget(QWidget* parent) :
ui->qrLabel->hide();
GlobalInstances::setPixmapManipulator(std::unique_ptr<Interfaces::PixbufManipulator>(new Interfaces::PixbufManipulator()));
try {
callModel_ = &CallModel::instance();
......@@ -589,8 +587,7 @@ CallWidget::contactReqListCurrentChanged(const QModelIndex &currentIdx, const QM
{
Q_UNUSED(previousIdx)
ContactRequest* cr = currentIdx.data((int)Ring::Role::Object).value<ContactRequest*>();
ui->contactRequestWidget->setCurrentContactRequest(cr);
ui->contactRequestWidget->setCurrentContactRequest(currentIdx);
ui->stackedWidget->setCurrentWidget(ui->contactRequestPage);
}
......
......@@ -22,6 +22,8 @@
#include "accountmodel.h"
#include "pendingcontactrequestmodel.h"
#include "contactrequest.h"
#include "globalinstances.h"
#include "pixmapmanipulatordefault.h"
#include <QPainter>
#include <QApplication>
......@@ -71,13 +73,11 @@ ContactRequestItemDelegate::paint(QPainter* painter
painter->drawText(rectText,text);
// Draw a picture
// TODO: Draw the incoming CR picture if part of the payload
// Draw the picture from the vCard
QRect rectPic(opt.rect.left() + dxImage_, opt.rect.top() + dyImage_, sizeImage_, sizeImage_);
drawDecoration(painter, opt, rectPic,
QPixmap::fromImage(QImage(":/images/user/btn-default-userpic.svg").scaled(QSize(sizeImage_, sizeImage_),
Qt::KeepAspectRatio,
Qt::SmoothTransformation)));
auto cr = index.data(static_cast<int>(Ring::Role::Object)).value<ContactRequest*>();
auto photo = GlobalInstances::pixmapManipulator().contactPhoto(cr->peer(), QSize(sizeImage_, sizeImage_), false);
drawDecoration(painter, opt, rectPic, QPixmap::fromImage(photo.value<QImage>()));
// Draw separator when item is not selected
if (not (opt.state & QStyle::State_Selected)) {
......
......@@ -19,6 +19,11 @@
#include "contactrequestwidget.h"
#include "ui_contactrequestwidget.h"
#include "person.h"
#include "pendingcontactrequestmodel.h"
#include "itemdataroles.h"
#include "globalinstances.h"
#include "pixmapmanipulatordefault.h"
ContactRequestWidget::ContactRequestWidget(QWidget *parent) :
QWidget(parent),
......@@ -33,12 +38,20 @@ ContactRequestWidget::~ContactRequestWidget()
}
void
ContactRequestWidget::setCurrentContactRequest(ContactRequest *cr)
ContactRequestWidget::setCurrentContactRequest(const QModelIndex &current)
{
cr_ = cr;
if (cr_ != nullptr) {
QString remoteId = QString::fromLocal8Bit(cr_->roleData(Qt::DisplayRole).value<QByteArray>());
ui->remoteIdLabel->setText(QString("Current ContactRequest: %1").arg(remoteId));
if (current.isValid()) {
auto bestId = current.data().value<QString>();
cr_ = current.data(static_cast<int>(Ring::Role::Object)).value<ContactRequest*>();
auto formattedName = current.model()->index(current.row(), PendingContactRequestModel::Columns::FORMATTED_NAME).data().value<QString>();
ui->nameLabel->setText(formattedName);
ui->bestIdLabel->setText(bestId);
auto photo = GlobalInstances::pixmapManipulator().contactPhoto(cr_->peer(), QSize(96, 96), false);
if(photo.isValid())
ui->pictureLabel->setPixmap(QPixmap::fromImage(photo.value<QImage>()));
} else {
cr_ = nullptr;
}
}
......@@ -48,7 +61,7 @@ ContactRequestWidget::on_acceptCRButton_clicked()
if (cr_ != nullptr) {
cr_->accept();
}
setCurrentContactRequest(nullptr);
setCurrentContactRequest(QModelIndex());
emit choiceMade();
}
......@@ -57,7 +70,7 @@ void ContactRequestWidget::on_discardCRButton_clicked()
if (cr_ != nullptr) {
cr_->discard();
}
setCurrentContactRequest(nullptr);
setCurrentContactRequest(QModelIndex());
emit choiceMade();
}
......@@ -66,6 +79,6 @@ void ContactRequestWidget::on_blockCRButton_clicked()
if (cr_ != nullptr) {
cr_->block();
}
setCurrentContactRequest(nullptr);
setCurrentContactRequest(QModelIndex());
emit choiceMade();
}
......@@ -34,7 +34,7 @@ class ContactRequestWidget : public QWidget
public:
explicit ContactRequestWidget(QWidget *parent = 0);
~ContactRequestWidget();
void setCurrentContactRequest(ContactRequest* cr);
void setCurrentContactRequest(const QModelIndex &current);
signals:
void choiceMade();
......
......@@ -14,47 +14,110 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="topMargin">
<number>0</number>
</property>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>20</pointsize>
</font>
</property>
<property name="text">
<string>Incoming Contact Request</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<spacer name="topSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Maximum</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="remoteIdLabel">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="pictureLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="text">
<string>Current ContactRequest:</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="ressources.qrc">:/images/user/btn-default-userpic.svg</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="nameLabel">
<property name="font">
<font>
<pointsize>15</pointsize>
</font>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
<property name="text">
<string>nameLabel</string>
</property>
</spacer>
</widget>
</item>
<item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="bestIdLabel">
<property name="font">
<font>
<pointsize>10</pointsize>
<italic>true</italic>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(63, 63, 63);</string>
</property>
<property name="text">
<string>bestIdLabel</string>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QWidget" name="buttonBar" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="acceptCRButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<width>150</width>
<height>30</height>
</size>
</property>
......@@ -67,24 +130,17 @@ padding-right: 15px;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="discardCRButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="blockCRButton">
<property name="minimumSize">
<size>
<width>0</width>
<width>150</width>
<height>30</height>
</size>
</property>
......@@ -93,28 +149,21 @@ padding-right: 15px;</string>
padding-right: 15px;</string>
</property>
<property name="text">
<string>Block</string>
<string>Discard</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="blockCRButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="discardCRButton">
<property name="minimumSize">
<size>
<width>0</width>
<width>150</width>
<height>30</height>
</size>
</property>
......@@ -123,15 +172,30 @@ padding-right: 15px;</string>
padding-right: 15px;</string>
</property>
<property name="text">
<string>Discard</string>
<string>Block</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<resources>
<include location="ressources.qrc"/>
</resources>
<connections/>
</ui>
......@@ -25,7 +25,8 @@
#include "media/video.h"
#include "media/text.h"
#include "media/file.h"
#include "globalinstances.h"
#include "pixbufmanipulator.h"
#include <QThread>
#include <QTranslator>
......@@ -67,6 +68,8 @@ main(int argc, char *argv[])
QApplication a(argc, argv);
GlobalInstances::setPixmapManipulator(std::unique_ptr<Interfaces::PixbufManipulator>(new Interfaces::PixbufManipulator()));
auto startMinimized = false;
QString uri = "";
......
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