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

implements send contact request page

This patch comprehends the ui of sending contact request and
the logic behind it

The ui is a new page on the stacked widget of callwidget
it contains a text field displaying the RingID of the contact
you want to request and another for a textual help,
there is also a text entry for future text added to contact request
payloads.

Change-Id: I592f74fefa125d6e8cd576f9a49fbd74581cf4c9
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 14a15ea3
......@@ -71,7 +71,8 @@ SOURCES += main.cpp\
qualitydialog.cpp \
ringbutton.cpp \
pathpassworddialog.cpp \
photoboothdialog.cpp
photoboothdialog.cpp \
sendcontactrequestwidget.cpp
HEADERS += mainwindow.h \
callwidget.h \
......@@ -106,7 +107,8 @@ HEADERS += mainwindow.h \
ringthemeutils.h \
ringbutton.h \
pathpassworddialog.h \
photoboothdialog.h
photoboothdialog.h \
sendcontactrequestwidget.h
contains(DEFINES, URI_PROTOCOL) {
HEADERS += shmclient.h
......@@ -129,7 +131,8 @@ FORMS += mainwindow.ui \
qualitydialog.ui \
ringbutton.ui \
pathpassworddialog.ui \
photoboothdialog.ui
photoboothdialog.ui \
sendcontactrequestwidget.ui
win32: LIBS += -lole32 -luuid -lshlwapi
LIBS += -lqrencode
......
......@@ -44,7 +44,6 @@
#include "contactmethod.h"
#include "globalinstances.h"
#include <availableaccountmodel.h>
#include "wizarddialog.h"
#include "windowscontactbackend.h"
#include "contactpicker.h"
......@@ -141,6 +140,8 @@ CallWidget::CallWidget(QWidget* parent) :
connect(&NameDirectory::instance(), SIGNAL(registeredNameFound(const Account*,NameDirectory::LookupStatus,const QString&,const QString&)),
this, SLOT(contactLineEdit_registeredNameFound(const Account*,NameDirectory::LookupStatus,const QString&,const QString&)));
connect(ui->sendContactRequestWidget, &SendContactRequestWidget::sendCRclicked, [=]{slidePage(ui->messagingPage);});
} catch (const std::exception& e) {
qDebug() << "INIT ERROR" << e.what();
}
......@@ -538,7 +539,7 @@ CallWidget::smartListCurrentChanged(const QModelIndex &currentIdx, const QModelI
setActualCall(currentIdxCall);
} else if (currentIdxCall == nullptr){ // if there is no call attached to this smartlist index (contact tab)
setActualCall(nullptr);
showIMOutOfCall(currentIdx); //change page to messaging page with correct behaviour
showIMOutOfCall(currentIdx); // change page to contact request of messaging page with correct behaviour
} else { // if non defined behaviour disconnect instant messaging and return to welcome page
setActualCall(nullptr);
if (imConnection_)
......@@ -547,6 +548,18 @@ CallWidget::smartListCurrentChanged(const QModelIndex &currentIdx, const QModelI
}
}
void
CallWidget::configureSendCRPageButton(const QModelIndex& currentIdx)
{
auto cmVector = RecentModel::instance().getContactMethods(currentIdx);
URI cmUri = cmVector[0]->uri();
if (cmUri.protocolHint() == URI::ProtocolHint::RING || uriNeedNameLookup(cmUri)) {
ui->sendContactRequestPageButton->show();
} else {
ui->sendContactRequestPageButton->hide();
}
}
void
CallWidget::placeCall()
{
......@@ -581,30 +594,35 @@ CallWidget::searchContactLineEditEntry(const URI &uri)
ui->ringContactLineEdit->clear();
}
bool
CallWidget::uriNeedNameLookup(const URI uri_passed)
{
if (uri_passed.protocolHint() == URI::ProtocolHint::RING_USERNAME ) {
return TRUE;
} else if (
uri_passed.protocolHint() != URI::ProtocolHint::RING && // not a RingID
uri_passed.schemeType() == URI::SchemeType::NONE // scheme type not specified
){
// if no scheme type has been specified, determine ring vs sip by the first available account
auto idx = AvailableAccountModel::instance().index(0, 0);
if (idx.isValid()) {
auto account = idx.data((int)Ring::Role::Object).value<Account *>();
if (account && account->protocol() == Account::Protocol::RING)
return TRUE;
}
}
return FALSE;
}
void
CallWidget::on_ringContactLineEdit_returnPressed()
{
bool lookup_username = false;
auto contactLineText = ui->ringContactLineEdit->text();
URI uri_passed = URI(contactLineText);
if (!contactLineText.isNull() && !contactLineText.isEmpty()){
if (uri_passed.protocolHint() == URI::ProtocolHint::RING_USERNAME ) {
lookup_username = TRUE;
} else if (
uri_passed.protocolHint() != URI::ProtocolHint::RING && // not a RingID
uri_passed.schemeType() == URI::SchemeType::NONE // scheme type not specified
){
// if no scheme type has been specified, determine ring vs sip by the first available account
auto idx = AvailableAccountModel::instance().index(0, 0);
if (idx.isValid()) {
auto account = idx.data((int)Ring::Role::Object).value<Account *>();
if (account && account->protocol() == Account::Protocol::RING)
lookup_username = TRUE;
}
}
if (lookup_username){
if (uriNeedNameLookup(uri_passed)){
NameDirectory::instance().lookupName(nullptr, QString(), uri_passed);
} else {
searchContactLineEditEntry(uri_passed);
......@@ -631,7 +649,7 @@ void
CallWidget::showIMOutOfCall(const QModelIndex& nodeIdx)
{
ui->contactMethodComboBox->clear();
configureSendCRPageButton(nodeIdx);
ui->imNameLabel->setText(QString(tr("Conversation with %1", "%1 is the contact name"))
.arg(nodeIdx.data(static_cast<int>(Ring::Role::Name)).toString()));
auto cmVector = RecentModel::instance().getContactMethods(nodeIdx);
......@@ -786,9 +804,13 @@ CallWidget::contactLineEdit_registeredNameFound(const Account* account,NameDirec
{
case NameDirectory::LookupStatus::SUCCESS:
{
uri = URI("ring:" + address);
qDebug() << "contactLineEdit username to search: " << username_to_lookup;
qDebug() << uri;
searchContactLineEditEntry(uri);
auto cm = PhoneDirectoryModel::instance().getNumber(uri);
//cm->setAccount(account);
break;
}
case NameDirectory::LookupStatus::INVALID_NAME:
......@@ -805,3 +827,17 @@ CallWidget::contactLineEdit_registeredNameFound(const Account* account,NameDirec
}
}
}
void
CallWidget::on_sendContactRequestPageButton_clicked()
{
ui->sendContactRequestWidget->sendCR(RecentModel::instance().selectionModel()->currentIndex());
// temporarly changed comportment waiting for message in payload implementation
/*ui->sendContactRequestWidget->setup(RecentModel::instance().selectionModel()->currentIndex());
slidePage(ui->sendContactRequestPage);*/
}
void CallWidget::on_sendCRBackButton_clicked()
{
slidePage(ui->messagingPage);
}
......@@ -56,6 +56,7 @@ public:
public slots:
void settingsButtonClicked();
void showIMOutOfCall(const QModelIndex& nodeIdx);
void configureSendCRPageButton(const QModelIndex& nodeIdx);
void btnComBarVideoClicked();
//UI SLOTS
......@@ -76,6 +77,8 @@ private slots:
void on_ringContactLineEdit_textChanged(const QString& text);
void on_imBackButton_clicked();
void on_copyCMButton_clicked();
void on_sendContactRequestPageButton_clicked();
void on_sendCRBackButton_clicked();
void on_smartList_clicked(const QModelIndex &index);
void on_qrButton_toggled(bool checked);
void on_shareButton_clicked();
......@@ -120,5 +123,6 @@ private:
void callStateToView(Call* value);
void setupQRCode(QString ringID);
void searchContactLineEditEntry(const URI &uri);
bool uriNeedNameLookup(const URI uri_passed);
};
......@@ -865,6 +865,78 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="sendContactRequestPage">
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="sendCRBackButton">
<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="toolTip">
<string/>
</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>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_14">
<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="SendContactRequestWidget" name="sendContactRequestWidget" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="locale">
<locale language="English" country="UnitedStates"/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="messagingPage">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
......@@ -925,6 +997,28 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="sendContactRequestPageButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>contact request</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
......@@ -1597,6 +1691,12 @@
<extends>QTreeView</extends>
<header>smartlist.h</header>
</customwidget>
<customwidget>
<class>SendContactRequestWidget</class>
<extends>QWidget</extends>
<header>sendcontactrequestwidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="ressources.qrc"/>
......
#include <QDebug>
#include "sendcontactrequestwidget.h"
#include "ui_sendcontactrequestwidget.h"
#include "account.h"
#include "accountmodel.h"
#include "recentmodel.h"
#include "contactmethod.h"
#include "phonedirectorymodel.h"
SendContactRequestWidget::SendContactRequestWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::SendContactRequestWidget)
{
ui->setupUi(this);
ui->contactRequestInfo->setText("Contact Request Bruh!!!!\n");
ui->peerContactID->setText("ContactID\n");
}
SendContactRequestWidget::~SendContactRequestWidget()
{
disconnect(sendCRClickedConnection_);
delete ui;
}
void
SendContactRequestWidget::setup(const QModelIndex& nodeIdx)
{
auto cmVector = RecentModel::instance().getContactMethods(nodeIdx);
disconnect(sendCRClickedConnection_);
QString number = cmVector[0]->uri();
ui->peerContactID->setText(number);
sendCRClickedConnection_ = connect(ui->sendContactRequestButton, &QPushButton::clicked, [this,nodeIdx]() {
sendCR(nodeIdx);
});
}
void SendContactRequestWidget::sendCR(const QModelIndex& nodeIdx)
{
auto cmVector = RecentModel::instance().getContactMethods(nodeIdx);
QString number = cmVector[0]->uri();
auto cm = PhoneDirectoryModel::instance().getNumber(number);
if(cm->account() != nullptr){
cm->account()->sendContactRequest(cm);
} else {
qDebug() << "no account linked to contact method";
cm->setAccount(AccountModel::instance().userChosenAccount());
cm->account()->sendContactRequest(cm);
}
//emit sendCRclicked();
}
#ifndef SENDCONTACTREQUESTWIDGET_H
#define SENDCONTACTREQUESTWIDGET_H
#include <QWidget>
namespace Ui {
class SendContactRequestWidget;
}
class SendContactRequestWidget : public QWidget
{
Q_OBJECT
public:
explicit SendContactRequestWidget(QWidget *parent = 0);
~SendContactRequestWidget();
void setup(const QModelIndex& nodeIdx);
void sendCR(const QModelIndex& nodeIdx);
private:
QMetaObject::Connection sendCRClickedConnection_;
Ui::SendContactRequestWidget *ui;
signals:
void sendCRclicked();
};
#endif // SENDCONTACTREQUESTWIDGET_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SendContactRequestWidget</class>
<widget class="QWidget" name="SendContactRequestWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>519</width>
<height>393</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="peerContactID">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QLabel" name="contactRequestInfo">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QTextEdit" name="contactRequestTextEdit"/>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="sendContactRequestButton">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">padding-left: 10px;
padding-right: 10px;</string>
</property>
<property name="text">
<string>Send contact request</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -184,19 +184,19 @@ QPushButton#hangupButton:pressed{
}
QPushButton#exitSettingsButton, QPushButton#settingsButton, QPushButton#addToContactButton,
QPushButton#imBackButton, QPushButton#copyCMButton{
QPushButton#imBackButton, QPushButton#sendCRBackButton, QPushButton#copyCMButton{
background-color: #414141;
border-radius: 15px;
border:solid 1px;
}
QPushButton#exitSettingsButton:hover, QPushButton#settingsButton:hover, QPushButton#imBackButton:hover,
QPushButton#copyCMButton:hover{
QPushButton#sendCRBackButton:hover, QPushButton#copyCMButton:hover{
background-color: #515151;
}
QPushButton#exitSettingsButton:pressed, QPushButton#settingsButton:pressed, QToolButton#imBackButton:pressed,
QPushButton#copyCMButton:pressed{
QToolButton#sendCRBackButton:pressed, QPushButton#copyCMButton:pressed{
background-color: #313131;
}
......@@ -254,7 +254,7 @@ QScrollBar::handle:vertical{
background: rgb(77, 77, 77);
}
QDialog#WizardDialog, QWidget#welcomePage{
QDialog#WizardDialog, QWidget#welcomePage, QWidget#sendContactRequestPage{
background: rgb(242, 242, 242);
background-image : url(:/images/background-light.png);
background-repeat : repeat-x;
......@@ -289,7 +289,8 @@ QPushButton#nextButton, QPushButton#playButton, QPushButton#clearHistoryButton,
QPushButton#checkUpdateButton, QPushButton#photoButton, QPushButton#takePhotoButton, QPushButton#importButton,
QPushButton#existingPushButton, QPushButton#newAccountButton, QPushButton#previousButton, QPushButton#exportButton,
QPushButton#cancelAddButton, QPushButton#exportOnRingButton, QPushButton#addDeviceButton, QPushButton#exportEndedOkButton,
QPushButton#errorPushButton, QPushButton#registerButton{
QPushButton#errorPushButton, QPushButton#registerButton, QPushButton#sendContactRequestPageButton,
QPushButton#sendContactRequestButton {
background-color: #3AC0D2;
border: 0px;
color: white;
......@@ -302,7 +303,8 @@ QPushButton#takePhotoButton:hover, QPushButton#importButton:hover,
QPushButton#existingPushButton:hover, QPushButton#newAccountButton:hover, QPushButton#previousButton:hover,
QPushButton#exportButton:hover, QPushButton#cancelAddButton:hover, QPushButton#exportOnRingButton:hover,
QPushButton#addDeviceButton:hover, QPushButton#exportEndedOkButton:hover, QPushButton#errorPushButton:hover,
QPushButton#registerButton:hover{
QPushButton#registerButton:hover, QPushButton#sendContactRequestPageButton:hover,
QPushButton#sendContactRequestButton:hover {
background-color: #4dc6d6;
}
......@@ -312,7 +314,8 @@ QPushButton#takePhotoButton:pressed, QPushButton#importButton:pressed,
QPushButton#existingPushButton:pressed, QPushButton#newAccountButton:pressed, QPushButton#previousButton:pressed,
QPushButton#exportButton:pressed, QPushButton#cancelAddButton:pressed, QPushButton#exportOnRingButton:pressed,
QPushButton#addDeviceButton:pressed, QPushButton#exportEndedOkButton:pressed, QPushButton#errorPushButton:pressed,
QPushButton#registerButton:pressed{
QPushButton#registerButton:pressed, QPushButton#sendContactRequestPageButton:pressed,
QPushButton#sendContactRequestButton: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