Changeset View
Changeset View
Standalone View
Standalone View
libs/libkis/BrushPreset.cpp
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2018 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Lesser General Public License as published by | ||||
6 | * the Free Software Foundation; either version 2 of the License, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU General Public License for more details. | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Lesser General Public License | ||||
15 | * along with this program; if not, write to the Free Software | ||||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
17 | */ | ||||
18 | #include "BrushPreset.h" | ||||
19 | #include <kis_paintop_preset.h> | ||||
20 | #include <kis_paintop_settings.h> | ||||
21 | #include "InfoObject.h" | ||||
22 | | ||||
23 | struct BrushPreset::Private { | ||||
24 | KisPaintOpPreset *BrushPreset {0}; | ||||
25 | }; | ||||
26 | | ||||
27 | BrushPreset::BrushPreset(KoResource *resource, QObject *parent) | ||||
28 | : Resource(resource, parent) | ||||
29 | , d(new Private()) | ||||
30 | { | ||||
31 | d->BrushPreset = dynamic_cast<KisPaintOpPreset*>(resource); | ||||
32 | } | ||||
33 | | ||||
34 | BrushPreset::~BrushPreset() | ||||
35 | { | ||||
36 | delete d; | ||||
37 | } | ||||
38 | | ||||
39 | QString BrushPreset::brushEngineName() const | ||||
40 | { | ||||
41 | return d->BrushPreset->paintOp().id(); | ||||
42 | } | ||||
43 | | ||||
44 | bool BrushPreset::setSettings(InfoObject *settings) | ||||
45 | { | ||||
46 | KisPaintOpSettingsSP paintopset = KisPaintOpSettingsSP(dynamic_cast<KisPaintOpSettings*>(settings->configuration().data())); | ||||
47 | if (paintopset) { | ||||
48 | d->BrushPreset->setSettings(paintopset); | ||||
49 | return true; | ||||
50 | } | ||||
51 | return false; | ||||
52 | } | ||||
53 | | ||||
54 | bool BrushPreset::load() | ||||
55 | { | ||||
56 | return d->BrushPreset->load(); | ||||
57 | } | ||||
58 | | ||||
59 | bool BrushPreset::isDirty() | ||||
60 | { | ||||
61 | return d->BrushPreset->isPresetDirty(); | ||||
62 | } | ||||
63 | | ||||
64 | InfoObject *BrushPreset::settings() const | ||||
65 | { | ||||
66 | return new InfoObject(d->BrushPreset->settings()); | ||||
67 | } | ||||
68 | | ||||
69 | KisPaintOpPreset *BrushPreset::preset() | ||||
70 | { | ||||
71 | return d->BrushPreset; | ||||
72 | } | ||||
73 | |