Commit 11a5ff9b authored by Ming Rui Zhang's avatar Ming Rui Zhang

sipinputpanel: add A,B,C,D dtmf signals onto sip input panel

- migrate sip input panel to popup widget

Change-Id: Ibca204d6e7f1ea69558f20a4ec751dfb1d63d7e6
parent 609c2292
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>261</width> <width>64</width>
<height>289</height> <height>16</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
......
...@@ -22,18 +22,13 @@ ...@@ -22,18 +22,13 @@
#include "lrcinstance.h" #include "lrcinstance.h"
SipInputPanel::SipInputPanel(QWidget* parent) SIPInputPanelWidget::SIPInputPanelWidget(QWidget* parent)
: QDialog(parent) : PopupWidget(parent, Qt::white, PopupDialog::SpikeLabelAlignment::AlignLeft)
, ui(new Ui::SIPInputPanelDialog) , ui(new Ui::SIPInputPanelWidget)
, signalMapper(new QSignalMapper(this)) , signalMapper(new QSignalMapper(this))
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(Qt::CustomizeWindowHint);
setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::NoDropShadowWindowHint);
setAttribute(Qt::WA_NoSystemBackground, true);
setAttribute(Qt::WA_TranslucentBackground, true);
//Adds a mapping so that when map() is signalled from the sender, the signal mapped(id) is emitted. //Adds a mapping so that when map() is signalled from the sender, the signal mapped(id) is emitted.
signalMapper->setMapping(ui->panelButton_0, 0); signalMapper->setMapping(ui->panelButton_0, 0);
signalMapper->setMapping(ui->panelButton_1, 1); signalMapper->setMapping(ui->panelButton_1, 1);
...@@ -47,6 +42,10 @@ SipInputPanel::SipInputPanel(QWidget* parent) ...@@ -47,6 +42,10 @@ SipInputPanel::SipInputPanel(QWidget* parent)
signalMapper->setMapping(ui->panelButton_9, 9); signalMapper->setMapping(ui->panelButton_9, 9);
signalMapper->setMapping(ui->panelButton_hash, 10); signalMapper->setMapping(ui->panelButton_hash, 10);
signalMapper->setMapping(ui->panelButton_star, 11); signalMapper->setMapping(ui->panelButton_star, 11);
signalMapper->setMapping(ui->panelButton_A, 12);
signalMapper->setMapping(ui->panelButton_B, 13);
signalMapper->setMapping(ui->panelButton_C, 14);
signalMapper->setMapping(ui->panelButton_D, 15);
connect(ui->panelButton_0, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->panelButton_0, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->panelButton_1, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->panelButton_1, SIGNAL(clicked()), signalMapper, SLOT(map()));
...@@ -60,26 +59,21 @@ SipInputPanel::SipInputPanel(QWidget* parent) ...@@ -60,26 +59,21 @@ SipInputPanel::SipInputPanel(QWidget* parent)
connect(ui->panelButton_9, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->panelButton_9, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->panelButton_hash, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->panelButton_hash, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->panelButton_star, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(ui->panelButton_star, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->panelButton_A, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->panelButton_B, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->panelButton_C, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(ui->panelButton_D, SIGNAL(clicked()), signalMapper, SLOT(map()));
connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(panelButtonClicked(int))); connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(panelButtonClicked(int)));
} }
SipInputPanel::~SipInputPanel() SIPInputPanelWidget::~SIPInputPanelWidget()
{ {
delete ui; delete ui;
} }
void void
SipInputPanel::panelButtonClicked(const int& id) SIPInputPanelWidget::panelButtonClicked(const int& id)
{ {
emit sipInputPanelClicked(id); emit sipInputPanelClicked(id);
} }
void
SipInputPanel::mousePressEvent(QMouseEvent *event)
{
auto sipPanelWidgetRect = ui->SIPInputPanelWidget->contentsRect();
if (!sipPanelWidgetRect.contains(event->pos())) {
emit willClose(event);
}
}
...@@ -18,31 +18,29 @@ ...@@ -18,31 +18,29 @@
#pragma once #pragma once
#include "widgethelpers.h"
#include <QDialog> #include <QDialog>
#include <QSignalMapper> #include <QSignalMapper>
namespace Ui { namespace Ui {
class SIPInputPanelDialog; class SIPInputPanelWidget;
} }
class SipInputPanel : public QDialog { class SIPInputPanelWidget : public PopupWidget {
Q_OBJECT Q_OBJECT
public: public:
SipInputPanel(QWidget* parent = nullptr); SIPInputPanelWidget(QWidget* parent = nullptr);
~SipInputPanel(); ~SIPInputPanelWidget();
signals: signals:
void sipInputPanelClicked(int id); void sipInputPanelClicked(int id);
void willClose(QMouseEvent *event);
private: private:
Ui::SIPInputPanelDialog* ui; Ui::SIPInputPanelWidget* ui;
QSignalMapper *signalMapper; QSignalMapper *signalMapper;
private slots: private slots:
void panelButtonClicked(const int&); void panelButtonClicked(const int&);
protected:
void mousePressEvent(QMouseEvent *event);
}; };
This diff is collapsed.
...@@ -787,15 +787,11 @@ SettingsWidget QListView::item:disabled { ...@@ -787,15 +787,11 @@ SettingsWidget QListView::item:disabled {
/* } SettingsWidget */ /* } SettingsWidget */
QWidget#SIPInputPanelWidget {
border-radius: 10px;
background-color: rgba(255,255,255, 0.85);
}
QPushButton#panelButton_0, QPushButton#panelButton_1, QPushButton#panelButton_2, QPushButton#panelButton_0, QPushButton#panelButton_1, QPushButton#panelButton_2,
QPushButton#panelButton_3, QPushButton#panelButton_4, QPushButton#panelButton_5, QPushButton#panelButton_3, QPushButton#panelButton_4, QPushButton#panelButton_5,
QPushButton#panelButton_6, QPushButton#panelButton_7, QPushButton#panelButton_8, QPushButton#panelButton_6, QPushButton#panelButton_7, QPushButton#panelButton_8,
QPushButton#panelButton_9, QPushButton#panelButton_hash { QPushButton#panelButton_9, QPushButton#panelButton_hash, QPushButton#panelButton_A,
QPushButton#panelButton_B, QPushButton#panelButton_C, QPushButton#panelButton_D {
text-align: center; text-align: center;
text-decoration: none; text-decoration: none;
background: #369; background: #369;
...@@ -818,14 +814,18 @@ QPushButton#panelButton_star { ...@@ -818,14 +814,18 @@ QPushButton#panelButton_star {
QPushButton#panelButton_0:hover, QPushButton#panelButton_1:hover, QPushButton#panelButton_2:hover, QPushButton#panelButton_0:hover, QPushButton#panelButton_1:hover, QPushButton#panelButton_2:hover,
QPushButton#panelButton_3:hover, QPushButton#panelButton_4:hover, QPushButton#panelButton_5:hover, QPushButton#panelButton_3:hover, QPushButton#panelButton_4:hover, QPushButton#panelButton_5:hover,
QPushButton#panelButton_6:hover, QPushButton#panelButton_7:hover, QPushButton#panelButton_8:hover, QPushButton#panelButton_6:hover, QPushButton#panelButton_7:hover, QPushButton#panelButton_8:hover,
QPushButton#panelButton_9:hover, QPushButton#panelButton_hash:hover, QPushButton#panelButton_star:hover { QPushButton#panelButton_9:hover, QPushButton#panelButton_hash:hover, QPushButton#panelButton_star:hover,
QPushButton#panelButton_A:hover, QPushButton#panelButton_B:hover, QPushButton#panelButton_C:hover,
QPushButton#panelButton_D:hover {
background: #47a; background: #47a;
} }
QPushButton#panelButton_0:pressed, QPushButton#panelButton_1:pressed, QPushButton#panelButton_2:pressed, QPushButton#panelButton_0:pressed, QPushButton#panelButton_1:pressed, QPushButton#panelButton_2:pressed,
QPushButton#panelButton_3:pressed, QPushButton#panelButton_4:pressed, QPushButton#panelButton_5:pressed, QPushButton#panelButton_3:pressed, QPushButton#panelButton_4:pressed, QPushButton#panelButton_5:pressed,
QPushButton#panelButton_6:pressed, QPushButton#panelButton_7:pressed, QPushButton#panelButton_8:pressed, QPushButton#panelButton_6:pressed, QPushButton#panelButton_7:pressed, QPushButton#panelButton_8:pressed,
QPushButton#panelButton_9:pressed, QPushButton#panelButton_hash:pressed, QPushButton#panelButton_star:pressed { QPushButton#panelButton_9:pressed, QPushButton#panelButton_hash:pressed, QPushButton#panelButton_star:pressed,
QPushButton#panelButton_A:pressed, QPushButton#panelButton_B:pressed, QPushButton#panelButton_C:pressed,
QPushButton#panelButton_D:pressed {
background: #58b; background: #58b;
} }
......
...@@ -34,7 +34,7 @@ VideoOverlay::VideoOverlay(QWidget* parent) ...@@ -34,7 +34,7 @@ VideoOverlay::VideoOverlay(QWidget* parent)
, ui(new Ui::VideoOverlay) , ui(new Ui::VideoOverlay)
, oneSecondTimer_(new QTimer(this)) , oneSecondTimer_(new QTimer(this))
, contactPicker_(new ContactPicker(this)) , contactPicker_(new ContactPicker(this))
, sipInputPanel_(new SipInputPanel(this)) , sipInputPanel_(new SIPInputPanelWidget(this))
{ {
ui->setupUi(this); ui->setupUi(this);
...@@ -52,7 +52,7 @@ VideoOverlay::VideoOverlay(QWidget* parent) ...@@ -52,7 +52,7 @@ VideoOverlay::VideoOverlay(QWidget* parent)
contactPicker_->getContainer()->setVisible(false); contactPicker_->getContainer()->setVisible(false);
sipInputPanel_->setVisible(false); sipInputPanel_->getContainer()->setVisible(false);
connect(contactPicker_, &ContactPicker::contactWillJoinConference, connect(contactPicker_, &ContactPicker::contactWillJoinConference,
this, &VideoOverlay::slotContactWillJoinConference); this, &VideoOverlay::slotContactWillJoinConference);
...@@ -60,7 +60,7 @@ VideoOverlay::VideoOverlay(QWidget* parent) ...@@ -60,7 +60,7 @@ VideoOverlay::VideoOverlay(QWidget* parent)
this, &VideoOverlay::slotCallWillJoinConference); this, &VideoOverlay::slotCallWillJoinConference);
connect(contactPicker_, &ContactPicker::contactWillDoTransfer, connect(contactPicker_, &ContactPicker::contactWillDoTransfer,
this, &VideoOverlay::slotWillDoTransfer); this, &VideoOverlay::slotWillDoTransfer);
connect(sipInputPanel_, &SipInputPanel::sipInputPanelClicked, connect(sipInputPanel_, &SIPInputPanelWidget::sipInputPanelClicked,
this, &VideoOverlay::slotSIPInputPanelClicked); this, &VideoOverlay::slotSIPInputPanelClicked);
ui->holdButton->setVisible(false); ui->holdButton->setVisible(false);
...@@ -154,7 +154,7 @@ VideoOverlay::shouldFadeOut() ...@@ -154,7 +154,7 @@ VideoOverlay::shouldFadeOut()
return not (hoveringOnButtons || return not (hoveringOnButtons ||
(callInfo.status == lrc::api::call::Status::PAUSED) || (callInfo.status == lrc::api::call::Status::PAUSED) ||
contactPicker_->getContainer()->isActiveWindow() || contactPicker_->getContainer()->isActiveWindow() ||
sipInputPanel_->isActiveWindow()); sipInputPanel_->getContainer()->isActiveWindow());
} }
void void
...@@ -419,13 +419,14 @@ VideoOverlay::on_sipInputPanelButton_toggled(bool checked) ...@@ -419,13 +419,14 @@ VideoOverlay::on_sipInputPanelButton_toggled(bool checked)
QPoint globalPos_button = mapToGlobal(ui->sipInputPanelButton->pos()); QPoint globalPos_button = mapToGlobal(ui->sipInputPanelButton->pos());
QPoint globalPos_bottomButtons = mapToGlobal(ui->bottomButtons->pos()); QPoint globalPos_bottomButtons = mapToGlobal(ui->bottomButtons->pos());
sipInputPanel_->move(globalPos_button.x(), globalPos_bottomButtons.y() - sipInputPanel_->height()); sipInputPanel_->getContainer()->move(globalPos_button.x(),
globalPos_bottomButtons.y() - sipInputPanel_->height() - popupMargin_);
// receive the signal that ensure the button checked status is correct and contactpicker // receive the signal that ensure the button checked status is correct and contactpicker
// is properly hidden // is properly hidden
Utils::oneShotConnect(sipInputPanel_, &SipInputPanel::willClose, Utils::oneShotConnect(sipInputPanel_->getContainer(), &PopupDialog::willClose,
[this](QMouseEvent *event) { [this](QMouseEvent *event) {
sipInputPanel_->hide(); sipInputPanel_->getContainer()->hide();
// check if current mouse position is on button // check if current mouse position is on button
auto relativeClickPos = ui->sipInputPanelButton->mapFromGlobal(event->globalPos()); auto relativeClickPos = ui->sipInputPanelButton->mapFromGlobal(event->globalPos());
if (!ui->sipInputPanelButton->rect().contains(relativeClickPos)) { if (!ui->sipInputPanelButton->rect().contains(relativeClickPos)) {
...@@ -435,13 +436,13 @@ VideoOverlay::on_sipInputPanelButton_toggled(bool checked) ...@@ -435,13 +436,13 @@ VideoOverlay::on_sipInputPanelButton_toggled(bool checked)
}); });
// for esc key, receive reject signal // for esc key, receive reject signal
Utils::oneShotConnect(sipInputPanel_, &QDialog::rejected, Utils::oneShotConnect(sipInputPanel_->getContainer(), &QDialog::rejected,
[this] { [this] {
ui->sipInputPanelButton->setChecked(false); ui->sipInputPanelButton->setChecked(false);
ui->sipInputPanelButton->resetToOriginal(); ui->sipInputPanelButton->resetToOriginal();
}); });
sipInputPanel_->show(); sipInputPanel_->getContainer()->show();
} }
void void
...@@ -462,7 +463,13 @@ VideoOverlay::slotSIPInputPanelClicked(const int& id) ...@@ -462,7 +463,13 @@ VideoOverlay::slotSIPInputPanelClicked(const int& id)
LRCInstance::getCurrentCallModel()->playDTMF(callId, "*"); LRCInstance::getCurrentCallModel()->playDTMF(callId, "*");
break; break;
default: default:
LRCInstance::getCurrentCallModel()->playDTMF(callId, std::to_string(id)); // id from 12 to 15 are A,B,C,D
if (id >= 12) {
//ASCII Key_A = 65
LRCInstance::getCurrentCallModel()->playDTMF(callId, std::string(1, char(id - 12 + 65)));
} else {
LRCInstance::getCurrentCallModel()->playDTMF(callId, std::to_string(id));
}
break; break;
} }
} }
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#include <QTimer> #include <QTimer>
class ContactPicker; class ContactPicker;
class SipInputPanel; class SIPInputPanelWidget;
namespace Ui { namespace Ui {
class VideoOverlay; class VideoOverlay;
...@@ -79,7 +79,7 @@ private: ...@@ -79,7 +79,7 @@ private:
std::string convUid_; std::string convUid_;
ContactPicker* contactPicker_; ContactPicker* contactPicker_;
SipInputPanel* sipInputPanel_; SIPInputPanelWidget* sipInputPanel_;
QTimer* oneSecondTimer_; QTimer* oneSecondTimer_;
quint16 popupMargin_{ 16 }; quint16 popupMargin_{ 16 };
......
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