From 7bcd6e91f248f4b3f146a8ac785cf92dbb56defa Mon Sep 17 00:00:00 2001 From: jpbl <jpbl> Date: Mon, 3 Oct 2005 18:33:25 +0000 Subject: [PATCH] we can mute --- src/gui/official/JPushButton.cpp | 34 +++++++++++++++++------ src/gui/official/JPushButton.hpp | 10 +++++-- src/gui/official/PhoneLine.cpp | 1 - src/gui/official/PhoneLineManagerImpl.cpp | 27 ++++++++++++++++++ src/gui/official/PhoneLineManagerImpl.hpp | 19 +++++++++++++ src/gui/official/SFLPhoneApp.cpp | 4 +++ src/gui/official/SFLPhoneWindow.cpp | 6 ++++ src/gui/official/SFLPhoneWindow.hpp | 1 + src/gui/official/Session.cpp | 12 ++++++++ src/gui/official/Session.hpp | 10 +++++++ src/gui/official/sflphone.qrc | 2 ++ 11 files changed, 115 insertions(+), 11 deletions(-) diff --git a/src/gui/official/JPushButton.cpp b/src/gui/official/JPushButton.cpp index d623717fb3..d17c2c8e6f 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 88309bc66b..4e394a97d4 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 97c91c921f..ef514ce937 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 b058402c3d..4855ecedc4 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 4788a638c8..9b927b153c 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 3286efabec..f292011161 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 0dda0aa73a..690647227b 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 754f826a4f..ddbf1d7979 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 c7c51ae2c6..2be43df820 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 eaae1722b3..8cabdea133 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 1897d0020f..f25ebfddad 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> -- GitLab