Skip to content
Snippets Groups Projects
Commit 7bcd6e91 authored by jpbl's avatar jpbl
Browse files

we can mute

parent 4efc809c
Branches
Tags
No related merge requests found
...@@ -35,8 +35,9 @@ JPushButton::JPushButton(const QString &released, ...@@ -35,8 +35,9 @@ JPushButton::JPushButton(const QString &released,
QWidget* parent, QWidget* parent,
Qt::WFlags flags) Qt::WFlags flags)
: QLabel(parent, flags) : QLabel(parent, flags)
, mIsPressed(false)
, mIsToggling(false)
{ {
mImages[0] = transparize(released); mImages[0] = transparize(released);
mImages[1] = transparize(pressed); mImages[1] = transparize(pressed);
release(); release();
...@@ -45,6 +46,12 @@ JPushButton::JPushButton(const QString &released, ...@@ -45,6 +46,12 @@ JPushButton::JPushButton(const QString &released,
JPushButton::~JPushButton() JPushButton::~JPushButton()
{} {}
void
JPushButton::setToggle(bool toggle)
{
mIsToggling = toggle;
}
QPixmap QPixmap
JPushButton::transparize(const QString &image) JPushButton::transparize(const QString &image)
{ {
...@@ -63,9 +70,8 @@ JPushButton::transparize(const QString &image) ...@@ -63,9 +70,8 @@ JPushButton::transparize(const QString &image)
} }
void void
JPushButton::release() JPushButton::release(bool modify)
{ {
mIsPressed = false;
setPixmap(mImages[0]); setPixmap(mImages[0]);
if(mImages[0].hasAlpha()) { if(mImages[0].hasAlpha()) {
setMask(mImages[0].mask()); setMask(mImages[0].mask());
...@@ -74,9 +80,8 @@ JPushButton::release() ...@@ -74,9 +80,8 @@ JPushButton::release()
} }
void void
JPushButton::press() JPushButton::press(bool modify)
{ {
mIsPressed = true;
setPixmap(mImages[1]); setPixmap(mImages[1]);
if(mImages[1].hasAlpha()) { if(mImages[1].hasAlpha()) {
setMask(mImages[1].mask()); setMask(mImages[1].mask());
...@@ -104,11 +109,24 @@ void ...@@ -104,11 +109,24 @@ void
JPushButton::mouseReleaseEvent (QMouseEvent *e) { JPushButton::mouseReleaseEvent (QMouseEvent *e) {
switch (e->button()) { switch (e->button()) {
case Qt::LeftButton: case Qt::LeftButton:
if(mIsToggling) {
mIsPressed = !mIsPressed;
if(mIsPressed) {
press();
}
else {
release();
}
emit clicked(mIsPressed);
}
else {
release(); release();
// Emulate the left mouse click
if (this->rect().contains(e->pos())) {
emit clicked(); emit clicked();
} }
// Emulate the left mouse click
//if (this->rect().contains(e->pos())) {
// emit clicked();
//}
break; break;
default: default:
......
...@@ -52,8 +52,10 @@ public slots: ...@@ -52,8 +52,10 @@ public slots:
/** /**
* This function will switch the button * This function will switch the button
*/ */
virtual void press(); virtual void press(bool modify = true);
virtual void release(); virtual void release(bool modify = true);
virtual void setToggle(bool toggled);
protected: protected:
QPixmap mImages[2]; QPixmap mImages[2];
...@@ -63,9 +65,13 @@ protected: ...@@ -63,9 +65,13 @@ protected:
void mousePressEvent(QMouseEvent *); void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *);
signals: signals:
void clicked(bool);
void clicked(); void clicked();
private:
bool mIsToggling;
}; };
#endif // defined(__J_PUSH_BUTTON_H__) #endif // defined(__J_PUSH_BUTTON_H__)
...@@ -284,7 +284,6 @@ PhoneLine::hangup() ...@@ -284,7 +284,6 @@ PhoneLine::hangup()
unselect(); unselect();
} }
QString QString
PhoneLine::getCallId() PhoneLine::getCallId()
{ {
......
...@@ -426,6 +426,33 @@ PhoneLineManagerImpl::hangup() ...@@ -426,6 +426,33 @@ PhoneLineManagerImpl::hangup()
} }
} }
void
PhoneLineManagerImpl::mute(bool muting)
{
if(muting) {
mute();
}
else {
unmute();
}
}
void
PhoneLineManagerImpl::mute()
{
isInitialized();
mSession->mute();
}
void
PhoneLineManagerImpl::unmute()
{
isInitialized();
mSession->unmute();
}
void void
PhoneLineManagerImpl::hangup(const QString &callId) PhoneLineManagerImpl::hangup(const QString &callId)
{ {
......
...@@ -93,6 +93,25 @@ public slots: ...@@ -93,6 +93,25 @@ public slots:
*/ */
void hangup(); void hangup();
/**
* This function will mute the current line if muting
* is true, it will unmute otherwise.
* If there's no current line, it will do nothing.
*/
void mute(bool);
/**
* This function will mute the current line
* If there's no current line, it will do nothing.
*/
void mute();
/**
* This function will unmute the current line
* If there's no current line, it will do nothing.
*/
void unmute();
/** /**
* This function will hanp up the line number given * This function will hanp up the line number given
* argument. Be aware that the first line is 1, not * argument. Be aware that the first line is 1, not
......
...@@ -27,6 +27,8 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv) ...@@ -27,6 +27,8 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv)
Requester::instance().registerObject< PermanentRequest >(QString("refuse")); Requester::instance().registerObject< PermanentRequest >(QString("refuse"));
Requester::instance().registerObject< PermanentRequest >(QString("call")); Requester::instance().registerObject< PermanentRequest >(QString("call"));
Requester::instance().registerObject< PermanentRequest >(QString("hangup")); Requester::instance().registerObject< PermanentRequest >(QString("hangup"));
Requester::instance().registerObject< TemporaryRequest >(QString("mute"));
Requester::instance().registerObject< TemporaryRequest >(QString("unmute"));
Requester::instance().registerObject< TemporaryRequest >(QString("hold")); Requester::instance().registerObject< TemporaryRequest >(QString("hold"));
Requester::instance().registerObject< TemporaryRequest >(QString("unhold")); Requester::instance().registerObject< TemporaryRequest >(QString("unhold"));
Requester::instance().registerObject< TemporaryRequest >(QString("senddtmf")); Requester::instance().registerObject< TemporaryRequest >(QString("senddtmf"));
...@@ -55,6 +57,8 @@ SFLPhoneApp::initConnections(SFLPhoneWindow *w) ...@@ -55,6 +57,8 @@ SFLPhoneApp::initConnections(SFLPhoneWindow *w)
QObject::connect(w->mOk, SIGNAL(clicked()), QObject::connect(w->mOk, SIGNAL(clicked()),
&PhoneLineManager::instance(), SLOT(call())); &PhoneLineManager::instance(), SLOT(call()));
QObject::connect(w->mMute, SIGNAL(clicked(bool)),
&PhoneLineManager::instance(), SLOT(mute(bool)));
QObject::connect(w->mHangup, SIGNAL(clicked()), QObject::connect(w->mHangup, SIGNAL(clicked()),
&PhoneLineManager::instance(), SLOT(hangup())); &PhoneLineManager::instance(), SLOT(hangup()));
QObject::connect(w->mHold, SIGNAL(clicked()), QObject::connect(w->mHold, SIGNAL(clicked()),
......
...@@ -72,6 +72,12 @@ SFLPhoneWindow::initGUIButtons() ...@@ -72,6 +72,12 @@ SFLPhoneWindow::initGUIButtons()
":/sflphone/images/clear_on", ":/sflphone/images/clear_on",
this); this);
mClear->move(225,130); mClear->move(225,130);
mMute = new JPushButton(":/sflphone/images/mute_off",
":/sflphone/images/mute_on",
this);
mMute->move(225,94);
mMute->setToggle(true);
} }
void void
......
...@@ -57,6 +57,7 @@ private: ...@@ -57,6 +57,7 @@ private:
JPushButton *mHold; JPushButton *mHold;
JPushButton *mOk; JPushButton *mOk;
JPushButton *mClear; JPushButton *mClear;
JPushButton *mMute;
SFLLcd *mLcd; SFLLcd *mLcd;
......
...@@ -62,6 +62,18 @@ Session::getEvents() const ...@@ -62,6 +62,18 @@ Session::getEvents() const
return Requester::instance().send(mId, "getevents", std::list< QString >()); return Requester::instance().send(mId, "getevents", std::list< QString >());
} }
QString
Session::mute() const
{
return Requester::instance().send(mId, "mute", std::list< QString >());
}
QString
Session::unmute() const
{
return Requester::instance().send(mId, "unmute", std::list< QString >());
}
QString QString
Session::getCallStatus() const Session::getCallStatus() const
{ {
......
...@@ -54,6 +54,16 @@ class Session ...@@ -54,6 +54,16 @@ class Session
*/ */
QString getCallStatus() const; QString getCallStatus() const;
/**
* This function will mute the microphone.
*/
QString mute() const;
/**
* This function will unmute the microphone.
*/
QString unmute() const;
/** /**
* This function will ask to the SessionIO * This function will ask to the SessionIO
* linked to this session to connect. * linked to this session to connect.
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
<file>images/main.png</file> <file>images/main.png</file>
<file>images/minimize_off.png</file> <file>images/minimize_off.png</file>
<file>images/minimize_on.png</file> <file>images/minimize_on.png</file>
<file>images/mute_off.png</file>
<file>images/mute_on.png</file>
<file>images/ok_off.png</file> <file>images/ok_off.png</file>
<file>images/ok_on.png</file> <file>images/ok_on.png</file>
<file>images/overscreen.png</file> <file>images/overscreen.png</file>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment