Krita

PresetChooser.cpp
1 /*
2  * SPDX-FileCopyrightText: 2017 Boudewijn Rempt <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 #include "PresetChooser.h"
7 
8 #include <KoResource.h>
9 #include <kis_config.h>
10 #include "Resource.h"
11 
12 PresetChooser::PresetChooser(QWidget *parent)
13  : KisPresetChooser(parent)
14 {
15  connect(this, SIGNAL(resourceSelected(KoResourceSP )), SLOT(slotResourceSelected(KoResourceSP )));
16  connect(this, SIGNAL(resourceClicked(KoResourceSP )), SLOT(slotResourceClicked(KoResourceSP )));
17  showTaggingBar(true);
18 }
19 
20 
22 {
23  KoResourceSP r = resource->resource();
24  setCurrentResource(r);
25 }
26 
28 {
29  KoResourceSP r = currentResource();
30  if (r) {
31  return new Resource(r->resourceId(), "paintoppreset", r->name(), r->filename(), r->image());
32  }
33  return 0;
34 }
35 
36 void PresetChooser::slotResourceSelected(KoResourceSP r)
37 {
38  emit presetSelected(Resource(r->resourceId(), "paintoppreset", r->name(), r->filename(), r->image()));
39 }
40 
41 void PresetChooser::slotResourceClicked(KoResourceSP r)
42 {
43  emit presetClicked(Resource(r->resourceId(), "paintoppreset", r->name(), r->filename(), r->image()));
44 }
Resource * currentPreset() const
A Resource represents a gradient, pattern, brush tip, brush preset, palette or workspace definition.
Definition: Resource.h:30
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void presetClicked(Resource resource)
Emitted whenever a user clicks on the given preset.
void presetSelected(Resource resource)
Emitted whenever a user selects the given preset.
void setCurrentPreset(Resource *resource)
Make the given preset active.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Dec 4 2022 04:12:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.