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