Commit 4c30560f authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

remove taxidermy directory from the git repository

parent d61789bf
/*
* 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();