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 @@
<rect>
<x>0</x>
<y>0</y>
<width>261</width>
<height>289</height>
<width>64</width>
<height>16</height>
</rect>
</property>
<property name="windowTitle">
......
......@@ -22,18 +22,13 @@
#include "lrcinstance.h"
SipInputPanel::SipInputPanel(QWidget* parent)
: QDialog(parent)
, ui(new Ui::SIPInputPanelDialog)
SIPInputPanelWidget::SIPInputPanelWidget(QWidget* parent)
: PopupWidget(parent, Qt::white, PopupDialog::SpikeLabelAlignment::AlignLeft)
, ui(new Ui::SIPInputPanelWidget)
, signalMapper(new QSignalMapper(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.
signalMapper->setMapping(ui->panelButton_0, 0);
signalMapper->setMapping(ui->panelButton_1, 1);
......@@ -47,6 +42,10 @@ SipInputPanel::SipInputPanel(QWidget* parent)
signalMapper->setMapping(ui->panelButton_9, 9);
signalMapper->setMapping(ui->panelButton_hash, 10);
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_1, SIGNAL(clicked()), signalMapper, SLOT(map()));
......@@ -60,26 +59,21 @@ SipInputPanel::SipInputPanel(QWidget* parent)
connect(ui->panelButton_9, 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_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)));
}
SipInputPanel::~SipInputPanel()
SIPInputPanelWidget::~SIPInputPanelWidget()
{
delete ui;
}
void
SipInputPanel::panelButtonClicked(const int& id)
SIPInputPanelWidget::panelButtonClicked(const int& 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 @@
#pragma once
#include "widgethelpers.h"
#include <QDialog>
#include <QSignalMapper>
namespace Ui {
class SIPInputPanelDialog;
class SIPInputPanelWidget;
}
class SipInputPanel : public QDialog {
class SIPInputPanelWidget : public PopupWidget {
Q_OBJECT
public:
SipInputPanel(QWidget* parent = nullptr);
~SipInputPanel();
SIPInputPanelWidget(QWidget* parent = nullptr);
~SIPInputPanelWidget();
signals:
void sipInputPanelClicked(int id);
void willClose(QMouseEvent *event);
private:
Ui::SIPInputPanelDialog* ui;
Ui::SIPInputPanelWidget* ui;
QSignalMapper *signalMapper;
private slots:
void panelButtonClicked(const int&);
protected:
void mousePressEvent(QMouseEvent *event);
};
This diff is collapsed.
......@@ -787,15 +787,11 @@ SettingsWidget QListView::item:disabled {
/* } 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_3, QPushButton#panelButton_4, QPushButton#panelButton_5,
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-decoration: none;
background: #369;
......@@ -818,14 +814,18 @@ QPushButton#panelButton_star {
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_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;
}
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_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;
}
......
......@@ -34,7 +34,7 @@ VideoOverlay::VideoOverlay(QWidget* parent)
, ui(new Ui::VideoOverlay)
, oneSecondTimer_(new QTimer(this))
, contactPicker_(new ContactPicker(this))
, sipInputPanel_(new SipInputPanel(this))
, sipInputPanel_(new SIPInputPanelWidget(this))
{
ui->setupUi(this);
......@@ -52,7 +52,7 @@ VideoOverlay::VideoOverlay(QWidget* parent)
contactPicker_->getContainer()->setVisible(false);
sipInputPanel_->setVisible(false);
sipInputPanel_->getContainer()->setVisible(false);
connect(contactPicker_, &ContactPicker::contactWillJoinConference,
this, &VideoOverlay::slotContactWillJoinConference);
......@@ -60,7 +60,7 @@ VideoOverlay::VideoOverlay(QWidget* parent)
this, &VideoOverlay::slotCallWillJoinConference);
connect(contactPicker_, &ContactPicker::contactWillDoTransfer,
this, &VideoOverlay::slotWillDoTransfer);
connect(sipInputPanel_, &SipInputPanel::sipInputPanelClicked,
connect(sipInputPanel_, &SIPInputPanelWidget::sipInputPanelClicked,
this, &VideoOverlay::slotSIPInputPanelClicked);
ui->holdButton->setVisible(false);
......@@ -154,7 +154,7 @@ VideoOverlay::shouldFadeOut()
return not (hoveringOnButtons ||
(callInfo.status == lrc::api::call::Status::PAUSED) ||
contactPicker_->getContainer()->isActiveWindow() ||
sipInputPanel_->isActiveWindow());
sipInputPanel_->getContainer()->isActiveWindow());
}
void
......@@ -419,13 +419,14 @@ VideoOverlay::on_sipInputPanelButton_toggled(bool checked)
QPoint globalPos_button = mapToGlobal(ui->sipInputPanelButton->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
// is properly hidden
Utils::oneShotConnect(sipInputPanel_, &SipInputPanel::willClose,
Utils::oneShotConnect(sipInputPanel_->getContainer(), &PopupDialog::willClose,
[this](QMouseEvent *event) {
sipInputPanel_->hide();
sipInputPanel_->getContainer()->hide();
// check if current mouse position is on button
auto relativeClickPos = ui->sipInputPanelButton->mapFromGlobal(event->globalPos());
if (!ui->sipInputPanelButton->rect().contains(relativeClickPos)) {
......@@ -435,13 +436,13 @@ VideoOverlay::on_sipInputPanelButton_toggled(bool checked)
});
// for esc key, receive reject signal
Utils::oneShotConnect(sipInputPanel_, &QDialog::rejected,
Utils::oneShotConnect(sipInputPanel_->getContainer(), &QDialog::rejected,
[this] {
ui->sipInputPanelButton->setChecked(false);
ui->sipInputPanelButton->resetToOriginal();
});
sipInputPanel_->show();
sipInputPanel_->getContainer()->show();
}
void
......@@ -462,7 +463,13 @@ VideoOverlay::slotSIPInputPanelClicked(const int& id)
LRCInstance::getCurrentCallModel()->playDTMF(callId, "*");
break;
default:
// 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;
}
}
......@@ -29,7 +29,7 @@
#include <QTimer>
class ContactPicker;
class SipInputPanel;
class SIPInputPanelWidget;
namespace Ui {
class VideoOverlay;
......@@ -79,7 +79,7 @@ private:
std::string convUid_;
ContactPicker* contactPicker_;
SipInputPanel* sipInputPanel_;
SIPInputPanelWidget* sipInputPanel_;
QTimer* oneSecondTimer_;
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