Commit 522e9518 authored by jpbl's avatar jpbl

we can set backgrounds for qwidgets

parent 35ffe2db
sflphoned (0.6.1-1) unstable; urgency=low
sflphoned (0.6.3-1) unstable; urgency=low
* Initial Release.
......
......@@ -101,7 +101,10 @@ taxidermy::Hunter::load(taxidermy::Taxidermist *skin)
Conf::ValuesMap values = config.getSection(*it);
Conf::ValuesMap::iterator type = values.find("type");
if(type != values.end()) {
if(type == values.end()) {
std::cerr << "Widget named \"" << *it << "\" don't have a type.\n";
}
else {
QMap< QString, QString > v;
WidgetBuilder *builder =
taxidermy::WidgetBuilderFactory::instance().create(type->second);
......
......@@ -5,6 +5,7 @@ BUILT_SOURCES = \
Huntermoc.cpp \
PaintEventFiltermoc.cpp \
QButtonBuildermoc.cpp \
QWidgetBuildermoc.cpp \
WidgetBuilderCreatormoc.cpp \
WidgetBuilderFactorymoc.cpp \
WidgetBuilderFactoryImplmoc.cpp \
......@@ -15,6 +16,7 @@ noinst_HEADERS = \
EventFilter.hpp \
Hunter.hpp \
PaintEventFilter.hpp \
QWidgetBuilder.hpp \
QButtonBuilder.hpp \
Taxidermist.hpp \
WidgetBuilderCreator.hpp WidgetBuilderCreator.inl \
......@@ -30,6 +32,7 @@ libtaxidermy_la_SOURCES = \
EventFilter.cpp \
Hunter.cpp \
PaintEventFilter.cpp \
QWidgetBuilder.cpp \
QButtonBuilder.cpp \
Taxidermist.cpp \
WidgetBuilder.cpp \
......
/*
* 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 <iostream>
#include <qpainter.h>
#include "PaintEventFilter.hpp"
#include "QWidgetBuilder.hpp"
#include "qtutils.hpp"
taxidermy::QWidgetBuilder::QWidgetBuilder()
: WidgetBuilder("QWidget")
, mWidget(NULL)
, mPosSet(false)
{}
void
taxidermy::QWidgetBuilder::load(const QMap< QString, QString > &values)
{
QMap< QString, QString >::ConstIterator xpos = values.find("x");
QMap< QString, QString >::ConstIterator ypos = values.find("y");
if(xpos != values.end() && ypos != values.end()) {
mPosSet = true;
mX = (*xpos).toInt();
mY = (*ypos).toInt();
}
QMap< QString, QString >::ConstIterator background = values.find("background");
if(background != values.end()) {
mBackground = qtutils::transparize(*background);
}
}
void
taxidermy::QWidgetBuilder::update()
{
update(mWidget);
}
void
taxidermy::QWidgetBuilder::update(QWidget *widget)
{
mWidget = widget;
if(mWidget) {
if(mPosSet) {
mWidget->move(mX, mY);
}
if(!mBackground.isNull()) {
mWidget->setPaletteBackgroundPixmap(mBackground);
if(mBackground.hasAlpha()) {
mWidget->setMask(*mBackground.mask());
}
mWidget->resize(mBackground.size());
}
}
}
/*
* 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 __TAXIDERMY_QWIDGET_BUILDER_HPP__
#define __TAXIDERMY_QWIDGET_BUILDER_HPP__
#include <qpixmap.h>
#include <qwidget.h>
#include "WidgetBuilder.hpp"
namespace taxidermy
{
class QWidgetBuilder : public WidgetBuilder
{
Q_OBJECT;
private:
QWidget *mWidget;
//Position
bool mPosSet;
int mX;
int mY;
//Images
QPixmap mBackground;
public:
QWidgetBuilder();
virtual void load(const QMap< QString, QString > &entries);
virtual void update();
virtual void update(QWidget *widget);
};
};
#endif
......@@ -18,6 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <iostream>
#include <stdexcept>
#include <qapplication.h>
#include <qwidgetlist.h>
......@@ -41,6 +42,8 @@ void
taxidermy::Taxidermist::skin(QWidget *widget)
{
QMap< QString, WidgetBuilder * >::Iterator pos = mBuilders.find(widget->name());
std::cout << "Trying to find a skin for: " << widget->name() << std::endl;
if(pos != mBuilders.end()) {
(*pos)->update(widget);
}
......@@ -51,6 +54,7 @@ taxidermy::Taxidermist::update(QApplication *app)
{
QWidget *mainWidget = app->mainWidget();
if(mainWidget) {
skin(mainWidget);
for(QMap< QString, WidgetBuilder * >::Iterator pos = mBuilders.begin();
pos != mBuilders.end();
pos++) {
......
......@@ -18,6 +18,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __TAXIDERMY_WIDGET_BUILDER_HPP__
#define __TAXIDERMY_WIDGET_BUILDER_HPP__
#include <qmap.h>
#include <qobject.h>
#include <qsettings.h>
......@@ -51,3 +54,5 @@ namespace taxidermy {
virtual void update(QWidget *widget) = 0;
};
};
#endif
......@@ -20,10 +20,12 @@
#include "WidgetBuilderFactoryImpl.hpp"
#include "QButtonBuilder.hpp"
#include "QWidgetBuilder.hpp"
taxidermy::WidgetBuilderFactoryImpl::WidgetBuilderFactoryImpl()
{
add<QButtonBuilder>("QButton");
add<QWidgetBuilder>("QWidget");
}
......
......@@ -168,6 +168,11 @@ pressed=redial_on.png
released=redial_off.png
paint=1
[main]
type=QWidget
background=main.png
# DTMF Keypad
#dtmf_1=12,22
#dtmf_2=58,22
......
......@@ -68,12 +68,7 @@ SFLPhoneWindow::SFLPhoneWindow()
this, SIGNAL(needRegister()));
// Initialize the background image
mMain = new QLabel(this);
QPixmap main(JPushButton::transparize(BACKGROUND_IMAGE));
mMain->setPixmap(main);
if(main.hasAlpha()) {
setMask(*main.mask());
}
setName("main");
mPaintTimer = new QTimer(this);
connect(mPaintTimer, SIGNAL(timeout()),
......@@ -81,8 +76,6 @@ SFLPhoneWindow::SFLPhoneWindow()
mPaintTimer->start(50);
resize(main.size());
mMain->resize(main.size());
QPixmap logo(QPixmap::fromMimeSource(LOGO_IMAGE));
#ifdef QIcon
......@@ -105,33 +98,33 @@ SFLPhoneWindow::~SFLPhoneWindow()
void
SFLPhoneWindow::initLCD()
{
mLcd = new SFLLcd(mMain);
mLcd = new SFLLcd(this);
mLcd->show();
}
void
SFLPhoneWindow::initGUIButtons()
{
mHangup = new QPushButton(QObject::tr("Hangup"), mMain, "hangup");
mHold = new QPushButton(QObject::tr("Hold"), mMain, "hold");
mOk = new QPushButton(QObject::tr("Ok"), mMain, "ok");
mClear = new QPushButton(QObject::tr("Clear"), mMain, "clear");
mMute = new QPushButton(QObject::tr("Mute"), mMain, "mute");
mHangup = new QPushButton(QObject::tr("Hangup"), this, "hangup");
mHold = new QPushButton(QObject::tr("Hold"), this, "hold");
mOk = new QPushButton(QObject::tr("Ok"), this, "ok");
mClear = new QPushButton(QObject::tr("Clear"), this, "clear");
mMute = new QPushButton(QObject::tr("Mute"), this, "mute");
mMute->setToggleButton(true);
mDtmf = new QPushButton(QObject::tr("DTMF"), mMain, "dtmf");
mDtmf = new QPushButton(QObject::tr("DTMF"), this, "dtmf");
mDtmf->setToggleButton(true);
mSetup = new QPushButton(QObject::tr("Setup"), mMain, "setup");
mTransfer = new QPushButton(QObject::tr("Transfer"), mMain, "transfer");
mRedial = new QPushButton(QObject::tr("Redial"), mMain, "redial");
mSetup = new QPushButton(QObject::tr("Setup"), this, "setup");
mTransfer = new QPushButton(QObject::tr("Transfer"), this, "transfer");
mRedial = new QPushButton(QObject::tr("Redial"), this, "redial");
mVolume = new VolumeControl(QString(VOLUME_IMAGE),
mMain);
this);
mVolume->setOrientation(VolumeControl::Vertical);
mVolume->move(365,91);
QObject::connect(mVolume, SIGNAL(valueUpdated(int)),
this, SIGNAL(volumeUpdated(int)));
mMicVolume = new VolumeControl(QString(VOLUME_IMAGE),
mMain);
this);
mMicVolume->setOrientation(VolumeControl::Vertical);
mMicVolume->move(347,91);
QObject::connect(mVolume, SIGNAL(valueUpdated(int)),
......@@ -143,17 +136,17 @@ void
SFLPhoneWindow::initLineButtons()
{
for(int i = 0; i < NB_PHONELINES; i++) {
PhoneLineButton *line = new PhoneLineButton(i, mMain);
PhoneLineButton *line = new PhoneLineButton(i, this);
mPhoneLineButtons.push_back(line);
}
}
void SFLPhoneWindow::initWindowButtons()
{
mCloseButton = new QPushButton(QObject::tr("Close"), mMain, "close");
mCloseButton = new QPushButton(QObject::tr("Close"), this, "close");
QObject::connect(mCloseButton, SIGNAL(clicked()),
this, SLOT(finish()));
mMinimizeButton = new QPushButton(QObject::tr("Minimize"), mMain, "minimize");
mMinimizeButton = new QPushButton(QObject::tr("Minimize"), this, "minimize");
QObject::connect(mMinimizeButton, SIGNAL(clicked()),
this, SLOT(showMinimized()));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment