diff --git a/libs/flake/resources/KoSvgSymbolCollectionResource.cpp b/libs/flake/resources/KoSvgSymbolCollectionResource.cpp index 535a9c3d70..d9beb8cb3a 100644 --- a/libs/flake/resources/KoSvgSymbolCollectionResource.cpp +++ b/libs/flake/resources/KoSvgSymbolCollectionResource.cpp @@ -1,237 +1,245 @@ /* This file is part of the KDE project Copyright (c) 2017 L. E. Segovia This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include #include #include #include #include #include #include #include #include #include #include #include #include "kis_debug.h" #include #include #include #include #include #include struct KoSvgSymbolCollectionResource::Private { QVector symbols; QString title; QString description; }; KoSvgSymbolCollectionResource::KoSvgSymbolCollectionResource(const QString& filename) : KoResource(filename) , d(new Private()) { } KoSvgSymbolCollectionResource::KoSvgSymbolCollectionResource() : KoResource(QString()) , d(new Private()) { } KoSvgSymbolCollectionResource::KoSvgSymbolCollectionResource(const KoSvgSymbolCollectionResource& rhs) : QObject(0) , KoResource(QString()) , d(new Private()) { setFilename(rhs.filename()); d->symbols = rhs.d->symbols; setValid(true); } KoSvgSymbolCollectionResource::~KoSvgSymbolCollectionResource() { } bool KoSvgSymbolCollectionResource::load() { qDebug() << "Going to load" << filename(); QFile file(filename()); if (file.size() == 0) return false; if (!file.open(QIODevice::ReadOnly)) { return false; } bool res = loadFromDevice(&file); file.close(); return res; } void paintGroup(KoShapeGroup *group, QPainter &painter, const KoViewConverter &converter, KoShapePaintingContext &paintContext) { QList shapes = group->shapes(); qSort(shapes.begin(), shapes.end(), KoShape::compareShapeZIndex); Q_FOREACH (KoShape *child, shapes) { // we paint recursively here, so we do not have to check recursively for visibility if (!child->isVisible()) continue; KoShapeGroup *childGroup = dynamic_cast(child); if (childGroup) { paintGroup(childGroup, painter, converter, paintContext); } else { painter.save(); KoShapeManager::renderSingleShape(child, painter, converter, paintContext); painter.restore(); } } } bool KoSvgSymbolCollectionResource::loadFromDevice(QIODevice *dev) { if (!dev->isOpen()) dev->open(QIODevice::ReadOnly); KoXmlDocument doc; QString errorMsg; int errorLine = 0; int errorColumn; bool ok = doc.setContent(dev->readAll(), false, &errorMsg, &errorLine, &errorColumn); if (!ok) { errKrita << "Parsing error in " << filename() << "! Aborting!" << endl << " In line: " << errorLine << ", column: " << errorColumn << endl << " Error message: " << errorMsg << endl; errKrita << i18n("Parsing error in the main document at line %1, column %2\nError message: %3" , errorLine , errorColumn , errorMsg); return false; } KoDocumentResourceManager manager; SvgParser parser(&manager); parser.setResolution(QRectF(0,0,100,100), 72); // initialize with default values QSizeF fragmentSize; // We're not interested in the shapes themselves qDeleteAll(parser.parseSvg(doc.documentElement(), &fragmentSize)); d->symbols = parser.takeSymbols(); qDebug() << "Loaded" << filename() << "\n\t" << "Title" << parser.documentTitle() << "\n\t" << "Description" << parser.documentDescription() << "\n\tgot" << d->symbols.size() << "symbols" << d->symbols[0]->shape->outlineRect() << d->symbols[0]->shape->size(); d->title = parser.documentTitle(); + setName(d->title); d->description = parser.documentDescription(); if (d->symbols.size() < 1) { setValid(false); return false; } setValid(true);; - QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); - QPainter gc(&image); - image.fill(Qt::white); - KoViewConverter vc; - KoShapePaintingContext ctx; + for(int i = 0; i < d->symbols.size(); ++i) { - KoShapeGroup *group = dynamic_cast(d->symbols[0]->shape); - group->setSize(QSizeF(100.0, 100.0)); - Q_ASSERT(group); - paintGroup(group, gc, vc, ctx); + QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); + QPainter gc(&image); + image.fill(Qt::white); + KoViewConverter vc; + KoShapePaintingContext ctx; + KoShapeGroup *group = dynamic_cast(d->symbols[i]->shape); + group->setSize(QSizeF(100.0, 100.0)); + Q_ASSERT(group); + paintGroup(group, gc, vc, ctx); + gc.end(); + d->symbols[i]->icon = image; - gc.end(); - setImage(image); + } - image.save("bla.png"); + setImage(d->symbols[0]->icon); return true; } bool KoSvgSymbolCollectionResource::save() { QFile file(filename()); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { return false; } saveToDevice(&file); file.close(); return true; } bool KoSvgSymbolCollectionResource::saveToDevice(QIODevice *dev) const { bool res; // XXX if (res) { KoResource::saveToDevice(dev); } return res; } QString KoSvgSymbolCollectionResource::defaultFileExtension() const { return QString(".svg"); } QString KoSvgSymbolCollectionResource::title() const { return d->title; } QString KoSvgSymbolCollectionResource::description() const { return d->description; } QString KoSvgSymbolCollectionResource::creator() const { return ""; } QString KoSvgSymbolCollectionResource::rights() const { return ""; } QString KoSvgSymbolCollectionResource::language() const { return ""; } QStringList KoSvgSymbolCollectionResource::subjects() const { return QStringList(); } QString KoSvgSymbolCollectionResource::license() const { return ""; } QStringList KoSvgSymbolCollectionResource::permits() const { return QStringList(); } + +QVector KoSvgSymbolCollectionResource::symbols() const +{ + return d->symbols; +} diff --git a/libs/flake/resources/KoSvgSymbolCollectionResource.h b/libs/flake/resources/KoSvgSymbolCollectionResource.h index 139b093b5a..58fcc3de6e 100644 --- a/libs/flake/resources/KoSvgSymbolCollectionResource.h +++ b/libs/flake/resources/KoSvgSymbolCollectionResource.h @@ -1,96 +1,101 @@ /* This file is part of the KDE project Copyright (c) 2017 Boudewijn Rempt This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #ifndef KOSVGSYMBOLCOLLECTIONRESOURCE #define KOSVGSYMBOLCOLLECTIONRESOURCE #include #include #include #include +#include #include #include #include "kritaflake_export.h" struct KoSvgSymbol { KoSvgSymbol() {} KoSvgSymbol(const QString &_title) : title(_title) {} ~KoSvgSymbol() { delete shape; } QString id; QString title; KoShape *shape; + QImage icon; bool operator==(const KoSvgSymbol& rhs) const { return title == rhs.title; } }; /** * Loads an svg file that contains "symbol" objects and creates a collection of those objects. */ class KRITAFLAKE_EXPORT KoSvgSymbolCollectionResource : public QObject, public KoResource { Q_OBJECT public: /** */ explicit KoSvgSymbolCollectionResource(const QString &filename); /// Create an empty color set KoSvgSymbolCollectionResource(); /// Explicit copy constructor (KoResource copy constructor is private) KoSvgSymbolCollectionResource(const KoSvgSymbolCollectionResource& rhs); ~KoSvgSymbolCollectionResource() override; bool load() override; bool loadFromDevice(QIODevice *dev) override; bool save() override; bool saveToDevice(QIODevice* dev) const override; QString defaultFileExtension() const override; QString title() const; QString description() const; QString creator() const; QString rights() const; QString language() const; QStringList subjects() const; QString license() const; QStringList permits() const; + QVector symbols() const; + + private: struct Private; const QScopedPointer d; }; #endif // KoSvgSymbolCollectionResource diff --git a/libs/widgets/KoResourceServerProvider.cpp b/libs/widgets/KoResourceServerProvider.cpp index a5079d4805..4503c3a0b1 100644 --- a/libs/widgets/KoResourceServerProvider.cpp +++ b/libs/widgets/KoResourceServerProvider.cpp @@ -1,261 +1,260 @@ /* This file is part of the KDE project Copyright (c) 1999 Matthias Elter Copyright (c) 2003 Patrick Julien Copyright (c) 2005 Sven Langkamp Copyright (C) 2011 Srikanth Tiyyagura This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "KoResourceServerProvider.h" #include #include #include #include #include #include #include #include #include "KoColorSpaceRegistry.h" #include "KoResourcePaths.h" #include using namespace std; class GradientResourceServer : public KoResourceServer { public: GradientResourceServer(const QString& type, const QString& extensions) : KoResourceServer(type, extensions) , m_foregroundToTransparent(0) , m_foregroundToBackground(0) { insertSpecialGradients(); } void insertSpecialGradients() { const KoColorSpace* cs = KoColorSpaceRegistry::instance()->rgb8(); QList stops; KoStopGradient* gradient = new KoStopGradient(); gradient->setType(QGradient::LinearGradient); gradient->setName("Foreground to Transparent"); stops << KoGradientStop(0.0, KoColor(Qt::black, cs)) << KoGradientStop(1.0, KoColor(QColor(0, 0, 0, 0), cs)); gradient->setStops(stops); gradient->setValid(true); gradient->setPermanent(true); addResource(gradient, false, true); m_foregroundToTransparent = gradient; gradient = new KoStopGradient(); gradient->setType(QGradient::LinearGradient); gradient->setName("Foreground to Background"); stops.clear(); stops << KoGradientStop(0.0, KoColor(Qt::black, cs)) << KoGradientStop(1.0, KoColor(Qt::white, cs)); gradient->setStops(stops); gradient->setValid(true); gradient->setPermanent(true); addResource(gradient, false, true); m_foregroundToBackground = gradient; } private: friend class KoResourceBundle; KoAbstractGradient* createResource( const QString & filename ) override { QString fileExtension; int index = filename.lastIndexOf('.'); if (index != -1) fileExtension = filename.mid(index).toLower(); KoAbstractGradient* grad = 0; if(fileExtension == ".svg" || fileExtension == ".kgr") grad = new KoStopGradient(filename); else if(fileExtension == ".ggr" ) grad = new KoSegmentGradient(filename); return grad; } QList< KoAbstractGradient* > sortedResources() override { QList< KoAbstractGradient* > resources = KoResourceServer::sortedResources(); QList< KoAbstractGradient* > sorted; if (m_foregroundToTransparent && resources.contains(m_foregroundToTransparent)) { sorted.append(resources.takeAt(resources.indexOf(m_foregroundToTransparent))); } if (m_foregroundToBackground && resources.contains(m_foregroundToBackground)) { sorted.append(resources.takeAt(resources.indexOf(m_foregroundToBackground))); } return sorted + resources; } KoAbstractGradient* m_foregroundToTransparent; KoAbstractGradient* m_foregroundToBackground; }; KoResourceLoaderThread::KoResourceLoaderThread(KoResourceServerBase * server) : QThread() , m_server(server) { m_fileNames = m_server->fileNames(); QStringList fileNames = m_server->blackListedFiles(); if (!fileNames.isEmpty()) { foreach (const QString &s, fileNames) { if (m_fileNames.contains(s)) { m_fileNames.removeAll(s); } } } connect(qApp, SIGNAL(aboutToQuit()), SLOT(barrier())); } KoResourceLoaderThread::~KoResourceLoaderThread() { } void KoResourceLoaderThread::loadSynchronously() { m_server->loadResources(m_fileNames); } void KoResourceLoaderThread::run() { m_server->loadResources(m_fileNames); } void KoResourceLoaderThread::barrier() { if(isRunning()) { wait(); } } struct Q_DECL_HIDDEN KoResourceServerProvider::Private { KoResourceServer* patternServer; KoResourceServer* gradientServer; KoResourceServer* paletteServer; KoResourceServer *svgSymbolCollectionServer; KoResourceLoaderThread *paletteThread; KoResourceLoaderThread *gradientThread; KoResourceLoaderThread *patternThread; KoResourceLoaderThread *svgSymbolCollectionThread; }; KoResourceServerProvider::KoResourceServerProvider() : d(new Private) { d->patternServer = new KoResourceServerSimpleConstruction("ko_patterns", "*.pat:*.jpg:*.gif:*.png:*.tif:*.xpm:*.bmp" ); if (!QFileInfo(d->patternServer->saveLocation()).exists()) { QDir().mkpath(d->patternServer->saveLocation()); } d->patternThread = new KoResourceLoaderThread(d->patternServer); d->patternThread->loadSynchronously(); // if (qApp->applicationName().contains(QLatin1String("test"), Qt::CaseInsensitive)) { // d->patternThread->barrier(); // } d->gradientServer = new GradientResourceServer("ko_gradients", "*.kgr:*.svg:*.ggr"); if (!QFileInfo(d->gradientServer->saveLocation()).exists()) { QDir().mkpath(d->gradientServer->saveLocation()); } d->gradientThread = new KoResourceLoaderThread(d->gradientServer); d->gradientThread->loadSynchronously(); // if (qApp->applicationName().contains(QLatin1String("test"), Qt::CaseInsensitive)) { // d->gradientThread->barrier(); // } d->paletteServer = new KoResourceServerSimpleConstruction("ko_palettes", "*.kpl:*.gpl:*.pal:*.act:*.aco:*.css:*.colors:*.xml:*.sbz"); if (!QFileInfo(d->paletteServer->saveLocation()).exists()) { QDir().mkpath(d->paletteServer->saveLocation()); } d->paletteThread = new KoResourceLoaderThread(d->paletteServer); d->paletteThread->loadSynchronously(); // if (qApp->applicationName().contains(QLatin1String("test"), Qt::CaseInsensitive)) { // d->paletteThread->barrier(); // } d->svgSymbolCollectionServer = new KoResourceServerSimpleConstruction("symbols", "*.svg"); if (!QFileInfo(d->svgSymbolCollectionServer->saveLocation()).exists()) { QDir().mkpath(d->svgSymbolCollectionServer->saveLocation()); } d->svgSymbolCollectionThread = new KoResourceLoaderThread(d->svgSymbolCollectionServer); d->svgSymbolCollectionThread ->loadSynchronously(); - } KoResourceServerProvider::~KoResourceServerProvider() { delete d->patternThread; delete d->gradientThread; delete d->paletteThread; delete d->svgSymbolCollectionThread; delete d->patternServer; delete d->gradientServer; delete d->paletteServer; delete d->svgSymbolCollectionServer; delete d; } Q_GLOBAL_STATIC(KoResourceServerProvider, s_instance); KoResourceServerProvider* KoResourceServerProvider::instance() { return s_instance; } KoResourceServer* KoResourceServerProvider::patternServer(bool block) { if (block) d->patternThread->barrier(); return d->patternServer; } KoResourceServer* KoResourceServerProvider::gradientServer(bool block) { if (block) d->gradientThread->barrier(); return d->gradientServer; } KoResourceServer* KoResourceServerProvider::paletteServer(bool block) { if (block) d->paletteThread->barrier(); return d->paletteServer; } KoResourceServer *KoResourceServerProvider::svgSymbolCollectionServer(bool block) { if (block) d->svgSymbolCollectionThread->barrier(); return d->svgSymbolCollectionServer; } diff --git a/plugins/dockers/shapedockers/CMakeLists.txt b/plugins/dockers/shapedockers/CMakeLists.txt index 9f14f2cfff..b01a1ef237 100644 --- a/plugins/dockers/shapedockers/CMakeLists.txt +++ b/plugins/dockers/shapedockers/CMakeLists.txt @@ -1,15 +1,20 @@ project(calligradockers) set(calligradockers_SRCS - shapecollection/ShapeCollectionDocker.cpp - shapecollection/CollectionItemModel.cpp - svgsymbolcollection/SvgSymbolCollectionDocker.cpp + ShapeCollectionDocker.cpp + CollectionItemModel.cpp + SvgSymbolCollectionDocker.cpp Plugin.cpp ) +ki18n_wrap_ui(calligradockers_SRCS + WdgSvgCollection.ui +) + + add_library(krita_docker_defaults MODULE ${calligradockers_SRCS}) target_link_libraries(krita_docker_defaults kritawidgets) install(TARGETS krita_docker_defaults DESTINATION ${KRITA_PLUGIN_INSTALL_DIR}) diff --git a/plugins/dockers/shapedockers/shapecollection/CollectionItemModel.cpp b/plugins/dockers/shapedockers/CollectionItemModel.cpp similarity index 100% rename from plugins/dockers/shapedockers/shapecollection/CollectionItemModel.cpp rename to plugins/dockers/shapedockers/CollectionItemModel.cpp diff --git a/plugins/dockers/shapedockers/shapecollection/CollectionItemModel.h b/plugins/dockers/shapedockers/CollectionItemModel.h similarity index 100% rename from plugins/dockers/shapedockers/shapecollection/CollectionItemModel.h rename to plugins/dockers/shapedockers/CollectionItemModel.h diff --git a/plugins/dockers/shapedockers/Plugin.cpp b/plugins/dockers/shapedockers/Plugin.cpp index 324145c463..b0f710cd27 100644 --- a/plugins/dockers/shapedockers/Plugin.cpp +++ b/plugins/dockers/shapedockers/Plugin.cpp @@ -1,38 +1,39 @@ /* This file is part of the KDE project - * Copyright (C) 2007 Thomas Zander + * + * Copyright (C) 2017 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "Plugin.h" -#include "shapecollection/ShapeCollectionDocker.h" -#include "svgsymbolcollection/SvgSymbolCollectionDocker.h" +#include "ShapeCollectionDocker.h" +#include "SvgSymbolCollectionDocker.h" #include #include K_PLUGIN_FACTORY_WITH_JSON(PluginFactory, "calligra_docker_defaults.json", registerPlugin();) Plugin::Plugin(QObject *parent, const QVariantList &) : QObject(parent) { Q_UNUSED(parent); KoDockRegistry::instance()->add(new ShapeCollectionDockerFactory()); KoDockRegistry::instance()->add(new SvgSymbolCollectionDockerFactory()); } #include diff --git a/plugins/dockers/shapedockers/shapecollection/ShapeCollectionDocker.cpp b/plugins/dockers/shapedockers/ShapeCollectionDocker.cpp similarity index 100% rename from plugins/dockers/shapedockers/shapecollection/ShapeCollectionDocker.cpp rename to plugins/dockers/shapedockers/ShapeCollectionDocker.cpp diff --git a/plugins/dockers/shapedockers/shapecollection/ShapeCollectionDocker.h b/plugins/dockers/shapedockers/ShapeCollectionDocker.h similarity index 100% rename from plugins/dockers/shapedockers/shapecollection/ShapeCollectionDocker.h rename to plugins/dockers/shapedockers/ShapeCollectionDocker.h diff --git a/plugins/dockers/shapedockers/svgsymbolcollection/SvgSymbolCollectionDocker.cpp b/plugins/dockers/shapedockers/SvgSymbolCollectionDocker.cpp similarity index 52% rename from plugins/dockers/shapedockers/svgsymbolcollection/SvgSymbolCollectionDocker.cpp rename to plugins/dockers/shapedockers/SvgSymbolCollectionDocker.cpp index 7ee9a791b7..ebaaaf9ebb 100644 --- a/plugins/dockers/shapedockers/svgsymbolcollection/SvgSymbolCollectionDocker.cpp +++ b/plugins/dockers/shapedockers/SvgSymbolCollectionDocker.cpp @@ -1,65 +1,104 @@ /* This file is part of the KDE project * Copyright (C) 2008 Peter Simonsson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #include "SvgSymbolCollectionDocker.h" #include #include +#include +#include + +#include "ui_WdgSvgCollection.h" + // // SvgSymbolCollectionDockerFactory // SvgSymbolCollectionDockerFactory::SvgSymbolCollectionDockerFactory() : KoDockFactoryBase() { } QString SvgSymbolCollectionDockerFactory::id() const { return QString("SvgSymbolCollectionDocker"); } QDockWidget *SvgSymbolCollectionDockerFactory::createDockWidget() { SvgSymbolCollectionDocker *docker = new SvgSymbolCollectionDocker(); return docker; } // // SvgSymbolCollectionDocker // SvgSymbolCollectionDocker::SvgSymbolCollectionDocker(QWidget *parent) : QDockWidget(parent) + , m_wdgSvgCollection(new Ui_WdgSvgCollection()) { setWindowTitle(i18n("Vector Libraries")); + QWidget* mainWidget = new QWidget(this); + setWidget(mainWidget); + m_wdgSvgCollection->setupUi(mainWidget); + + connect(m_wdgSvgCollection->cmbCollections, SIGNAL(activated(int)), SLOT(collectionActivated(int))); + + KoResourceServer *svgCollectionProvider = KoResourceServerProvider::instance()->svgSymbolCollectionServer(); + Q_FOREACH(KoSvgSymbolCollectionResource *r, svgCollectionProvider->resources()) { + QVariant v = QVariant::fromValue(r); + m_wdgSvgCollection->cmbCollections->addItem(r->name(), v); + } + + m_wdgSvgCollection->listCollection->setDragEnabled(true); + m_wdgSvgCollection->listCollection->setDragDropMode(QAbstractItemView::DragOnly); + m_wdgSvgCollection->listCollection->setSelectionMode(QListView::SingleSelection); + + collectionActivated(0); + } void SvgSymbolCollectionDocker::setCanvas(KoCanvasBase *canvas) { setEnabled(canvas != 0); } void SvgSymbolCollectionDocker::unsetCanvas() { setEnabled(false); } + +void SvgSymbolCollectionDocker::collectionActivated(int index) +{ + QVariant v = m_wdgSvgCollection->cmbCollections->itemData(index); + KoSvgSymbolCollectionResource *r = v.value(); + if (r) { + m_wdgSvgCollection->listCollection->clear(); + Q_FOREACH(KoSvgSymbol *symbol, r->symbols()) { + QListWidgetItem *item = new QListWidgetItem(symbol->title); + item->setIcon(QIcon(QPixmap::fromImage(symbol->icon))); + m_wdgSvgCollection->listCollection->addItem(item); + } + } + +} diff --git a/plugins/dockers/shapedockers/svgsymbolcollection/SvgSymbolCollectionDocker.h b/plugins/dockers/shapedockers/SvgSymbolCollectionDocker.h similarity index 91% rename from plugins/dockers/shapedockers/svgsymbolcollection/SvgSymbolCollectionDocker.h rename to plugins/dockers/shapedockers/SvgSymbolCollectionDocker.h index 2aa9945587..25e3fe8c27 100644 --- a/plugins/dockers/shapedockers/svgsymbolcollection/SvgSymbolCollectionDocker.h +++ b/plugins/dockers/shapedockers/SvgSymbolCollectionDocker.h @@ -1,57 +1,66 @@ /* This file is part of the KDE project * Copyright (C) 2017 Boudewijn Rempt * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this library; see the file COPYING.LIB. If not, write to * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef SVGSYMBOLCOLLECTIONDOCKER_H #define SVGSYMBOLCOLLECTIONDOCKER_H #include #include #include #include #include #include +#include "ui_WdgSvgCollection.h" + + class SvgSymbolCollectionDockerFactory : public KoDockFactoryBase { public: SvgSymbolCollectionDockerFactory(); QString id() const override; QDockWidget *createDockWidget() override; DockPosition defaultDockPosition() const override { return DockRight; } }; class SvgSymbolCollectionDocker : public QDockWidget, public KoCanvasObserverBase { Q_OBJECT public: explicit SvgSymbolCollectionDocker(QWidget *parent = 0); /// reimplemented void setCanvas(KoCanvasBase *canvas) override; void unsetCanvas() override; - +private Q_SLOTS: + + void collectionActivated(int index); + +private: + + Ui_WdgSvgCollection *m_wdgSvgCollection; }; #endif //KOSHAPECOLLECTIONDOCKER_H diff --git a/plugins/dockers/shapedockers/WdgSvgCollection.ui b/plugins/dockers/shapedockers/WdgSvgCollection.ui new file mode 100644 index 0000000000..e3057847eb --- /dev/null +++ b/plugins/dockers/shapedockers/WdgSvgCollection.ui @@ -0,0 +1,27 @@ + + + WdgSvgCollection + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + + + + + + + +