diff --git a/src/gui/official/JPushButton.cpp b/src/gui/official/JPushButton.cpp index 505f7d4925bf5446ffaff6d9ce894562dd362c5c..64a389e7b47c8482aba3ba3ea695d543efd7273f 100644 --- a/src/gui/official/JPushButton.cpp +++ b/src/gui/official/JPushButton.cpp @@ -29,6 +29,7 @@ #include "globals.h" #include "JPushButton.hpp" +#include "TransparentWidget.hpp" JPushButton::JPushButton(const QString &released, const QString &pressed, @@ -54,28 +55,16 @@ JPushButton::setToggle(bool toggle) QPixmap JPushButton::transparize(const QString &image) { - /** - if (!p.mask()) { - if (p.hasAlphaChannel()) { - p.setMask(p.alphaChannel()); - } - else { - p.setMask(p.createHeuristicMask()); - } - } - */ - return QPixmap::fromMimeSource(image); + return TransparentWidget::transparize(image); } void JPushButton::release() { setPixmap(mImages[0]); - /* if(mImages[0].hasAlpha()) { - setMask(mImages[0].mask()); + setMask(*mImages[0].mask()); } - */ resize(mImages[0].size()); } @@ -83,10 +72,9 @@ void JPushButton::press() { setPixmap(mImages[1]); - /* if(mImages[1].hasAlpha()) { - setMask(mImages[1].mask()); - }*/ + setMask(*mImages[1].mask()); + } resize(mImages[1].size()); } diff --git a/src/gui/official/RequesterImpl.cpp b/src/gui/official/RequesterImpl.cpp index a98f2c4de7f2773daaba76e1ced2dc051442b196..2c5bfa4bc6df7d81c74769b45444e1de243c5297 100644 --- a/src/gui/official/RequesterImpl.cpp +++ b/src/gui/official/RequesterImpl.cpp @@ -164,7 +164,7 @@ RequesterImpl::generateCallId() QString RequesterImpl::generateSessionId() { - return QString("cSessionID:").arg(mSequenceIdCount++); + return QString("cSessionID:%1").arg(mSequenceIdCount++); } QString diff --git a/src/gui/official/SFLLcd.cpp b/src/gui/official/SFLLcd.cpp index 065e56070b97c33dbc4518a4e5caf1100569957f..39ac11f83e53c8b270f8293206666efd98793dda 100644 --- a/src/gui/official/SFLLcd.cpp +++ b/src/gui/official/SFLLcd.cpp @@ -5,18 +5,19 @@ #include "globals.h" #include "JPushButton.hpp" #include "SFLLcd.hpp" +#include "TransparentWidget.hpp" #define FONT_FAMILY "Courier" // Others fixed font support "Monospace", "Fixed", "MiscFixed" #define FONT_SIZE 10 -#define SCREEN "images/screen_main.png" -#define OVERSCREEN "images/overscreen.png" +#define SCREEN "screen_main.png" +#define OVERSCREEN "overscreen.png" SFLLcd::SFLLcd(QWidget *parent) : QLabel(parent) - , mScreen(JPushButton::transparize(SCREEN)) - , mOverscreen(JPushButton::transparize(OVERSCREEN)) + , mScreen(TransparentWidget::retreive(SCREEN)) + , mOverscreen(TransparentWidget::transparize(OVERSCREEN)) , mGlobalStatusPos(-1) , mLineStatusPos(-1) , mBufferStatusPos(-1) @@ -159,7 +160,6 @@ SFLLcd::paintEvent(QPaintEvent *) extractVisibleText(mBufferStatus, mBufferStatusPos)); p.drawText(QPoint(margin, mScreen.size().height() - margin), getTimeStatus()); - //p.drawPixmap(0,0, mScreen); p.drawPixmap(0,0, mOverscreen); p.end(); } diff --git a/src/gui/official/SFLPhoneWindow.cpp b/src/gui/official/SFLPhoneWindow.cpp index d6eec60b7ef547f1dc7aa2875bbd760d677ae6a8..49efd30cfc0b2495cc19417bfbdfb6b97bbc5a4d 100644 --- a/src/gui/official/SFLPhoneWindow.cpp +++ b/src/gui/official/SFLPhoneWindow.cpp @@ -20,23 +20,23 @@ #include "SFLLcd.hpp" #include "VolumeControl.hpp" -#define LOGO_IMAGE "images/logo_ico.png" -#define BACKGROUND_IMAGE "images/main.png" -#define HANGUP_RELEASED_IMAGE "images/hangup_off.png" -#define HANGUP_PRESSED_IMAGE "images/hangup_on.png" -#define HOLD_RELEASED_IMAGE "images/hold_off.png" -#define HOLD_PRESSED_IMAGE "images/hold_on.png" -#define OK_RELEASED_IMAGE "images/ok_off.png" -#define OK_PRESSED_IMAGE "images/ok_on.png" -#define CLEAR_RELEASED_IMAGE "images/clear_off.png" -#define CLEAR_PRESSED_IMAGE "images/clear_on.png" -#define MUTE_RELEASED_IMAGE "images/mute_off.png" -#define MUTE_PRESSED_IMAGE "images/mute_on.png" -#define VOLUME_IMAGE "images/volume.png" -#define CLOSE_RELEASED_IMAGE "images/close_off.png" -#define CLOSE_PRESSED_IMAGE "images/close_on.png" -#define MINIMIZE_RELEASED_IMAGE "images/minimize_off.png" -#define MINIMIZE_PRESSED_IMAGE "images/minimize_on.png" +#define LOGO_IMAGE "logo_ico.png" +#define BACKGROUND_IMAGE "main.png" +#define HANGUP_RELEASED_IMAGE "hangup_off.png" +#define HANGUP_PRESSED_IMAGE "hangup_on.png" +#define HOLD_RELEASED_IMAGE "hold_off.png" +#define HOLD_PRESSED_IMAGE "hold_on.png" +#define OK_RELEASED_IMAGE "ok_off.png" +#define OK_PRESSED_IMAGE "ok_on.png" +#define CLEAR_RELEASED_IMAGE "clear_off.png" +#define CLEAR_PRESSED_IMAGE "clear_on.png" +#define MUTE_RELEASED_IMAGE "mute_off.png" +#define MUTE_PRESSED_IMAGE "mute_on.png" +#define VOLUME_IMAGE "volume.png" +#define CLOSE_RELEASED_IMAGE "close_off.png" +#define CLOSE_PRESSED_IMAGE "close_on.png" +#define MINIMIZE_RELEASED_IMAGE "minimize_off.png" +#define MINIMIZE_PRESSED_IMAGE "minimize_on.png" @@ -54,12 +54,9 @@ SFLPhoneWindow::SFLPhoneWindow() mMain = new QLabel(this); QPixmap main(JPushButton::transparize(BACKGROUND_IMAGE)); mMain->setPixmap(main); - //mMain->move(100,100); - /* if(main.hasAlpha()) { - setMask(main.mask()); + setMask(*main.mask()); } - */ resize(main.size()); mMain->resize(main.size()); @@ -142,8 +139,8 @@ SFLPhoneWindow::initLineButtons() int ypos = 151; int offset = 31; for(int i = 0; i < NB_PHONELINES; i++) { - PhoneLineButton *line = new PhoneLineButton(QString("images/l%1_off.png").arg(i + 1), - QString("images/l%1_on.png").arg(i + 1), + PhoneLineButton *line = new PhoneLineButton(QString("l%1_off.png").arg(i + 1), + QString("l%1_on.png").arg(i + 1), i, mMain); line->move(xpos, ypos); diff --git a/src/gui/official/TCPSessionIO.cpp b/src/gui/official/TCPSessionIO.cpp index be682479fd176dac6641815d6efe99c3cdae0e0c..d141f2e96360d4c28db5c3a75d5f787f530d2925 100644 --- a/src/gui/official/TCPSessionIO.cpp +++ b/src/gui/official/TCPSessionIO.cpp @@ -76,7 +76,7 @@ TCPSessionIO::connect() void TCPSessionIO::sendWaitingRequests() { - _debug("TCPSessionIO: Connected.\n"); + DebugOutput::instance() << QObject::tr("TCPSessionIO: Connected.\n"); QTextStream stream(mSocket); QMutexLocker guard(&mStackMutex); while(mSocket->state() == QSocket::Connected && diff --git a/src/gui/official/TransparentWidget.cpp b/src/gui/official/TransparentWidget.cpp index 6807b34dbb1392918256e40e6a78e354d8dd7998..5107f46ca85b6404092f2b5b3250f1f75b114dc0 100644 --- a/src/gui/official/TransparentWidget.cpp +++ b/src/gui/official/TransparentWidget.cpp @@ -20,8 +20,11 @@ #include <qbitmap.h> #include <qcolor.h> +#include <qdragobject.h> +#include <qmime.h> #include <iostream> +#include "DebugOutput.hpp" #include "TransparentWidget.hpp" @@ -31,11 +34,8 @@ TransparentWidget::TransparentWidget(const QString &pixmap, { mImage = transparize(pixmap); setPixmap(mImage); - /* - if(mImage.hasAlpha()) { - setMask(mImage.mask()); - } - */ + updateMask(this, mImage); + resize(mImage.size()); } @@ -43,6 +43,25 @@ TransparentWidget::TransparentWidget(QWidget* parent) : QLabel(parent) {} +void +TransparentWidget::updateMask(QWidget *w, QPixmap image) +{ +#ifdef QT3_SUPPORT + if(image.hasAlpha()) { + w->setMask(image.mask()); + } +#else + if(image.mask()) { + w->setMask(*image.mask()); + } +#endif +} + +QPixmap +TransparentWidget::retreive(const QString &image) +{ + return QPixmap::fromMimeSource(image); +} QPixmap TransparentWidget::transparize(const QSize &) @@ -65,8 +84,8 @@ TransparentWidget::~TransparentWidget() QPixmap TransparentWidget::transparize(const QString &image) { - QPixmap p(QPixmap::fromMimeSource(image)); - /* +#ifdef QT3_SUPPORT + QPixmap p(retreive(image)); if (!p.mask()) { if (p.hasAlphaChannel()) { p.setMask(p.alphaChannel()); @@ -75,7 +94,22 @@ TransparentWidget::transparize(const QString &image) p.setMask(p.createHeuristicMask()); } } - */ +#else + // QPixmap p(QPixmap::fromMimeSource(image)); + QImage img(QImage::fromMimeSource(image)); + QPixmap p; + p.convertFromImage(img); + + + QBitmap bm; + if (img.hasAlphaBuffer()) { + bm = img.createAlphaMask(); + } + else { + bm = img.createHeuristicMask(); + } + p.setMask(bm); +#endif return p; } diff --git a/src/gui/official/TransparentWidget.hpp b/src/gui/official/TransparentWidget.hpp index d8626b38f1ababbc9a4a2482088d2b5766723826..7ce9c85d47fa773285e374f0872f0fb001cb4ffe 100644 --- a/src/gui/official/TransparentWidget.hpp +++ b/src/gui/official/TransparentWidget.hpp @@ -40,9 +40,17 @@ public: TransparentWidget(QWidget *parent); ~TransparentWidget(); + static QPixmap retreive(const QString &size); static QPixmap transparize(const QSize &size); static QPixmap transparize(const QString &image); + /** + * This function will update the mask of the widget + * to the QPixmap mask. + */ + void updateMask(QWidget *w, QPixmap image); + + bool hasAlpha() {return mImage.hasAlpha();} diff --git a/src/gui/official/VolumeControl.cpp b/src/gui/official/VolumeControl.cpp index 8b5ea41777ccd66d2b1dc5f4f3d06005b9418b94..026b687b15e2819557661e1a168649f8877dd9db 100644 --- a/src/gui/official/VolumeControl.cpp +++ b/src/gui/official/VolumeControl.cpp @@ -24,7 +24,7 @@ #include "TransparentWidget.hpp" #include "VolumeControl.hpp" -#define SLIDER_IMAGE "images/slider.png" +#define SLIDER_IMAGE "slider.png" VolumeControl::VolumeControl (const QString &pixname, QWidget *parent, @@ -47,8 +47,12 @@ VolumeControl::~VolumeControl() void VolumeControl::resize() { - QPixmap q(TransparentWidget::transparize(SLIDER_IMAGE)); + QPixmap q(QPixmap::fromMimeSource(SLIDER_IMAGE)); setPixmap(q); + if(q.hasAlpha()) { + setMask(*q.mask()); + } + QWidget::resize(q.size()); mMaxPosition = q.height() - mSlider->height(); } diff --git a/src/gui/official/globals.h b/src/gui/official/globals.h index a25d31c4f4ac80f89fd9a2df538790dc5178e386..5744341997ba383547cb67c160523dcedf72f55c 100644 --- a/src/gui/official/globals.h +++ b/src/gui/official/globals.h @@ -3,12 +3,6 @@ #define DEBUG -#ifdef DEBUG - #define _debug(...) fprintf(stderr, "[debug] " __VA_ARGS__) -#else - #define _debug(...) -#endif - #define NB_PHONELINES 6 #define PROGNAME "SFLPhone" #define VERSION "0.4.2" diff --git a/src/gui/official/sflphone.pro b/src/gui/official/sflphone.pro index f4eb7ddfaf9b4b7423e108ed1ef13d54a04dbbed..fa78c870d0d8594fe0affa30cfdc0bcac020a3c7 100644 --- a/src/gui/official/sflphone.pro +++ b/src/gui/official/sflphone.pro @@ -86,6 +86,7 @@ images/setup_on.png \ images/sfl-logo.png \ images/sflphone_logo.png \ images/signalisations.png \ +images/slider.png \ images/transfer_off.png \ images/transfer_on.png \ images/tray-icon.png \