Commit 80e0b21f authored by Edric Milaret's avatar Edric Milaret Committed by gerrit2

conference : UI implementation

- add a button on to add people
- add a button to join call with a parent
(launched with add people button)
- reuse transferdialog to present the information for add people
- rename transferdialog to callutilsdialog
- add a method to set the current distant renderer instead of being
dependant of LRC signals
- various code clean-up

Tuleap: #29
Change-Id: I7f8875011702b586f2155e87c60f43f806494e65
parent 5ac7ef23
...@@ -56,8 +56,8 @@ SOURCES += main.cpp\ ...@@ -56,8 +56,8 @@ SOURCES += main.cpp\
contactpicker.cpp \ contactpicker.cpp \
contactmethodpicker.cpp \ contactmethodpicker.cpp \
globalsystemtray.cpp \ globalsystemtray.cpp \
transferdialog.cpp \ smartlistdelegate.cpp \
smartlistdelegate.cpp callutilsdialog.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
callwidget.h \ callwidget.h \
...@@ -84,8 +84,8 @@ HEADERS += mainwindow.h \ ...@@ -84,8 +84,8 @@ HEADERS += mainwindow.h \
contactmethodpicker.h \ contactmethodpicker.h \
settingskey.h \ settingskey.h \
globalsystemtray.h \ globalsystemtray.h \
transferdialog.h \ smartlistdelegate.h \
smartlistdelegate.h callutilsdialog.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
callwidget.ui \ callwidget.ui \
...@@ -99,7 +99,7 @@ FORMS += mainwindow.ui \ ...@@ -99,7 +99,7 @@ FORMS += mainwindow.ui \
videooverlay.ui \ videooverlay.ui \
contactpicker.ui \ contactpicker.ui \
contactmethodpicker.ui \ contactmethodpicker.ui \
transferdialog.ui callutilsdialog.ui
win32: LIBS += -lole32 -luuid -lshlwapi win32: LIBS += -lole32 -luuid -lshlwapi
......
...@@ -16,57 +16,74 @@ ...@@ -16,57 +16,74 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/ **************************************************************************/
#include "transferdialog.h" #include "callutilsdialog.h"
#include "ui_transferdialog.h" #include "ui_callutilsdialog.h"
#include "callmodel.h" #include "callmodel.h"
#include "phonedirectorymodel.h" #include "phonedirectorymodel.h"
#include "recentmodel.h"
#include "contactmethod.h"
#include "person.h"
TransferDialog::TransferDialog(QWidget *parent) : CallUtilsDialog::CallUtilsDialog(QWidget* parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::TransferDialog), ui(new Ui::CallUtilsDialog),
activeProxy_(nullptr) confMode_(false),
smartListDelegate_(nullptr),
notCurrentProxyModel_(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint); this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint); this->setWindowFlags(Qt::FramelessWindowHint | Qt::Popup);
} }
TransferDialog::~TransferDialog() CallUtilsDialog::~CallUtilsDialog()
{ {
delete smartListDelegate_;
delete notCurrentProxyModel_;
delete ui; delete ui;
} }
void void
TransferDialog::showEvent(QShowEvent *event) CallUtilsDialog::showEvent(QShowEvent* event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
ui->numberBar->clear(); ui->numberBar->clear();
selectedCall_ = nullptr; if (not notCurrentProxyModel_) {
if (not activeProxy_) { notCurrentProxyModel_ = new NotCurrentProxyModel(&RecentModel::instance());
activeProxy_ = new ActiveCallsProxyModel(&CallModel::instance());
activeProxy_->setDynamicSortFilter(false);
} }
ui->activeCallsView->setModel(activeProxy_); ui->contactView->setModel(notCurrentProxyModel_);
ui->activeCallsView->clearSelection(); if (not smartListDelegate_) {
smartListDelegate_ = new SmartListDelegate();
}
ui->contactView->setItemDelegate(smartListDelegate_);
} }
void void CallUtilsDialog::removeProxyModel()
TransferDialog::on_transferButton_clicked() {
ui->contactView->setModel(nullptr);
}
void CallUtilsDialog::closeEvent(QCloseEvent* event)
{ {
//This prevent a crash happening in Qt5.5 in QSortFilterProxyModel
Q_UNUSED(event)
removeProxyModel(); removeProxyModel();
}
void
CallUtilsDialog::on_transferButton_clicked()
{
auto callList = CallModel::instance().getActiveCalls(); auto callList = CallModel::instance().getActiveCalls();
for (auto c : callList) { for (auto c : callList) {
if (c->state() == Call::State::CURRENT) { if (c->state() == Call::State::CURRENT) {
if (not ui->numberBar->text().isEmpty()) { if (not ui->numberBar->text().isEmpty()) {
auto number = PhoneDirectoryModel::instance().getNumber(ui->numberBar->text()); auto number = PhoneDirectoryModel::instance().getNumber(ui->numberBar->text());
CallModel::instance().transfer(c, number); CallModel::instance().transfer(c, number);
} else if (selectedCall_) {
CallModel::instance().attendedTransfer(c, selectedCall_);
} }
removeProxyModel();
this->close(); this->close();
return; return;
} }
...@@ -74,33 +91,47 @@ TransferDialog::on_transferButton_clicked() ...@@ -74,33 +91,47 @@ TransferDialog::on_transferButton_clicked()
} }
void void
TransferDialog::removeProxyModel() CallUtilsDialog::setConfMode(bool active)
{ {
//This prevent a crash happening in Qt5.5 in QSortFilterProxyModel confMode_ = active;
ui->activeCallsView->setModel(nullptr); ui->transferButton->setVisible(not active);
ui->numberBar->setVisible(not active);
} }
void void
TransferDialog::on_activeCallsView_doubleClicked(const QModelIndex &index) CallUtilsDialog::on_contactView_doubleClicked(const QModelIndex& index)
{ {
Q_UNUSED(index)
removeProxyModel(); removeProxyModel();
if (not index.isValid())
auto callList = CallModel::instance().getActiveCalls(); return;
for (auto c : callList) { auto realIdx = notCurrentProxyModel_->mapToSource(index);
if (c->state() == Call::State::CURRENT) { if (not RecentModel::instance().hasActiveCall(realIdx)) {
if (c != selectedCall_) { ContactMethod* m = nullptr;
CallModel::instance().attendedTransfer(c, selectedCall_); if (auto cm = realIdx.data(static_cast<int>(Call::Role::ContactMethod)).value<ContactMethod*>()) {
this->close(); m = cm;
return; } else {
if (auto person = realIdx.data(static_cast<int>(Person::Role::Object)).value<Person*>()) {
m = person->phoneNumbers().first();
} }
} }
if (confMode_) {
if (m && !RecentModel::instance().index(0, 0, realIdx).isValid()) {
Call* c = CallModel::instance().dialingCall(m, CallModel::instance().selectedCall());
c->performAction(Call::Action::ACCEPT);
}
} else {
if (m) {
auto activeCall = CallModel::instance().selectedCall();
CallModel::instance().transfer(activeCall, m);
}
}
} else {
auto activeCall = CallModel::instance().selectedCall();
auto call = RecentModel::instance().getActiveCall(realIdx);
if (not confMode_)
CallModel::instance().attendedTransfer(activeCall, call);
else
CallModel::instance().createJoinOrMergeConferenceFromCall(activeCall, call);
} }
} this->close();
void
TransferDialog::on_activeCallsView_clicked(const QModelIndex &index)
{
selectedCall_ = CallModel::instance().getCall(index);
} }
...@@ -22,15 +22,18 @@ ...@@ -22,15 +22,18 @@
#include <QSortFilterProxyModel> #include <QSortFilterProxyModel>
#include "callmodel.h" #include "callmodel.h"
#include "recentmodel.h"
#include "smartlistdelegate.h"
namespace Ui { namespace Ui {
class TransferDialog; class CallUtilsDialog;
} }
class ActiveCallsProxyModel : public QSortFilterProxyModel class NotCurrentProxyModel : public QSortFilterProxyModel
{ {
public: public:
ActiveCallsProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent) NotCurrentProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
{ {
setSourceModel(parent); setSourceModel(parent);
} }
...@@ -41,32 +44,34 @@ public: ...@@ -41,32 +44,34 @@ public:
auto idx = sourceModel()->index(source_row,0,source_parent); auto idx = sourceModel()->index(source_row,0,source_parent);
if (not idx.isValid()) if (not idx.isValid())
return false; return false;
return idx.data(static_cast<int>(Call::Role::State)) auto call = RecentModel::instance().getActiveCall(idx);
.value<Call::State>() != Call::State::CURRENT; return not call || not (call->state() == Call::State::CURRENT);
} }
}; };
class CallUtilsDialog : public QDialog
class TransferDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TransferDialog(QWidget *parent = 0); explicit CallUtilsDialog(QWidget* parent = 0);
~TransferDialog(); ~CallUtilsDialog();
void setConfMode(bool active);
//UI SLOTS //UI SLOTS
protected slots: protected slots:
void showEvent(QShowEvent *event); void showEvent(QShowEvent* event);
void closeEvent(QCloseEvent* event);
private slots: private slots:
void on_transferButton_clicked(); void on_transferButton_clicked();
void on_activeCallsView_doubleClicked(const QModelIndex &index); void on_contactView_doubleClicked(const QModelIndex& index);
void on_activeCallsView_clicked(const QModelIndex &index);
private: private:
Ui::TransferDialog *ui; Ui::CallUtilsDialog* ui;
Call *selectedCall_; bool confMode_;
ActiveCallsProxyModel *activeProxy_; SmartListDelegate* smartListDelegate_;
NotCurrentProxyModel* notCurrentProxyModel_;
void removeProxyModel(); void removeProxyModel();
}; };
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>TransferDialog</class> <class>CallUtilsDialog</class>
<widget class="QDialog" name="TransferDialog"> <widget class="QDialog" name="CallUtilsDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
...@@ -13,18 +13,23 @@ ...@@ -13,18 +13,23 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0" columnstretch="0,0"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="1" column="0"> <property name="leftMargin">
<widget class="QListView" name="activeCallsView"/> <number>0</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
<widget class="QListView" name="contactView"/>
</item> </item>
<item row="3" column="0" colspan="2"> <item>
<widget class="QPushButton" name="transferButton">
<property name="text">
<string>Transfer</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLineEdit" name="numberBar"> <widget class="QLineEdit" name="numberBar">
<property name="placeholderText"> <property name="placeholderText">
<string>or type number...</string> <string>or type number...</string>
...@@ -34,10 +39,10 @@ ...@@ -34,10 +39,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="0"> <item>
<widget class="QLabel" name="label"> <widget class="QPushButton" name="transferButton">
<property name="text"> <property name="text">
<string>Current Calls</string> <string>Transfer</string>
</property> </property>
</widget> </widget>
</item> </item>
......
...@@ -150,8 +150,8 @@ CallWidget::CallWidget(QWidget *parent) : ...@@ -150,8 +150,8 @@ CallWidget::CallWidget(QWidget *parent) :
findRingAccount(); findRingAccount();
} catch (...) { } catch (const std::exception& e) {
qDebug() << "INIT ERROR"; qDebug() << "INIT ERROR" << e.what();
} }
} }
...@@ -270,9 +270,6 @@ CallWidget::callStateChanged(Call* call, Call::State previousState) ...@@ -270,9 +270,6 @@ CallWidget::callStateChanged(Call* call, Call::State previousState)
if (call == nullptr) if (call == nullptr)
return; return;
//Force update of smartList
ui->smartList->setFocus();
if (call->state() == Call::State::OVER if (call->state() == Call::State::OVER
|| call->state() == Call::State::ERROR || call->state() == Call::State::ERROR
|| call->state() == Call::State::FAILURE || call->state() == Call::State::FAILURE
...@@ -349,8 +346,8 @@ void ...@@ -349,8 +346,8 @@ void
CallWidget::setActualCall(Call* value) CallWidget::setActualCall(Call* value)
{ {
actualCall_ = value; actualCall_ = value;
if (value) CallModel::instance().selectCall(value);
CallModel::instance().selectCall(value); ui->videoWidget->pushRenderer(value);
} }
void void
...@@ -395,18 +392,14 @@ CallWidget::smartListSelectionChanged(const QItemSelection &newSel, const QItemS ...@@ -395,18 +392,14 @@ CallWidget::smartListSelectionChanged(const QItemSelection &newSel, const QItemS
Q_UNUSED(oldSel) Q_UNUSED(oldSel)
auto newIdx = newSel.indexes().first(); auto newIdx = newSel.indexes().first();
if (newIdx.parent().isValid()) if (not newIdx.isValid())
return; return;
auto newIdxCall = RecentModel::instance().getActiveCall(RecentModel::instance().peopleProxy()->mapToSource(newIdx)); auto newIdxCall = RecentModel::instance().getActiveCall(RecentModel::instance().peopleProxy()->mapToSource(newIdx));
if (newIdxCall == actualCall_) if (newIdxCall == actualCall_)
return; return;
if (actualCall_ != nullptr) {
actualCall_->performAction(Call::Action::HOLD);
}
if (newIdxCall) { if (newIdxCall) {
newIdxCall->performAction(Call::Action::HOLD);
setActualCall(newIdxCall); setActualCall(newIdxCall);
ui->stackedWidget->setCurrentWidget(ui->videoPage); ui->stackedWidget->setCurrentWidget(ui->videoPage);
} else { } else {
......
...@@ -21,15 +21,14 @@ ...@@ -21,15 +21,14 @@
#include "callmodel.h" #include "callmodel.h"
VideoOverlay::VideoOverlay(QWidget *parent) : VideoOverlay::VideoOverlay(QWidget* parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::VideoOverlay), ui(new Ui::VideoOverlay),
transferDialog_(new TransferDialog()) transferDialog_(new CallUtilsDialog())
{ {
ui->setupUi(this); ui->setupUi(this);
ui->chatButton->setCheckable(true); ui->chatButton->setCheckable(true);
ui->transferButton->setCheckable(true);
actionModel_ = CallModel::instance().userActionModel(); actionModel_ = CallModel::instance().userActionModel();
setAttribute(Qt::WA_NoSystemBackground); setAttribute(Qt::WA_NoSystemBackground);
...@@ -62,6 +61,10 @@ VideoOverlay::VideoOverlay(QWidget *parent) : ...@@ -62,6 +61,10 @@ VideoOverlay::VideoOverlay(QWidget *parent) :
muteVideo->setChecked(idx.data(Qt::CheckStateRole).value<bool>()); muteVideo->setChecked(idx.data(Qt::CheckStateRole).value<bool>());
muteVideo->setEnabled(idx.flags() & Qt::ItemIsEnabled); muteVideo->setEnabled(idx.flags() & Qt::ItemIsEnabled);
break; break;
case UserActionModel::Action::HOLD:
ui->holdButton->setChecked(idx.data(Qt::CheckStateRole).value<bool>());
ui->holdButton->setEnabled(idx.flags() & Qt::ItemIsEnabled);
break;
default: default:
break; break;
} }
...@@ -69,6 +72,30 @@ VideoOverlay::VideoOverlay(QWidget *parent) : ...@@ -69,6 +72,30 @@ VideoOverlay::VideoOverlay(QWidget *parent) :
}); });
ui->moreButton->setMenu(menu_); ui->moreButton->setMenu(menu_);
connect(CallModel::instance().selectionModel(), &QItemSelectionModel::currentChanged, [=](const QModelIndex &current, const QModelIndex &previous) {
Q_UNUSED(previous)
Call* c = current.data(static_cast<int>(Call::Role::Object)).value<Call*>();
if (c) {
if (c->hasParentCall()) {
ui->holdButton->hide();
ui->moreButton->hide();
ui->transferButton->hide();
ui->addPersonButton->hide();
ui->chatButton->hide();
ui->joinButton->show();
} else {
ui->holdButton->show();
ui->moreButton->show();
ui->transferButton->show();
ui->addPersonButton->show();
ui->chatButton->show();
ui->joinButton->hide();
}
}
});
} }
VideoOverlay::~VideoOverlay() VideoOverlay::~VideoOverlay()
...@@ -90,13 +117,6 @@ VideoOverlay::setTime(const QString& time) ...@@ -90,13 +117,6 @@ VideoOverlay::setTime(const QString& time)
ui->timerLabel->setText(time); ui->timerLabel->setText(time);
} }
void
VideoOverlay::on_holdButton_toggled(bool checked)
{
Q_UNUSED(checked)
actionModel_->execute(UserActionModel::Action::HOLD);
}
void void
VideoOverlay::on_hangupButton_clicked() VideoOverlay::on_hangupButton_clicked()
{ {
...@@ -111,9 +131,36 @@ VideoOverlay::on_chatButton_toggled(bool checked) ...@@ -111,9 +131,36 @@ VideoOverlay::on_chatButton_toggled(bool checked)
} }
void void
VideoOverlay::on_transferButton_toggled(bool checked) VideoOverlay::on_transferButton_clicked()
{ {
transferDialog_->setConfMode(false);
auto pos = this->mapToGlobal(ui->transferButton->pos()); auto pos = this->mapToGlobal(ui->transferButton->pos());
transferDialog_->move(pos.x() + ui->transferButton->width(), pos.y() - (transferDialog_->height()/2)); transferDialog_->move(pos.x()
checked ? transferDialog_->show() : transferDialog_->hide(); - transferDialog_->size().width()/2
+ ui->transferButton->size().width()/2,
pos.y() - (transferDialog_->height()));
transferDialog_->show();
}
void
VideoOverlay::on_addPersonButton_clicked()
{
transferDialog_->setConfMode(true);
auto pos = this->mapToGlobal(ui->addPersonButton->pos());
transferDialog_->move(pos.x()
- transferDialog_->size().width()/2
+ ui->addPersonButton->size().width()/2,
pos.y() - (transferDialog_->height()));
transferDialog_->show();
}
void
VideoOverlay::on_holdButton_clicked()
{
actionModel_->execute(UserActionModel::Action::HOLD);
}
void VideoOverlay::on_joinButton_clicked()
{
CallModel::instance().selectedCall()->joinToParent();
} }
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "useractionmodel.h" #include "useractionmodel.h"
#include "transferdialog.h" #include "callutilsdialog.h"
namespace Ui { namespace Ui {
class VideoOverlay; class VideoOverlay;
...@@ -34,25 +34,27 @@ class VideoOverlay : public QWidget ...@@ -34,25 +34,27 @@ class VideoOverlay : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit VideoOverlay(QWidget *parent = 0); explicit VideoOverlay(QWidget* parent = 0);
~VideoOverlay(); ~VideoOverlay();
public: public:
void setName(const QString &name); void setName(const QString& name);
void setTime(const QString &time); void setTime(const QString& time);
//UI SLOTS //UI SLOTS
private slots: private slots:
void on_holdButton_toggled(bool checked);
void on_hangupButton_clicked(); void on_hangupButton_clicked();
void on_chatButton_toggled(bool checked); void on_chatButton_toggled(bool checked);
void on_transferButton_toggled(bool checked); void on_transferButton_clicked();
void on_addPersonButton_clicked();
void on_holdButton_clicked();
void on_joinButton_clicked();
private: private:
Ui::VideoOverlay *ui; Ui::VideoOverlay* ui;
UserActionModel* actionModel_; UserActionModel* actionModel_;
QMenu* menu_; QMenu* menu_;
TransferDialog *transferDialog_; CallUtilsDialog* transferDialog_;
signals: signals:
void setChatVisibility(bool visible); void setChatVisibility(bool visible);
......
...@@ -23,22 +23,8 @@ ...@@ -23,22 +23,8 @@
<string/> <string/>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="2"> <item row="1" column="8">
<widget class="QPushButton" name="hangupButton"> <spacer name="horizontalSpacer_2">
<property name="text">
<string>Hangup</string>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QPushButton" name="moreButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
...@@ -50,21 +36,15 @@ ...@@ -50,21 +36,15 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="6"> <item row="1" column="2">
<spacer name="horizontalSpacer_2"> <widget class="QPushButton" name="hangupButton">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Hangup</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer> </widget>
</item> </item>
<item row="0" column="0" alignment="Qt::AlignTop"> <item row="0" column="8" alignment="Qt::AlignRight|Qt::AlignTop">
<widget class="QLabel" name="nameLabel"> <widget class="QLabel" name="timerLabel">
<property name="palette"> <property name="palette">
<palette> <palette>
<active> <active>
...@@ -103,12 +83,26 @@ ...@@ -103,12 +83,26 @@
</palette> </palette>
</property> </property>
<property name="text">