diff --git a/src/gui/official/JPushButton.cpp b/src/gui/official/JPushButton.cpp index d623717fb3caed915c7d06ee2a3e6d1b3291a907..d17c2c8e6f3c548d13ccf47dbdc2fb477fb40b47 100644 --- a/src/gui/official/JPushButton.cpp +++ b/src/gui/official/JPushButton.cpp @@ -35,8 +35,9 @@ JPushButton::JPushButton(const QString &released, QWidget* parent, Qt::WFlags flags) : QLabel(parent, flags) + , mIsPressed(false) + , mIsToggling(false) { - mImages[0] = transparize(released); mImages[1] = transparize(pressed); release(); @@ -45,6 +46,12 @@ JPushButton::JPushButton(const QString &released, JPushButton::~JPushButton() {} +void +JPushButton::setToggle(bool toggle) +{ + mIsToggling = toggle; +} + QPixmap JPushButton::transparize(const QString &image) { @@ -63,9 +70,8 @@ JPushButton::transparize(const QString &image) } void -JPushButton::release() +JPushButton::release(bool modify) { - mIsPressed = false; setPixmap(mImages[0]); if(mImages[0].hasAlpha()) { setMask(mImages[0].mask()); @@ -74,9 +80,8 @@ JPushButton::release() } void -JPushButton::press() +JPushButton::press(bool modify) { - mIsPressed = true; setPixmap(mImages[1]); if(mImages[1].hasAlpha()) { setMask(mImages[1].mask()); @@ -104,11 +109,24 @@ void JPushButton::mouseReleaseEvent (QMouseEvent *e) { switch (e->button()) { case Qt::LeftButton: - release(); - // Emulate the left mouse click - if (this->rect().contains(e->pos())) { + if(mIsToggling) { + mIsPressed = !mIsPressed; + if(mIsPressed) { + press(); + } + else { + release(); + } + emit clicked(mIsPressed); + } + else { + release(); emit clicked(); } + // Emulate the left mouse click + //if (this->rect().contains(e->pos())) { + // emit clicked(); + //} break; default: diff --git a/src/gui/official/JPushButton.hpp b/src/gui/official/JPushButton.hpp index 88309bc66b0438dcd8a36060e85e6b715d72776b..4e394a97d44d7617f09c0e1db782efd02bb010d7 100644 --- a/src/gui/official/JPushButton.hpp +++ b/src/gui/official/JPushButton.hpp @@ -52,8 +52,10 @@ public slots: /** * This function will switch the button */ - virtual void press(); - virtual void release(); + virtual void press(bool modify = true); + virtual void release(bool modify = true); + + virtual void setToggle(bool toggled); protected: QPixmap mImages[2]; @@ -63,9 +65,13 @@ protected: void mousePressEvent(QMouseEvent *); void mouseReleaseEvent(QMouseEvent *); void mouseMoveEvent(QMouseEvent *); + signals: + void clicked(bool); void clicked(); +private: + bool mIsToggling; }; #endif // defined(__J_PUSH_BUTTON_H__) diff --git a/src/gui/official/PhoneLine.cpp b/src/gui/official/PhoneLine.cpp index 97c91c921fc6c39c82f37961d0c75283f4ab4670..ef514ce937ab8a036356494d9c52baebe47679cd 100644 --- a/src/gui/official/PhoneLine.cpp +++ b/src/gui/official/PhoneLine.cpp @@ -284,7 +284,6 @@ PhoneLine::hangup() unselect(); } - QString PhoneLine::getCallId() { diff --git a/src/gui/official/PhoneLineManagerImpl.cpp b/src/gui/official/PhoneLineManagerImpl.cpp index b058402c3d7c2c80a12e5e9a327ec27bc8db84e9..4855ecedc4b9bfc42b8e9f40df8f7d6e5dd72e8c 100644 --- a/src/gui/official/PhoneLineManagerImpl.cpp +++ b/src/gui/official/PhoneLineManagerImpl.cpp @@ -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 PhoneLineManagerImpl::hangup(const QString &callId) { diff --git a/src/gui/official/PhoneLineManagerImpl.hpp b/src/gui/official/PhoneLineManagerImpl.hpp index 4788a638c8f61b0cd348a55c7bbeeff146159b1f..9b927b153c5956958cd8be7fa5d98921e2e0b490 100644 --- a/src/gui/official/PhoneLineManagerImpl.hpp +++ b/src/gui/official/PhoneLineManagerImpl.hpp @@ -93,6 +93,25 @@ public slots: */ 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 * argument. Be aware that the first line is 1, not diff --git a/src/gui/official/SFLPhoneApp.cpp b/src/gui/official/SFLPhoneApp.cpp index 3286efabeccdde00e38ff3169b159db01ec25e9b..f2920111617fdcd9953f29a732b903fa0125d81b 100644 --- a/src/gui/official/SFLPhoneApp.cpp +++ b/src/gui/official/SFLPhoneApp.cpp @@ -27,6 +27,8 @@ SFLPhoneApp::SFLPhoneApp(int argc, char **argv) Requester::instance().registerObject< PermanentRequest >(QString("refuse")); Requester::instance().registerObject< PermanentRequest >(QString("call")); 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("unhold")); Requester::instance().registerObject< TemporaryRequest >(QString("senddtmf")); @@ -55,6 +57,8 @@ SFLPhoneApp::initConnections(SFLPhoneWindow *w) QObject::connect(w->mOk, SIGNAL(clicked()), &PhoneLineManager::instance(), SLOT(call())); + QObject::connect(w->mMute, SIGNAL(clicked(bool)), + &PhoneLineManager::instance(), SLOT(mute(bool))); QObject::connect(w->mHangup, SIGNAL(clicked()), &PhoneLineManager::instance(), SLOT(hangup())); QObject::connect(w->mHold, SIGNAL(clicked()), diff --git a/src/gui/official/SFLPhoneWindow.cpp b/src/gui/official/SFLPhoneWindow.cpp index 0dda0aa73aa957f112a7fa7655e2b4979a190111..690647227bc05a40fce60a4e474f8488abad7752 100644 --- a/src/gui/official/SFLPhoneWindow.cpp +++ b/src/gui/official/SFLPhoneWindow.cpp @@ -72,6 +72,12 @@ SFLPhoneWindow::initGUIButtons() ":/sflphone/images/clear_on", this); mClear->move(225,130); + + mMute = new JPushButton(":/sflphone/images/mute_off", + ":/sflphone/images/mute_on", + this); + mMute->move(225,94); + mMute->setToggle(true); } void diff --git a/src/gui/official/SFLPhoneWindow.hpp b/src/gui/official/SFLPhoneWindow.hpp index 754f826a4f56c049a7f71164a769f229f7150fa5..ddbf1d797965555d2c66826333f854d9ec78cf63 100644 --- a/src/gui/official/SFLPhoneWindow.hpp +++ b/src/gui/official/SFLPhoneWindow.hpp @@ -57,6 +57,7 @@ private: JPushButton *mHold; JPushButton *mOk; JPushButton *mClear; + JPushButton *mMute; SFLLcd *mLcd; diff --git a/src/gui/official/Session.cpp b/src/gui/official/Session.cpp index c7c51ae2c6d7582ed23bb8c7f4ec89be536f5ffb..2be43df8205ebcb9c533dc6f04ed09e2368b8adf 100644 --- a/src/gui/official/Session.cpp +++ b/src/gui/official/Session.cpp @@ -62,6 +62,18 @@ Session::getEvents() const 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 Session::getCallStatus() const { diff --git a/src/gui/official/Session.hpp b/src/gui/official/Session.hpp index eaae1722b3e78a8bd73115d4823ecbad8640643a..8cabdea1334b5dd0272905e09b38eaf36b9bcc3c 100644 --- a/src/gui/official/Session.hpp +++ b/src/gui/official/Session.hpp @@ -54,6 +54,16 @@ class Session */ 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 * linked to this session to connect. diff --git a/src/gui/official/sflphone.qrc b/src/gui/official/sflphone.qrc index 1897d0020ffa673a4e4496a5bd1dad5a31c8ff9a..f25ebfddad46fa16249dfe3723c413f913e449cb 100644 --- a/src/gui/official/sflphone.qrc +++ b/src/gui/official/sflphone.qrc @@ -26,6 +26,8 @@ <file>images/main.png</file> <file>images/minimize_off.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_on.png</file> <file>images/overscreen.png</file>