diff --git a/src/gui/official/PhoneLineManagerImpl.cpp b/src/gui/official/PhoneLineManagerImpl.cpp index 4855ecedc4b9bfc42b8e9f40df8f7d6e5dd72e8c..ff62fd8a3432f3cc9ffd41dd55a909f8a070547a 100644 --- a/src/gui/official/PhoneLineManagerImpl.cpp +++ b/src/gui/official/PhoneLineManagerImpl.cpp @@ -423,6 +423,7 @@ PhoneLineManagerImpl::hangup() if(selectedLine) { selectedLine->hangup(); + lineStatusSet(""); } } diff --git a/src/gui/official/SFLPhoneWindow.cpp b/src/gui/official/SFLPhoneWindow.cpp index 690647227bc05a40fce60a4e474f8488abad7752..961fa9092104ee106851819f75535307bffe92c3 100644 --- a/src/gui/official/SFLPhoneWindow.cpp +++ b/src/gui/official/SFLPhoneWindow.cpp @@ -13,6 +13,7 @@ #include "JPushButton.hpp" #include "PhoneLineButton.hpp" #include "SFLLcd.hpp" +#include "VolumeControl.hpp" SFLPhoneWindow::SFLPhoneWindow() : QMainWindow(NULL, Qt::FramelessWindowHint) @@ -78,6 +79,12 @@ SFLPhoneWindow::initGUIButtons() this); mMute->move(225,94); mMute->setToggle(true); + + mVolume = new VolumeControl(":/sflphone/images/volume.png", + this); + mVolume->setOrientation(VolumeControl::Vertical); + mVolume->move(10,10); + } void diff --git a/src/gui/official/SFLPhoneWindow.hpp b/src/gui/official/SFLPhoneWindow.hpp index ddbf1d797965555d2c66826333f854d9ec78cf63..f37c1b2175e1a237b2f35c0eaf6e317e61366f9b 100644 --- a/src/gui/official/SFLPhoneWindow.hpp +++ b/src/gui/official/SFLPhoneWindow.hpp @@ -6,6 +6,7 @@ class JPushButton; class PhoneLineButton; class SFLLcd; +class VolumeControl; class SFLPhoneWindow : public QMainWindow { @@ -58,6 +59,8 @@ private: JPushButton *mOk; JPushButton *mClear; JPushButton *mMute; + + VolumeControl *mVolume; SFLLcd *mLcd; diff --git a/src/gui/official/TransparentWidget.cpp b/src/gui/official/TransparentWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..98ad0d8c6fe0e17bc094c6689a05380fbd550a5f --- /dev/null +++ b/src/gui/official/TransparentWidget.cpp @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2004-2005 Savoir-Faire Linux inc. + * Author: Jean-Philippe Barrette-LaPierre + * (jean-philippe.barrette-lapierre@savoirfairelinux.com) + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with dpkg; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <QBitmap> + +#include "TransparentWidget.hpp" + + +TransparentWidget::TransparentWidget(const QString &pixmap, + QWidget* parent, + Qt::WFlags flags) + : QLabel(parent, flags) +{ + mImage = transparize(pixmap); + setPixmap(mImage); + if(mImage.hasAlpha()) { + setMask(mImage.mask()); + } + resize(mImage.size()); +} + +TransparentWidget::TransparentWidget(QWidget* parent, + Qt::WFlags flags) + : QLabel(parent, flags) +{} + +TransparentWidget::~TransparentWidget() +{} + +QPixmap +TransparentWidget::transparize(const QString &image) +{ + QPixmap p(image); + + if (!p.mask()) { + if (p.hasAlphaChannel()) { + p.setMask(p.alphaChannel()); + } + else { + p.setMask(p.createHeuristicMask()); + } + } + + return p; +} + + diff --git a/src/gui/official/TransparentWidget.hpp b/src/gui/official/TransparentWidget.hpp new file mode 100644 index 0000000000000000000000000000000000000000..c9c2f9f1c12ea5e2f7d8065088fe8ba30c8ca288 --- /dev/null +++ b/src/gui/official/TransparentWidget.hpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2004-2005 Savoir-Faire Linux inc. + * Author: Jean-Philippe Barrette-LaPierre + * (jean-philippe.barrette-lapierre@savoirfairelinux.com) + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2, + * or (at your option) any later version. + * + * This is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with dpkg; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef __TRANSPARENT_WIDGET_HPP__ +#define __TRANSPARENT_WIDGET_HPP__ + +#include <QLabel> +#include <QPixmap> +#include <QImage> + +/** + * This class Emulate a PushButton but takes two + * images to display its state. + */ +class TransparentWidget : public QLabel +{ + Q_OBJECT + +public: + TransparentWidget(const QString &pixmap, + QWidget *parent, + Qt::WFlags flags = 0); + TransparentWidget(QWidget *parent, + Qt::WFlags flags = 0); + ~TransparentWidget(); + + static QPixmap transparize(const QString &image); + +private: + QPixmap mImage; + +}; + +#endif diff --git a/src/gui/official/VolumeControl.cpp b/src/gui/official/VolumeControl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a7b2a6a91a7bf622fc52b9c9585060082141172a --- /dev/null +++ b/src/gui/official/VolumeControl.cpp @@ -0,0 +1,117 @@ +/** + * Copyright (C) 2004-2005 Savoir-Faire Linux inc. + * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include <qevent.h> +#include <iostream> + +#include "VolumeControl.hpp" +#include "TransparentWidget.hpp" + +VolumeControl::VolumeControl (const QString &pixname, + QWidget *parent, + int minValue, + int maxValue) + : TransparentWidget(parent) + , mMin(minValue) + , mMax(maxValue) + , mValue(minValue) + , mOrientation(VolumeControl::Horizontal) + , mSlider(new TransparentWidget(pixname, this)) + , mMaxPosition(100) +{ + resize(); +} + +VolumeControl::~VolumeControl() +{} + +void +VolumeControl::resize() +{ + if(mOrientation == VolumeControl::Horizontal) { + QLabel::resize(QSize(mSlider->size().width(), + mMaxPosition + mSlider->size().height())); + } + else { + QLabel::resize(QSize(mMaxPosition + mSlider->size().width(), + mSlider->size().height())); + } +} + +void +VolumeControl::setOrientation(VolumeControl::Orientation orientation) +{ + mOrientation = orientation; +} + +void +VolumeControl::setMax(int value) +{ + if(value >= mMin) { + mMax = value; + } +} + +void +VolumeControl::setMin(int value) +{ + if(value <= mMax) { + mMin = value; + } +} + +void +VolumeControl::setValue(int value) +{ + if(value <= mMax && value >= mMin) { + mValue = value; + } +} + + +void +VolumeControl::mouseMoveEvent (QMouseEvent *e) { + if (mOrientation == VolumeControl::Vertical) { + // If the slider for the volume is vertical + int yoffset = e->y() - mPos.y(); + std::cout << "yoffset: " << yoffset << std::endl; + if(yoffset < 0) { + yoffset = 0; + } + + if(yoffset > mMaxPosition) { + yoffset = mMaxPosition; + } + + std::cout << "new yoffset: " << yoffset << std::endl << std::endl; + + mSlider->move(mSlider->x(), yoffset); + } + else { + mSlider->move(e->y() - mPos.x(), mSlider->y()); + } +} + +void +VolumeControl::mousePressEvent (QMouseEvent *e) +{ + mPos = e->pos(); +} + +// EOF diff --git a/src/gui/official/transqwidget.h b/src/gui/official/VolumeControl.hpp similarity index 50% rename from src/gui/official/transqwidget.h rename to src/gui/official/VolumeControl.hpp index 2da8357df0c7aace8317a39d4348d94f306a9fe8..cd6098df7755d66f1aabfbbf04981280f272960a 100644 --- a/src/gui/official/transqwidget.h +++ b/src/gui/official/VolumeControl.hpp @@ -1,34 +1,64 @@ /** * Copyright (C) 2004-2005 Savoir-Faire Linux inc. - * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> - * + * Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com> + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifndef __TRANS_QWIDGET_H__ -#define __TRANS_QWIDGET_H__ +#ifndef __VOLUMECONTROL_HPP__ +#define __VOLUMECONTROL_HPP__ -#include <QLabel> +#include "TransparentWidget.hpp" -class TransQWidget : public QLabel +class VolumeControl : public TransparentWidget { - public: - TransQWidget(QWidget* = NULL, Qt::WFlags = 0); - ~TransQWidget() - {}; -}; + Q_OBJECT + +public: + typedef enum {Vertical = 0, Horizontal} Orientation; + + VolumeControl(const QString &pixmap, + QWidget *parent = 0, + int minValue = 0, + int maxValue = 100); + ~VolumeControl(void); + + void setOrientation(Orientation orientation); + void setMin(int value); + void setMax(int value); + void setValue(int value); + void resize(); + +signals: + void setVolumeValue(int); +private: + + void mouseMoveEvent(QMouseEvent*); + void mousePressEvent(QMouseEvent*); + + + int mMin; + int mMax; + int mValue; + + VolumeControl::Orientation mOrientation; + QPoint mPos; + + TransparentWidget *mSlider; + int mMaxPosition; +}; -#endif // __TRANS_QWIDGET_H__ +#endif // __VOLUME_CONTROL_H__ diff --git a/src/gui/official/sflphone.pro b/src/gui/official/sflphone.pro index 9d14b58100109463d6b1721a9f1d56a752f3fd6f..0e660ce07ebba3725783fffe3dd5e7947b1335a1 100644 --- a/src/gui/official/sflphone.pro +++ b/src/gui/official/sflphone.pro @@ -39,7 +39,8 @@ HEADERS += Account.hpp \ SFLRequest.hpp \ TCPSessionIO.hpp \ TCPSessionIOCreator.hpp \ - transqwidget.h \ + TransparentWidget.hpp \ + VolumeControl.hpp \ ObjectFactory.inl \ RequesterImpl.inl \ ObjectPool.inl @@ -62,5 +63,7 @@ SOURCES += Account.cpp \ SFLPhoneWindow.cpp \ SFLRequest.cpp \ TCPSessionIO.cpp \ - TCPSessionIOCreator.cpp + TCPSessionIOCreator.cpp \ + TransparentWidget.cpp \ + VolumeControl.cpp RESOURCES += sflphone.qrc diff --git a/src/gui/official/sflphone.qrc b/src/gui/official/sflphone.qrc index f25ebfddad46fa16249dfe3723c413f913e449cb..ae96e4cf96050763fa34c5cbf0617df17a8c6c69 100644 --- a/src/gui/official/sflphone.qrc +++ b/src/gui/official/sflphone.qrc @@ -32,5 +32,8 @@ <file>images/ok_on.png</file> <file>images/overscreen.png</file> <file>images/screen_main.png</file> + <file>images/volume.png</file> + <file>images/volume_off.png</file> + <file>images/volume_on.png</file> </qresource> </RCC>