Skip to content
Snippets Groups Projects
Commit 4c30560f authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

remove taxidermy directory from the git repository

parent d61789bf
No related branches found
No related tags found
No related merge requests found
Showing
with 0 additions and 1236 deletions
/*
* 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.
*/
/*
* WengoPhone, a voice over Internet phone
* Copyright (C) 2004-2005 Wengo
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "EventFilter.hpp"
taxidermy::EventFilter::EventFilter(QObject * receiver, const char * member, QObject * watched)
: QObject()
{
mWatched = watched;
connect(this, SIGNAL(activate(QEvent *)),
receiver, member);
}
void
taxidermy::EventFilter::filter(QEvent * event)
{
emit activate(event);
}
bool
taxidermy::EventFilter::eventFilter(QObject * watched, QEvent * event)
{
return QObject::eventFilter(watched, event);
}
/*
* WengoPhone, a voice over Internet phone
* Copyright (C) 2004-2005 Wengo
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef EVENTFILTER_H
#define EVENTFILTER_H
#include "utilspp/NonCopyable.hpp"
#include <qobject.h>
#include <qevent.h>
namespace taxidermy {
/**
* EventFilter for QObject.
*
* Permits to make some special actions on Qt events.
* Example:
* <code>
* QMainWindow * widget = new QMainWindow();
* CloseEventFilter * closeFilter = new CloseEventFilter(this, SLOT(printHelloWorld()));
* ResizeEventFilter * resizeFilter = new ResizeEventFilter(this, SLOT(printHelloWorld()));
* widget->installEventFilter(closeFilter);
* widget->installEventFilter(resizeFilter);
* </code>
*
* @author Tanguy Krotoff
*/
class EventFilter : public QObject, utilspp::NonCopyable {
Q_OBJECT
public:
/**
* Filters an event.
*
* @param receiver object receiver of the filter signal
* @param member member of the object called by the filter signal
* @param watched watched object the filter is going to be applied on
*/
EventFilter(QObject * receiver, const char * member, QObject * watched);
protected:
/**
* Emits the filter signal.
*
* @param event event filtered
*/
void filter(QEvent * event);
/**
* Filters the event.
*
* @param watched watched object
* @param event event filtered of the watched object
* @return true then stops the event being handled further
*/
virtual bool eventFilter(QObject * watched, QEvent * event);
/**
* Watched object.
*
* The filter is going to be applied only on this QObject.
*/
QObject * mWatched;
signals:
void activate(QEvent * event);
};
};
#endif //EVENTFILTER_H
/*
* 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 <stdexcept>
#include "Hunter.hpp"
#include "WidgetBuilder.hpp"
#include "WidgetBuilderFactory.hpp"
#include "config.h"
#include "qtutils.hpp"
#define DEFAULT_DIRECTORY "skins/"
#define fill_config_str(name, value) \
(_config.addConfigTreeItem(section, Conf::ConfigTreeItem(std::string(name), std::string(value), type_str)))
#define fill_config_int(name, value) \
(_config.addConfigTreeItem(section, Conf::ConfigTreeItem(std::string(name), std::string(value), type_int)))
taxidermy::Hunter::Hunter()
: mSkinsDirectory(DEFAULT_DIRECTORY)
{
qtutils::addFilePath(mSkinsDirectory.absPath());
}
taxidermy::Hunter::Hunter(const QString &directory)
: mSkinsDirectory(directory)
{
qtutils::addFilePath(mSkinsDirectory.absPath());
}
taxidermy::Hunter::Hunter(const QDir &directory)
: mSkinsDirectory(directory)
{
qtutils::addFilePath(mSkinsDirectory.absPath());
}
QStringList
taxidermy::Hunter::getSkinNames()
{
QStringList skins;
mSkinsDirectory.setNameFilter("*.ini");
QStringList list = mSkinsDirectory.entryList(QDir::Files);
for(QStringList::Iterator it = list.begin(); it != list.end(); ++it) {
QString skin(*it);
skin = skin.left(skin.length() - 4);
skins.push_back(skin);
}
return skins;
}
QString
taxidermy::Hunter::getSkinFile(const QString &name)
{
return mSkinsDirectory.absPath() + "/" + name + ".ini";
}
taxidermy::Taxidermist
taxidermy::Hunter::getTaxidermist(const QString &skinName)
{
taxidermy::Taxidermist skin(skinName);
qtutils::addFilePath(mSkinsDirectory.absFilePath(skinName));
load(&skin);
return skin;
}
// void
// taxidermy::Hunter::load(taxidermy::Taxidermist *skin)
// {
// load(mSkinsDirectory, skin);
// }
void
taxidermy::Hunter::load(taxidermy::Taxidermist *skin)
{
Conf::ConfigTree config;
config.populateFromFile(getSkinFile(skin->name()));
Conf::TokenList tree = config.getSectionNames();
for(Conf::TokenList::iterator it = tree.begin(); it != tree.end(); it++) {
Conf::ValuesMap values = config.getSection(*it);
Conf::ValuesMap::iterator type = values.find("type");
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);
if(builder != NULL) {
for(Conf::ValuesMap::iterator pos = values.begin();
pos != values.end();
pos++) {
v.insert(pos->first, pos->second);
}
builder->load(v);
skin->add(*it, builder);
}
}
}
}
/*
* 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_HUNTER_HPP__
#define __TAXIDERMY_HUNTER_HPP__
#include <qdir.h>
#include <qfile.h>
#include <qstring.h>
#include <qstringlist.h>
#include "Taxidermist.hpp"
#include "config.h"
namespace taxidermy
{
/**
* This class is responsible of finding skins directories.
* It is also responsible of reading the settings.
*/
class Hunter
{
private:
QDir mSkinsDirectory;
public:
Hunter();
Hunter(const QString &directory);
Hunter(const QDir &dir);
QStringList getSkinNames();
QString getSkinFile(const QString &skinName);
Taxidermist getTaxidermist(const QString &skinName);
void load(Taxidermist *skin);
//static void load(QFile file, Taxidermist *skin);
};
};
#endif
noinst_LTLIBRARIES = libtaxidermy.la
BUILT_SOURCES = \
EventFiltermoc.cpp \
Huntermoc.cpp \
PaintEventFiltermoc.cpp \
QButtonBuildermoc.cpp \
QWidgetBuildermoc.cpp \
WidgetBuilderCreatormoc.cpp \
WidgetBuilderFactorymoc.cpp \
WidgetBuilderFactoryImplmoc.cpp \
WidgetBuildermoc.cpp
noinst_HEADERS = \
EventFilter.hpp \
Hunter.hpp \
PaintEventFilter.hpp \
QWidgetBuilder.hpp \
QButtonBuilder.hpp \
Taxidermist.hpp \
WidgetBuilderCreator.hpp WidgetBuilderCreator.inl \
WidgetBuilderFactory.hpp \
WidgetBuilderFactoryImpl.hpp WidgetBuilderFactoryImpl.inl \
WidgetBuilder.hpp \
config.h \
qtutils.hpp
libtaxidermy_la_SOURCES = \
$(BUILT_SOURCES) \
EventFilter.cpp \
Hunter.cpp \
PaintEventFilter.cpp \
QWidgetBuilder.cpp \
QButtonBuilder.cpp \
Taxidermist.cpp \
WidgetBuilder.cpp \
WidgetBuilderFactoryImpl.cpp \
config.cpp \
qtutils.cpp
CLEANFILES = \
$(BUILT_SOURCES)
AM_CPPFLAGS = -I$(top_srcdir)/libs/ $(QT_CXXFLAGS) $(X_INCLUDES)
#AM_LDFLAGS = $(QT_LDADD) $(X_LDFLAGS)
libtaxidermy_la_LIBADD = $(QT_LDADD)
%.h: %.ui
$(UIC) -o $@ $<
moc_%.cpp: %.h
$(MOC) -o $@ $<
%moc.cpp: %.hpp
$(MOC) -o $@ $<
%ui.cpp: %.ui
$(UIC) -o $@ -impl $*.h $<
#UI_DIR = bin/ui
#MOC_DIR = bin/moc
#OBJECTS_DIR = bin/obj
/*
* WengoPhone, a voice over Internet phone
* Copyright (C) 2004-2005 Wengo
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "PaintEventFilter.hpp"
taxidermy::PaintEventFilter::PaintEventFilter(QObject * receiver, const char * member, QObject * watched)
: EventFilter(receiver, member, watched) {
}
bool
taxidermy::PaintEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (mWatched == watched) {
if (event->type() == QEvent::Paint) {
filter(event);
return true;
}
}
return EventFilter::eventFilter(watched, event);
}
/*
* WengoPhone, a voice over Internet phone
* Copyright (C) 2004-2005 Wengo
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __TAXIDERMY_PAINT_EVENT_FILTER_HPP__
#define __TAXIDERMY_PAINT_EVENT_FILTER_HPP__
#include "EventFilter.hpp"
namespace taxidermy
{
/**
* Catch Paint.
*
* @author Tanguy Krotoff
*/
class PaintEventFilter : public EventFilter
{
public:
PaintEventFilter(QObject * receiver, const char * member, QObject * watched);
protected:
virtual bool eventFilter(QObject * watched, QEvent * event);
};
};
#endif
/*
* 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 "QButtonBuilder.hpp"
#include "qtutils.hpp"
taxidermy::QButtonBuilder::QButtonBuilder()
: WidgetBuilder("QButton")
, mButton(NULL)
, mPosSet(false)
, mX(0)
, mY(0)
, mImages(false)
, mPaint(false)
{}
void
taxidermy::QButtonBuilder::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 pressed = values.find("pressed");
QMap< QString, QString >::ConstIterator released = values.find("released");
QMap< QString, QString >::ConstIterator paint = values.find("paint");
if(pressed != values.end() && released != values.end()) {
mImages = true;
mPressed = qtutils::transparize(*pressed);
mReleased = qtutils::transparize(*released);
if(paint != values.end() && (*paint).toInt()) {
mPaint = true;
}
}
}
void
taxidermy::QButtonBuilder::update()
{
update(mButton);
}
void
taxidermy::QButtonBuilder::update(QWidget *widget)
{
setButton(widget);
if(mButton) {
if(mPosSet) {
mButton->move(mX, mY);
}
if(mImages) {
if(mButton->isToggleButton()) {
QObject::connect(mButton, SIGNAL(toggled(bool)),
this, SLOT(toggled(bool)));
}
else {
QObject::connect(mButton, SIGNAL(pressed()),
this, SLOT(pressed()));
QObject::connect(mButton, SIGNAL(released()),
this, SLOT(released()));
}
if(mPaint) {
mButton->installEventFilter(new PaintEventFilter(this, SLOT(paintEvent()), mButton));
}
if(mButton->isDown()) {
pressed();
}
else {
released();
}
}
}
}
void
taxidermy::QButtonBuilder::setButton(QWidget *widget) {
if(widget) {
mButton = (QButton *)widget;
}
else {
mButton = NULL;
}
}
void
taxidermy::QButtonBuilder::pressed()
{
mButton->setPixmap(mPressed);
if(mPressed.hasAlpha()) {
mButton->setMask(*mPressed.mask());
}
mButton->resize(mPressed.size());
}
void
taxidermy::QButtonBuilder::released()
{
if(mButton) {
mButton->setPixmap(mReleased);
if(mReleased.hasAlpha()) {
mButton->setMask(*mReleased.mask());
}
mButton->resize(mReleased.size());
}
}
void
taxidermy::QButtonBuilder::toggled(bool on)
{
if(on) {
pressed();
}
else {
released();
}
}
void
taxidermy::QButtonBuilder::paintEvent()
{
const QPixmap *p = mButton->pixmap();
if (p && !p->isNull()) {
QPainter painter(mButton);
painter.drawPixmap(QPoint(0, 0), *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 __TAXIDERMY_QBUTTON_BUILDER_HPP__
#define __TAXIDERMY_QBUTTON_BUILDER_HPP__
#include <qbutton.h>
#include <qpixmap.h>
#include <qwidget.h>
#include "WidgetBuilder.hpp"
namespace taxidermy
{
class QButtonBuilder : public WidgetBuilder
{
Q_OBJECT;
private:
QButton *mButton;
//Position
bool mPosSet;
int mX;
int mY;
//Images
bool mImages;
bool mPaint;
QPixmap mPressed;
QPixmap mReleased;
virtual void setButton(QWidget *widget);
public slots:
void pressed();
void released();
void toggled(bool);
void paintEvent();
public:
QButtonBuilder();
virtual void load(const QMap< QString, QString > &entries);
virtual void update();
virtual void update(QWidget *widget);
};
};
#endif
/*
* 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)
, mSizeSet(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 height = values.find("height");
QMap< QString, QString >::ConstIterator width = values.find("width");
if(height != values.end() && width != values.end()) {
mSizeSet = true;
mHeight = (*height).toInt();
mWidth = (*width).toInt();
}
QMap< QString, QString >::ConstIterator transparent = values.find("transparent");
QMap< QString, QString >::ConstIterator bimage = values.find("bImage");
if(bimage != values.end()) {
if(transparent == values.end() || (*transparent).toInt()) {
mBackgroundImage = qtutils::transparize(*bimage);
}
else {
qtutils::retreive(*bimage, mBackgroundImage);
}
}
QMap< QString, QString >::ConstIterator bcolor = values.find("bColor");
if(bcolor != values.end()) {
mBackgroundColor = QColor(*bcolor);
}
}
void
taxidermy::QWidgetBuilder::update()
{
update(mWidget);
}
void
taxidermy::QWidgetBuilder::update(QWidget *widget)
{
mWidget = widget;
if(mWidget) {
if(mPosSet) {
mWidget->move(mX, mY);
}
if(!mBackgroundImage.isNull()) {
mWidget->setPaletteBackgroundPixmap(mBackgroundImage);
if(mBackgroundImage.hasAlpha()) {
mWidget->setMask(*mBackgroundImage.mask());
}
mWidget->resize(mBackgroundImage.size());
}
else if(mBackgroundColor.isValid()) {
mWidget->setPaletteBackgroundColor(mBackgroundColor);
}
//If the user took the energy to specify the size,
//Then we must use this size.
if(mSizeSet) {
mWidget->resize(mWidth, mHeight);
}
}
}
/*
* 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 <qcolor.h>
#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;
//Size
bool mSizeSet;
int mWidth;
int mHeight;
//Images
QPixmap mBackgroundImage;
QColor mBackgroundColor;
public:
QWidgetBuilder();
virtual void load(const QMap< QString, QString > &entries);
virtual void update();
virtual void update(QWidget *widget);
};
};
#endif
/*
* WengoPhone, a voice over Internet phone
* Copyright (C) 2004-2005 Wengo
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <ResizeEventFilter.h>
#include <QEvent>
ResizeEventFilter::ResizeEventFilter(QObject * receiver, const char * member, QObject * watched)
: EventFilter(receiver, member, watched) {
}
bool ResizeEventFilter::eventFilter(QObject * watched, QEvent * event) {
if (_watched == watched) {
if (event->type() == QEvent::Resize) {
filter(event);
return true;
}
}
return EventFilter::eventFilter(watched, event);
}
/*
* WengoPhone, a voice over Internet phone
* Copyright (C) 2004-2005 Wengo
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef RESIZEEVENTFILTER_H
#define RESIZEEVENTFILTER_H
#include <EventFilter.h>
/**
* Catch Resize.
*
* @author Tanguy Krotoff
*/
class ResizeEventFilter : public EventFilter {
public:
ResizeEventFilter(QObject * receiver, const char * member, QObject * watched);
protected:
virtual bool eventFilter(QObject * watched, QEvent * event);
};
#endif //RESIZEEVENTFILTER_H
/*
* 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 <stdexcept>
#include <qapplication.h>
#include <qwidgetlist.h>
#include "Hunter.hpp"
#include "Taxidermist.hpp"
#include "WidgetBuilder.hpp"
taxidermy::Taxidermist::Taxidermist(const QString &skinName)
{
mSkinName = skinName;
}
void
taxidermy::Taxidermist::add(const QString &name, WidgetBuilder *builder)
{
mBuilders.insert(name, builder, true);
}
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);
}
}
void
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++) {
QObject *w = mainWidget->child(pos.key());
if(w && w->isWidgetType()) {
pos.data()->update((QWidget *)w);
}
}
}
}
/*
* 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_TAXIDERMIST_HPP__
#define __TAXIDERMY_TAXIDERMIST_HPP__
#include <qmap.h>
#include <qstring.h>
#include <qwidget.h>
namespace taxidermy {
class WidgetBuilder;
class Taxidermist
{
private:
QMap< QString, WidgetBuilder * > mBuilders;
QString mSkinName;
public:
Taxidermist(const QString &skinName);
QString name()
{return mSkinName;}
/**
* This function will set the skin to the widget.
* It will use the widget's name to find what to
* specify for the skin.
*/
void skin(QWidget *widget);
/**
* This function will add a widget builder for a specific
* widget. This widget is identified by his name.
*/
void add(const QString &name, WidgetBuilder *builder);
/**
* This function will load the current skin, by
* retreiving each QWidget skinnable and updating it.
*
* Note: if you have an another skin currently used, you
* need to unload it.
*/
void update(QApplication *app);
};
};
#endif
/*
* 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 "WidgetBuilder.hpp"
taxidermy::WidgetBuilder::WidgetBuilder(const QString &type)
: mObjectType(type)
{}
QString
taxidermy::WidgetBuilder::getObjectType()
{
return mObjectType;
}
/*
* 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_WIDGET_BUILDER_HPP__
#define __TAXIDERMY_WIDGET_BUILDER_HPP__
#include <qmap.h>
#include <qobject.h>
#include <qsettings.h>
#include <qstring.h>
#include <qwidget.h>
namespace taxidermy {
/**
* This class is responsible of loading a skin for a
* type of widget from a QSettings, and then be able to
* set the values loaded to a widget.
*/
class WidgetBuilder : public QObject
{
Q_OBJECT
private:
QString mObjectType;
private:
WidgetBuilder();
public:
WidgetBuilder(const QString &objectType);
virtual ~WidgetBuilder() {}
QString getObjectType();
virtual void load(const QMap< QString, QString > &entries) = 0;
virtual void update() = 0;
virtual void update(QWidget *widget) = 0;
};
};
#endif
/*
* 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_WIDGET_BUILDER_CREATOR_HPP
#define TAXIDERMY_WIDGET_BUILDER_CREATOR_HPP
namespace taxidermy
{
class WidgetBuilder;
class WidgetBuilderCreatorBase
{
public:
virtual WidgetBuilder *create() = 0;
virtual ~WidgetBuilderCreatorBase() {}
};
template< typename T >
class WidgetBuilderCreator : public WidgetBuilderCreatorBase
{
virtual WidgetBuilder *create();
virtual ~WidgetBuilderCreator() {}
};
};
#include "WidgetBuilderCreator.inl"
#endif
/*
* 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.
*/
template< typename T >
taxidermy::WidgetBuilder *
taxidermy::WidgetBuilderCreator< T >::create()
{
return new T();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment