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

contactrequest: add ui for managing pending CR

Those modifications are only a part of the contact request
system. In details :
 * A panel on the left displays the incoming CRs for the
   selected account.
 * A tab system makes it possible to switch between the
   smartlist and the pending CR list.
 * When a CR is selected, a view of it is shown on the right
   with 2 buttons. One for accepting it, the other for
   discarding it.
 * The stylesheet is updated to adapt the new widgets
   with the design of the client.
 * When selected account is changed, we get back to the
   welcome page

Change-Id: I86dc7f32105c0454b0e4d002b6a78fde2c581a44
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent 47aa97f9
......@@ -73,7 +73,8 @@ SOURCES += main.cpp\
pathpassworddialog.cpp \
photoboothdialog.cpp \
sendcontactrequestwidget.cpp \
currentaccountwidget.cpp
currentaccountwidget.cpp \
contactrequestwidget.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -110,7 +111,8 @@ HEADERS += mainwindow.h \
pathpassworddialog.h \
photoboothdialog.h \
sendcontactrequestwidget.h \
currentaccountwidget.h
currentaccountwidget.h \
contactrequestwidget.h
contains(DEFINES, URI_PROTOCOL) {
HEADERS += shmclient.h
......@@ -135,7 +137,8 @@ FORMS += mainwindow.ui \
pathpassworddialog.ui \
photoboothdialog.ui \
sendcontactrequestwidget.ui \
currentaccountwidget.ui
currentaccountwidget.ui \
contactrequestwidget.ui
win32: LIBS += -lole32 -luuid -lshlwapi
LIBS += -lqrencode
......
......@@ -47,6 +47,8 @@
#include "contactmethod.h"
#include "globalinstances.h"
#include <availableaccountmodel.h>
#include "pendingcontactrequestmodel.h"
#include "wizarddialog.h"
#include "windowscontactbackend.h"
#include "contactpicker.h"
......@@ -148,6 +150,17 @@ CallWidget::CallWidget(QWidget* parent) :
connect(ui->sendContactRequestWidget, &SendContactRequestWidget::sendCRclicked, [=]{slidePage(ui->messagingPage);});
connect(ui->contactRequestWidget, &ContactRequestWidget::choiceMade, [this]() {
slidePage(ui->welcomePage);
});
connect(AccountModel::instance().userSelectionModel(), &QItemSelectionModel::currentChanged,
this, &CallWidget::selectedAccountChanged);
// It needs to be called manually once to initialize the ui with the account selected at start.
// The second argument (previous) is set to an invalid QModelIndex as it is the first selection.
selectedAccountChanged(AccountModel::instance().userSelectionModel()->currentIndex(), QModelIndex());
} catch (const std::exception& e) {
qDebug() << "INIT ERROR" << e.what();
}
......@@ -298,6 +311,7 @@ CallWidget::findRingAccount(QModelIndex idx1, QModelIndex idx2, QVector<int> vec
} else
ui->ringIdLabel->setText(registeredName);
setupQRCode(username.toString());
return;
}
}
......@@ -590,6 +604,16 @@ CallWidget::configureSendCRPageButton(const QModelIndex& currentIdx)
}
}
void
CallWidget::contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx)
{
Q_UNUSED(previousIdx)
ContactRequest* cr = currentIdx.data((int)Ring::Role::Object).value<ContactRequest*>();
ui->contactRequestWidget->setCurrentContactRequest(cr);
ui->stackedWidget->setCurrentWidget(ui->contactRequestView);
}
void
CallWidget::placeCall()
{
......@@ -681,6 +705,32 @@ CallWidget::btnComBarVideoClicked()
on_smartList_doubleClicked(highLightedIndex_);
}
void
CallWidget::selectedAccountChanged(const QModelIndex &current, const QModelIndex &previous)
{
Q_UNUSED(previous)
if (current.isValid()) {
auto ac = AccountModel::instance().getAccountByModelIndex(current);
// First, we get back to the welcome view
if (ui->stackedWidget->currentWidget() != ui->welcomePage) {
slidePage(ui->welcomePage);
}
// Then, we update the pending CR list with those from the newly selected account
if (disconnect(crListSelectionConnection_)) {
// The selection model must be deleted by the application (see QT doc).
QItemSelectionModel* sMod = ui->contactReqList->selectionModel();
delete sMod;
}
ui->contactReqList->setModel(ac->pendingContactRequestModel());
crListSelectionConnection_ = connect(ui->contactReqList->selectionModel(), &QItemSelectionModel::currentChanged,
this, &CallWidget::contactReqListCurrentChanged);
}
}
void
CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
{
......@@ -870,3 +920,10 @@ CallWidget::on_sendCRBackButton_clicked()
{
slidePage(ui->messagingPage);
}
void
CallWidget::on_pendingCRBackButton_clicked()
{
ui->contactReqList->selectionModel()->clear();
slidePage(ui->welcomePage);
}
......@@ -82,17 +82,20 @@ private slots:
void on_smartList_clicked(const QModelIndex &index);
void on_qrButton_toggled(bool checked);
void on_shareButton_clicked();
void on_pendingCRBackButton_clicked();
private slots:
void callIncoming(Call* call);
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 contactReqListCurrentChanged(const QModelIndex &currentIdx, const QModelIndex &previousIdx);
void slotAccountMessageReceived(const QMap<QString,QString> message,ContactMethod* cm,Media::Media::Direction dir);
void onIncomingMessage(::Media::TextRecording* t, ContactMethod* cm);
void callChangedSlot();
void contactLineEdit_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
void contactLineEdit_registeredNameFound(Account *account, NameDirectory::LookupStatus status, const QString& address, const QString& name);
void searchBtnClicked();
void selectedAccountChanged(const QModelIndex &current, const QModelIndex &previous);
private:
Ui::CallWidget* ui;
......@@ -109,6 +112,7 @@ private:
QMetaObject::Connection imVisibleConnection_;
QMetaObject::Connection callChangedConnection_;
QMetaObject::Connection imClickedConnection_;
QMetaObject::Connection crListSelectionConnection_;
QPropertyAnimation* pageAnim_;
QMenu* shareMenu_;
......@@ -127,4 +131,3 @@ private:
bool uriNeedNameLookup(const URI uri_passed);
void processContactLineEdit();
};
......@@ -284,7 +284,7 @@
<number>0</number>
</property>
<item>
<widget class="QStackedWidget" name="mainTabMenu">
<widget class="QTabWidget" name="mainTabMenu">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
......@@ -303,13 +303,13 @@
<height>16777215</height>
</size>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="mainTabMenuPage1">
<widget class="QWidget" name="mainTabMenuPage1_2">
<attribute name="title">
<string>Conversations</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<property name="spacing">
<number>0</number>
......@@ -347,6 +347,31 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mainTabMenuPage2">
<attribute name="title">
<string>Contact Requests</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QListView" name="contactReqList"/>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......@@ -1638,6 +1663,78 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="contactRequestView">
<layout class="QVBoxLayout" name="verticalLayout_8">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pendingCRBackButton">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="ressources.qrc">
<normaloff>:/images/icons/ic_arrow_back_white_24dp.png</normaloff>:/images/icons/ic_arrow_back_white_24dp.png</iconset>
</property>
<property name="iconSize">
<size>
<width>18</width>
<height>18</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="ContactRequestWidget" name="contactRequestWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
......@@ -1691,6 +1788,12 @@
<header>currentaccountwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ContactRequestWidget</class>
<extends>QWidget</extends>
<header>contactrequestwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="ressources.qrc"/>
......
#include "contactrequestwidget.h"
#include "ui_contactrequestwidget.h"
ContactRequestWidget::ContactRequestWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::ContactRequestWidget)
{
ui->setupUi(this);
}
ContactRequestWidget::~ContactRequestWidget()
{
delete ui;
}
void
ContactRequestWidget::setCurrentContactRequest(ContactRequest *cr)
{
cr_ = cr;
if (cr_ != nullptr) {
ui->remoteIdLabel->setText(QString("Current ContactRequest: %1").arg(QString::fromLocal8Bit(cr_->roleData(Qt::DisplayRole).value<QByteArray>())));
}
}
void
ContactRequestWidget::on_acceptCRButton_clicked()
{
if (cr_ != nullptr) {
cr_->accept();
}
setCurrentContactRequest(nullptr);
emit choiceMade();
}
void ContactRequestWidget::on_discardCRButton_clicked()
{
if (cr_ != nullptr) {
cr_->discard();
}
setCurrentContactRequest(nullptr);
emit choiceMade();
}
#ifndef CONTACTREQUESTWIDGET_H
#define CONTACTREQUESTWIDGET_H
#include <QWidget>
#include "contactrequest.h"
namespace Ui {
class ContactRequestWidget;
}
class ContactRequestWidget : public QWidget
{
Q_OBJECT
public:
explicit ContactRequestWidget(QWidget *parent = 0);
~ContactRequestWidget();
void setCurrentContactRequest(ContactRequest* cr);
signals:
void choiceMade();
private slots:
void on_acceptCRButton_clicked();
void on_discardCRButton_clicked();
private:
Ui::ContactRequestWidget *ui;
ContactRequest* cr_ = nullptr;
};
#endif // CONTACTREQUESTWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ContactRequestWidget</class>
<widget class="QWidget" name="ContactRequestWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>472</width>
<height>408</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="remoteIdLabel">
<property name="text">
<string>Current ContactRequest:</string>
</property>
</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>
<item>
<widget class="QWidget" name="buttonBar" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="acceptCRButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">padding-left: 15px;
padding-right: 15px;</string>
</property>
<property name="text">
<string>Accept</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>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="discardCRButton">
<property name="minimumSize">
<size>
<width>0</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">padding-left: 15px;
padding-right: 15px;</string>
</property>
<property name="text">
<string>Discard</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -106,6 +106,11 @@ QListView#cipherListView::item:disabled
background-color: transparent;
}
QListView#contactReqList
{
border: none;
}
SmartList::item:selected, QListView#accountView::item:selected, QListView#contactView::item:selected{
background-color: rgba(220, 220, 220, 255);
border: none;
......@@ -184,19 +189,19 @@ QPushButton#hangupButton:pressed{
}
QPushButton#exitSettingsButton, QPushButton#settingsButton, QPushButton#addToContactButton,
QPushButton#imBackButton, QPushButton#sendCRBackButton, QPushButton#copyCMButton{
QPushButton#imBackButton, QPushButton#sendCRBackButton, QPushButton#copyCMButton, QPushButton#pendingCRBackButton{
background-color: #414141;
border-radius: 15px;
border:solid 1px;
}
QPushButton#exitSettingsButton:hover, QPushButton#settingsButton:hover, QPushButton#imBackButton:hover,
QPushButton#sendCRBackButton:hover, QPushButton#copyCMButton:hover{
QPushButton#sendCRBackButton:hover, QPushButton#copyCMButton:hover, QPushButton#pendingCRBackButton:hover{
background-color: #515151;
}
QPushButton#exitSettingsButton:pressed, QPushButton#settingsButton:pressed, QPushButton#imBackButton:pressed,
QPushButton#sendCRBackButton:pressed, QPushButton#copyCMButton:pressed{
QPushButton#sendCRBackButton:pressed, QPushButton#copyCMButton:pressed, QPushButton#pendingCRBackButton:pressed{
background-color: #313131;
}
......@@ -281,7 +286,7 @@ QListView#contactView{
background: transparent;
}
QWidget#messagingPage{
QWidget#messagingPage, QWidget#contactRequestView{
background: rgb(242, 242, 242);
}
......@@ -290,7 +295,7 @@ QPushButton#checkUpdateButton, QPushButton#photoButton, QPushButton#takePhotoBut
QPushButton#existingPushButton, QPushButton#newAccountButton, QPushButton#previousButton, QPushButton#exportButton,
QPushButton#cancelAddButton, QPushButton#exportOnRingButton, QPushButton#addDeviceButton, QPushButton#exportEndedOkButton,
QPushButton#errorPushButton, QPushButton#registerButton, QPushButton#sendContactRequestPageButton,
QPushButton#sendContactRequestButton {
QPushButton#sendContactRequestButton, QPushButton#acceptCRButton, QPushButton#discardCRButton{
background-color: #3AC0D2;
border: 0px;
color: white;
......@@ -304,7 +309,7 @@ QPushButton#existingPushButton:hover, QPushButton#newAccountButton:hover, QPushB
QPushButton#exportButton:hover, QPushButton#cancelAddButton:hover, QPushButton#exportOnRingButton:hover,
QPushButton#addDeviceButton:hover, QPushButton#exportEndedOkButton:hover, QPushButton#errorPushButton:hover,
QPushButton#registerButton:hover, QPushButton#sendContactRequestPageButton:hover,
QPushButton#sendContactRequestButton:hover {
QPushButton#sendContactRequestButton:hover, QPushButton#acceptCRButton:hover, QPushButton#discardCRButton:hover{
background-color: #4dc6d6;
}
......@@ -315,7 +320,7 @@ QPushButton#existingPushButton:pressed, QPushButton#newAccountButton:pressed, QP
QPushButton#exportButton:pressed, QPushButton#cancelAddButton:pressed, QPushButton#exportOnRingButton:pressed,
QPushButton#addDeviceButton:pressed, QPushButton#exportEndedOkButton:pressed, QPushButton#errorPushButton:pressed,
QPushButton#registerButton:pressed, QPushButton#sendContactRequestPageButton:pressed,
QPushButton#sendContactRequestButton:pressed {
QPushButton#sendContactRequestButton:pressed, QPushButton#acceptCRButton:pressed, QPushButton#discardCRButton:pressed{
background-color: #34acbd;
}
......
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