Commit 5cbf2b66 authored by Edric Milaret's avatar Edric Milaret

call: implement transfer feature

Issue: #76241
Change-Id: I90e236698017ccad679a0f10e6e01a5c0409c313
parent 2cf34296
...@@ -54,7 +54,8 @@ SOURCES += main.cpp\ ...@@ -54,7 +54,8 @@ SOURCES += main.cpp\
imdelegate.cpp \ imdelegate.cpp \
contactpicker.cpp \ contactpicker.cpp \
contactmethodpicker.cpp \ contactmethodpicker.cpp \
globalsystemtray.cpp globalsystemtray.cpp \
transferdialog.cpp
HEADERS += mainwindow.h \ HEADERS += mainwindow.h \
callwidget.h \ callwidget.h \
...@@ -81,7 +82,8 @@ HEADERS += mainwindow.h \ ...@@ -81,7 +82,8 @@ HEADERS += mainwindow.h \
contactpicker.h \ contactpicker.h \
contactmethodpicker.h \ contactmethodpicker.h \
settingskey.h \ settingskey.h \
globalsystemtray.h globalsystemtray.h \
transferdialog.h
FORMS += mainwindow.ui \ FORMS += mainwindow.ui \
callwidget.ui \ callwidget.ui \
...@@ -95,7 +97,8 @@ FORMS += mainwindow.ui \ ...@@ -95,7 +97,8 @@ FORMS += mainwindow.ui \
videoview.ui \ videoview.ui \
videooverlay.ui \ videooverlay.ui \
contactpicker.ui \ contactpicker.ui \
contactmethodpicker.ui contactmethodpicker.ui \
transferdialog.ui
win32: LIBS += -lole32 -luuid -lshlwapi win32: LIBS += -lole32 -luuid -lshlwapi
......
/***************************************************************************
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#include "transferdialog.h"
#include "ui_transferdialog.h"
#include "callmodel.h"
#include "phonedirectorymodel.h"
TransferDialog::TransferDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::TransferDialog)
{
ui->setupUi(this);
this->setWindowFlags(Qt::CustomizeWindowHint);
this->setWindowFlags(Qt::FramelessWindowHint);
auto activeProxy = new ActiveCallsProxyModel(CallModel::instance());
ui->activeCallsView->setModel(activeProxy);
ui->activeCallsView->clearSelection();
}
TransferDialog::~TransferDialog()
{
delete ui;
}
void
TransferDialog::showEvent(QShowEvent *event)
{
Q_UNUSED(event)
ui->numberBar->clear();
selectedCall_ = nullptr;
}
void
TransferDialog::on_transferButton_clicked()
{
auto callList = CallModel::instance()->getActiveCalls();
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
if (not ui->numberBar->text().isEmpty()) {
auto number = PhoneDirectoryModel::instance()->getNumber(ui->numberBar->text());
CallModel::instance()->transfer(c, number);
} else if (selectedCall_) {
CallModel::instance()->attendedTransfer(c, selectedCall_);
}
this->close();
return;
}
}
}
void
TransferDialog::on_activeCallsView_doubleClicked(const QModelIndex &index)
{
auto callList = CallModel::instance()->getActiveCalls();
for (auto c : callList) {
if (c->state() == Call::State::CURRENT) {
auto selectedCall = CallModel::instance()->getCall(index);
if (c != selectedCall) {
CallModel::instance()->attendedTransfer(c, selectedCall);
this->close();
return;
}
}
}
}
void
TransferDialog::on_activeCallsView_clicked(const QModelIndex &index)
{
selectedCall_ = CallModel::instance()->getCall(index);
}
/***************************************************************************
* Copyright (C) 2015 by Savoir-Faire Linux *
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>*
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
**************************************************************************/
#ifndef TRANSFERDIALOG_H
#define TRANSFERDIALOG_H
#include <QDialog>
#include <QSortFilterProxyModel>
#include "callmodel.h"
namespace Ui {
class TransferDialog;
}
class ActiveCallsProxyModel : public QSortFilterProxyModel
{
public:
ActiveCallsProxyModel(QAbstractItemModel* parent) : QSortFilterProxyModel(parent)
{
setSourceModel(parent);
}
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const
{
return sourceModel()->index(source_row,0,source_parent)
.data(static_cast<int>(Call::Role::State)).value<Call::State>() != Call::State::CURRENT;
}
};
class TransferDialog : public QDialog
{
Q_OBJECT
public:
explicit TransferDialog(QWidget *parent = 0);
~TransferDialog();
//UI SLOTS
protected slots:
void showEvent(QShowEvent *event);
private slots:
void on_transferButton_clicked();
void on_activeCallsView_doubleClicked(const QModelIndex &index);
void on_activeCallsView_clicked(const QModelIndex &index);
private:
Ui::TransferDialog *ui;
Call *selectedCall_;
};
#endif // TRANSFERDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TransferDialog</class>
<widget class="QDialog" name="TransferDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>268</width>
<height>385</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0" columnstretch="0,0">
<item row="1" column="0">
<widget class="QListView" name="activeCallsView"/>
</item>
<item row="3" column="0" colspan="2">
<widget class="QPushButton" name="transferButton">
<property name="text">
<string>Transfer</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLineEdit" name="numberBar">
<property name="placeholderText">
<string>or type number...</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Current Calls</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
...@@ -23,11 +23,13 @@ ...@@ -23,11 +23,13 @@
VideoOverlay::VideoOverlay(QWidget *parent) : VideoOverlay::VideoOverlay(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::VideoOverlay) ui(new Ui::VideoOverlay),
transferDialog_(new TransferDialog())
{ {
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);
...@@ -73,6 +75,7 @@ VideoOverlay::~VideoOverlay() ...@@ -73,6 +75,7 @@ VideoOverlay::~VideoOverlay()
{ {
delete ui; delete ui;
delete menu_; delete menu_;
delete transferDialog_;
} }
void void
...@@ -107,3 +110,10 @@ VideoOverlay::on_chatButton_toggled(bool checked) ...@@ -107,3 +110,10 @@ VideoOverlay::on_chatButton_toggled(bool checked)
emit setChatVisibility(checked); emit setChatVisibility(checked);
} }
void
VideoOverlay::on_transferButton_toggled(bool checked)
{
auto pos = this->mapToGlobal(ui->transferButton->pos());
transferDialog_->move(pos.x() + ui->transferButton->width(), pos.y() - (transferDialog_->height()/2));
checked ? transferDialog_->show() : transferDialog_->hide();
}
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "useractionmodel.h" #include "useractionmodel.h"
#include "transferdialog.h"
namespace Ui { namespace Ui {
class VideoOverlay; class VideoOverlay;
} }
...@@ -45,11 +47,13 @@ private slots: ...@@ -45,11 +47,13 @@ private slots:
void on_holdButton_toggled(bool checked); 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);
private: private:
Ui::VideoOverlay *ui; Ui::VideoOverlay *ui;
UserActionModel* actionModel_; UserActionModel* actionModel_;
QMenu* menu_; QMenu* menu_;
TransferDialog *transferDialog_;
signals: signals:
void setChatVisibility(bool visible); void setChatVisibility(bool visible);
......
...@@ -23,20 +23,17 @@ ...@@ -23,20 +23,17 @@
<string/> <string/>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="1" column="1"> <item row="1" column="2">
<widget class="QPushButton" name="holdButton"> <widget class="QPushButton" name="hangupButton">
<property name="text"> <property name="text">
<string>Hold</string> <string>Hangup</string>
</property>
<property name="checkable">
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="3"> <item row="1" column="5">
<widget class="QPushButton" name="chatButton"> <widget class="QPushButton" name="moreButton">
<property name="text"> <property name="text">
<string>Chat</string> <string>...</string>
</property> </property>
</widget> </widget>
</item> </item>
...@@ -53,7 +50,7 @@ ...@@ -53,7 +50,7 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="1" column="5"> <item row="1" column="6">
<spacer name="horizontalSpacer_2"> <spacer name="horizontalSpacer_2">
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
...@@ -110,7 +107,7 @@ ...@@ -110,7 +107,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="5" alignment="Qt::AlignRight|Qt::AlignTop"> <item row="0" column="6" alignment="Qt::AlignRight|Qt::AlignTop">
<widget class="QLabel" name="timerLabel"> <widget class="QLabel" name="timerLabel">
<property name="palette"> <property name="palette">
<palette> <palette>
...@@ -154,17 +151,27 @@ ...@@ -154,17 +151,27 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="2"> <item row="1" column="1">
<widget class="QPushButton" name="hangupButton"> <widget class="QPushButton" name="holdButton">
<property name="text"> <property name="text">
<string>Hangup</string> <string>Hold</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QPushButton" name="chatButton">
<property name="text">
<string>Chat</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="4"> <item row="1" column="4">
<widget class="QPushButton" name="moreButton"> <widget class="QPushButton" name="transferButton">
<property name="text"> <property name="text">
<string>...</string> <string>Transfer</string>
</property> </property>
</widget> </widget>
</item> </item>
......
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