...
 
Commits (364)
...@@ -4,8 +4,8 @@ if (WIN32) ...@@ -4,8 +4,8 @@ if (WIN32)
-skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects -skip qtconnectivity -skip qtdoc -skip qtgraphicaleffects
-skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland -skip qtlocation -skip qtsensors -skip qtserialport -skip qtwayland
-skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview -skip qtwebchannel -skip qtwebengine -skip qtwebsockets -skip qtwebview
-skip qtxmlpatterns -no-sql-sqlite -nomake examples -nomake tools -skip qtxmlpatterns -nomake examples -nomake tools
-no-compile-examples -no-dbus -no-iconv -no-qml-debug -no-compile-examples -no-dbus -no-iconv -no-qml-debug
-no-libproxy -no-system-proxies -no-icu -no-mtdev -no-libproxy -no-system-proxies -no-icu -no-mtdev
-skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtnetworkauth -skip qtcharts -skip qtdatavis3d -skip qtgamepad -skip qtnetworkauth
-skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus -skip qtpurchasing -skip qtremoteobjects -skip qtscxml -skip qtserialbus
......
...@@ -300,6 +300,7 @@ find_package(Qt5 ${MIN_QT_VERSION} ...@@ -300,6 +300,7 @@ find_package(Qt5 ${MIN_QT_VERSION}
Svg Svg
Test Test
Concurrent Concurrent
Sql
) )
if (WIN32) if (WIN32)
......
...@@ -55,8 +55,11 @@ ...@@ -55,8 +55,11 @@
/* Defines if KCrash is present */ /* Defines if KCrash is present */
#cmakedefine HAVE_KCRASH 1 #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}" #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 */ /* 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" #define KRITA_EXTRA_RESOURCE_DIRS "${CMAKE_INSTALL_PREFIX}/${DATA_INSTALL_DIR}:${CMAKE_SOURCE_DIR}/krita/data"
...@@ -59,7 +59,7 @@ void KisGradientBenchmark::benchmarkGradient() ...@@ -59,7 +59,7 @@ void KisGradientBenchmark::benchmarkGradient()
QLinearGradient grad; QLinearGradient grad;
grad.setColorAt(0, Qt::white); grad.setColorAt(0, Qt::white);
grad.setColorAt(1.0, Qt::red); grad.setColorAt(1.0, Qt::red);
KoAbstractGradient* kograd = KoStopGradient::fromQGradient(&grad); KoAbstractGradientSP kograd(KoStopGradient::fromQGradient(&grad));
Q_ASSERT(kograd); Q_ASSERT(kograd);
KisGradientPainter fillPainter(m_device); KisGradientPainter fillPainter(m_device);
//setupPainter(&fillPainter); //setupPainter(&fillPainter);
......
...@@ -61,7 +61,7 @@ void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName, ...@@ -61,7 +61,7 @@ void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName,
int poolLimitMiB, int poolLimitMiB,
int index) 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); LOAD_PRESET_OR_RETURN(preset, presetFileName);
......
...@@ -436,7 +436,7 @@ void KisStrokeBenchmark::predefinedBrushRL() ...@@ -436,7 +436,7 @@ void KisStrokeBenchmark::predefinedBrushRL()
inline void KisStrokeBenchmark::benchmarkLine(QString presetFileName) inline void KisStrokeBenchmark::benchmarkLine(QString presetFileName)
{ {
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName); KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
preset->load(); preset->load();
m_painter->setPaintOpPreset(preset, m_layer, m_image); m_painter->setPaintOpPreset(preset, m_layer, m_image);
...@@ -461,7 +461,7 @@ void KisStrokeBenchmark::benchmarkCircle(QString presetFileName) ...@@ -461,7 +461,7 @@ void KisStrokeBenchmark::benchmarkCircle(QString presetFileName)
{ {
dbgKrita << "(circle)preset : " << presetFileName; dbgKrita << "(circle)preset : " << presetFileName;
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName); KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
if (!preset->load()){ if (!preset->load()){
dbgKrita << "Preset was not loaded"; dbgKrita << "Preset was not loaded";
return; return;
...@@ -512,7 +512,7 @@ QBENCHMARK{ ...@@ -512,7 +512,7 @@ QBENCHMARK{
void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName) void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName)
{ {
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName); KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
bool loadedOk = preset->load(); bool loadedOk = preset->load();
if (!loadedOk){ if (!loadedOk){
dbgKrita << "The preset was not loaded correctly. Done."; dbgKrita << "The preset was not loaded correctly. Done.";
...@@ -541,7 +541,7 @@ void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName) ...@@ -541,7 +541,7 @@ void KisStrokeBenchmark::benchmarkRandomLines(QString presetFileName)
void KisStrokeBenchmark::benchmarkRectangle(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(); bool loadedOk = preset->load();
if (!loadedOk){ if (!loadedOk){
dbgKrita << "The preset was not loaded correctly. Done."; dbgKrita << "The preset was not loaded correctly. Done.";
...@@ -570,7 +570,7 @@ void KisStrokeBenchmark::benchmarkRectangle(QString presetFileName) ...@@ -570,7 +570,7 @@ void KisStrokeBenchmark::benchmarkRectangle(QString presetFileName)
void KisStrokeBenchmark::benchmarkStroke(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(); bool loadedOk = preset->load();
if (!loadedOk){ if (!loadedOk){
dbgKrita << "The preset was not loaded correctly. Done."; dbgKrita << "The preset was not loaded correctly. Done.";
...@@ -619,7 +619,7 @@ void KisStrokeBenchmark::benchmarkRand() ...@@ -619,7 +619,7 @@ void KisStrokeBenchmark::benchmarkRand()
void KisStrokeBenchmark::becnhmarkPresetCloning() void KisStrokeBenchmark::becnhmarkPresetCloning()
{ {
QString presetFileName = "spray_21_textures1.kpp"; QString presetFileName = "spray_21_textures1.kpp";
KisPaintOpPresetSP preset = new KisPaintOpPreset(m_dataPath + presetFileName); KisPaintOpPresetSP preset(new KisPaintOpPreset(m_dataPath + presetFileName));
bool loadedOk = preset->load(); bool loadedOk = preset->load();
KIS_ASSERT_RECOVER_RETURN(loadedOk); KIS_ASSERT_RECOVER_RETURN(loadedOk);
KIS_ASSERT_RECOVER_RETURN(preset->settings()); KIS_ASSERT_RECOVER_RETURN(preset->settings());
......
...@@ -3,3 +3,15 @@ a\)_Eraser_Circle.kpp ...@@ -3,3 +3,15 @@ a\)_Eraser_Circle.kpp
b\)_Basic-5_Size_default.kpp b\)_Basic-5_Size_default.kpp
DESTINATION ${DATA_INSTALL_DIR}/krita/paintoppresets) 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 ...@@ -44,7 +44,6 @@ delete_keyframe=none
deselect=Ctrl+Shift+A deselect=Ctrl+Shift+A
dual=none dual=none
duplicatelayer=Ctrl+J duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C edit_copy=Ctrl+C
edit_cut=Ctrl+X edit_cut=Ctrl+X
EditLayerMetaData=none EditLayerMetaData=none
......
...@@ -59,7 +59,6 @@ delete_keyframe=none ...@@ -59,7 +59,6 @@ delete_keyframe=none
deselect=Ctrl+Shift+A deselect=Ctrl+Shift+A
dual=none dual=none
duplicatelayer=Ctrl+J duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C edit_copy=Ctrl+C
edit_cut=Ctrl+X edit_cut=Ctrl+X
edit_deselect_all=Ctrl+Shift+A edit_deselect_all=Ctrl+Shift+A
......
[Shortcuts] black[Shortcuts]
activateNextLayer=Alt+] activateNextLayer=Alt+]
activatePreviousLayer=Alt+[ activatePreviousLayer=Alt+[
add_blank_frame=none add_blank_frame=none
...@@ -59,7 +59,6 @@ delete_keyframe=none ...@@ -59,7 +59,6 @@ delete_keyframe=none
deselect=Ctrl+D deselect=Ctrl+D
dual=none dual=none
duplicatelayer=Ctrl+J duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C edit_copy=Ctrl+C
edit_cut=Ctrl+X edit_cut=Ctrl+X
edit_deselect_all=Ctrl+Shift+A edit_deselect_all=Ctrl+Shift+A
......
...@@ -65,7 +65,6 @@ deselect=Ctrl+Shift+A ...@@ -65,7 +65,6 @@ deselect=Ctrl+Shift+A
drop_frames=none drop_frames=none
dual=none dual=none
duplicatelayer=Ctrl+J duplicatelayer=Ctrl+J
edit_blacklist_cleanup=none
edit_copy=Ctrl+C edit_copy=Ctrl+C
edit_cut=Ctrl+X edit_cut=Ctrl+X
edit_deselect_all=Ctrl+Shift+A edit_deselect_all=Ctrl+Shift+A
......
...@@ -14,18 +14,6 @@ ...@@ -14,18 +14,6 @@
<isCheckable>false</isCheckable> <isCheckable>false</isCheckable>
<statusTip></statusTip> <statusTip></statusTip>
</Action> </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"> <Action name="windows_cascade">
<icon></icon> <icon></icon>
<text>C&amp;ascade</text> <text>C&amp;ascade</text>
......
...@@ -341,6 +341,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org ...@@ -341,6 +341,7 @@ xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org
<text>Setti&amp;ngs</text> <text>Setti&amp;ngs</text>
<Action name="options_configure"/> <Action name="options_configure"/>
<Action name="manage_bundles"/> <Action name="manage_bundles"/>
<Action name="dbexplorer"/>
<Separator/> <Separator/>
<Action name="options_configure_toolbars"/> <Action name="options_configure_toolbars"/>
<Merge name="StandardToolBarMenuHandler" /> <Merge name="StandardToolBarMenuHandler" />
......
...@@ -20,5 +20,6 @@ add_subdirectory( libkis ) ...@@ -20,5 +20,6 @@ add_subdirectory( libkis )
if (NOT APPLE AND HAVE_QT_QUICK) if (NOT APPLE AND HAVE_QT_QUICK)
add_subdirectory( libqml ) add_subdirectory( libqml )
endif() endif()
add_subdirectory( resources )
add_subdirectory( metadata ) add_subdirectory( metadata )
add_subdirectory( resourcewidgets )
...@@ -11,7 +11,7 @@ set(kritalibbrush_LIB_SRCS ...@@ -11,7 +11,7 @@ set(kritalibbrush_LIB_SRCS
kis_brush.cpp kis_brush.cpp
kis_scaling_size_brush.cpp kis_scaling_size_brush.cpp
kis_brush_registry.cpp kis_brush_registry.cpp
kis_brush_server.cpp KisBrushServerProvider.cpp
kis_gbr_brush.cpp kis_gbr_brush.cpp
kis_abr_brush.cpp kis_abr_brush.cpp
kis_abr_brush_collection.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 @@ ...@@ -15,46 +15,40 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#ifndef KIS_BRUSH_SERVER_H #ifndef KIS_BRUSH_SERVER_PROVIDER_H
#define KIS_BRUSH_SERVER_H #define KIS_BRUSH_SERVER_PROVIDER_H
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QList> #include <QList>
#include <KoResourceServer.h> #include <KoResourceServer.h>
#include <KoResourceServerAdapter.h>
#include "kritabrush_export.h" #include "kritabrush_export.h"
#include "kis_brush.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 Q_OBJECT
public: public:
KisBrushServer(); KisBrushServerProvider();
~KisBrushServer() override; ~KisBrushServerProvider() override;
KisBrushResourceServer* brushServer();
static KisBrushServer* instance(); KoResourceServer<KisBrush>* brushServer();
public Q_SLOTS: static KisBrushServerProvider* instance();
void slotRemoveBlacklistedResources();
private: private:
KisBrushServer(const KisBrushServer&); KisBrushServerProvider(const KisBrushServerProvider&);
KisBrushServer operator=(const KisBrushServer&); KisBrushServerProvider operator=(const KisBrushServerProvider&);
KisBrushResourceServer* m_brushServer; KoResourceServer<KisBrush>* m_brushServer;
}; };
#endif #endif
...@@ -61,9 +61,9 @@ KisAbrBrush::KisAbrBrush(const KisAbrBrush& rhs, KisAbrBrushCollection *parent) ...@@ -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() bool KisAbrBrush::load()
......
...@@ -46,7 +46,7 @@ public: ...@@ -46,7 +46,7 @@ public:
KisAbrBrush(const QString& filename, KisAbrBrushCollection *parent); KisAbrBrush(const QString& filename, KisAbrBrushCollection *parent);
KisAbrBrush(const KisAbrBrush& rhs); KisAbrBrush(const KisAbrBrush& rhs);
KisAbrBrush(const KisAbrBrush& rhs, KisAbrBrushCollection *parent); KisAbrBrush(const KisAbrBrush& rhs, KisAbrBrushCollection *parent);
KisBrush* clone() const override; KisBrushSP clone() const override;
bool load() override; bool load() override;
...@@ -73,5 +73,7 @@ private: ...@@ -73,5 +73,7 @@ private:
KisAbrBrushCollection *m_parent; KisAbrBrushCollection *m_parent;
}; };
typedef QSharedPointer<KisAbrBrush> KisAbrBrushSP;
#endif // KIS_ABR_BRUSH_ #endif // KIS_ABR_BRUSH_
...@@ -378,12 +378,12 @@ quint32 KisAbrBrushCollection::abr_brush_load_v6(QDataStream & abr, AbrInfo *abr ...@@ -378,12 +378,12 @@ quint32 KisAbrBrushCollection::abr_brush_load_v6(QDataStream & abr, AbrInfo *abr
if (width < quint16_MAX && height < quint16_MAX) { if (width < quint16_MAX && height < quint16_MAX) {
// filename - filename of the file , e.g. test.abr // filename - filename of the file , e.g. test.abr
// name - test_number_of_the_brush, e.g test_1, test_2 // name - test_number_of_the_brush, e.g test_1, test_2
KisAbrBrush* abrBrush = 0; KisAbrBrushSP abrBrush;
if (m_abrBrushes.contains(name)) { if (m_abrBrushes.contains(name)) {
abrBrush = m_abrBrushes[name]; abrBrush = m_abrBrushes[name];
} }
else { else {
abrBrush = new KisAbrBrush(name, this); abrBrush = KisAbrBrushSP(new KisAbrBrush(name, this));
abrBrush->setMD5(md5()); abrBrush->setMD5(md5());
} }
...@@ -477,12 +477,12 @@ qint32 KisAbrBrushCollection::abr_brush_load_v12(QDataStream & abr, AbrInfo *abr ...@@ -477,12 +477,12 @@ qint32 KisAbrBrushCollection::abr_brush_load_v12(QDataStream & abr, AbrInfo *abr
rle_decode(abr, buffer, height); rle_decode(abr, buffer, height);
} }
KisAbrBrush* abrBrush = 0; KisAbrBrushSP abrBrush;
if (m_abrBrushes.contains(name)) { if (m_abrBrushes.contains(name)) {
abrBrush = m_abrBrushes[name]; abrBrush = m_abrBrushes[name];
} }
else { else {
abrBrush = new KisAbrBrush(name, this); abrBrush = KisAbrBrushSP(new KisAbrBrush(name, this));
abrBrush->setMD5(md5()); abrBrush->setMD5(md5());
} }
...@@ -534,13 +534,13 @@ KisAbrBrushCollection::KisAbrBrushCollection(const KisAbrBrushCollection& rhs) ...@@ -534,13 +534,13 @@ KisAbrBrushCollection::KisAbrBrushCollection(const KisAbrBrushCollection& rhs)
it != rhs.m_abrBrushes.end(); it != rhs.m_abrBrushes.end();
++it) { ++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() bool KisAbrBrushCollection::load()
......
...@@ -30,11 +30,13 @@ ...@@ -30,11 +30,13 @@
#include <kis_types.h> #include <kis_types.h>
#include <kis_shared.h> #include <kis_shared.h>
#include <brushengine/kis_paint_information.h> #include <brushengine/kis_paint_information.h>
#include <kis_abr_brush.h>
class QString; class QString;
class QIODevice; class QIODevice;
class KisAbrBrush;
struct AbrInfo; struct AbrInfo;
/** /**
...@@ -50,7 +52,7 @@ public: ...@@ -50,7 +52,7 @@ public:
/// Construct brush to load filename later as brush /// Construct brush to load filename later as brush
KisAbrBrushCollection(const QString& filename); KisAbrBrushCollection(const QString& filename);
KisBrush* clone() const override; KisBrushSP clone() const override;
~KisAbrBrushCollection() override {} ~KisAbrBrushCollection() override {}
...@@ -72,7 +74,7 @@ public: ...@@ -72,7 +74,7 @@ public:
*/ */
QString defaultFileExtension() const override; QString defaultFileExtension() const override;
QList<KisAbrBrush*> brushes() { QList<KisAbrBrushSP> brushes() {
return m_abrBrushes.values(); return m_abrBrushes.values();
} }
...@@ -86,7 +88,7 @@ private: ...@@ -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(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); 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); 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 #endif
......
...@@ -115,9 +115,9 @@ KisAutoBrush::KisAutoBrush(const KisAutoBrush& rhs) ...@@ -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 /* It's difficult to predict the mask height when exaclty when there are
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
KisAutoBrush(KisMaskGenerator* as, qreal angle, qreal randomness, qreal density = 1.0); KisAutoBrush(KisMaskGenerator* as, qreal angle, qreal randomness, qreal density = 1.0);
KisAutoBrush(const KisAutoBrush& rhs); KisAutoBrush(const KisAutoBrush& rhs);
KisBrush* clone() const override; KisBrushSP clone() const override;
~KisAutoBrush() override; ~KisAutoBrush() override;
......
...@@ -36,7 +36,7 @@ KisBrushSP KisAutoBrushFactory::createBrush(const QDomElement &brushDefinition) ...@@ -36,7 +36,7 @@ KisBrushSP KisAutoBrushFactory::createBrush(const QDomElement &brushDefinition)
bool useAutoSpacing = KisDomUtils::toInt(brushDefinition.attribute("useAutoSpacing", "0")); bool useAutoSpacing = KisDomUtils::toInt(brushDefinition.attribute("useAutoSpacing", "0"));
qreal autoSpacingCoeff = KisDomUtils::toDouble(brushDefinition.attribute("autoSpacingCoeff", "1.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->setSpacing(spacing);
brush->setAutoSpacing(useAutoSpacing, autoSpacingCoeff); brush->setAutoSpacing(useAutoSpacing, autoSpacingCoeff);
return brush; return brush;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <QImage> #include <QImage>
#include <resources/KoResource.h> #include <KoResource.h>
#include <kis_types.h> #include <kis_types.h>
#include <kis_shared.h> #include <kis_shared.h>
...@@ -51,7 +51,7 @@ enum enumBrushType { ...@@ -51,7 +51,7 @@ enum enumBrushType {
static const qreal DEFAULT_SOFTNESS_FACTOR = 1.0; static const qreal DEFAULT_SOFTNESS_FACTOR = 1.0;
class KisBrush; class KisBrush;
typedef KisSharedPtr<KisBrush> KisBrushSP; typedef QSharedPointer<KisBrush> KisBrushSP;
/** /**
* KisBrush is the base class for brush resources. A brush resource * KisBrush is the base class for brush resources. A brush resource
...@@ -339,7 +339,7 @@ public: ...@@ -339,7 +339,7 @@ public:
virtual void lodLimitations(KisPaintopLodLimitations *l) const; virtual void lodLimitations(KisPaintopLodLimitations *l) const;
virtual KisBrush* clone() const = 0; virtual KisBrushSP clone() const = 0;
protected: protected:
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <kis_debug.h> #include <kis_debug.h>
#include "kis_brush_server.h" #include "KoResourceServer.h"
#include "kis_auto_brush_factory.h" #include "kis_auto_brush_factory.h"
#include "kis_text_brush_factory.h" #include "kis_text_brush_factory.h"
#include "kis_predefined_brush_factory.h" #include "kis_predefined_brush_factory.h"
...@@ -36,7 +36,6 @@ Q_GLOBAL_STATIC(KisBrushRegistry, s_instance) ...@@ -36,7 +36,6 @@ Q_GLOBAL_STATIC(KisBrushRegistry, s_instance)
KisBrushRegistry::KisBrushRegistry() KisBrushRegistry::KisBrushRegistry()
{ {
KisBrushServer::instance();
} }
KisBrushRegistry::~KisBrushRegistry() 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 @@ ...@@ -20,6 +20,7 @@
#define __KIS_BRUSHES_PIPE_H #define __KIS_BRUSHES_PIPE_H
#include <kis_fixed_paint_device.h> #include <kis_fixed_paint_device.h>
#include <kis_brush.h>
template<class BrushType> template<class BrushType>
class KisBrushesPipe class KisBrushesPipe
...@@ -29,34 +30,31 @@ public: ...@@ -29,34 +30,31 @@ public:
} }
KisBrushesPipe(const KisBrushesPipe &rhs) { KisBrushesPipe(const KisBrushesPipe &rhs) {
qDeleteAll(m_brushes);
m_brushes.clear(); m_brushes.clear();
Q_FOREACH (BrushType * brush, rhs.m_brushes) { Q_FOREACH (QSharedPointer<BrushType> brush, rhs.m_brushes) {
BrushType *clonedBrush = dynamic_cast<BrushType*>(brush->clone()); KisBrushSP clonedBrush = brush->clone();
QSharedPointer<BrushType> actualClonedBrush = clonedBrush.dynamicCast<BrushType>();
m_brushes.append(actualClonedBrush );
KIS_ASSERT_RECOVER(clonedBrush) {continue;} KIS_ASSERT_RECOVER(clonedBrush) {continue;}
m_brushes.append(clonedBrush);
} }
} }
virtual ~KisBrushesPipe() { virtual ~KisBrushesPipe() {
qDeleteAll(m_brushes);
} }
virtual void clear() { virtual void clear() {
qDeleteAll(m_brushes);
m_brushes.clear(); m_brushes.clear();
} }
BrushType* firstBrush() const { QSharedPointer<BrushType> firstBrush() const {
return m_brushes.first(); return m_brushes.first();
} }
BrushType* lastBrush() const { QSharedPointer<BrushType> lastBrush() const {
return m_brushes.last(); 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; return !m_brushes.isEmpty() ? m_brushes.at(chooseNextBrush(info)) : 0;
} }
...@@ -65,35 +63,35 @@ public: ...@@ -65,35 +63,35 @@ public:
} }
qint32 maskWidth(KisDabShape const& shape, double subPixelX, double subPixelY, const KisPaintInformation& info) { 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; return brush ? brush->maskWidth(shape, subPixelX, subPixelY, info) : 0;
} }
qint32 maskHeight(KisDabShape const& shape, double subPixelX, double subPixelY, const KisPaintInformation& info) { 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; return brush ? brush->maskHeight(shape, subPixelX, subPixelY, info) : 0;
} }
void setAngle(qreal angle) { void setAngle(qreal angle) {
Q_FOREACH (BrushType * brush, m_brushes) { Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
brush->setAngle(angle); brush->setAngle(angle);
} }
} }
void setScale(qreal scale) { void setScale(qreal scale) {
Q_FOREACH (BrushType * brush, m_brushes) { Q_FOREACH (QSharedPointer<BrushType> brush, m_brushes) {
brush->setScale(scale); brush->setScale(scale);
} }
} }
void setSpacing(double spacing) { void setSpacing(double spacing) {
Q_FOREACH (BrushType * brush, m_brushes) {