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

We have a slider

parent 7bcd6e91
Branches
Tags
No related merge requests found
......@@ -423,6 +423,7 @@ PhoneLineManagerImpl::hangup()
if(selectedLine) {
selectedLine->hangup();
lineStatusSet("");
}
}
......
......@@ -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
......
......@@ -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;
......
/*
* 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;
}
/*
* 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
/**
* 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
/**
* 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__
......@@ -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
......@@ -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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment