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

we can mute

parent 4efc809c
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -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__)
......@@ -284,7 +284,6 @@ PhoneLine::hangup()
unselect();
}
QString
PhoneLine::getCallId()
{
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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()),
......
......@@ -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
......
......@@ -57,6 +57,7 @@ private:
JPushButton *mHold;
JPushButton *mOk;
JPushButton *mClear;
JPushButton *mMute;
SFLLcd *mLcd;
......
......@@ -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
{
......
......@@ -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.
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment