...
 
Commits (364)
......@@ -4,8 +4,8 @@ if (WIN32)
-skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects
-skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland
-skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview
-skip qtxmlpatterns -no-sql-sqlite -nomake examples -nomake tools
-no-compile-examples -no-dbus -no-iconv -no-qml-debug
-skip qtxmlpatterns -nomake examples -nomake tools
-no-compile-examples -no-dbus -no-iconv -no-qml-debug
-no-libproxy -no-system-proxies -no-icu -no-mtdev
-skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtnetworkauth
-skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus
......
......@@ -300,6 +300,7 @@ find_package(Qt5 ${MIN_QT_VERSION}
Svg
Test
Concurrent
Sql
)
if (WIN32)
......
......@@ -55,8 +55,11 @@
/* Defines if KCrash is present */
#cmakedefine HAVE_KCRASH 1
/* This variable contains the path to the current build directory */
/* This variable contains the path to the root of the build directory */
#define KRITA_BUILD_DIR "${CMAKE_BINARY_DIR}"
/* This variable contains the path to the root of the source directory */
#define KRITA_SOURCE_DIR "${CMAKE_SOURCE_DIR}"
/* This variable contains the path to the data install dir */
#define KRITA_EXTRA_RESOURCE_DIRS "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}:${CMAKE_SOURCE_DIR}/krita/data"
......@@ -59,7 +59,7 @@ void KisGradientBenchmark::benchmarkGradient()
QLinearGradient grad;
grad.setColorAt(0, Qt::white);
grad.setColorAt(1.0, Qt::red);
KoAbstractGradient* kograd = KoStopGradient::fromQGradient(&grad);
KoAbstractGradientSP kograd(KoStopGradient::fromQGradient(&grad));
Q_ASSERT(kograd);
KisGradientPainter fillPainter(m_device);
//setupPainter(&fillPainter);
......
......@@ -61,7 +61,7 @@ void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName,
int poolLimitMiB,
int index)
{
KisPaintOpPresetSP preset = new KisPaintOpPreset(QString(FILES_DATA_DIR) + QDir::separator() + presetFileName);
KisPaintOpPresetSP preset(new KisPaintOpPreset(QString(FILES_DATA_DIR) + QDir::separator() + presetFileName));
LOAD_PRESET_OR_RETURN(preset, presetFileName);
......
......@@ -436,7 +436,7 @@ void KisStrokeBenchmark::predefinedBrushRL()
inline void KisStrokeBenchmark::benchmarkLine(QString presetFileName)
{
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName);
KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
preset->load();
m_painter->setPaintOpPreset(preset, m_layer, m_image);
......@@ -461,7 +461,7 @@ void KisStrokeBenchmark::benchmarkCircle(QString presetFileName)
{
dbgKrita << "(circle)preset : " << presetFileName;
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName);
KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
if (!preset->load()){
dbgKrita << "Preset was not loaded";
return;
......@@ -512,7 +512,7 @@ QBENCHMARK{
void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName)
{
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName);
KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
bool loadedOk = preset->load();
if (!loadedOk){
dbgKrita << "The preset was not loaded correctly. Done.";
......@@ -541,7 +541,7 @@ void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName)
void KisStrokeBenchmark::benchmarkRectangle(QString presetFileName)
{
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName);
KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
bool loadedOk = preset->load();
if (!loadedOk){
dbgKrita << "The preset was not loaded correctly. Done.";
......@@ -570,7 +570,7 @@ void KisStrokeBenchmark::benchmarkRectangle(QString presetFileName)
void KisStrokeBenchmark::benchmarkStroke(QString presetFileName)
{
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName);
KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
bool loadedOk = preset->load();
if (!loadedOk){
dbgKrita << "The preset was not loaded correctly. Done.";
......@@ -619,7 +619,7 @@ void KisStrokeBenchmark::benchmarkRand()
void KisStrokeBenchmark::becnhmarkPresetCloning()
{
QString presetFileName = "spray_21_textures1.kpp";
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName);
KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
bool loadedOk = preset->load();
KIS_ASSERT_RECOVER_RETURN(loadedOk);
KIS_ASSERT_RECOVER_RETURN(preset->settings());
......
......@@ -3,3 +3,15 @@ a\)_Eraser_Circle.kpp
b\)_Basic-5_Size_default.kpp
DESTINATION ${DATA_INSTALL_DIR}/krita/paintoppresets)
install( FILES
"Favorites.tag"
"Pixel Art.tag"
Digital.tag
Erasers.tag
FX.tag
Ink.tag
Paint.tag
Sketch.tag
Textures.tag
DESTINATION ${DATA_INSTALL_DIR}/krita/paintoppresets)
[Desktop Entry]
Type=Tag
Name=Digital
Comment=Brush presets with a digital look and feel.
URL=Digital
Default Resources=a)_Eraser_Circle,b)_Basic-5_Size
[Desktop Entry]
Type=Tag
Name=Erasers
Comment=Eraser Brush Presets
URL=Erasers
Default Resources=a)_Eraser_Circle
[Desktop Entry]
Type=Tag
Name=FX
Comment=Special Effects
URL=FX
[Desktop Entry]
Type=Tag
Name=* Favorites
Comment=Your favorite brush presets
URL=* Favorites
[Desktop Entry]
Type=Tag
Name=Ink
Comment=Inking Brush Presets
URL=Ink
[Desktop Entry]
Type=Tag
Name=Paint
Comment=Paint Brushes
URL=Paint
[Desktop Entry]
Type=Tag
Name=Pixel Art
Comment=Presets for working with individual pixels
URL=Pixel Art
[Desktop Entry]
Type=Tag
Name=Sketch
Comment=Sketching brush presets
URL=Sketch
[Desktop Entry]
Type=Tag
Name=Textures
Comment=Textured Brush Presets
URL=Textures
......@@ -44,7 +44,6 @@ delete_keyframe=none
deselect=Ctrl+Shift+A
dual=none
duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C
edit_cut=Ctrl+X
EditLayerMetaData=none
......
......@@ -59,7 +59,6 @@ delete_keyframe=none
deselect=Ctrl+Shift+A
dual=none
duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C
edit_cut=Ctrl+X
edit_deselect_all=Ctrl+Shift+A
......
[Shortcuts]
black[Shortcuts]
activateNextLayer=Alt+]
activatePreviousLayer=Alt+[
add_blank_frame=none
......@@ -59,7 +59,6 @@ delete_keyframe=none
deselect=Ctrl+D
dual=none
duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C
edit_cut=Ctrl+X
edit_deselect_all=Ctrl+Shift+A
......
......@@ -65,7 +65,6 @@ deselect=Ctrl+Shift+A
drop_frames=none
dual=none
duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C
edit_cut=Ctrl+X
edit_deselect_all=Ctrl+Shift+A
......
......@@ -14,18 +14,6 @@
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="edit_blacklist_cleanup">
<icon></icon>
<text>Cleanup removed files...</text>
<whatsThis></whatsThis>
<toolTip>Cleanup removed files</toolTip>
<iconText>Cleanup removed files</iconText>
<activationFlags>0</activationFlags>
<activationConditions>0</activationConditions>
<shortcut></shortcut>
<isCheckable>false</isCheckable>
<statusTip></statusTip>
</Action>
<Action name="windows_cascade">
<icon></icon>
<text>C&amp;ascade</text>
......
......@@ -341,6 +341,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<text>Setti&amp;ngs</text>
<Action name="options_configure"/>
<Action name="manage_bundles"/>
<Action name="dbexplorer"/>
<Separator/>
<Action name="options_configure_toolbars"/>
<Merge name="StandardToolBarMenuHandler" />
......
......@@ -20,5 +20,6 @@ add_subdirectory( libkis )
if (NOT APPLE AND HAVE_QT_QUICK)
add_subdirectory( libqml )
endif()
add_subdirectory( resources )
add_subdirectory( metadata )
add_subdirectory( resourcewidgets )
......@@ -11,7 +11,7 @@ set(kritalibbrush_LIB_SRCS
kis_brush.cpp
kis_scaling_size_brush.cpp
kis_brush_registry.cpp
kis_brush_server.cpp
KisBrushServerProvider.cpp
kis_gbr_brush.cpp
kis_abr_brush.cpp
kis_abr_brush_collection.cpp
......
/*
* Copyright (c) 2008 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "KisBrushServerProvider.h"
#include <QDir>
#include <QApplication>
#include <QGlobalStatic>
#include <KoResourcePaths.h>
#include <KoResource.h>
#include <kis_debug.h>
Q_GLOBAL_STATIC(KisBrushServerProvider, s_instance)
KisBrushServerProvider::KisBrushServerProvider()
{
m_brushServer = new KoResourceServer<KisBrush>(ResourceType::Brushes);
}
KisBrushServerProvider::~KisBrushServerProvider()
{
delete m_brushServer;
}
KisBrushServerProvider* KisBrushServerProvider::instance()
{
return s_instance;
}
KoResourceServer<KisBrush>* KisBrushServerProvider::brushServer()
{
return m_brushServer;
}
......@@ -15,46 +15,40 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_BRUSH_SERVER_H
#define KIS_BRUSH_SERVER_H
#ifndef KIS_BRUSH_SERVER_PROVIDER_H
#define KIS_BRUSH_SERVER_PROVIDER_H
#include <QString>
#include <QStringList>
#include <QList>
#include <KoResourceServer.h>
#include <KoResourceServerAdapter.h>
#include "kritabrush_export.h"
#include "kis_brush.h"
typedef KoResourceServer<KisBrush, SharedPointerStoragePolicy<KisBrushSP> > KisBrushResourceServer;
typedef KoResourceServerAdapter<KisBrush, SharedPointerStoragePolicy<KisBrushSP> > KisBrushResourceServerAdapter;
/**
*
*/
class BRUSH_EXPORT KisBrushServer : public QObject
class BRUSH_EXPORT KisBrushServerProvider : public QObject
{
Q_OBJECT
public:
KisBrushServer();
~KisBrushServer() override;
KisBrushResourceServer* brushServer();
KisBrushServerProvider();
~KisBrushServerProvider() override;
static KisBrushServer* instance();
KoResourceServer<KisBrush>* brushServer();
public Q_SLOTS:
void slotRemoveBlacklistedResources();
static KisBrushServerProvider* instance();
private:
KisBrushServer(const KisBrushServer&);
KisBrushServer operator=(const KisBrushServer&);
KisBrushServerProvider(const KisBrushServerProvider&);
KisBrushServerProvider operator=(const KisBrushServerProvider&);
KisBrushResourceServer* m_brushServer;
KoResourceServer<KisBrush>* m_brushServer;
};
#endif
......@@ -61,9 +61,9 @@ KisAbrBrush::KisAbrBrush(const KisAbrBrush& rhs, KisAbrBrushCollection *parent)
{
}
KisBrush* KisAbrBrush::clone() const
KisBrushSP KisAbrBrush::clone() const
{
return new KisAbrBrush(*this);
return KisBrushSP(new KisAbrBrush(*this));
}
bool KisAbrBrush::load()
......
......@@ -46,7 +46,7 @@ public:
KisAbrBrush(const QString& filename, KisAbrBrushCollection *parent);
KisAbrBrush(const KisAbrBrush& rhs);
KisAbrBrush(const KisAbrBrush& rhs, KisAbrBrushCollection *parent);
KisBrush* clone() const override;
KisBrushSP clone() const override;
bool load() override;
......@@ -73,5 +73,7 @@ private:
KisAbrBrushCollection *m_parent;
};
typedef QSharedPointer<KisAbrBrush> KisAbrBrushSP;
#endif // KIS_ABR_BRUSH_
......@@ -378,12 +378,12 @@ quint32 KisAbrBrushCollection::abr_brush_load_v6(QDataStream & abr, AbrInfo *abr
if (width < quint16_MAX && height < quint16_MAX) {
// filename - filename of the file , e.g. test.abr
// name - test_number_of_the_brush, e.g test_1, test_2
KisAbrBrush* abrBrush = 0;
KisAbrBrushSP abrBrush;
if (m_abrBrushes.contains(name)) {
abrBrush = m_abrBrushes[name];
}
else {
abrBrush = new KisAbrBrush(name, this);
abrBrush = KisAbrBrushSP(new KisAbrBrush(name, this));
abrBrush->setMD5(md5());
}
......@@ -477,12 +477,12 @@ qint32 KisAbrBrushCollection::abr_brush_load_v12(QDataStream & abr, AbrInfo *abr
rle_decode(abr, buffer, height);
}
KisAbrBrush* abrBrush = 0;
KisAbrBrushSP abrBrush;
if (m_abrBrushes.contains(name)) {
abrBrush = m_abrBrushes[name];
}
else {
abrBrush = new KisAbrBrush(name, this);
abrBrush = KisAbrBrushSP(new KisAbrBrush(name, this));
abrBrush->setMD5(md5());
}
......@@ -534,13 +534,13 @@ KisAbrBrushCollection::KisAbrBrushCollection(const KisAbrBrushCollection& rhs)
it != rhs.m_abrBrushes.end();
++it) {
m_abrBrushes.insert(it.key(), new KisAbrBrush(*it.value(), this));
m_abrBrushes.insert(it.key(), KisAbrBrushSP(new KisAbrBrush(*it.value(), this)));
}
}
KisBrush* KisAbrBrushCollection::clone() const
KisBrushSP KisAbrBrushCollection::clone() const
{
return new KisAbrBrushCollection(*this);
return KisBrushSP(new KisAbrBrushCollection(*this));
}
bool KisAbrBrushCollection::load()
......
......@@ -30,11 +30,13 @@
#include <kis_types.h>
#include <kis_shared.h>
#include <brushengine/kis_paint_information.h>
#include <kis_abr_brush.h>
class QString;
class QIODevice;
class KisAbrBrush;
struct AbrInfo;
/**
......@@ -50,7 +52,7 @@ public:
/// Construct brush to load filename later as brush
KisAbrBrushCollection(const QString& filename);
KisBrush* clone() const override;
KisBrushSP clone() const override;
~KisAbrBrushCollection() override {}
......@@ -72,7 +74,7 @@ public:
*/
QString defaultFileExtension() const override;
QList<KisAbrBrush*> brushes() {
QList<KisAbrBrushSP> brushes() {
return m_abrBrushes.values();
}
......@@ -86,7 +88,7 @@ private:
qint32 abr_brush_load(QDataStream & abr, AbrInfo *abr_hdr, const QString filename, qint32 image_ID, qint32 id);
qint32 abr_brush_load_v12(QDataStream & abr, AbrInfo *abr_hdr, const QString filename, qint32 image_ID, qint32 id);
quint32 abr_brush_load_v6(QDataStream & abr, AbrInfo *abr_hdr, const QString filename, qint32 image_ID, qint32 id);
QMap<QString, KisAbrBrush*> m_abrBrushes;
QMap<QString, KisAbrBrushSP> m_abrBrushes;
};
#endif
......
......@@ -115,9 +115,9 @@ KisAutoBrush::KisAutoBrush(const KisAutoBrush& rhs)
{
}
KisBrush* KisAutoBrush::clone() const
KisBrushSP KisAutoBrush::clone() const
{
return new KisAutoBrush(*this);
return KisBrushSP(new KisAutoBrush(*this));
}
/* It's difficult to predict the mask height when exaclty when there are
......
......@@ -36,7 +36,7 @@ public:
KisAutoBrush(KisMaskGenerator* as, qreal angle, qreal randomness, qreal density = 1.0);
KisAutoBrush(const KisAutoBrush& rhs);
KisBrush* clone() const override;
KisBrushSP clone() const override;
~KisAutoBrush() override;
......
......@@ -36,7 +36,7 @@ KisBrushSP KisAutoBrushFactory::createBrush(const QDomElement &brushDefinition)
bool useAutoSpacing = KisDomUtils::toInt(brushDefinition.attribute("useAutoSpacing", "0"));
qreal autoSpacingCoeff = KisDomUtils::toDouble(brushDefinition.attribute("autoSpacingCoeff", "1.0"));
KisBrushSP brush = new KisAutoBrush(mask, angle, randomness, density);
KisBrushSP brush = KisBrushSP(new KisAutoBrush(mask, angle, randomness, density));
brush->setSpacing(spacing);
brush->setAutoSpacing(useAutoSpacing, autoSpacingCoeff);
return brush;
......
......@@ -22,7 +22,7 @@
#include <QImage>
#include <resources/KoResource.h>
#include <KoResource.h>
#include <kis_types.h>
#include <kis_shared.h>
......@@ -51,7 +51,7 @@ enum enumBrushType {
static const qreal DEFAULT_SOFTNESS_FACTOR = 1.0;
class KisBrush;
typedef KisSharedPtr<KisBrush> KisBrushSP;
typedef QSharedPointer<KisBrush> KisBrushSP;
/**
* KisBrush is the base class for brush resources. A brush resource
......@@ -339,7 +339,7 @@ public:
virtual void lodLimitations(KisPaintopLodLimitations *l) const;
virtual KisBrush* clone() const = 0;
virtual KisBrushSP clone() const = 0;
protected:
......
......@@ -26,7 +26,7 @@
#include <kis_debug.h>
#include "kis_brush_server.h"
#include "KoResourceServer.h"
#include "kis_auto_brush_factory.h"
#include "kis_text_brush_factory.h"
#include "kis_predefined_brush_factory.h"
......@@ -36,7 +36,6 @@ Q_GLOBAL_STATIC(KisBrushRegistry, s_instance)
KisBrushRegistry::KisBrushRegistry()
{
KisBrushServer::instance();
}
KisBrushRegistry::~KisBrushRegistry()
......
/*
* Copyright (c) 2008 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_brush_server.h"
#include <QDir>
#include <QApplication>
#include <QGlobalStatic>
#include <KoResourcePaths.h>
#include <resources/KoResource.h>
#include <KoResourceServerProvider.h>
#include <kis_debug.h>
#include "kis_abr_brush.h"
#include "kis_abr_brush_collection.h"
#include "kis_gbr_brush.h"
#include "kis_imagepipe_brush.h"
#include "kis_png_brush.h"
#include "kis_svg_brush.h"
Q_GLOBAL_STATIC(KisBrushServer, s_instance)
class BrushResourceServer : public KisBrushResourceServer
{
public:
BrushResourceServer()
: KisBrushResourceServer("kis_brushes", "*.gbr:*.gih:*.abr:*.png:*.svg")
{
}
///Reimplemented
bool importResourceFile(const QString& filename, bool fileCreation = true) override {
QFileInfo fi(filename);
if (fi.exists() == false)
return false;
if (fi.size() == 0) return false;
if (fi.suffix().toLower() == "abr") {
if (fileCreation) {
QFile::copy(filename, saveLocation() + fi.fileName());
}
QList<KisBrushSP> collectionResources = createResources(filename);
Q_FOREACH (KisBrushSP brush, collectionResources) {
addResource(brush);
}
}
else {
return KisBrushResourceServer::importResourceFile(filename, fileCreation);
}
qApp->processEvents(QEventLoop::AllEvents);
return true;
}
private:
///Reimplemented
QList<KisBrushSP> createResources(const QString & filename) override {
QList<KisBrushSP> brushes;
QString fileExtension = QFileInfo(filename).suffix().toLower();
if (fileExtension == "abr") {
KisAbrBrushCollection collection(filename);
collection.load();
Q_FOREACH (KisAbrBrush * abrBrush, collection.brushes()) {
// abrBrush->setBrushTipImage(QImage());
brushes.append(abrBrush);
addTag(abrBrush, collection.filename());
}
}
else {
brushes.append(createResource(filename));
}
return brushes;
}
///Reimplemented
KisBrushSP createResource(const QString & filename) override {
QString fileExtension = QFileInfo(filename).suffix().toLower();
KisBrushSP brush;
if (fileExtension == "gbr") {
brush = new KisGbrBrush(filename);
}
else if (fileExtension == "gih") {
brush = new KisImagePipeBrush(filename);
}
else if (fileExtension == "png") {
brush = new KisPngBrush(filename);
}
else if (fileExtension == "svg") {
brush = new KisSvgBrush(filename);
}
return brush;
}
};
KisBrushServer::KisBrushServer()
{
m_brushServer = new BrushResourceServer();
m_brushServer->loadResources(KoResourceServerProvider::blacklistFileNames(m_brushServer->fileNames(), m_brushServer->blackListedFiles()));
Q_FOREACH (KisBrushSP brush, m_brushServer->resources()) {
if (!dynamic_cast<KisAbrBrush*>(brush.data())) {
brush->setBrushTipImage(QImage());
}
}
}
KisBrushServer::~KisBrushServer()
{
delete m_brushServer;
}
KisBrushServer* KisBrushServer::instance()
{
return s_instance;
}
KisBrushResourceServer* KisBrushServer::brushServer()
{
return m_brushServer;
}
void KisBrushServer::slotRemoveBlacklistedResources()
{
m_brushServer->removeBlackListedFiles();
}
......@@ -20,6 +20,7 @@
#define __KIS_BRUSHES_PIPE_H
#include <kis_fixed_paint_device.h>
#include <kis_brush.h>
template<class BrushType>
class KisBrushesPipe
......@@ -29,34 +30,31 @@ public:
}
KisBrushesPipe(const KisBrushesPipe &rhs) {
qDeleteAll(m_brushes);
m_brushes.clear();
Q_FOREACH (BrushType * brush, rhs.m_brushes) {
BrushType *clonedBrush = dynamic_cast<BrushType*>(brush->clone());
Q_FOREACH (QSharedPointer<BrushType> brush, rhs.m_brushes) {
KisBrushSP clonedBrush = brush->clone();
QSharedPointer<BrushType> actualClonedBrush = clonedBrush.dynamicCast<BrushType>();
m_brushes.append(actualClonedBrush );
KIS_ASSERT_RECOVER(clonedBrush) {continue;}
m_brushes.append(clonedBrush);
}
}
virtual ~KisBrushesPipe() {
qDeleteAll(m_brushes);
}
virtual void clear() {
qDeleteAll(m_brushes);
m_brushes.clear();
}
BrushType* firstBrush() const {
QSharedPointer<BrushType> firstBrush() const {
return m_brushes.first();
}
BrushType* lastBrush() const {
QSharedPointer<BrushType> lastBrush() const {
return m_brushes.last();
}
BrushType* currentBrush(const KisPaintInformation& info) {
QSharedPointer<BrushType> currentBrush(const KisPaintInformation& info) {
return !m_brushes.isEmpty() ? m_brushes.at(chooseNextBrush(info)) : 0;
}
......@@ -65,35 +63,35 @@ public:
}
qint32 maskWidth(KisDabShape const& shape, double subPixelX, double subPixelY, const KisPaintInformation& info) {
BrushType *brush = currentBrush(info);
QSharedPointer<BrushType> brush = currentBrush(info);
return brush ? brush->maskWidth(shape, subPixelX, subPixelY, info) : 0;
}
qint32 maskHeight(KisDabShape const& shape, double subPixelX, double subPixelY, const KisPaintInformation& info) {
BrushType *brush = currentBrush(info);
QSharedPointer<BrushType> brush = currentBrush(info);
return brush ? brush->maskHeight(shape, subPixelX, subPixelY, info) : 0;
}
void setAngle(qreal angle) {
Q_FOREACH (BrushType * brush, m_brushes) {
Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
brush->setAngle(angle);
}
}
void setScale(qreal scale) {
Q_FOREACH (BrushType * brush, m_brushes) {
Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
brush->setScale(scale);
}
}
void setSpacing(double spacing) {
Q_FOREACH (BrushType * brush, m_brushes) {
Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
brush->setSpacing(spacing);
}
}
bool hasColor() const {
Q_FOREACH (BrushType * brush, m_brushes) {
Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
if (brush->hasColor()) return true;
}
return false;
......@@ -113,7 +111,7 @@ public:
double subPixelX , double subPixelY,
qreal softnessFactor) {
BrushType *brush = currentBrush(info);
QSharedPointer<BrushType> brush = currentBrush(info);
if (!brush) return;
......@@ -126,7 +124,7 @@ public:
const KisPaintInformation& info,
double subPixelX, double subPixelY) {
BrushType *brush = currentBrush(info);
QSharedPointer<BrushType> brush = currentBrush(info);
if (!brush) return 0;
KisFixedPaintDeviceSP device = brush->paintDevice(colorSpace, shape, info, subPixelX, subPixelY);
......@@ -134,7 +132,7 @@ public:
return device;
}
QVector<BrushType*> brushes() {
QVector<QSharedPointer<BrushType>> brushes() {
return m_brushes;
}
......@@ -151,7 +149,7 @@ public:
virtual void notifyStrokeStarted() = 0;
protected:
void addBrush(BrushType *brush) {
void addBrush(QSharedPointer<BrushType> brush) {
m_brushes.append(brush);
}
......@@ -176,7 +174,7 @@ protected:
virtual void updateBrushIndexes(const KisPaintInformation& info, int seqNo) = 0;
protected:
QVector<BrushType*> m_brushes;
QVector<QSharedPointer<BrushType>> m_brushes;
};
#endif /* __KIS_BRUSHES_PIPE_H */
......@@ -463,9 +463,9 @@ void KisGbrBrush::makeMaskImage()
clearBrushPyramid();
}
KisBrush* KisGbrBrush::clone() const
KisBrushSP KisGbrBrush::clone() const
{
return new KisGbrBrush(*this);
return KisBrushSP(new KisGbrBrush(*this));
}
void KisGbrBrush::toXML(QDomDocument& d, QDomElement& e) const
......
......@@ -90,7 +90,7 @@ public:
/**
* Makes a copy of this brush.
*/
KisBrush* clone() const override;
KisBrushSP clone() const override;
/**
* @return default file extension for saving the brush
......@@ -118,5 +118,7 @@ private:
Private* const d;
};
typedef QSharedPointer<KisGbrBrush> KisGbrBrushSP;
#endif // KIS_GBR_BRUSH_
......@@ -151,19 +151,19 @@ public:
}
void setUseColorAsMask(bool useColorAsMask) {
Q_FOREACH (KisGbrBrush * brush, m_brushes) {
Q_FOREACH (KisGbrBrushSP brush, m_brushes) {
brush->setUseColorAsMask(useColorAsMask);
}
}
void makeMaskImage() {
Q_FOREACH (KisGbrBrush * brush, m_brushes) {
Q_FOREACH (KisGbrBrushSP brush, m_brushes) {
brush->makeMaskImage();
}
}
bool saveToDevice(QIODevice* dev) const {
Q_FOREACH (KisGbrBrush * brush, m_brushes) {
Q_FOREACH (KisGbrBrushSP brush, m_brushes) {
if (!brush->saveToDevice(dev)) {
return false;
}
......@@ -292,9 +292,9 @@ bool KisImagePipeBrush::initFromData(const QByteArray &data)
for (int brushIndex = 0;
brushIndex < numOfBrushes && i < data.size(); brushIndex++) {
KisGbrBrush* brush = new KisGbrBrush(name() + '_' + QString().setNum(brushIndex),
KisGbrBrushSP brush = KisGbrBrushSP(new KisGbrBrush(name() + '_' + QString().setNum(brushIndex),
data,
i);
i));