[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kipi-plugins] /: BUG: 283321
From: Łukasz_Spas <lukasz.spas () gmail ! com>
Date: 2011-10-16 13:32:42
Message-ID: 20111016133242.F1824A60A6 () git ! kde ! org
[Download RAW message or body]
Git commit 2b5ed81d9d378f439f51f4319d62ef69fd8c40e7 by Łukasz Spas.
Committed on 16/10/2011 at 15:31.
Pushed by lukaszspas into branch 'master'.
BUG: 283321
M +1 -1 CMakeLists.txt
M +7 -2 photolayoutseditor/CMakeLists.txt
A +27 -0 photolayoutseditor/borderplugins/StandardBordersFactory.cpp \
[License: UNKNOWN] * A +21 -0 \
photolayoutseditor/borderplugins/StandardBordersFactory.h [License: UNKNOWN] * M \
+4 -18 photolayoutseditor/borderplugins/polaroid/CMakeLists.txt M +183 -11 \
photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.cpp M +99 -13 \
photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.h D +0 -37 \
photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_global.h D +0 -209 \
photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.cpp D +0 -127 \
photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.h D +0 -31 \
photolayoutseditor/borderplugins/polaroid/photolayoutseditorborderplugin_polaroid.desktop
M +4 -18 photolayoutseditor/borderplugins/solid/CMakeLists.txt
M +177 -11 photolayoutseditor/borderplugins/solid/SolidBorderDrawer.cpp
M +96 -13 photolayoutseditor/borderplugins/solid/SolidBorderDrawer.h
D +0 -207 photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.cpp
D +0 -126 photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.h
D +0 -31 photolayoutseditor/borderplugins/solid/photolayoutseditorborderplugin_solid.desktop
M +0 -4 photolayoutseditor/borders/BorderChangeListener.cpp
M +2 -2 photolayoutseditor/borders/BorderDrawerFactoryInterface.h
R +1 -12 photolayoutseditor/borders/BorderDrawerInterface.cpp [from: \
photolayoutseditor/borderplugins/solid/SolidBorderDrawer_global.h - 077% similarity] \
M +4 -4 photolayoutseditor/borders/BorderDrawerInterface.h M +8 -13 \
photolayoutseditor/borders/BorderDrawersLoader.cpp M +8 -2 \
photolayoutseditor/borders/BordersGroup.cpp M +13 -2 \
photolayoutseditor/borders/BordersGroup.h M +2 -1 \
photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.cpp M +1 -1 \
photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.h M +0 -4 \
photolayoutseditor/effects/PhotoEffectChangeListener.cpp M +39 -236 \
photolayoutseditor/effects/PhotoEffectsGroup.cpp M +1 -14 \
photolayoutseditor/effects/PhotoEffectsGroup.h M +2 -22 \
photolayoutseditor/effects/PhotoEffectsLoader.cpp M +5 -1 \
photolayoutseditor/plugin/photolayoutseditor.cpp M +4 -0 \
photolayoutseditor/threads/AbstractPhotoItemLoader.cpp M +1 -0 \
photolayoutseditor/widgets/canvas/RotationWidgetItem.cpp M +1 -0 \
photolayoutseditor/widgets/items/AbstractPhoto.cpp M +4 -0 \
photolayoutseditor/widgets/items/TextItem.cpp M +74 -73 \
photolayoutseditor/widgets/tools/AbstractItemsListViewTool.cpp M +3 -5 \
photolayoutseditor/widgets/tools/AbstractItemsListViewTool.h M +14 -16 \
photolayoutseditor/widgets/tools/AbstractItemsListViewTool_p.h M +2 -1 \
photolayoutseditor/widgets/tools/AbstractItemsTool.cpp M +1 -1 \
photolayoutseditor/widgets/tools/EffectsEditorTool.cpp M +1 -0 \
photolayoutseditor/widgets/tools/ToolsDockWidget.cpp
The files marked with a * at the end have a non valid license. Please read: \
http://techbase.kde.org/Policies/Licensing_Policy and use the headers which are \
listed at that page.
http://commits.kde.org/kipi-plugins/2b5ed81d9d378f439f51f4319d62ef69fd8c40e7
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dce9f18..05d00e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -435,7 +435,7 @@ IF(KIPIPLUGINS_CAN_BE_COMPILED)
IF(EXPAT_FOUND)
IF(CMAKE_USE_PTHREADS_INIT OR CMAKE_USE_WIN32_THREADS_INIT)
- ADD_SUBDIRECTORY(dngconverter)
+ #ADD_SUBDIRECTORY(dngconverter)
ENDIF(CMAKE_USE_PTHREADS_INIT OR CMAKE_USE_WIN32_THREADS_INIT)
ENDIF(EXPAT_FOUND)
diff --git a/photolayoutseditor/CMakeLists.txt b/photolayoutseditor/CMakeLists.txt
index a09ba8f..f018285 100644
--- a/photolayoutseditor/CMakeLists.txt
+++ b/photolayoutseditor/CMakeLists.txt
@@ -67,7 +67,11 @@
)
SET( PLE_Borders_SRCS
+ borderplugins/StandardBordersFactory.cpp
+ borderplugins/polaroid/PolaroidBorderDrawer.cpp
+ borderplugins/solid/SolidBorderDrawer.cpp
borders/BorderChangeListener.cpp
+ borders/BorderDrawerInterface.cpp
borders/BorderDrawersLoader.cpp
borders/BordersGroup.cpp
)
@@ -95,6 +99,7 @@
)
ADD_SUBDIRECTORY( effectplugins )
+ ADD_SUBDIRECTORY( borderplugins )
SET( PhotoLayoutsEditor_SRCS
${PLE_Common_SRCS}
@@ -114,6 +119,8 @@
SET( INCLUDE_DIRS
borders
borderplugins
+ borderplugins/polaroid
+ borderplugins/solid
effects
effectplugins
effectplugins/blur
@@ -199,5 +206,3 @@
INSTALL( FILES plugin/photolayoutseditorui.rc DESTINATION \
${DATA_INSTALL_DIR}/photolayoutseditor ) INSTALL( FILES \
effects/photolayoutseditoreffectplugin.desktop DESTINATION \
${SERVICETYPES_INSTALL_DIR} ) INSTALL( FILES \
borders/photolayoutseditorborderplugin.desktop DESTINATION \
${SERVICETYPES_INSTALL_DIR} )
-
- ADD_SUBDIRECTORY( ./borderplugins )
diff --git a/photolayoutseditor/borderplugins/StandardBordersFactory.cpp \
b/photolayoutseditor/borderplugins/StandardBordersFactory.cpp new file mode 100644
index 0000000..f699f3d
--- /dev/null
+++ b/photolayoutseditor/borderplugins/StandardBordersFactory.cpp
@@ -0,0 +1,27 @@
+#include "StandardBordersFactory.h"
+#include "PolaroidBorderDrawer.h"
+#include "SolidBorderDrawer.h"
+
+#include <klocalizedstring.h>
+
+using namespace KIPIPhotoLayoutsEditor;
+
+StandardBordersFactory::StandardBordersFactory(QObject * parent) :
+ BorderDrawerFactoryInterface(parent)
+{
+}
+
+QString StandardBordersFactory::drawersNames() const
+{
+ return i18n("Polaroid border") + QString(";") +
+ i18n("Solid border");
+}
+
+BorderDrawerInterface * StandardBordersFactory::getDrawerInstance(const QString & \
name) +{
+ if (name == i18n("Solid border"))
+ return new SolidBorderDrawer(this);
+ if (name == i18n("Polaroid border"))
+ return new PolaroidBorderDrawer(this);
+ return 0;
+}
diff --git a/photolayoutseditor/borderplugins/StandardBordersFactory.h \
b/photolayoutseditor/borderplugins/StandardBordersFactory.h new file mode 100644
index 0000000..19614ce
--- /dev/null
+++ b/photolayoutseditor/borderplugins/StandardBordersFactory.h
@@ -0,0 +1,21 @@
+#ifndef STANDARDBORDERSFACTORY_H
+#define STANDARDBORDERSFACTORY_H
+
+#include "BorderDrawerFactoryInterface.h"
+
+namespace KIPIPhotoLayoutsEditor
+{
+ class StandardBordersFactory : public BorderDrawerFactoryInterface
+ {
+ public:
+
+ explicit StandardBordersFactory(QObject *parent = 0);
+
+ virtual QString drawersNames() const;
+
+ virtual BorderDrawerInterface * getDrawerInstance(const QString & name);
+
+ };
+}
+
+#endif // STANDARDBORDERSFACTORY_H
diff --git a/photolayoutseditor/borderplugins/polaroid/CMakeLists.txt \
b/photolayoutseditor/borderplugins/polaroid/CMakeLists.txt index 26a7ad6..7f63b46 \
100644
--- a/photolayoutseditor/borderplugins/polaroid/CMakeLists.txt
+++ b/photolayoutseditor/borderplugins/polaroid/CMakeLists.txt
@@ -1,18 +1,4 @@
-SET(photolayoutseditorborderplugin_polaroid_SRCS
- PolaroidBorderDrawer.cpp
- PolaroidBorderDrawer_p.cpp
- )
-
-KDE4_ADD_PLUGIN(photolayoutseditorborderplugin_polaroid \
${photolayoutseditorborderplugin_polaroid_SRCS})
-
-TARGET_LINK_LIBRARIES(
- photolayoutseditorborderplugin_polaroid
- libphotolayoutseditor
- ${KDE4_KDECORE_LIBS}
- ${KDE4_KDEUI_LIBS}
- ${QT_QTCORE_LIBRARY}
- ${QT_QTGUI_LIBRARY}
- )
-
-INSTALL(TARGETS photolayoutseditorborderplugin_polaroid DESTINATION \
${PLUGIN_INSTALL_DIR})
-INSTALL(FILES photolayoutseditorborderplugin_polaroid.desktop DESTINATION \
${SERVICES_INSTALL_DIR}) + SET( PLE_Borders_SRCS
+ ${PLE_Borders_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/PolaroidBorderDrawer.cpp
+)
diff --git a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.cpp \
b/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.cpp index \
d3a7933..a476984 100644
--- a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.cpp
+++ b/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.cpp
@@ -23,26 +23,198 @@
*
* ============================================================ */
-#include "PolaroidBorderDrawer.h"
-#include "PolaroidBorderDrawer_p.h"
+#include "PolaroidBorderDrawer.moc"
+#include "StandardBordersFactory.h"
-#include <kpluginfactory.h>
#include <klocalizedstring.h>
-K_PLUGIN_FACTORY( PolaroidBorderDrawerFactoryLoader, \
registerPlugin<PolaroidBorderDrawerFactory>(); )
-K_EXPORT_PLUGIN ( PolaroidBorderDrawerFactoryLoader("photolayoutseditorborderplugin_polaroid") \
) +#include <QPainter>
+#include <QPaintEngine>
+#include <QMetaProperty>
+#include <QDebug>
-PolaroidBorderDrawerFactory::PolaroidBorderDrawerFactory(QObject * parent, const \
QVariantList&) :
- BorderDrawerFactoryInterface(parent)
+using namespace KIPIPhotoLayoutsEditor;
+
+QMap<const char *,QString> PolaroidBorderDrawer::m_properties;
+int PolaroidBorderDrawer::m_default_width = 20;
+QString PolaroidBorderDrawer::m_default_text = i18n("Write here some text");
+QColor PolaroidBorderDrawer::m_default_color = Qt::black;
+QFont PolaroidBorderDrawer::m_default_font(QFont().family(), 24);
+
+PolaroidBorderDrawer::PolaroidBorderDrawer(StandardBordersFactory * factory, QObject \
* parent) : + BorderDrawerInterface(factory, parent),
+ m_width(m_default_width),
+ m_text(m_default_text),
+ m_color(m_default_color),
+ m_font(m_default_font)
+{
+ if (m_properties.isEmpty())
+ {
+ const QMetaObject * meta = this->metaObject();
+ int count = meta->propertyCount();
+ while (count--)
+ {
+ QMetaProperty property = meta->property(count);
+ if (!QString("width").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Width"));
+ else if (!QString("text").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Text"));
+ else if (!QString("color").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Color"));
+ else if (!QString("font").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Font"));
+ }
+ }
+}
+
+QPainterPath PolaroidBorderDrawer::path(const QPainterPath & path)
+{
+ QPainterPath temp;
+
+ QRectF r = path.boundingRect();
+
+ m_text_rect.setTop(r.bottom());
+
+ r.setTop(r.top()-m_width);
+ r.setBottom(r.bottom()+m_width*5);
+ r.setLeft(r.left()-m_width);
+ r.setRight(r.right()+m_width);
+
+ m_text_rect.setBottom(r.bottom());
+ m_text_rect.setLeft(r.left());
+ m_text_rect.setRight(r.right());
+
+ temp.addRect(r);
+ temp -= path;
+
+ m_path = temp;
+ return m_path;
+}
+
+void PolaroidBorderDrawer::paint(QPainter * painter, const QStyleOptionGraphicsItem \
* /*option*/) +{
+ if (m_path.isEmpty())
+ return;
+ painter->save();
+ painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->fillPath(m_path, Qt::white);
+ painter->setFont(m_font);
+ painter->setPen(m_color);
+ painter->drawText(m_text_rect, Qt::AlignCenter, m_text);
+ painter->restore();
+}
+
+QString PolaroidBorderDrawer::propertyName(const QMetaProperty & property) const
+{
+ return m_properties.value(property.name());
+}
+
+QVariant PolaroidBorderDrawer::propertyValue(const QString & propertyName) const
+{
+ if (!m_properties.key(propertyName))
+ return QVariant();
+ const QMetaObject * meta = this->metaObject();
+ int index = meta->indexOfProperty( m_properties.key(propertyName) );
+ if (index >= meta->propertyCount())
+ return QVariant();
+ return meta->property( index ).read(this);
+}
+
+void PolaroidBorderDrawer::setPropertyValue(const QString & propertyName, const \
QVariant & value) +{
+ if (!m_properties.key(propertyName))
+ return;
+ const QMetaObject * meta = this->metaObject();
+ int index = meta->indexOfProperty( m_properties.key(propertyName) );
+ if (index >= meta->propertyCount())
+ return;
+ meta->property( index ).write(this, value);
+}
+
+QDomElement PolaroidBorderDrawer::toSvg(QDomDocument & document) const
+{
+ QDomElement result = document.createElement("g");
+ QDomElement path = document.createElement("path");
+ result.appendChild(path);
+ path.setAttribute("d", pathToSvg(m_path));
+ path.setAttribute("fill", "#ffffff");
+ path.setAttribute("fill-rule", "evenodd");
+
+ QPainterPath p;
+ p.addText(0, 0, m_font, m_text);
+ p.translate(m_text_rect.center() - p.boundingRect().center());
+
+ QDomElement text = document.createElement("path");
+ result.appendChild(text);
+ text.setAttribute("d", pathToSvg(p));
+ text.setAttribute("fill", m_color.name());
+
+ return result;
+}
+
+QString PolaroidBorderDrawer::name() const
+{
+ return i18n("Polaroid border");
+}
+
+QString PolaroidBorderDrawer::toString() const
+{
+ return name().append(" [") + m_text + QString("]");
+}
+
+PolaroidBorderDrawer::operator QString() const
+{
+ return this->toString();
+}
+
+QVariant PolaroidBorderDrawer::minimumValue(const QMetaProperty & property)
+{
+ const char * name = property.name();
+ if (!QString("width").compare(name))
+ return 0;
+ return QVariant();
+}
+
+QVariant PolaroidBorderDrawer::maximumValue(const QMetaProperty & property)
{
+ const char * name = property.name();
+ if (!QString("width").compare(name))
+ return 100;
+ return QVariant();
}
-QString PolaroidBorderDrawerFactory::drawerName() const
+QVariant PolaroidBorderDrawer::stepValue(const QMetaProperty & property)
{
- return i18n("Polaroid");
+ const char * name = property.name();
+ if (!QString("width").compare(name))
+ return 1;
+ return QVariant();
}
-BorderDrawerInterface * PolaroidBorderDrawerFactory::getDrawerInstance(QObject * \
parent) +QString PolaroidBorderDrawer::pathToSvg(const QPainterPath & path) const
{
- return new PolaroidBorderDrawer(this, parent);
+ int count = path.elementCount();
+ QString str_path_d;
+ for (int i = 0; i < count; ++i)
+ {
+ QPainterPath::Element e = path.elementAt(i);
+ switch (e.type)
+ {
+ case QPainterPath::LineToElement:
+ str_path_d.append("L " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' '); + break;
+ case QPainterPath::MoveToElement:
+ str_path_d.append("M " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' '); + break;
+ case QPainterPath::CurveToElement:
+ str_path_d.append("C " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' '); + break;
+ case QPainterPath::CurveToDataElement:
+ str_path_d.append(QString::number(e.x) + ' ' + QString::number(e.y) + ' \
'); + break;
+ }
+ }
+ str_path_d.append("z");
+ return str_path_d;
}
diff --git a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.h \
b/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.h index \
0c8df94..4f8778a 100644
--- a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.h
+++ b/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer.h
@@ -26,25 +26,111 @@
#ifndef POLAROIDBORDERDRAWER_H
#define POLAROIDBORDERDRAWER_H
-#include "PolaroidBorderDrawer_global.h"
-#include "BorderDrawerFactoryInterface.h"
+#include "BorderDrawerInterface.h"
-#include <QVariantList>
+#include <QColor>
-using namespace KIPIPhotoLayoutsEditor;
-
-class POLAROIDBORDERDRAWERSHARED_EXPORT PolaroidBorderDrawerFactory : public \
BorderDrawerFactoryInterface +namespace KIPIPhotoLayoutsEditor
{
- Q_OBJECT
- Q_INTERFACES(KIPIPhotoLayoutsEditor::BorderDrawerFactoryInterface)
+ class StandardBordersFactory;
+
+ class PolaroidBorderDrawer : public BorderDrawerInterface
+ {
+ Q_OBJECT
+
+ int m_width;
+ QString m_text;
+ QColor m_color;
+ QFont m_font;
+ QPainterPath m_path;
+ QRectF m_text_rect;
+
+ static QMap<const char *,QString> m_properties;
+ static int m_default_width;
+ static QString m_default_text;
+ static QColor m_default_color;
+ static QFont m_default_font;
+
+ public:
+
+ explicit PolaroidBorderDrawer(StandardBordersFactory * factory, QObject \
* parent = 0); +
+ virtual QPainterPath path(const QPainterPath & path);
+
+ virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * \
option); +
+ virtual QString propertyName(const QMetaProperty & property) const;
+
+ virtual QVariant propertyValue(const QString & propertyName) const;
+
+ virtual void setPropertyValue(const QString & propertyName, const \
QVariant & value); +
+ virtual QDomElement toSvg(QDomDocument & document) const;
+
+ virtual QString name() const;
+
+ virtual QString toString() const;
+
+ virtual operator QString() const;
+
+ Q_PROPERTY(int width READ width WRITE setWidth)
+ int width() const
+ {
+ return m_width;
+ }
+ void setWidth(int width)
+ {
+ if (width > 0)
+ {
+ m_default_width = m_width = width;
+ this->propertiesChanged();
+ }
+ }
+
+ Q_PROPERTY(QString text READ text WRITE setText)
+ QString text() const
+ {
+ return m_text;
+ }
+ void setText(const QString & text)
+ {
+ m_text = text;
+ this->propertiesChanged();
+ }
+
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ QColor color() const
+ {
+ return m_color;
+ }
+ void setColor(const QColor & color)
+ {
+ if (color.isValid())
+ {
+ m_default_color = m_color = color;
+ this->propertiesChanged();
+ }
+ }
- public:
+ Q_PROPERTY(QFont font READ font WRITE setFont)
+ QFont font() const
+ {
+ return m_font;
+ }
+ void setFont(const QFont & font)
+ {
+ m_default_font = m_font = font;
+ this->propertiesChanged();
+ }
- PolaroidBorderDrawerFactory(QObject * parent, const QVariantList&);
+ virtual QVariant minimumValue(const QMetaProperty & property);
+ virtual QVariant maximumValue(const QMetaProperty & property);
+ virtual QVariant stepValue(const QMetaProperty & property);
- virtual QString drawerName() const;
+ private:
- virtual BorderDrawerInterface * getDrawerInstance(QObject * parent = 0);
-};
+ QString pathToSvg(const QPainterPath & path) const;
+ };
+}
#endif // POLAROIDBORDERDRAWER_H
diff --git a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_global.h \
b/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_global.h deleted \
file mode 100644 index 6175025..0000000
--- a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_global.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ============================================================
- *
- * This file is a part of kipi-plugins project
- * http://www.kipi-plugins.org
- *
- * Date : 2011-09-01
- * Description : a plugin to create photo layouts by fusion of several images.
- * Acknowledge : based on the expoblending plugin
- *
- * Copyright (C) 2011 by Łukasz Spas <lukasz dot spas at gmail dot com>
- * Copyright (C) 2009-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
- *
- * 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, 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.
- *
- * ============================================================ */
-
-#ifndef POLAROIDBORDERDRAWER_GLOBAL_H
-#define POLAROIDBORDERDRAWER_GLOBAL_H
-
-#include <QtCore/qglobal.h>
-
-#if defined(POLAROIDBORDERDRAWER_LIBRARY)
-# define POLAROIDBORDERDRAWERSHARED_EXPORT Q_DECL_EXPORT
-#else
-# define POLAROIDBORDERDRAWERSHARED_EXPORT Q_DECL_IMPORT
-#endif
-
-#endif // POLAROIDBORDERDRAWER_GLOBAL_H
diff --git a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.cpp \
b/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.cpp deleted file \
mode 100644 index d2b5b85..0000000
--- a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/* ============================================================
- *
- * This file is a part of kipi-plugins project
- * http://www.kipi-plugins.org
- *
- * Date : 2011-09-01
- * Description : a plugin to create photo layouts by fusion of several images.
- * Acknowledge : based on the expoblending plugin
- *
- * Copyright (C) 2011 by Łukasz Spas <lukasz dot spas at gmail dot com>
- * Copyright (C) 2009-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
- *
- * 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, 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.
- *
- * ============================================================ */
-
-#include "PolaroidBorderDrawer_p.h"
-#include "PolaroidBorderDrawer.h"
-
-#include <klocalizedstring.h>
-
-#include <QPainter>
-#include <QPaintEngine>
-#include <QMetaProperty>
-#include <QDebug>
-
-QMap<const char *,QString> PolaroidBorderDrawer::m_properties;
-int PolaroidBorderDrawer::m_default_width = 20;
-QString PolaroidBorderDrawer::m_default_text = i18n("Write here some text");
-QColor PolaroidBorderDrawer::m_default_color = Qt::black;
-QFont PolaroidBorderDrawer::m_default_font(QFont().family(), 24);
-
-PolaroidBorderDrawer::PolaroidBorderDrawer(PolaroidBorderDrawerFactory * factory, \
QObject * parent) :
- BorderDrawerInterface(factory, parent),
- m_width(m_default_width),
- m_text(m_default_text),
- m_color(m_default_color),
- m_font(m_default_font)
-{
- if (m_properties.isEmpty())
- {
- const QMetaObject * meta = this->metaObject();
- int count = meta->propertyCount();
- while (count--)
- {
- QMetaProperty property = meta->property(count);
- if (!QString("width").compare(property.name()))
- m_properties.insert(property.name(), i18n("Width"));
- else if (!QString("text").compare(property.name()))
- m_properties.insert(property.name(), i18n("Text"));
- else if (!QString("color").compare(property.name()))
- m_properties.insert(property.name(), i18n("Color"));
- else if (!QString("font").compare(property.name()))
- m_properties.insert(property.name(), i18n("Font"));
- }
- }
-}
-
-QPainterPath PolaroidBorderDrawer::path(const QPainterPath & path)
-{
- QPainterPath temp;
-
- QRectF r = path.boundingRect();
-
- m_text_rect.setTop(r.bottom());
-
- r.setTop(r.top()-m_width);
- r.setBottom(r.bottom()+m_width*5);
- r.setLeft(r.left()-m_width);
- r.setRight(r.right()+m_width);
-
- m_text_rect.setBottom(r.bottom());
- m_text_rect.setLeft(r.left());
- m_text_rect.setRight(r.right());
-
- temp.addRect(r);
- temp -= path;
-
- m_path = temp;
- return m_path;
-}
-
-void PolaroidBorderDrawer::paint(QPainter * painter, const QStyleOptionGraphicsItem \
* /*option*/)
-{
- if (m_path.isEmpty())
- return;
- painter->save();
- painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
- painter->setRenderHint(QPainter::Antialiasing);
- painter->fillPath(m_path, Qt::white);
- painter->setFont(m_font);
- painter->setPen(m_color);
- painter->drawText(m_text_rect, Qt::AlignCenter, m_text);
- painter->restore();
-}
-
-QString PolaroidBorderDrawer::propertyName(const QMetaProperty & property) const
-{
- return m_properties.value(property.name());
-}
-
-QVariant PolaroidBorderDrawer::propertyValue(const QString & propertyName) const
-{
- const QMetaObject * meta = this->metaObject();
- int index = meta->indexOfProperty( m_properties.key(propertyName) );
- if (index >= meta->propertyCount())
- return QVariant();
- return meta->property( index ).read(this);
-}
-
-void PolaroidBorderDrawer::setPropertyValue(const QString & propertyName, const \
QVariant & value)
-{
- const QMetaObject * meta = this->metaObject();
- int index = meta->indexOfProperty( m_properties.key(propertyName) );
- if (index >= meta->propertyCount())
- return;
- meta->property( index ).write(this, value);
-}
-
-QDomElement PolaroidBorderDrawer::toSvg(QDomDocument & document) const
-{
- QDomElement result = document.createElement("g");
- QDomElement path = document.createElement("path");
- result.appendChild(path);
- path.setAttribute("d", pathToSvg(m_path));
- path.setAttribute("fill", "#ffffff");
- path.setAttribute("fill-rule", "evenodd");
-
- QPainterPath p;
- p.addText(0, 0, m_font, m_text);
- p.translate(m_text_rect.center() - p.boundingRect().center());
-
- QDomElement text = document.createElement("path");
- result.appendChild(text);
- text.setAttribute("d", pathToSvg(p));
- text.setAttribute("fill", m_color.name());
-
- return result;
-}
-
-QString PolaroidBorderDrawer::toString() const
-{
- return factory()->drawerName().append(" [") + m_text + QString("]");
-}
-
-PolaroidBorderDrawer::operator QString() const
-{
- return this->toString();
-}
-
-QVariant PolaroidBorderDrawer::minimumValue(const QMetaProperty & property)
-{
- const char * name = property.name();
- if (!QString("width").compare(name))
- return 0;
- return QVariant();
-}
-
-QVariant PolaroidBorderDrawer::maximumValue(const QMetaProperty & property)
-{
- const char * name = property.name();
- if (!QString("width").compare(name))
- return 100;
- return QVariant();
-}
-
-QVariant PolaroidBorderDrawer::stepValue(const QMetaProperty & property)
-{
- const char * name = property.name();
- if (!QString("width").compare(name))
- return 1;
- return QVariant();
-}
-
-QString PolaroidBorderDrawer::pathToSvg(const QPainterPath & path) const
-{
- int count = path.elementCount();
- QString str_path_d;
- for (int i = 0; i < count; ++i)
- {
- QPainterPath::Element e = path.elementAt(i);
- switch (e.type)
- {
- case QPainterPath::LineToElement:
- str_path_d.append("L " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' ');
- break;
- case QPainterPath::MoveToElement:
- str_path_d.append("M " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' ');
- break;
- case QPainterPath::CurveToElement:
- str_path_d.append("C " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' ');
- break;
- case QPainterPath::CurveToDataElement:
- str_path_d.append(QString::number(e.x) + ' ' + QString::number(e.y) + ' \
');
- break;
- }
- }
- str_path_d.append("z");
- return str_path_d;
-}
diff --git a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.h \
b/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.h deleted file \
mode 100644 index 7217c8c..0000000
--- a/photolayoutseditor/borderplugins/polaroid/PolaroidBorderDrawer_p.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* ============================================================
- *
- * This file is a part of kipi-plugins project
- * http://www.kipi-plugins.org
- *
- * Date : 2011-09-01
- * Description : a plugin to create photo layouts by fusion of several images.
- * Acknowledge : based on the expoblending plugin
- *
- * Copyright (C) 2011 by Łukasz Spas <lukasz dot spas at gmail dot com>
- * Copyright (C) 2009-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
- *
- * 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, 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.
- *
- * ============================================================ */
-
-#ifndef SOLIDBORDERDRAWER_P_H
-#define SOLIDBORDERDRAWER_P_H
-
-#include "BorderDrawerInterface.h"
-
-#include <QColor>
-
-using namespace KIPIPhotoLayoutsEditor;
-
-class PolaroidBorderDrawerFactory;
-class PolaroidBorderDrawer : public BorderDrawerInterface
-{
- Q_OBJECT
- Q_INTERFACES(KIPIPhotoLayoutsEditor::BorderDrawerInterface)
-
- int m_width;
- QString m_text;
- QColor m_color;
- QFont m_font;
- QPainterPath m_path;
- QRectF m_text_rect;
-
- static QMap<const char *,QString> m_properties;
- static int m_default_width;
- static QString m_default_text;
- static QColor m_default_color;
- static QFont m_default_font;
-
- public:
-
- explicit PolaroidBorderDrawer(PolaroidBorderDrawerFactory * factory, QObject \
* parent = 0);
-
- virtual QPainterPath path(const QPainterPath & path);
-
- virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * \
option);
-
- virtual QString propertyName(const QMetaProperty & property) const;
-
- virtual QVariant propertyValue(const QString & propertyName) const;
-
- virtual void setPropertyValue(const QString & propertyName, const QVariant & \
value);
-
- virtual QDomElement toSvg(QDomDocument & document) const;
-
- virtual QString toString() const;
-
- virtual operator QString() const;
-
- Q_PROPERTY(int width READ width WRITE setWidth)
- int width() const
- {
- return m_width;
- }
- void setWidth(int width)
- {
- if (width > 0)
- m_default_width = m_width = width;
- }
-
- Q_PROPERTY(QString text READ text WRITE setText)
- QString text() const
- {
- return m_text;
- }
- void setText(const QString & text)
- {
- m_text = text;
- }
-
- Q_PROPERTY(QColor color READ color WRITE setColor)
- QColor color() const
- {
- return m_color;
- }
- void setColor(const QColor & color)
- {
- if (color.isValid())
- m_default_color = m_color = color;
- }
-
- Q_PROPERTY(QFont font READ font WRITE setFont)
- QFont font() const
- {
- return m_font;
- }
- void setFont(const QFont & font)
- {
- m_default_font = m_font = font;
- }
-
- virtual QVariant minimumValue(const QMetaProperty & property);
- virtual QVariant maximumValue(const QMetaProperty & property);
- virtual QVariant stepValue(const QMetaProperty & property);
-
- private:
-
- QString pathToSvg(const QPainterPath & path) const;
-
- friend class PolaroidBorderDrawerFactory;
-};
-
-#endif // SOLIDBORDERDRAWER_P_H
diff --git a/photolayoutseditor/borderplugins/polaroid/photolayoutseditorborderplugin_polaroid.desktop \
b/photolayoutseditor/borderplugins/polaroid/photolayoutseditorborderplugin_polaroid.desktop
deleted file mode 100644
index e8046e9..0000000
--- a/photolayoutseditor/borderplugins/polaroid/photolayoutseditorborderplugin_polaroid.desktop
+++ /dev/null
@@ -1,31 +0,0 @@
-[Desktop Entry]
-Name=PolaroidBorderDrawerFactory
-Name[ca]=PolaroidBorderDrawerFactory
-Name[el]=PolaroidBorderDrawerFactory
-Name[it]=Disegnatore di bordi Polaroid
-Name[nb]=PolaroidBorderDrawerFactory
-Name[nl]=PolaroidRandenAanbrenger
-Name[pt]=PolaroidBorderDrawerFactory
-Name[pt_BR]=PolaroidBorderDrawerFactory
-Name[sv]=Skapa uppritare av polaroidkant
-Name[uk]=Малювання поляризованої рамки
-Name[x-test]=xxPolaroidBorderDrawerFactoryxx
-Name[zh_TW]=PolaroidBorderDrawerFactory
-Type=Service
-ServiceTypes=PhotoLayoutsEditor/BorderPlugin
-Encoding=UTF-8
-Comment=Polaroid border drawer for Photo Layouts Editor
-Comment[ca]=Motllura de Polaroid per l'editor de formats de foto
-Comment[el]=Polaroid σχεδιαστής περιγράμματος για τον \
επεξεργαστή διατάξεων φωτογραφιών
-Comment[it]=Disegnatore di bordi Polaroid per l'editor di impaginazioni di foto
-Comment[nb]=Polaroid kanttegner for fotoutleggsredigering
-Comment[nl]=Polaroid-randen aanbrenger voor Foto-indelingbewerker
-Comment[pt]=Moldura de Polaroid para o Editor de Formatos de Fotografias
-Comment[pt_BR]=Moldura de Polaroid para o editor de formatos de fotos
-Comment[sv]=Uppritning av polaroidkanter för fotolayouteditor
-Comment[uk]=Інструмент малювання рамки Поляроїд \
для редактора компонуванння \
фотографії
-Comment[x-test]=xxPolaroid border drawer for Photo Layouts Editorxx
-Comment[zh_TW]=相片佈局編輯器裡的拍立得邊框繪製器
-
-X-KDE-Library=photolayoutseditorborderplugin_polaroid
-author=Łukasz Spas, lukasz dot spas at gmail dot com
diff --git a/photolayoutseditor/borderplugins/solid/CMakeLists.txt \
b/photolayoutseditor/borderplugins/solid/CMakeLists.txt index 4c8c0df..505d03e 100644
--- a/photolayoutseditor/borderplugins/solid/CMakeLists.txt
+++ b/photolayoutseditor/borderplugins/solid/CMakeLists.txt
@@ -1,18 +1,4 @@
-SET(photolayoutseditorborderplugin_solid_SRCS
- SolidBorderDrawer.cpp
- SolidBorderDrawer_p.cpp
- )
-
-KDE4_ADD_PLUGIN(photolayoutseditorborderplugin_solid \
${photolayoutseditorborderplugin_solid_SRCS})
-
-TARGET_LINK_LIBRARIES(
- photolayoutseditorborderplugin_solid
- libphotolayoutseditor
- ${KDE4_KDECORE_LIBS}
- ${KDE4_KDEUI_LIBS}
- ${QT_QTCORE_LIBRARY}
- ${QT_QTGUI_LIBRARY}
- )
-
-INSTALL(TARGETS photolayoutseditorborderplugin_solid DESTINATION \
${PLUGIN_INSTALL_DIR})
-INSTALL(FILES photolayoutseditorborderplugin_solid.desktop DESTINATION \
${SERVICES_INSTALL_DIR}) + SET( PLE_Borders_SRCS
+ ${PLE_Borders_SRCS}
+ ${CMAKE_CURRENT_SOURCE_DIR}/SolidBorderDrawer.cpp
+)
diff --git a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.cpp \
b/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.cpp index c6a539e..9f7deff \
100644
--- a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.cpp
+++ b/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.cpp
@@ -23,26 +23,192 @@
*
* ============================================================ */
-#include "SolidBorderDrawer.h"
-#include "SolidBorderDrawer_p.h"
+#include "SolidBorderDrawer.moc"
+#include "StandardBordersFactory.h"
-#include <kpluginfactory.h>
#include <klocalizedstring.h>
-K_PLUGIN_FACTORY( SolidBorderDrawerFactoryLoader, \
registerPlugin<SolidBorderDrawerFactory>(); )
-K_EXPORT_PLUGIN ( SolidBorderDrawerFactoryLoader("photolayoutseditorborderplugin_solid") \
) +#include <QPainter>
+#include <QPaintEngine>
+#include <QMetaProperty>
+#include <QDebug>
-SolidBorderDrawerFactory::SolidBorderDrawerFactory(QObject * parent, const \
QVariantList&) :
- BorderDrawerFactoryInterface(parent)
+using namespace KIPIPhotoLayoutsEditor;
+
+QMap<const char *,QString> SolidBorderDrawer::m_properties;
+QMap<Qt::PenJoinStyle, QString> SolidBorderDrawer::m_corners_style_names;
+int SolidBorderDrawer::m_default_width = 1;
+QColor SolidBorderDrawer::m_default_color = Qt::red;
+int SolidBorderDrawer::m_default_spacing = 0;
+Qt::PenJoinStyle SolidBorderDrawer::m_default_corners_style = Qt::MiterJoin;
+
+SolidBorderDrawer::SolidBorderDrawer(StandardBordersFactory * factory, QObject * \
parent) : + BorderDrawerInterface(factory, parent),
+ m_width(m_default_width),
+ m_color(m_default_color),
+ m_spacing(m_default_spacing),
+ m_corners_style(m_default_corners_style)
+{
+ if (m_corners_style_names.isEmpty())
+ {
+ SolidBorderDrawer::m_corners_style_names.insert(Qt::MiterJoin, "Miter");
+ SolidBorderDrawer::m_corners_style_names.insert(Qt::BevelJoin, "Bevel");
+ SolidBorderDrawer::m_corners_style_names.insert(Qt::RoundJoin, "Round");
+ }
+
+ if (m_properties.isEmpty())
+ {
+ const QMetaObject * meta = this->metaObject();
+ int count = meta->propertyCount();
+ while (count--)
+ {
+ QMetaProperty property = meta->property(count);
+ if (!QString("color").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Color"));
+ else if (!QString("corners_style").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Corners style"));
+ else if (!QString("width").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Width"));
+ else if (!QString("spacing").compare(property.name()))
+ m_properties.insert(property.name(), i18n("Spacing"));
+ }
+ }
+}
+
+QPainterPath SolidBorderDrawer::path(const QPainterPath & path)
+{
+ QPainterPath temp = path;
+ if (m_spacing != 0)
+ {
+ QPainterPathStroker spacing;
+ spacing.setWidth(qAbs(m_spacing));
+ spacing.setJoinStyle(Qt::MiterJoin);
+ if (m_spacing > 0)
+ temp += spacing.createStroke(temp);
+ else
+ temp -= spacing.createStroke(path);
+ }
+ else
+ temp = path;
+ QPainterPathStroker stroker;
+ stroker.setJoinStyle(this->m_corners_style);
+ stroker.setWidth(m_width);
+ m_path = stroker.createStroke( temp );
+ return m_path;
+}
+
+void SolidBorderDrawer::paint(QPainter * painter, const QStyleOptionGraphicsItem * \
/*option*/) +{
+ if (m_path.isEmpty())
+ return;
+ painter->save();
+ painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->fillPath(m_path, m_color);
+ painter->restore();
+}
+
+QString SolidBorderDrawer::propertyName(const QMetaProperty & property) const
+{
+ return m_properties.value(property.name());
+}
+
+QVariant SolidBorderDrawer::propertyValue(const QString & propertyName) const
+{
+ const QMetaObject * meta = this->metaObject();
+ int index = meta->indexOfProperty( m_properties.key(propertyName) );
+ if (index >= meta->propertyCount())
+ return QVariant();
+ return meta->property( index ).read(this);
+}
+
+void SolidBorderDrawer::setPropertyValue(const QString & propertyName, const \
QVariant & value) +{
+ const QMetaObject * meta = this->metaObject();
+ int index = meta->indexOfProperty( m_properties.key(propertyName) );
+ if (index >= meta->propertyCount())
+ return;
+ meta->property( index ).write(this, value);
+}
+
+QDomElement SolidBorderDrawer::toSvg(QDomDocument & document) const
+{
+ QDomElement result = document.createElement("path");
+ int count = m_path.elementCount();
+ QString str_path_d;
+ for (int i = 0; i < count; ++i)
+ {
+ QPainterPath::Element e = m_path.elementAt(i);
+ switch (e.type)
+ {
+ case QPainterPath::LineToElement:
+ str_path_d.append("L " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' '); + break;
+ case QPainterPath::MoveToElement:
+ str_path_d.append("M " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' '); + break;
+ case QPainterPath::CurveToElement:
+ str_path_d.append("C " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' '); + break;
+ case QPainterPath::CurveToDataElement:
+ str_path_d.append(QString::number(e.x) + ' ' + QString::number(e.y) + ' \
'); + break;
+ }
+ }
+ result.setAttribute("d", str_path_d);
+ result.setAttribute("fill", m_color.name());
+ return result;
+}
+
+QString SolidBorderDrawer::name() const
+{
+ return i18n("Solid border");
+}
+
+QString SolidBorderDrawer::toString() const
+{
+ return name().append(" [") + QString::number(m_width).append(" ") + \
m_color.name().append("]"); +}
+
+SolidBorderDrawer::operator QString() const
+{
+ return this->toString();
+}
+
+QVariant SolidBorderDrawer::stringNames(const QMetaProperty & property)
+{
+ const char * name = property.name();
+ if (!QString("corners_style").compare(name))
+ return QVariant(m_corners_style_names.values());
+ return QVariant();
+}
+
+QVariant SolidBorderDrawer::minimumValue(const QMetaProperty & property)
{
+ const char * name = property.name();
+ if (!QString("width").compare(name))
+ return 0;
+ if (!QString("spacing").compare(name))
+ return -100;
+ return QVariant();
}
-QString SolidBorderDrawerFactory::drawerName() const
+QVariant SolidBorderDrawer::maximumValue(const QMetaProperty & property)
{
- return i18n("Solid");
+ const char * name = property.name();
+ if (!QString("width").compare(name))
+ return 100;
+ if (!QString("spacing").compare(name))
+ return 100;
+ return QVariant();
}
-BorderDrawerInterface * SolidBorderDrawerFactory::getDrawerInstance(QObject * \
parent) +QVariant SolidBorderDrawer::stepValue(const QMetaProperty & property)
{
- return new SolidBorderDrawer(this, parent);
+ const char * name = property.name();
+ if (!QString("width").compare(name))
+ return 1;
+ if (!QString("spacing").compare(name))
+ return 1;
+ return QVariant();
}
diff --git a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.h \
b/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.h index 53c7c49..b200f10 \
100644
--- a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.h
+++ b/photolayoutseditor/borderplugins/solid/SolidBorderDrawer.h
@@ -26,25 +26,108 @@
#ifndef SOLIDBORDERDRAWER_H
#define SOLIDBORDERDRAWER_H
-#include "SolidBorderDrawer_global.h"
-#include "BorderDrawerFactoryInterface.h"
+#include "BorderDrawerInterface.h"
-#include <QVariantList>
+#include <QColor>
-using namespace KIPIPhotoLayoutsEditor;
-
-class SOLIDBORDERDRAWERSHARED_EXPORT SolidBorderDrawerFactory : public \
BorderDrawerFactoryInterface +namespace KIPIPhotoLayoutsEditor
{
- Q_OBJECT
- Q_INTERFACES(KIPIPhotoLayoutsEditor::BorderDrawerFactoryInterface)
+ class StandardBordersFactory;
+
+ class SolidBorderDrawer : public BorderDrawerInterface
+ {
+ Q_OBJECT
+
+ int m_width;
+ QColor m_color;
+ int m_spacing;
+ Qt::PenJoinStyle m_corners_style;
+ QPainterPath m_path;
+
+ static QMap<const char *,QString> m_properties;
+ static QMap<Qt::PenJoinStyle, QString> m_corners_style_names;
+ static int m_default_width;
+ static QColor m_default_color;
+ static int m_default_spacing;
+ static Qt::PenJoinStyle m_default_corners_style;
+
+ public:
+
+ explicit SolidBorderDrawer(StandardBordersFactory * factory, QObject * \
parent = 0); +
+ virtual QPainterPath path(const QPainterPath & path);
+
+ virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * \
option); +
+ virtual QString propertyName(const QMetaProperty & property) const;
+
+ virtual QVariant propertyValue(const QString & propertyName) const;
+
+ virtual void setPropertyValue(const QString & propertyName, const \
QVariant & value); +
+ virtual QDomElement toSvg(QDomDocument & document) const;
+
+ virtual QString name() const;
+
+ virtual QString toString() const;
+
+ virtual operator QString() const;
+
+ Q_PROPERTY(int width READ width WRITE setWidth)
+ int width() const
+ {
+ return m_width;
+ }
+ void setWidth(int width)
+ {
+ if (width > 0)
+ {
+ m_default_width = m_width = width;
+ this->propertiesChanged();
+ }
+ }
- public:
+ Q_PROPERTY(QString corners_style READ cornersStyle WRITE \
setCornersStyle) + QString cornersStyle() const
+ {
+ return m_corners_style_names.value(m_corners_style);
+ }
+ void setCornersStyle(const QString & cornersStyle)
+ {
+ m_default_corners_style = m_corners_style = \
m_corners_style_names.key(cornersStyle); + this->propertiesChanged();
+ }
- SolidBorderDrawerFactory(QObject * parent, const QVariantList&);
+ Q_PROPERTY(QColor color READ color WRITE setColor)
+ QColor color() const
+ {
+ return m_color;
+ }
+ void setColor(const QColor & color)
+ {
+ if (color.isValid())
+ {
+ m_default_color = m_color = color;
+ this->propertiesChanged();
+ }
+ }
- virtual QString drawerName() const;
+ Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
+ int spacing() const
+ {
+ return m_spacing;
+ }
+ void setSpacing(int spacing)
+ {
+ m_default_spacing = m_spacing = spacing;
+ this->propertiesChanged();
+ }
- virtual BorderDrawerInterface * getDrawerInstance(QObject * parent = 0);
-};
+ virtual QVariant stringNames(const QMetaProperty & property);
+ virtual QVariant minimumValue(const QMetaProperty & property);
+ virtual QVariant maximumValue(const QMetaProperty & property);
+ virtual QVariant stepValue(const QMetaProperty & property);
+ };
+}
#endif // SOLIDBORDERDRAWER_H
diff --git a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.cpp \
b/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.cpp deleted file mode \
100644 index 37299ee..0000000
--- a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.cpp
+++ /dev/null
@@ -1,207 +0,0 @@
-/* ============================================================
- *
- * This file is a part of kipi-plugins project
- * http://www.kipi-plugins.org
- *
- * Date : 2011-09-01
- * Description : a plugin to create photo layouts by fusion of several images.
- * Acknowledge : based on the expoblending plugin
- *
- * Copyright (C) 2011 by Łukasz Spas <lukasz dot spas at gmail dot com>
- * Copyright (C) 2009-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
- *
- * 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, 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.
- *
- * ============================================================ */
-
-#include "SolidBorderDrawer_p.h"
-#include "SolidBorderDrawer.h"
-
-#include <klocalizedstring.h>
-
-#include <QPainter>
-#include <QPaintEngine>
-#include <QMetaProperty>
-#include <QDebug>
-
-QMap<const char *,QString> SolidBorderDrawer::m_properties;
-QMap<Qt::PenJoinStyle, QString> SolidBorderDrawer::m_corners_style_names;
-int SolidBorderDrawer::m_default_width = 1;
-QColor SolidBorderDrawer::m_default_color = Qt::red;
-int SolidBorderDrawer::m_default_spacing = 0;
-Qt::PenJoinStyle SolidBorderDrawer::m_default_corners_style = Qt::MiterJoin;
-
-SolidBorderDrawer::SolidBorderDrawer(SolidBorderDrawerFactory * factory, QObject * \
parent) :
- BorderDrawerInterface(factory, parent),
- m_width(m_default_width),
- m_color(m_default_color),
- m_spacing(m_default_spacing),
- m_corners_style(m_default_corners_style)
-{
- if (m_corners_style_names.isEmpty())
- {
- SolidBorderDrawer::m_corners_style_names.insert(Qt::MiterJoin, "Miter");
- SolidBorderDrawer::m_corners_style_names.insert(Qt::BevelJoin, "Bevel");
- SolidBorderDrawer::m_corners_style_names.insert(Qt::RoundJoin, "Round");
- }
-
- if (m_properties.isEmpty())
- {
- const QMetaObject * meta = this->metaObject();
- int count = meta->propertyCount();
- while (count--)
- {
- QMetaProperty property = meta->property(count);
- if (!QString("color").compare(property.name()))
- m_properties.insert(property.name(), i18n("Color"));
- else if (!QString("corners_style").compare(property.name()))
- m_properties.insert(property.name(), i18n("Corners style"));
- else if (!QString("width").compare(property.name()))
- m_properties.insert(property.name(), i18n("Width"));
- else if (!QString("spacing").compare(property.name()))
- m_properties.insert(property.name(), i18n("Spacing"));
- }
- }
-}
-
-QPainterPath SolidBorderDrawer::path(const QPainterPath & path)
-{
- QPainterPath temp = path;
- if (m_spacing != 0)
- {
- QPainterPathStroker spacing;
- spacing.setWidth(qAbs(m_spacing));
- spacing.setJoinStyle(Qt::MiterJoin);
- if (m_spacing > 0)
- temp += spacing.createStroke(temp);
- else
- temp -= spacing.createStroke(path);
- }
- else
- temp = path;
- QPainterPathStroker stroker;
- stroker.setJoinStyle(this->m_corners_style);
- stroker.setWidth(m_width);
- m_path = stroker.createStroke( temp );
- return m_path;
-}
-
-void SolidBorderDrawer::paint(QPainter * painter, const QStyleOptionGraphicsItem * \
/*option*/)
-{
- if (m_path.isEmpty())
- return;
- painter->save();
- painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
- painter->setRenderHint(QPainter::Antialiasing);
- painter->fillPath(m_path, m_color);
- painter->restore();
-}
-
-QString SolidBorderDrawer::propertyName(const QMetaProperty & property) const
-{
- return m_properties.value(property.name());
-}
-
-QVariant SolidBorderDrawer::propertyValue(const QString & propertyName) const
-{
- const QMetaObject * meta = this->metaObject();
- int index = meta->indexOfProperty( m_properties.key(propertyName) );
- if (index >= meta->propertyCount())
- return QVariant();
- return meta->property( index ).read(this);
-}
-
-void SolidBorderDrawer::setPropertyValue(const QString & propertyName, const \
QVariant & value)
-{
- const QMetaObject * meta = this->metaObject();
- int index = meta->indexOfProperty( m_properties.key(propertyName) );
- if (index >= meta->propertyCount())
- return;
- meta->property( index ).write(this, value);
-}
-
-QDomElement SolidBorderDrawer::toSvg(QDomDocument & document) const
-{
- QDomElement result = document.createElement("path");
- int count = m_path.elementCount();
- QString str_path_d;
- for (int i = 0; i < count; ++i)
- {
- QPainterPath::Element e = m_path.elementAt(i);
- switch (e.type)
- {
- case QPainterPath::LineToElement:
- str_path_d.append("L " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' ');
- break;
- case QPainterPath::MoveToElement:
- str_path_d.append("M " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' ');
- break;
- case QPainterPath::CurveToElement:
- str_path_d.append("C " + QString::number(e.x) + ' ' + \
QString::number(e.y) + ' ');
- break;
- case QPainterPath::CurveToDataElement:
- str_path_d.append(QString::number(e.x) + ' ' + QString::number(e.y) + ' \
');
- break;
- }
- }
- result.setAttribute("d", str_path_d);
- result.setAttribute("fill", m_color.name());
- return result;
-}
-
-QString SolidBorderDrawer::toString() const
-{
- return factory()->drawerName().append(" [") + QString::number(m_width).append(" \
") + m_color.name().append("]");
-}
-
-SolidBorderDrawer::operator QString() const
-{
- return this->toString();
-}
-
-QVariant SolidBorderDrawer::stringNames(const QMetaProperty & property)
-{
- const char * name = property.name();
- if (!QString("corners_style").compare(name))
- return QVariant(m_corners_style_names.values());
- return QVariant();
-}
-
-QVariant SolidBorderDrawer::minimumValue(const QMetaProperty & property)
-{
- const char * name = property.name();
- if (!QString("width").compare(name))
- return 0;
- if (!QString("spacing").compare(name))
- return -100;
- return QVariant();
-}
-
-QVariant SolidBorderDrawer::maximumValue(const QMetaProperty & property)
-{
- const char * name = property.name();
- if (!QString("width").compare(name))
- return 100;
- if (!QString("spacing").compare(name))
- return 100;
- return QVariant();
-}
-
-QVariant SolidBorderDrawer::stepValue(const QMetaProperty & property)
-{
- const char * name = property.name();
- if (!QString("width").compare(name))
- return 1;
- if (!QString("spacing").compare(name))
- return 1;
- return QVariant();
-}
diff --git a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.h \
b/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.h deleted file mode \
100644 index 5f54057..0000000
--- a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_p.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ============================================================
- *
- * This file is a part of kipi-plugins project
- * http://www.kipi-plugins.org
- *
- * Date : 2011-09-01
- * Description : a plugin to create photo layouts by fusion of several images.
- * Acknowledge : based on the expoblending plugin
- *
- * Copyright (C) 2011 by Łukasz Spas <lukasz dot spas at gmail dot com>
- * Copyright (C) 2009-2011 by Gilles Caulier <caulier dot gilles at gmail dot com>
- *
- * 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, 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.
- *
- * ============================================================ */
-
-#ifndef SOLIDBORDERDRAWER_P_H
-#define SOLIDBORDERDRAWER_P_H
-
-#include "BorderDrawerInterface.h"
-
-#include <QColor>
-
-using namespace KIPIPhotoLayoutsEditor;
-
-class SolidBorderDrawerFactory;
-class SolidBorderDrawer : public BorderDrawerInterface
-{
- Q_OBJECT
- Q_INTERFACES(KIPIPhotoLayoutsEditor::BorderDrawerInterface)
-
- int m_width;
- QColor m_color;
- int m_spacing;
- Qt::PenJoinStyle m_corners_style;
- QPainterPath m_path;
-
- static QMap<const char *,QString> m_properties;
- static QMap<Qt::PenJoinStyle, QString> m_corners_style_names;
- static int m_default_width;
- static QColor m_default_color;
- static int m_default_spacing;
- static Qt::PenJoinStyle m_default_corners_style;
-
- public:
-
- explicit SolidBorderDrawer(SolidBorderDrawerFactory * factory, QObject * \
parent = 0);
-
- virtual QPainterPath path(const QPainterPath & path);
-
- virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * \
option);
-
- virtual QString propertyName(const QMetaProperty & property) const;
-
- virtual QVariant propertyValue(const QString & propertyName) const;
-
- virtual void setPropertyValue(const QString & propertyName, const QVariant & \
value);
-
- virtual QDomElement toSvg(QDomDocument & document) const;
-
- virtual QString toString() const;
-
- virtual operator QString() const;
-
- Q_PROPERTY(int width READ width WRITE setWidth)
- int width() const
- {
- return m_width;
- }
- void setWidth(int width)
- {
- if (width > 0)
- m_default_width = m_width = width;
- }
-
- Q_PROPERTY(QString corners_style READ cornersStyle WRITE setCornersStyle)
- QString cornersStyle() const
- {
- return m_corners_style_names.value(m_corners_style);
- }
- void setCornersStyle(const QString & cornersStyle)
- {
- m_default_corners_style = m_corners_style = \
m_corners_style_names.key(cornersStyle);
- }
-
- Q_PROPERTY(QColor color READ color WRITE setColor)
- QColor color() const
- {
- return m_color;
- }
- void setColor(const QColor & color)
- {
- if (color.isValid())
- m_default_color = m_color = color;
- }
-
- Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
- int spacing() const
- {
- return m_spacing;
- }
- void setSpacing(int spacing)
- {
- m_default_spacing = m_spacing = spacing;
- }
-
- virtual QVariant stringNames(const QMetaProperty & property);
- virtual QVariant minimumValue(const QMetaProperty & property);
- virtual QVariant maximumValue(const QMetaProperty & property);
- virtual QVariant stepValue(const QMetaProperty & property);
-
- private:
-
- friend class SolidBorderDrawerFactory;
-};
-
-#endif // SOLIDBORDERDRAWER_P_H
diff --git a/photolayoutseditor/borderplugins/solid/photolayoutseditorborderplugin_solid.desktop \
b/photolayoutseditor/borderplugins/solid/photolayoutseditorborderplugin_solid.desktop \
deleted file mode 100644 index 60e80f3..0000000
--- a/photolayoutseditor/borderplugins/solid/photolayoutseditorborderplugin_solid.desktop
+++ /dev/null
@@ -1,31 +0,0 @@
-[Desktop Entry]
-Name=SolidBorderDrawerFactory
-Name[ca]=SolidBorderDrawerFactory
-Name[el]=SolidBorderDrawerFactory
-Name[it]=Disegnatore di bordi solidi
-Name[nb]=SolidBorderDrawerFactory
-Name[nl]=VasteRandAanbrenger
-Name[pt]=SolidBorderDrawerFactory
-Name[pt_BR]=SolidBorderDrawerFactory
-Name[sv]=Skapa uppritare av ifylld kant
-Name[uk]=Малювання суцільної рамки
-Name[x-test]=xxSolidBorderDrawerFactoryxx
-Name[zh_TW]=SolidBorderDrawerFactory
-Type=Service
-ServiceTypes=PhotoLayoutsEditor/BorderPlugin
-Encoding=UTF-8
-Comment=Solid border drawer for Photo Layouts Editor
-Comment[ca]=Motllura sòlida per l'editor de formats de foto
-Comment[el]=Solid σχεδιαστής περιγράμματος για τον \
επεξεργαστή διατάξεων φωτογραφιών
-Comment[it]=Disegnatore di bordi solidi per l'editor di impaginazioni di foto
-Comment[nb]=Heltrukken kanttegner for fotoutleggsredigering
-Comment[nl]=Aanbrenger van vaste rand voor Foto-indelingbewerker
-Comment[pt]=Moldura sólida para o Editor de Formatos de Fotografias
-Comment[pt_BR]=Moldura sólida para o editor de formatos de fotos
-Comment[sv]=Uppritning av ifyllda kanter för fotolayouteditor
-Comment[uk]=Інструмент малювання суцільної рамки \
для редактора компонуванння \
фотографії
-Comment[x-test]=xxSolid border drawer for Photo Layouts Editorxx
-Comment[zh_TW]=相片佈局編輯器裡的實心邊框繪製器
-
-X-KDE-Library=photolayoutseditorborderplugin_solid
-author=Łukasz Spas, lukasz dot spas at gmail dot com
diff --git a/photolayoutseditor/borders/BorderChangeListener.cpp \
b/photolayoutseditor/borders/BorderChangeListener.cpp index 8e6646f..5804de9 100644
--- a/photolayoutseditor/borders/BorderChangeListener.cpp
+++ b/photolayoutseditor/borders/BorderChangeListener.cpp
@@ -53,8 +53,6 @@ class KIPIPhotoLayoutsEditor::BorderChangeCommand : public \
QUndoCommand QVariant temp = drawer->propertyValue(propertyName);
drawer->setPropertyValue(propertyName, value);
value = temp;
- if (drawer->group())
- drawer->group()->refresh();
}
virtual void undo()
{
@@ -62,8 +60,6 @@ class KIPIPhotoLayoutsEditor::BorderChangeCommand : public \
QUndoCommand QVariant temp = drawer->propertyValue(propertyName);
drawer->setPropertyValue(propertyName, value);
value = temp;
- if (drawer->group())
- drawer->group()->refresh();
}
void setPropertyValue(const QString & propertyName, const QVariant & value)
{
diff --git a/photolayoutseditor/borders/BorderDrawerFactoryInterface.h \
b/photolayoutseditor/borders/BorderDrawerFactoryInterface.h index a7792e2..75c6dc3 \
100644
--- a/photolayoutseditor/borders/BorderDrawerFactoryInterface.h
+++ b/photolayoutseditor/borders/BorderDrawerFactoryInterface.h
@@ -41,9 +41,9 @@ namespace KIPIPhotoLayoutsEditor
virtual ~BorderDrawerFactoryInterface()
{}
- virtual QString drawerName() const = 0;
+ virtual QString drawersNames() const = 0;
- virtual BorderDrawerInterface * getDrawerInstance(QObject * parent = 0) \
= 0; + virtual BorderDrawerInterface * getDrawerInstance(const QString & \
name) = 0; };
}
diff --git a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_global.h \
b/photolayoutseditor/borders/BorderDrawerInterface.cpp similarity index 77%
rename from photolayoutseditor/borderplugins/solid/SolidBorderDrawer_global.h
rename to photolayoutseditor/borders/BorderDrawerInterface.cpp
index 5987cbc..fbefef4 100644
--- a/photolayoutseditor/borderplugins/solid/SolidBorderDrawer_global.h
+++ b/photolayoutseditor/borders/BorderDrawerInterface.cpp
@@ -23,15 +23,4 @@
*
* ============================================================ */
-#ifndef SOLIDBORDERDRAWER_GLOBAL_H
-#define SOLIDBORDERDRAWER_GLOBAL_H
-
-#include <QtCore/qglobal.h>
-
-#if defined(SOLIDBORDERDRAWER_LIBRARY)
-# define SOLIDBORDERDRAWERSHARED_EXPORT Q_DECL_EXPORT
-#else
-# define SOLIDBORDERDRAWERSHARED_EXPORT Q_DECL_IMPORT
-#endif
-
-#endif // SOLIDBORDERDRAWER_GLOBAL_H
+#include "BorderDrawerInterface.moc"
diff --git a/photolayoutseditor/borders/BorderDrawerInterface.h \
b/photolayoutseditor/borders/BorderDrawerInterface.h index 226e83c..2421f7c 100644
--- a/photolayoutseditor/borders/BorderDrawerInterface.h
+++ b/photolayoutseditor/borders/BorderDrawerInterface.h
@@ -33,13 +33,14 @@
#include <QDebug>
#include <QCoreApplication>
-#include "BorderDrawerFactoryInterface.h"
-
namespace KIPIPhotoLayoutsEditor
{
class BordersGroup;
+ class BorderDrawerFactoryInterface;
class BorderDrawerInterface : public QObject
{
+ Q_OBJECT
+
BordersGroup * m_group;
BorderDrawerFactoryInterface * m_factory;
@@ -76,6 +77,7 @@ namespace KIPIPhotoLayoutsEditor
virtual QVariant stepValue(const QMetaProperty & /*property*/){ return \
QVariant(); }
virtual QDomElement toSvg(QDomDocument & document) const = 0;
+ virtual QString name() const = 0;
virtual QString toString() const = 0;
virtual operator QString() const = 0;
@@ -92,6 +94,4 @@ namespace KIPIPhotoLayoutsEditor
};
}
-Q_DECLARE_INTERFACE(KIPIPhotoLayoutsEditor::BorderDrawerInterface, \
"pl.coder89.ple.BorderDrawerInterface/1.0")
-
#endif // BORDERDRAWERINTERFACE_H
diff --git a/photolayoutseditor/borders/BorderDrawersLoader.cpp \
b/photolayoutseditor/borders/BorderDrawersLoader.cpp index 8c5acf0..3d975c1 100644
--- a/photolayoutseditor/borders/BorderDrawersLoader.cpp
+++ b/photolayoutseditor/borders/BorderDrawersLoader.cpp
@@ -70,7 +70,9 @@ BorderDrawersLoader * BorderDrawersLoader::instance(QObject * \
parent) void BorderDrawersLoader::registerDrawer(BorderDrawerFactoryInterface * \
factory) {
factory->setParent(instance());
- instance()->d->factories.insert(factory->drawerName(), factory);
+ QStringList names = factory->drawersNames().split(';', QString::SkipEmptyParts);
+ foreach (QString name, names)
+ instance()->d->factories.insert(name, factory);
}
QStringList BorderDrawersLoader::registeredDrawers()
@@ -83,23 +85,14 @@ BorderDrawerFactoryInterface * \
BorderDrawersLoader::getFactoryByName(const QStri return \
instance()->d->factories.value(name, 0); }
-BorderDrawerInterface * BorderDrawersLoader::getDrawerByName(const QString & name/*, \
const QMap<QString,QString> & properties*/) +BorderDrawerInterface * \
BorderDrawersLoader::getDrawerByName(const QString & name) {
BorderDrawerFactoryInterface * factory = getFactoryByName(name);
if (factory)
{
- BorderDrawerInterface * drawer = factory->getDrawerInstance();
+ BorderDrawerInterface * drawer = factory->getDrawerInstance(name);
if (!drawer)
return 0;
-// const QMetaObject * meta = drawer->metaObject();
-// for (int i = meta->propertyCount()-1; i >= 0; --i)
-// {
-// QMetaProperty prop = meta->property(i);
-// QString value = properties.value(QString(prop.name()));
-// if (value.isEmpty())
-// continue;
-// prop.write(drawer, QVariant(value.toAscii()));
-// }
return drawer;
}
return 0;
@@ -138,7 +131,7 @@ QDomElement \
BorderDrawersLoader::drawerToSvg(BorderDrawerInterface * drawer, QDo if (!drawer)
return QDomElement();
QDomElement result = document.createElement("g");
- result.setAttribute("name", drawer->factory()->drawerName());
+ result.setAttribute("name", drawer->name());
result.appendChild( drawer->toSvg(document) );
@@ -243,6 +236,8 @@ QWidget * BorderDrawersLoader::createEditor(BorderDrawerInterface \
* drawer, bool }
property = variantManager->addProperty(metaProperty.type(), \
propertyName);
variantManager->setValue(property, metaProperty.read(drawer));
+ foreach (QtProperty * p, property->subProperties())
+ p->setEnabled(false);
}
}
browser->addProperty(property);
diff --git a/photolayoutseditor/borders/BordersGroup.cpp \
b/photolayoutseditor/borders/BordersGroup.cpp index a22194d..43019f4 100644
--- a/photolayoutseditor/borders/BordersGroup.cpp
+++ b/photolayoutseditor/borders/BordersGroup.cpp
@@ -54,10 +54,12 @@ BordersGroup::BordersGroup(AbstractPhoto * photo) :
d(new BordersGroupPrivate(this))
{
d->photo = photo;
+ connect(this, SIGNAL(drawersChanged()), photo, SLOT(refresh()));
}
BordersGroup::~BordersGroup()
{
+ qDebug() << "PhotoEffectsGroup delete";
delete d;
}
@@ -131,6 +133,7 @@ bool BordersGroup::insertDrawer(BorderDrawerInterface * drawer, \
int position) return false;
d->borders.takeAt(position);
d->borders.insert(position, drawer);
+ connect(drawer, SIGNAL(changed()), this, SLOT(emitBordersChanged()));
return true;
}
@@ -233,8 +236,11 @@ void BordersGroup::setItem(QObject * item, const QModelIndex & \
index) return;
if (drawer == d->borders.at(row))
return;
- d->borders.removeAt(row);
+ BorderDrawerInterface * temp = d->borders.takeAt(row);
+ if (temp)
+ temp->disconnect(this);
d->borders.insert(row, drawer);
+ connect(drawer, SIGNAL(changed()), this, SLOT(emitBordersChanged()));
drawer->setGroup(this);
this->refresh();
}
@@ -284,7 +290,7 @@ QModelIndex BordersGroup::parent(const QModelIndex & /*child*/) \
const
bool BordersGroup::removeRows(int row, int count, const QModelIndex & parent)
{
- if (row >= rowCount(parent) || count < 0 || row+count > rowCount(parent))
+ if (row >= rowCount(parent) || count <= 0 || row+count > rowCount(parent))
return false;
beginRemoveRows(QModelIndex(), row, row+count-1);
while (count--)
diff --git a/photolayoutseditor/borders/BordersGroup.h \
b/photolayoutseditor/borders/BordersGroup.h index 12a7554..02b3264 100644
--- a/photolayoutseditor/borders/BordersGroup.h
+++ b/photolayoutseditor/borders/BordersGroup.h
@@ -64,6 +64,14 @@ namespace KIPIPhotoLayoutsEditor
QDomElement toSvg(QDomDocument & document);
static BordersGroup * fromSvg(QDomElement & element, AbstractPhoto * \
graphicsItem);
+ signals:
+
+ void drawersChanged();
+
+ public slots:
+
+ void refresh();
+
protected:
virtual QObject * item(const QModelIndex & index) const;
@@ -77,9 +85,12 @@ namespace KIPIPhotoLayoutsEditor
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
virtual bool moveRows(int sourcePosition, int sourceCount, int \
destPosition);
- public slots:
+ protected slots:
- void refresh();
+ void emitBordersChanged()
+ {
+ emit drawersChanged();
+ }
private:
diff --git a/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.cpp \
b/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.cpp index \
9722596..6678083 100644
--- a/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.cpp
+++ b/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.cpp
@@ -33,7 +33,8 @@ using namespace KIPIPhotoLayoutsEditor;
QColor ColorizePhotoEffect::m_last_color = QColor(255,255,255,0);
ColorizePhotoEffect::ColorizePhotoEffect(StarndardEffectsFactory * factory, QObject \
* parent) :
- AbstractPhotoEffectInterface(factory, parent)
+ AbstractPhotoEffectInterface(factory, parent),
+ m_color(m_last_color)
{
}
diff --git a/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.h \
b/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.h index \
02c044b..0b13ad5 100644
--- a/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.h
+++ b/photolayoutseditor/effectplugins/colorize/ColorizePhotoEffect.h
@@ -75,7 +75,7 @@ namespace KIPIPhotoLayoutsEditor
}
void setColor(QColor color)
{
- if (color.isValid())
+ if (!color.isValid())
return;
m_color = color;
m_last_color = color;
diff --git a/photolayoutseditor/effects/PhotoEffectChangeListener.cpp \
b/photolayoutseditor/effects/PhotoEffectChangeListener.cpp index 8c957b1..5c5df3d \
100644
--- a/photolayoutseditor/effects/PhotoEffectChangeListener.cpp
+++ b/photolayoutseditor/effects/PhotoEffectChangeListener.cpp
@@ -51,16 +51,12 @@ class KIPIPhotoLayoutsEditor::PhotoEffectChangeCommand : public \
QUndoCommand QVariant temp = effect->propertyValue(propertyName);
effect->setPropertyValue(propertyName, value);
value = temp;
- if (effect->group() && effect->group()->photo())
- effect->group()->photo()->refresh();
}
virtual void undo()
{
QVariant temp = effect->propertyValue(propertyName);
effect->setPropertyValue(propertyName, value);
value = temp;
- if (effect->group() && effect->group()->photo())
- effect->group()->photo()->refresh();
}
void setPropertyValue(const QString & propertyName, const QVariant & value)
{
diff --git a/photolayoutseditor/effects/PhotoEffectsGroup.cpp \
b/photolayoutseditor/effects/PhotoEffectsGroup.cpp index afd932d..13fddbe 100644
--- a/photolayoutseditor/effects/PhotoEffectsGroup.cpp
+++ b/photolayoutseditor/effects/PhotoEffectsGroup.cpp
@@ -38,130 +38,23 @@
using namespace KIPIPhotoLayoutsEditor;
-class KIPIPhotoLayoutsEditor::PhotoEffectsGroup::MoveItemsUndoCommand : public \
QUndoCommand
-{
- PhotoEffectsGroup * m_model;
- int m_starting_row;
- int m_rows_count;
- int m_destination_row;
-
- public:
- MoveItemsUndoCommand(int sourcePosition, int sourceCount, int destPosition, \
PhotoEffectsGroup * model, QUndoCommand * parent = 0) :
- QUndoCommand(i18n("Change effect layer"), parent),
- m_model(model),
- m_starting_row(sourcePosition),
- m_rows_count(sourceCount),
- m_destination_row(destPosition)
- {}
- virtual void redo()
- {
- if (m_model)
- {
- m_model->moveRowsInModel(m_starting_row, m_rows_count, \
m_destination_row);
- reverse();
- }
- }
- virtual void undo()
- {
- if (m_model)
- {
- m_model->moveRowsInModel(m_starting_row, m_rows_count, \
m_destination_row);
- reverse();
- }
- }
- private:
- void reverse()
- {
- int temp = m_destination_row;
- m_destination_row = m_starting_row;
- m_starting_row = temp;
- if (m_destination_row > m_starting_row)
- m_destination_row += m_rows_count;
- else
- m_starting_row -= m_rows_count;
- }
-};
-class KIPIPhotoLayoutsEditor::PhotoEffectsGroup::RemoveItemsUndoCommand : public \
QUndoCommand
-{
- int m_starting_pos;
- int m_count;
- PhotoEffectsGroup * m_model;
- QList<AbstractPhotoEffectInterface*> tempItemsList;
- public:
- RemoveItemsUndoCommand(int startingPos, int count, PhotoEffectsGroup * \
model, QUndoCommand * parent = 0) :
- QUndoCommand(i18n("Remove effect"), parent),
- m_starting_pos(startingPos),
- m_count(count),
- m_model(model)
- {}
- ~RemoveItemsUndoCommand()
- {
- qDeleteAll(tempItemsList);
- }
- virtual void redo()
- {
- tempItemsList = m_model->removeRowsInModel(m_starting_pos, m_count);
- }
- virtual void undo()
- {
- m_model->insertRemovedRowsInModel(tempItemsList, m_starting_pos);
- tempItemsList.clear();
- }
-};
-class KIPIPhotoLayoutsEditor::PhotoEffectsGroup::InsertItemUndoCommand : public \
QUndoCommand
-{
- int m_row;
- AbstractPhotoEffectInterface * m_effect;
- PhotoEffectsGroup * m_model;
- bool commandCorupped;
- bool done;
- public:
- InsertItemUndoCommand(int row, AbstractPhotoEffectInterface * effect, \
PhotoEffectsGroup * model, QUndoCommand * parent = 0) :
- QUndoCommand(i18n("Add effect"), parent),
- m_row(row),
- m_effect(effect),
- m_model(model),
- commandCorupped(false),
- done(false)
- {}
- ~InsertItemUndoCommand()
- {
- if (!done)
- m_effect->deleteLater();
- }
- virtual void redo()
- {
- if (commandCorupped || !m_model)
- return;
- if (m_model->insertRow(m_row))
- m_model->setEffectPointer(m_row,m_effect);
- else
- commandCorupped = true;
- done = true;
- }
- virtual void undo()
- {
- if (commandCorupped || !m_model)
- return;
- QList<AbstractPhotoEffectInterface*> removedList = \
m_model->removeRowsInModel(m_row,1);
- if (removedList.count() != 1 || removedList.at(0) != m_effect)
- commandCorupped = true;
- done = false;
- }
-};
-
PhotoEffectsGroup::PhotoEffectsGroup(AbstractPhoto * photo, QObject * parent) :
AbstractMovableModel(parent),
m_photo(photo)
{
+ connect(this, SIGNAL(effectsChanged()), photo, SLOT(refresh()));
+}
+
+PhotoEffectsGroup::~PhotoEffectsGroup()
+{
}
QDomElement PhotoEffectsGroup::toSvg(QDomDocument & document) const
{
QDomElement effectsGroup = document.createElement("effects");
- foreach (AbstractPhotoEffectInterface * effect, m_effects_list)
+ for (int i = m_effects_list.count()-1; i >= 0; --i)
{
- QDomElement e = PhotoEffectsLoader::effectToSvg(effect, document);
+ QDomElement e = PhotoEffectsLoader::effectToSvg(m_effects_list[i], \
document); if (e.isNull())
continue;
effectsGroup.appendChild(e);
@@ -178,7 +71,7 @@ PhotoEffectsGroup * PhotoEffectsGroup::fromSvg(const QDomElement & \
element, Abst return 0;
PhotoEffectsGroup * group = new PhotoEffectsGroup(0);
QDomNodeList effectsList = temp.childNodes();
- for (int i = 0; i < effectsList.count(); ++i)
+ for (int i = effectsList.count()-1; i >= 0; --i)
{
QDomElement effect = effectsList.at(i).toElement();
if (effect.isNull())
@@ -202,7 +95,7 @@ void PhotoEffectsGroup::push_back(AbstractPhotoEffectInterface * \
effect)
void PhotoEffectsGroup::push_front(AbstractPhotoEffectInterface * effect)
{
- m_effects_list.push_back(effect);
+ m_effects_list.push_front(effect);
connect(effect, SIGNAL(changed()), this, SLOT(emitEffectsChanged()));
effect->setParent(this);
effect->setGroup(this);
@@ -212,9 +105,12 @@ void PhotoEffectsGroup::push_front(AbstractPhotoEffectInterface \
* effect) QImage PhotoEffectsGroup::apply(const QImage & image)
{
QImage temp = image;
- foreach (AbstractPhotoEffectInterface * effect, m_effects_list)
+ for (int i = m_effects_list.count()-1; i >= 0; --i)
+ {
+ AbstractPhotoEffectInterface * effect = m_effects_list[i];
if (effect)
temp = effect->apply(temp);
+ }
return temp;
}
@@ -238,10 +134,14 @@ void PhotoEffectsGroup::setItem(QObject * item, const \
QModelIndex & index) int row = index.row();
if (row < 0 || row >= rowCount())
return;
+ AbstractPhotoEffectInterface * temp = m_effects_list.takeAt(row);
+ if (temp)
+ temp->disconnect(this);
m_effects_list.removeAt(row);
m_effects_list.insert(row, effect);
effect->setParent(this);
effect->setGroup(this);
+ connect(effect, SIGNAL(changed()), this, SLOT(emitEffectsChanged()));
emitEffectsChanged(effect);
}
@@ -251,35 +151,27 @@ AbstractPhotoEffectInterface * \
PhotoEffectsGroup::graphicsItem(const QModelIndex }
bool PhotoEffectsGroup::moveRows(int sourcePosition, int sourceCount, int \
destPosition)
-{
- if ( sourceCount &&
- sourcePosition < rowCount() &&
- sourcePosition+sourceCount <= rowCount() &&
- destPosition <= rowCount() &&
- sourcePosition != destPosition &&
- sourcePosition != destPosition-1 &&
- sourcePosition >= 0 &&
- destPosition >= 0)
- {
- QUndoCommand * command = new MoveItemsUndoCommand(sourcePosition, \
sourceCount, destPosition, this);
- PLE_PostUndoCommand(command);
- return true;
- }
- return false;
-}
-
-bool PhotoEffectsGroup::insertRow(int row, AbstractPhotoEffectInterface * effect)
-{
- if (row < 0 || row > rowCount() || !effect)
+{
+ if ( (sourcePosition <= destPosition && sourcePosition+sourceCount >= \
destPosition) || + sourceCount <= 0 ||
+ m_effects_list.count() <= sourcePosition+sourceCount-1 ||
+ sourcePosition < 0 ||
+ destPosition < 0 ||
+ m_effects_list.count() < destPosition)
return false;
- QUndoCommand * command = new InsertItemUndoCommand(row,effect,this);
- PLE_PostUndoCommand(command);
- return true;
-}
-bool PhotoEffectsGroup::insertRow(int row, const QModelIndex & index)
-{
- return QAbstractItemModel::insertRow(row,index);
+ beginMoveRows(QModelIndex(), sourcePosition, sourcePosition+sourceCount-1, \
QModelIndex(), destPosition); + QList<AbstractPhotoEffectInterface*> movingItems;
+ if (destPosition > sourcePosition)
+ destPosition -= sourceCount;
+ while(sourceCount--)
+ movingItems.push_back(m_effects_list.takeAt(sourcePosition));
+ for ( ; movingItems.count() ; movingItems.pop_back())
+ m_effects_list.insert(destPosition, movingItems.last());
+ endMoveRows();
+ this->emitEffectsChanged();
+ emit layoutChanged();
+ return true;
}
int PhotoEffectsGroup::columnCount(const QModelIndex & /*parent*/) const
@@ -320,7 +212,7 @@ QModelIndex PhotoEffectsGroup::index(int row, int column, const \
QModelIndex & pa return QModelIndex();
if (parent.isValid())
return QModelIndex();
- return createIndex(row,column,m_effects_list.at(rowCount()-row-1));
+ return createIndex(row,column,m_effects_list.at(row));
}
bool PhotoEffectsGroup::insertRows(int row, int count, const QModelIndex & parent)
@@ -328,7 +220,6 @@ bool PhotoEffectsGroup::insertRows(int row, int count, const \
QModelIndex & paren if (row < 0 || row > rowCount() || count < 1 || \
parent.isValid()) return false;
beginInsertRows(parent, row, row+count-1);
- row = rowCount()-row;
while(count--)
m_effects_list.insert(row,0);
endInsertRows();
@@ -351,7 +242,7 @@ int PhotoEffectsGroup::rowCount(const QModelIndex & parent) const
bool PhotoEffectsGroup::removeRows(int row, int count, const QModelIndex & parent)
{
- if (!count || parent.isValid() || row < 0 || row >= rowCount() || row+count-1 >= \
rowCount()) + if (count <= 0 || parent.isValid() || row < 0 || row >= \
rowCount(parent) || row+count > rowCount(parent)) return false;
beginRemoveRows(QModelIndex(), row, row+count-1);
while (count--)
@@ -369,7 +260,7 @@ void \
PhotoEffectsGroup::emitEffectsChanged(AbstractPhotoEffectInterface * effect \
m_photo->refresh(); if (effect)
{
- int row = m_effects_list.count()-m_effects_list.indexOf(effect)-1;
+ int row = m_effects_list.indexOf(effect);
QModelIndex indexChanged = index(row,0);
emit dataChanged(indexChanged,indexChanged);
}
@@ -377,91 +268,3 @@ void \
PhotoEffectsGroup::emitEffectsChanged(AbstractPhotoEffectInterface * effect emit \
dataChanged(index(0,0),index(rowCount()-1,0)); emit effectsChanged();
}
-
-void PhotoEffectsGroup::moveRowsInModel(int sourcePosition, int sourceCount, int \
destPosition)
-{
- beginMoveRows(QModelIndex(), sourcePosition, sourcePosition+sourceCount-1, \
QModelIndex(), destPosition);
-
- // Inverse directions becouse effects stack is presented in reverse order
- destPosition = rowCount()-destPosition;
- sourcePosition = rowCount()-sourcePosition-1;
-
- QList<AbstractPhotoEffectInterface*> movingItems;
- if (destPosition > sourcePosition)
- destPosition -= sourceCount;
- while(sourceCount--)
- movingItems.push_back(m_effects_list.takeAt(sourcePosition));
- for ( ; movingItems.count() ; movingItems.pop_back())
- m_effects_list.insert(destPosition, movingItems.last());
-
- endMoveRows();
- emitEffectsChanged();
- emit layoutChanged();
-}
-
-QList<AbstractPhotoEffectInterface*> PhotoEffectsGroup::removeRowsInModel(int \
startingPosition, int count)
-{
- beginRemoveRows(QModelIndex(), startingPosition, startingPosition+count-1);
-
- // Inverse directions becouse effects stack is presented in reverse order
- startingPosition = rowCount()-startingPosition-1;
-
- QList<AbstractPhotoEffectInterface*> removedItems;
- int removedCount = 0;
- while (count--)
- {
- AbstractPhotoEffectInterface * temp = \
m_effects_list.takeAt(startingPosition);
- if (temp)
- {
- ++removedCount;
- removedItems.push_back(temp);
- temp->setParent(0);
- temp->setGroup(0);
- }
- }
-
- endRemoveRows();
-
- // Prevent emmiting changes then empty row is removed
- if (removedCount)
- emitEffectsChanged();
-
- emit layoutChanged();
-
- return removedItems;
-}
-
-void PhotoEffectsGroup::insertRemovedRowsInModel(const \
QList<AbstractPhotoEffectInterface*> & itemList, int \
startingPosition)
-{
- beginInsertRows(QModelIndex(), startingPosition, \
startingPosition+itemList.count()-1);
-
- // Inverse directions becouse effects stack is presented in reverse order
- startingPosition = rowCount()-startingPosition;
-
- foreach (AbstractPhotoEffectInterface * effect, itemList)
- {
- m_effects_list.insert(startingPosition, effect);
- ++startingPosition;
- effect->setParent(this);
- effect->setGroup(this);
- }
-
- endInsertRows();
- emitEffectsChanged();
- emit layoutChanged();
-}
-
-void PhotoEffectsGroup::setEffectPointer(int row, AbstractPhotoEffectInterface * \
effect)
-{
- if (row < 0 || row >= rowCount())
- return;
- int effectiveRow = rowCount()-row-1;
- AbstractPhotoEffectInterface * temp = m_effects_list[effectiveRow];
- if (temp)
- delete temp;
- m_effects_list[effectiveRow] = effect;
- effect->setParent(this);
- effect->setGroup(this);
- emitEffectsChanged(effect);
- emit dataChanged(index(row,0),index(row,0));
-}
diff --git a/photolayoutseditor/effects/PhotoEffectsGroup.h \
b/photolayoutseditor/effects/PhotoEffectsGroup.h index 0a8804d..f4c8ee5 100644
--- a/photolayoutseditor/effects/PhotoEffectsGroup.h
+++ b/photolayoutseditor/effects/PhotoEffectsGroup.h
@@ -44,13 +44,10 @@ namespace KIPIPhotoLayoutsEditor
AbstractPhoto * m_photo;
QList<AbstractPhotoEffectInterface*> m_effects_list;
- class MoveItemsUndoCommand;
- class RemoveItemsUndoCommand;
- class InsertItemUndoCommand;
-
public:
explicit PhotoEffectsGroup(AbstractPhoto * photo, QObject * parent = 0);
+ ~PhotoEffectsGroup();
QDomElement toSvg(QDomDocument & document) const;
static PhotoEffectsGroup * fromSvg(const QDomElement & element, \
AbstractPhoto * graphicsItem); AbstractPhoto * photo() const;
@@ -82,17 +79,7 @@ namespace KIPIPhotoLayoutsEditor
void emitEffectsChanged(AbstractPhotoEffectInterface * effect = 0);
QImage apply(const QImage & image);
- private:
-
- void moveRowsInModel(int sourcePosition, int sourceCount, int \
destPosition);
- QList<AbstractPhotoEffectInterface*> removeRowsInModel(int \
startingPosition, int count);
- void insertRemovedRowsInModel(const QList<AbstractPhotoEffectInterface*> \
& itemList, int startingPosition);
- void setEffectPointer(int row, AbstractPhotoEffectInterface * effect);
-
friend class AbstractPhoto;
- friend class MoveItemsUndoCommand;
- friend class RemoveItemsUndoCommand;
- friend class InsertItemUndoCommand;
};
}
diff --git a/photolayoutseditor/effects/PhotoEffectsLoader.cpp \
b/photolayoutseditor/effects/PhotoEffectsLoader.cpp index 2c98cf0..2b24ffc 100644
--- a/photolayoutseditor/effects/PhotoEffectsLoader.cpp
+++ b/photolayoutseditor/effects/PhotoEffectsLoader.cpp
@@ -123,10 +123,6 @@ QtAbstractPropertyBrowser * \
PhotoEffectsLoader::propertyBrowser(AbstractPhotoEff QtDoublePropertyManager * \
doubleManager = 0; KDoubleSpinBoxFactory * doubleFactory = 0;
- // QVariant::Color
- QtColorPropertyManager * colorManager = 0;
- KColorEditorFactory * colorFactory = 0;
-
// QVariant others....
QtVariantPropertyManager * variantManager = 0;
KVariantEditorFactory * variantFactory = 0;
@@ -172,19 +168,6 @@ QtAbstractPropertyBrowser * \
PhotoEffectsLoader::propertyBrowser(AbstractPhotoEff
integerManager->setSingleStep(property, \
effect->maximumValue(metaProperty).toDouble()); }
break;
- case QVariant::Color:
- {
- if (!colorManager || !colorFactory)
- {
- colorManager = new QtColorPropertyManager(browser);
- colorFactory = new KColorEditorFactory(browser);
- browser->setFactoryForManager(colorManager,colorFactory);
- }
- property = colorManager->addProperty(propertyName);
- colorManager->setValue(property, \
metaProperty.read(effect).value<QColor>());
- browser->addProperty(property);
- }
- break;
default:
{
if (!variantManager || !variantFactory)
@@ -195,6 +178,8 @@ QtAbstractPropertyBrowser * \
PhotoEffectsLoader::propertyBrowser(AbstractPhotoEff }
property = variantManager->addProperty(metaProperty.type(), \
propertyName);
variantManager->setValue(property, metaProperty.read(effect));
+ foreach (QtProperty * p, property->subProperties())
+ p->setEnabled(false);
}
}
if (property)
@@ -207,11 +192,6 @@ QtAbstractPropertyBrowser * \
PhotoEffectsLoader::propertyBrowser(AbstractPhotoEff
connect(doubleManager,SIGNAL(propertyChanged(QtProperty*)),listener,SLOT(propertyChanged(QtProperty*)));
connect(doubleFactory,SIGNAL(editingFinished()),listener,SLOT(editingFinished()));
}
- if (colorManager && colorFactory)
- {
- connect(colorManager,SIGNAL(propertyChanged(QtProperty*)),listener,SLOT(propertyChanged(QtProperty*)));
- connect(colorFactory,SIGNAL(editingFinished()),listener,SLOT(editingFinished()));
- }
if (variantManager && variantFactory)
{
connect(variantManager,SIGNAL(propertyChanged(QtProperty*)),listener,SLOT(propertyChanged(QtProperty*)));
diff --git a/photolayoutseditor/plugin/photolayoutseditor.cpp \
b/photolayoutseditor/plugin/photolayoutseditor.cpp index 9845c51..00738f0 100644
--- a/photolayoutseditor/plugin/photolayoutseditor.cpp
+++ b/photolayoutseditor/plugin/photolayoutseditor.cpp
@@ -80,6 +80,7 @@
#include "PLEConfigSkeleton.h"
#include "PLEAboutData.h"
#include "StarndardEffectsFactory.h"
+#include "StandardBordersFactory.h"
#include "global.h"
#include "ProgressEvent.h"
#include "BorderDrawerInterface.h"
@@ -153,7 +154,7 @@ PhotoLayoutsEditor::~PhotoLayoutsEditor()
PLEConfigSkeleton::self()->writeConfig();
if (m_canvas)
- delete m_canvas;
+ m_canvas->deleteLater();
if (d)
delete d;
@@ -754,6 +755,9 @@ void PhotoLayoutsEditor::loadEffects()
void PhotoLayoutsEditor::loadBorders()
{
+ StandardBordersFactory * stdBorders = new StandardBordersFactory( \
BorderDrawersLoader::instance() ); + BorderDrawersLoader::registerDrawer( \
stdBorders ); +
const KService::List offers = \
KServiceTypeTrader::self()->query("PhotoLayoutsEditor/BorderPlugin"); foreach (const \
KService::Ptr& service, offers) {
diff --git a/photolayoutseditor/threads/AbstractPhotoItemLoader.cpp \
b/photolayoutseditor/threads/AbstractPhotoItemLoader.cpp index 5c9df1e..663dd2b \
100644
--- a/photolayoutseditor/threads/AbstractPhotoItemLoader.cpp
+++ b/photolayoutseditor/threads/AbstractPhotoItemLoader.cpp
@@ -144,6 +144,8 @@ void AbstractPhotoItemLoader::run()
m_item->d->m_borders_group = BordersGroup::fromSvg(itemDataElement, m_item);
if (!m_item->d->m_borders_group)
this->exit(1);
+ else
+ connect(m_item->d->m_borders_group, SIGNAL(drawersChanged()), m_item, \
SLOT(refresh()));
QDomElement clipPath = defs.firstChildElement("clipPath");
if (clipPath.isNull() || clipPath.attribute("id") != "clipPath_"+m_item->id())
@@ -168,6 +170,8 @@ void AbstractPhotoItemLoader::run()
m_item->d->m_effects_group = PhotoEffectsGroup::fromSvg(appNS, m_item);
if (!m_item->d->m_effects_group)
this->exit(1);
+ else
+ connect(m_item->d->m_effects_group, SIGNAL(effectsChanged()), m_item, \
SLOT(refresh()));
if (observer)
{
diff --git a/photolayoutseditor/widgets/canvas/RotationWidgetItem.cpp \
b/photolayoutseditor/widgets/canvas/RotationWidgetItem.cpp index d23d06c..4776da8 \
100644
--- a/photolayoutseditor/widgets/canvas/RotationWidgetItem.cpp
+++ b/photolayoutseditor/widgets/canvas/RotationWidgetItem.cpp
@@ -264,6 +264,7 @@ void RotationWidgetItem::mousePressEvent(QGraphicsSceneMouseEvent \
* event) else
d->elipse_pressed = false;
this->setCursor(QCursor(Qt::ClosedHandCursor));
+ event->setAccepted(true);
}
void RotationWidgetItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * /*event*/)
diff --git a/photolayoutseditor/widgets/items/AbstractPhoto.cpp \
b/photolayoutseditor/widgets/items/AbstractPhoto.cpp index 28fbe99..cba9b06 100644
--- a/photolayoutseditor/widgets/items/AbstractPhoto.cpp
+++ b/photolayoutseditor/widgets/items/AbstractPhoto.cpp
@@ -117,6 +117,7 @@ AbstractPhoto::AbstractPhoto(const QString & name, Scene * scene) \
:
AbstractPhoto::~AbstractPhoto()
{
+ qDebug() << "Abstractphoto delete";
d->m_effects_group->deleteLater();
d->m_borders_group->deleteLater();
delete d;
diff --git a/photolayoutseditor/widgets/items/TextItem.cpp \
b/photolayoutseditor/widgets/items/TextItem.cpp index b7fa530..e0765f4 100644
--- a/photolayoutseditor/widgets/items/TextItem.cpp
+++ b/photolayoutseditor/widgets/items/TextItem.cpp
@@ -758,6 +758,8 @@ QtAbstractPropertyBrowser * TextItem::propertyBrowser()
TextColorChangeListener * colorListener = new TextColorChangeListener(this);
colorListener->connect(browser, SIGNAL(destroyed()), SLOT(deleteLater()));
colorListener->connect(colorManager, SIGNAL(propertyChanged(QtProperty*)), \
SLOT(propertyChanged(QtProperty*))); + foreach (QtProperty * p, \
colorProperty->subProperties()) + p->setEnabled(false);
// Font
QtFontPropertyManager * fontManager = new QtFontPropertyManager(browser);
@@ -769,6 +771,8 @@ QtAbstractPropertyBrowser * TextItem::propertyBrowser()
TextFontChangeListener * fontListener = new TextFontChangeListener(this);
fontListener->connect(browser, SIGNAL(destroyed()), SLOT(deleteLater()));
fontListener->connect(fontManager, SIGNAL(propertyChanged(QtProperty*)), \
SLOT(propertyChanged(QtProperty*))); + foreach (QtProperty * p, \
fontProperty->subProperties()) + p->setEnabled(false);
return browser;
}
diff --git a/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.cpp \
b/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.cpp index \
560efa1..4dc6d0b 100644
--- a/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.cpp
+++ b/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.cpp
@@ -23,8 +23,8 @@
*
* ============================================================ */
-#include "AbstractItemsListViewTool.moc"
-#include "AbstractItemsListViewTool_p.moc"
+#include "AbstractItemsListViewTool.h"
+#include "AbstractItemsListViewTool_p.h"
#include "AbstractPhoto.h"
#include "ToolsDockWidget.h"
#include "BorderDrawersLoader.h"
@@ -155,7 +155,7 @@ class KIPIPhotoLayoutsEditor::AbstractItemsListViewToolPrivate
m_remove_button(0),
m_down_button(0),
m_up_button(0),
- m_opened_editor(0,QModelIndex()),
+ m_delegate(0),
m_editors_object(0)
{}
AbstractListToolView * m_list_widget;
@@ -163,25 +163,14 @@ class KIPIPhotoLayoutsEditor::AbstractItemsListViewToolPrivate
KPushButton * m_remove_button;
KPushButton * m_down_button;
KPushButton * m_up_button;
- QPair<AbstractListToolViewDelegate*,QPersistentModelIndex> m_opened_editor;
+ AbstractListToolViewDelegate * m_delegate;
QObject * m_editors_object;
void closeChooser()
{
- if (m_opened_editor.first)
- m_opened_editor.first->deleteLater();
- m_opened_editor.first = 0;
- m_opened_editor.second = QPersistentModelIndex();
- m_editors_object = 0;
- }
-
- void removeChoosed()
- {
- if (m_opened_editor.second.isValid() && \
!m_opened_editor.second.internalPointer())
- const_cast<QAbstractItemModel*>(m_opened_editor.second.model())->removeRow(m_opened_editor.second.row());
- if (m_editors_object)
- m_editors_object->deleteLater();
- m_editors_object = 0;
+ if (m_delegate)
+ m_delegate->deleteLater();
+ m_delegate = 0;
}
void setButtonsEnabled(bool isEnabled)
@@ -253,13 +242,15 @@ AbstractItemsListViewTool::AbstractItemsListViewTool(const \
QString & toolName, S
AbstractItemsListViewTool::~AbstractItemsListViewTool()
{
- this->chooserCancelled();
+ if (d->m_delegate)
+ d->m_delegate->editorAccepted();
delete d;
}
void AbstractItemsListViewTool::currentItemAboutToBeChanged()
{
- this->chooserCancelled();
+ if (d->m_delegate)
+ d->m_delegate->editorAccepted();
}
void AbstractItemsListViewTool::currentItemChanged()
@@ -272,7 +263,19 @@ void AbstractItemsListViewTool::viewCurrentEditor(const \
QModelIndex & index) {
closeEditor();
d->setButtonsEnabled(true);
- QWidget * editor = createEditor(static_cast<QObject*>(index.internalPointer()), \
(static_cast<QObject*>(index.internalPointer()) != d->m_editors_object)); + \
QWidget * editor = createEditor(static_cast<QObject*>(index.internalPointer()), \
true); + if (editor)
+ {
+ static_cast<QGridLayout*>(layout())->addWidget(editor,2,0,1,-1);
+ editor->show();
+ }
+}
+
+void AbstractItemsListViewTool::viewCurrentEditor(QObject * object)
+{
+ closeEditor();
+ d->setButtonsEnabled(true);
+ QWidget * editor = createEditor(object, false);
if (editor)
{
static_cast<QGridLayout*>(layout())->addWidget(editor,2,0,1,-1);
@@ -293,58 +296,25 @@ void AbstractItemsListViewTool::createChooser()
model->insertRow(row);
// Create chooser
- AbstractListToolViewDelegate * w = new AbstractListToolViewDelegate(this);
- d->m_opened_editor.first = w;
- d->m_opened_editor.second = QPersistentModelIndex(model->index(row,0));
- d->m_list_widget->setIndexWidget(model->index(row,0),w);
-
+ d->m_delegate = new AbstractListToolViewDelegate(model, model->index(row,0), \
this); + d->m_list_widget->setIndexWidget(model->index(row,0),d->m_delegate);
d->m_list_widget->setSelectionMode(QAbstractItemView::NoSelection);
- connect(w,SIGNAL(editorAccepted()),this,SLOT(chooserAccepted()));
- connect(w,SIGNAL(editorClosed()),this,SLOT(chooserCancelled()));
- connect(w,SIGNAL(itemSelected(QString)),this,SLOT(itemSelected(QString)));
+ connect(d->m_delegate,SIGNAL(editorClosed()),this,SLOT(closeChooser()));
+ connect(d->m_delegate,SIGNAL(showEditor(QObject*)),this,SLOT(viewCurrentEditor(QObject*)));
d->setButtonsEnabled(false);
d->m_list_widget->setSelection(QRect(),QItemSelectionModel::Clear);
}
}
-void AbstractItemsListViewTool::itemSelected(const QString & name)
+void AbstractItemsListViewTool::closeChooser()
{
- AbstractListToolViewDelegate * w = d->m_opened_editor.first;
- AbstractMovableModel * model = this->model();
- if (model && w)
- {
- if ((d->m_editors_object = createItem(name)))
- {
- model->setItem(d->m_editors_object, d->m_opened_editor.second);
- QWidget * editor = createEditor(d->m_editors_object, false);
- if (editor)
- {
- static_cast<QGridLayout*>(layout())->addWidget(editor,2,0,1,-1);
- editor->show();
- }
- }
- }
-}
-
-void AbstractItemsListViewTool::chooserAccepted()
-{
- addItemCommand(d->m_editors_object, d->m_opened_editor.second.row());
closeEditor();
d->closeChooser();
d->m_list_widget->setSelectionMode(QAbstractItemView::SingleSelection);
d->setButtonsEnabled(true);
}
-void AbstractItemsListViewTool::chooserCancelled()
-{
- closeEditor();
- d->removeChoosed();
- d->closeChooser();
- d->m_list_widget->setSelectionMode(QAbstractItemView::SingleSelection);
- d->setButtonsEnabled(true);
-}
-
void AbstractItemsListViewTool::removeSelected()
{
if (!d->m_list_widget)
@@ -413,18 +383,14 @@ void AbstractItemsListViewTool::closeEditor()
browser->deleteLater();
}
-void AbstractItemsListViewTool::addItemCommand(QObject * item, int row)
-{
- AbstractMovableModel * model = this->model();
- if (!item || !model)
- return;
- ItemCreatedCommand * command = new ItemCreatedCommand(item, row, model);
- PLE_PostUndoCommand(command);
-}
-
-AbstractListToolViewDelegate::AbstractListToolViewDelegate(AbstractItemsListViewTool \
* parent) :
- QWidget(parent)
+AbstractListToolViewDelegate::AbstractListToolViewDelegate(AbstractMovableModel * \
model, QModelIndex index, AbstractItemsListViewTool * parent) : + QWidget(parent),
+ m_parent(parent),
+ m_model(model),
+ m_index(index),
+ m_object(0)
{
+ // GUI setup
QHBoxLayout * layout = new QHBoxLayout();
layout->setSpacing(0);
layout->setMargin(0);
@@ -433,15 +399,50 @@ \
AbstractListToolViewDelegate::AbstractListToolViewDelegate(AbstractItemsListView \
KComboBox * comboBox = new KComboBox(this); comboBox->addItems(registeredDrawers);
comboBox->setCurrentIndex(-1);
- connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(emitItemSelected(QString)));
+ connect(comboBox,SIGNAL(currentIndexChanged(QString)),this,SLOT(itemSelected(QString)));
layout->addWidget(comboBox,1);
m_acceptButton = new KPushButton(KIcon(":action_check.png"), "", this);
m_acceptButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
m_acceptButton->setEnabled(false);
- connect(m_acceptButton,SIGNAL(clicked()),this,SLOT(emitEditorAccepted()));
+ connect(m_acceptButton,SIGNAL(clicked()),this,SLOT(editorAccepted()));
layout->addWidget(m_acceptButton);
KPushButton * cancelButton = new KPushButton(KIcon(":action_delete.png"), "", \
this);
cancelButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum);
- connect(cancelButton,SIGNAL(clicked()),this,SLOT(emitEditorClosed()));
+ connect(cancelButton,SIGNAL(clicked()),this,SLOT(editorCancelled()));
layout->addWidget(cancelButton);
}
+
+void AbstractListToolViewDelegate::editorCancelled()
+{
+ if (m_index.isValid() && !m_index.internalPointer())
+ m_model->removeRow(m_index.row());
+ if (m_object)
+ m_object->deleteLater();
+ m_object = 0;
+ emit editorClosed();
+}
+
+void AbstractListToolViewDelegate::editorAccepted()
+{
+ qDebug() << "isAccepted sent" << m_object << m_model;
+ if (!m_object || !m_model)
+ return;
+ qDebug() << "isAccepted sent";
+ ItemCreatedCommand * command = new ItemCreatedCommand(m_object, m_index.row(), \
m_model); + PLE_PostUndoCommand(command);
+ emit editorClosed();
+}
+
+void AbstractListToolViewDelegate::itemSelected(const QString & selectedItem)
+{
+ if (m_model)
+ {
+ if ((m_object = m_parent->createItem(selectedItem)))
+ {
+ m_model->setItem(m_object, m_index);
+ emit showEditor(m_object);
+ }
+ }
+
+ m_acceptButton->setEnabled(!selectedItem.isEmpty());
+}
diff --git a/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.h \
b/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.h index 894de11..0c5edea \
100644
--- a/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.h
+++ b/photolayoutseditor/widgets/tools/AbstractItemsListViewTool.h
@@ -42,7 +42,7 @@ namespace KIPIPhotoLayoutsEditor
public:
explicit AbstractItemsListViewTool(const QString & toolsName, Scene * \
scene, Canvas::SelectionMode selectionMode, QWidget * parent = 0);
- ~AbstractItemsListViewTool();
+ virtual ~AbstractItemsListViewTool();
virtual void currentItemAboutToBeChanged();
virtual void currentItemChanged();
virtual void positionAboutToBeChanged(){} // Unused
@@ -54,12 +54,10 @@ namespace KIPIPhotoLayoutsEditor
virtual AbstractMovableModel * model() = 0;
void viewCurrentEditor(const QModelIndex & index);
+ void viewCurrentEditor(QObject * object);
virtual QWidget * createEditor(QObject * item, bool createCommands = \
true) = 0; void createChooser();
- void itemSelected(const QString & selectedItem);
- virtual void addItemCommand(QObject * item, int row);
- void chooserAccepted();
- void chooserCancelled();
+ void closeChooser();
void removeSelected();
void moveSelectedDown();
void moveSelectedUp();
diff --git a/photolayoutseditor/widgets/tools/AbstractItemsListViewTool_p.h \
b/photolayoutseditor/widgets/tools/AbstractItemsListViewTool_p.h index \
d19bb21..015fbd0 100644
--- a/photolayoutseditor/widgets/tools/AbstractItemsListViewTool_p.h
+++ b/photolayoutseditor/widgets/tools/AbstractItemsListViewTool_p.h
@@ -33,31 +33,29 @@
namespace KIPIPhotoLayoutsEditor
{
class AbstractItemsListViewTool;
+ class AbstractMovableModel;
class AbstractListToolViewDelegate : public QWidget
{
- KPushButton * m_acceptButton;
Q_OBJECT
+
+ KPushButton * m_acceptButton;
+ AbstractItemsListViewTool * m_parent;
+ AbstractMovableModel * m_model;
+ QModelIndex m_index;
+ QObject * m_object;
+
public:
- AbstractListToolViewDelegate(AbstractItemsListViewTool * parent = 0);
+ AbstractListToolViewDelegate(AbstractMovableModel * model, QModelIndex \
index, AbstractItemsListViewTool * parent); signals:
void editorClosed();
+ void showEditor(QObject * object);
+ protected slots:
void editorAccepted();
+ void editorCancelled();
void itemSelected(const QString & selectedItem);
- protected slots:
- void emitEditorClosed()
- {
- emit editorClosed();
- }
- void emitEditorAccepted()
- {
- emit editorAccepted();
- }
- void emitItemSelected(const QString & selectedItem)
- {
- m_acceptButton->setEnabled(!selectedItem.isEmpty());
- emit itemSelected(selectedItem);
- }
+
+ friend class AbstractItemsListViewTool;
};
class AbstractListToolView : public QListView
diff --git a/photolayoutseditor/widgets/tools/AbstractItemsTool.cpp \
b/photolayoutseditor/widgets/tools/AbstractItemsTool.cpp index 390360c..40b753a \
100644
--- a/photolayoutseditor/widgets/tools/AbstractItemsTool.cpp
+++ b/photolayoutseditor/widgets/tools/AbstractItemsTool.cpp
@@ -30,7 +30,8 @@
using namespace KIPIPhotoLayoutsEditor;
AbstractItemsTool::AbstractItemsTool(Scene * scene, Canvas::SelectionMode \
selectionMode, QWidget * parent) :
- AbstractTool(scene, selectionMode, parent)
+ AbstractTool(scene, selectionMode, parent),
+ m_photo(0)
{
}
diff --git a/photolayoutseditor/widgets/tools/EffectsEditorTool.cpp \
b/photolayoutseditor/widgets/tools/EffectsEditorTool.cpp index 229f731..d7b7360 \
100644
--- a/photolayoutseditor/widgets/tools/EffectsEditorTool.cpp
+++ b/photolayoutseditor/widgets/tools/EffectsEditorTool.cpp
@@ -60,7 +60,7 @@ AbstractMovableModel * EffectsEditorTool::model()
QObject * EffectsEditorTool::createItem(const QString & name)
{
- return PhotoEffectsLoader::getEffectByName(name);\
+ return PhotoEffectsLoader::getEffectByName(name);
}
QWidget * EffectsEditorTool::createEditor(QObject * item, bool createCommands)
diff --git a/photolayoutseditor/widgets/tools/ToolsDockWidget.cpp \
b/photolayoutseditor/widgets/tools/ToolsDockWidget.cpp index 13bae53..2f6fdb3 100644
--- a/photolayoutseditor/widgets/tools/ToolsDockWidget.cpp
+++ b/photolayoutseditor/widgets/tools/ToolsDockWidget.cpp
@@ -266,6 +266,7 @@ void ToolsDockWidget::itemSelected(AbstractPhoto * photo)
AbstractItemsTool * tool =qobject_cast<AbstractItemsTool*>(w);
if (tool)
tool->setCurrentItem(photo);
+ qDebug() << tool;
}
void ToolsDockWidget::mousePositionChoosen(const QPointF & position)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic