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

*** empty log message ***

parent e45e859e
Branches
Tags
No related merge requests found
......@@ -19,15 +19,16 @@ SFLPhoneWindow::SFLPhoneWindow()
: QMainWindow(NULL, Qt::FramelessWindowHint)
{
// Initialize the background image
QLabel *l = new QLabel(this);
mMain = new QLabel(this);
QPixmap main(JPushButton::transparize(":/sflphone/images/main.png"));
l->setPixmap(main);
mMain->setPixmap(main);
//mMain->move(100,100);
if(main.hasAlpha()) {
setMask(main.mask());
}
resize(main.size());
l->resize(main.size());
mMain->resize(main.size());
setWindowIcon(QIcon(QPixmap(":/sflphone/images/logo_ico")));
setMouseTracking(false);
......@@ -46,7 +47,7 @@ SFLPhoneWindow::~SFLPhoneWindow()
void
SFLPhoneWindow::initLCD()
{
mLcd = new SFLLcd(this);
mLcd = new SFLLcd(mMain);
mLcd->show();
}
......@@ -55,35 +56,35 @@ SFLPhoneWindow::initGUIButtons()
{
mHangup = new JPushButton(":/sflphone/images/hangup_off",
":/sflphone/images/hangup_on",
this);
mMain);
mHangup->move(225,156);
mHold = new JPushButton(":/sflphone/images/hold_off",
":/sflphone/images/hold_on",
this);
mMain);
mHold->move(225,68);
mOk = new JPushButton(":/sflphone/images/ok_off",
":/sflphone/images/ok_on",
this);
mMain);
mOk->move(225,182);
mClear = new JPushButton(":/sflphone/images/clear_off",
":/sflphone/images/clear_on",
this);
mMain);
mClear->move(225,130);
mMute = new JPushButton(":/sflphone/images/mute_off",
":/sflphone/images/mute_on",
this);
mMain);
mMute->move(225,94);
mMute->setToggle(true);
mVolume = new VolumeControl(":/sflphone/images/volume.png",
this);
mMain);
mVolume->setOrientation(VolumeControl::Vertical);
mVolume->move(10,10);
mVolume->move(0,0);
}
......@@ -101,7 +102,7 @@ SFLPhoneWindow::initLineButtons()
QString::number(i + 1) +
"_on.png",
i,
this);
mMain);
line->move(xpos, ypos);
xpos += offset;
mPhoneLineButtons.push_back(line);
......@@ -112,13 +113,13 @@ void SFLPhoneWindow::initWindowButtons()
{
mCloseButton = new JPushButton(":/sflphone/images/close_off.png",
":/sflphone/images/close_on.png",
this);
mMain);
QObject::connect(mCloseButton, SIGNAL(clicked()),
this, SLOT(close()));
mCloseButton->move(374,5);
mMinimizeButton = new JPushButton(":/sflphone/images/minimize_off.png",
":/sflphone/images/minimize_on.png",
this);
mMain);
QObject::connect(mMinimizeButton, SIGNAL(clicked()),
this, SLOT(lower()));
mMinimizeButton->move(354,5);
......
#include <QLabel>
#include <QMainWindow>
#include <QObject>
#include <QPoint>
......@@ -63,6 +64,7 @@ private:
VolumeControl *mVolume;
SFLLcd *mLcd;
QLabel *mMain;
QPoint mLastPos;
};
......@@ -19,6 +19,8 @@
*/
#include <QBitmap>
#include <QColor>
#include <iostream>
#include "TransparentWidget.hpp"
......@@ -41,6 +43,22 @@ TransparentWidget::TransparentWidget(QWidget* parent,
: QLabel(parent, flags)
{}
QPixmap
TransparentWidget::transparize(const QSize &size)
{
QImage image(size, QImage::Format_RGB32);
QColor c(12,32,35,123);
image.fill(c.rgb());
QPixmap p(QPixmap::fromImage(image));
p.setMask(p.createHeuristicMask());
//p.setMask(p.alphaChannel());
return p;
}
TransparentWidget::~TransparentWidget()
{}
......
......@@ -21,6 +21,7 @@
#ifndef __TRANSPARENT_WIDGET_HPP__
#define __TRANSPARENT_WIDGET_HPP__
#include <QBitmap>
#include <QLabel>
#include <QPixmap>
#include <QImage>
......@@ -41,7 +42,14 @@ public:
Qt::WFlags flags = 0);
~TransparentWidget();
static QPixmap transparize(const QSize &size);
static QPixmap transparize(const QString &image);
bool hasAlpha()
{return mImage.hasAlpha();}
QBitmap mask() const
{return mImage.mask();}
private:
QPixmap mImage;
......
......@@ -27,7 +27,7 @@ VolumeControl::VolumeControl (const QString &pixname,
QWidget *parent,
int minValue,
int maxValue)
: TransparentWidget(parent)
: QLabel(parent)
, mMin(minValue)
, mMax(maxValue)
, mValue(minValue)
......@@ -45,13 +45,22 @@ void
VolumeControl::resize()
{
if(mOrientation == VolumeControl::Horizontal) {
QLabel::resize(QSize(mSlider->size().width(),
QWidget::resize(QSize(mSlider->size().width(),
mMaxPosition + mSlider->size().height()));
}
else {
QLabel::resize(QSize(mMaxPosition + mSlider->size().width(),
QWidget::resize(QSize(mMaxPosition + mSlider->size().width(),
mSlider->size().height()));
}
QPixmap q(TransparentWidget::transparize(QString(":/sflphone/images/slider")));
std::cout << "mask isNull: " << q.mask().isNull() << std::endl;
std::cout << "isNull: " << q.isNull() << std::endl;
std::cout << q.size().width() << "," << q.size().height() << std::endl;
setPixmap(q);
if(q.hasAlpha()) {
std::cout << "has alpha" << std::endl;
setMask(q.mask());
}
}
void
......@@ -118,12 +127,7 @@ VolumeControl::mouseMoveEvent (QMouseEvent *e) {
void
VolumeControl::updateValue()
{
std::cout << "offset: " << offset() << std::endl;
std::cout << "max pos: " << mMaxPosition << std::endl;
std::cout << "min: " << mMin << std::endl;
std::cout << "max: " << mMax << std::endl;
int value = (int)((float)offset() / mMaxPosition * (mMax - mMin));
std::cout << "Real Value: " << value << std::endl;
mValue = value;
emit valueUpdated(mValue);
}
......
......@@ -20,9 +20,10 @@
#ifndef __VOLUMECONTROL_HPP__
#define __VOLUMECONTROL_HPP__
#include <qlabel.h>
#include "TransparentWidget.hpp"
class VolumeControl : public TransparentWidget
class VolumeControl : public QLabel
{
Q_OBJECT
......
......@@ -32,6 +32,7 @@
<file>images/ok_on.png</file>
<file>images/overscreen.png</file>
<file>images/screen_main.png</file>
<file>images/slider.png</file>
<file>images/volume.png</file>
<file>images/volume_off.png</file>
<file>images/volume_on.png</file>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment