Krita Source Code Documentation
Loading...
Searching...
No Matches
KisPresetChooser Class Reference

#include <kis_preset_chooser.h>

+ Inheritance diagram for KisPresetChooser:

Public Types

enum  ViewMode { THUMBNAIL , DETAIL }
 

Public Slots

void saveIconSize ()
 saves the icon size for the presets. called by the horizontal slider release event.
 
void setIconSize (int newSize)
 sets the icon size. Used by slider in view menu
 
void showHideBrushNames (ListViewMode newViewMode)
 
void updateViewSettings ()
 

Signals

void resourceClicked (KoResourceSP resource)
 
void resourceSelected (KoResourceSP resource)
 

Public Member Functions

KoResourceSP currentResource () const
 
int iconSize ()
 get the base size for the icons. Used by the slider in the view options
 
KisResourceItemChooseritemChooser ()
 
 KisPresetChooser (QWidget *parent=0)
 
void setCurrentResource (KoResourceSP resource)
 
void setPresetFilter (const QString &paintOpId)
 
void setViewMode (ViewMode mode)
 Sets a list of resources in the paintop list, when ever user press enter in the lineedit of paintop_presets_popup Class.
 
void setViewModeToDetail ()
 
void setViewModeToThumbnail ()
 
void showTaggingBar (bool show)
 Sets the visibility of tagging klineEdits.
 
 ~KisPresetChooser () override
 

Private Slots

void notifyConfigChanged ()
 
void slotCurrentPresetChanged ()
 
void slotResourceWasSelected (KoResourceSP resource)
 

Private Attributes

KisResourceItemChooserm_chooser {0}
 
KisSignalAutoConnectionsStore m_currentPresetConnections
 
KisPresetDelegatem_delegate {0}
 
ViewMode m_mode
 
QPointer< PaintOpFilterModel > m_paintOpFilterModel
 

Detailed Description

A special type of item chooser that can contain extra widgets that show more information about the currently selected item. Reimplement update() to extract that information and fill the appropriate widgets.

Definition at line 31 of file kis_preset_chooser.h.

Member Enumeration Documentation

◆ ViewMode

Enumerator
THUMBNAIL 
DETAIL 

Shows thumbnails.

Shows thumbnails with text next to it

Definition at line 40 of file kis_preset_chooser.h.

40 {
41 THUMBNAIL,
42 DETAIL
43 };
@ DETAIL
Shows thumbnails.

Constructor & Destructor Documentation

◆ KisPresetChooser()

KisPresetChooser::KisPresetChooser ( QWidget * parent = 0)

Definition at line 169 of file kis_preset_chooser.cpp.

170 : QWidget(parent)
171{
172 setObjectName("KisPresetChooser");
173
174 QVBoxLayout * layout = new QVBoxLayout(this);
175 layout->setContentsMargins(0, 0, 0, 0);
176
179 m_delegate = new KisPresetDelegate(this);
181 m_chooser->setSynced(true);
183 layout->addWidget(m_chooser);
184
185 connect(m_chooser, SIGNAL(resourceSelected(KoResourceSP )),
187
188 connect(m_chooser, SIGNAL(resourceSelected(KoResourceSP )),
189 this, SIGNAL(resourceSelected(KoResourceSP )));
190 connect(m_chooser, SIGNAL(resourceClicked(KoResourceSP )),
191 this, SIGNAL(resourceClicked(KoResourceSP )));
192
194
196
197 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()),
198 SLOT(notifyConfigChanged()));
199
200
202}
static KisConfigNotifier * instance()
void slotResourceWasSelected(KoResourceSP resource)
void resourceSelected(KoResourceSP resource)
KisResourceItemChooser * m_chooser
KisPresetDelegate * m_delegate
void showHideBrushNames(ListViewMode newViewMode)
void resourceClicked(KoResourceSP resource)
The resource item delegate for rendering the resource preview.
void listViewModeChanged(ListViewMode newViewMode)
Emitted when the view mode for the internal KisResourceItemListView changes.
void setRowHeight(int rowHeight)
Sets the height of the view rows.
void setItemDelegate(QAbstractItemDelegate *delegate)
Sets a custom delegate for the view.
const QString PaintOpPresets

References KisConfigNotifier::instance(), KisResourceItemChooser::listViewModeChanged(), m_chooser, m_delegate, m_mode, notifyConfigChanged(), ResourceType::PaintOpPresets, resourceClicked(), resourceSelected(), KisResourceItemChooser::setItemDelegate(), KisResourceItemChooser::setRowHeight(), KisResourceItemChooser::setSynced(), showHideBrushNames(), KisResourceItemChooser::showImportExportBtns(), slotResourceWasSelected(), and THUMBNAIL.

◆ ~KisPresetChooser()

KisPresetChooser::~KisPresetChooser ( )
override

Definition at line 204 of file kis_preset_chooser.cpp.

205{
206}

Member Function Documentation

◆ currentResource()

KoResourceSP KisPresetChooser::currentResource ( ) const

Definition at line 276 of file kis_preset_chooser.cpp.

277{
278 return m_chooser->currentResource();
279}

References KisResourceItemChooser::currentResource, and m_chooser.

◆ iconSize()

int KisPresetChooser::iconSize ( )

get the base size for the icons. Used by the slider in the view options

Definition at line 307 of file kis_preset_chooser.cpp.

References KisResourceItemChooserSync::baseLength, and KisResourceItemChooserSync::instance().

◆ itemChooser()

KisResourceItemChooser * KisPresetChooser::itemChooser ( )

Definition at line 286 of file kis_preset_chooser.cpp.

287{
288 return m_chooser;
289}

References m_chooser.

◆ notifyConfigChanged

void KisPresetChooser::notifyConfigChanged ( )
privateslot

Definition at line 224 of file kis_preset_chooser.cpp.

225{
226 KisConfig cfg(true);
227 m_delegate->setUseDirtyPresets(cfg.useDirtyPresets());
228 setIconSize(cfg.presetIconSize());
229}
void setIconSize(int newSize)
sets the icon size. Used by slider in view menu
void setUseDirtyPresets(bool value)

References m_delegate, KisConfig::presetIconSize(), setIconSize(), KisPresetDelegate::setUseDirtyPresets(), and KisConfig::useDirtyPresets().

◆ resourceClicked

void KisPresetChooser::resourceClicked ( KoResourceSP resource)
signal

◆ resourceSelected

void KisPresetChooser::resourceSelected ( KoResourceSP resource)
signal

◆ saveIconSize

void KisPresetChooser::saveIconSize ( )
slot

saves the icon size for the presets. called by the horizontal slider release event.

Definition at line 313 of file kis_preset_chooser.cpp.

314{
315 // save icon size
316 if (KisConfig(true).presetIconSize() != iconSize()) {
318 }
319}
void setPresetIconSize(const int value) const
int iconSize()
get the base size for the icons. Used by the slider in the view options

References iconSize(), and KisConfig::setPresetIconSize().

◆ setCurrentResource()

void KisPresetChooser::setCurrentResource ( KoResourceSP resource)

Definition at line 271 of file kis_preset_chooser.cpp.

272{
273 m_chooser->setCurrentResource(resource);
274}
void setCurrentResource(KoResourceSP resource)
Sets the item representing the resource as selected.

References m_chooser, and KisResourceItemChooser::setCurrentResource().

◆ setIconSize

void KisPresetChooser::setIconSize ( int newSize)
slot

sets the icon size. Used by slider in view menu

Definition at line 301 of file kis_preset_chooser.cpp.

302{
304 chooserSync->setBaseLength(newSize);
305}

References KisResourceItemChooserSync::instance(), and KisResourceItemChooserSync::setBaseLength().

◆ setPresetFilter()

void KisPresetChooser::setPresetFilter ( const QString & paintOpId)

Definition at line 291 of file kis_preset_chooser.cpp.

292{
293 QMap<QString, QVariant> metaDataFilter;
294 if (!paintOpId.isEmpty()) { // empty means "all"
295 metaDataFilter["paintopid"] = paintOpId;
296 }
297 m_chooser->tagFilterModel()->setMetaDataFilter(metaDataFilter);
299}
KisTagFilterResourceProxyModel * tagFilterModel() const
void setMetaDataFilter(QMap< QString, QVariant > metaDataMap)
setMetaDataFilter provides a set of metadata to filter on, for instance by paintop id category.

References m_chooser, KisTagFilterResourceProxyModel::setMetaDataFilter(), KisResourceItemChooser::tagFilterModel(), and updateViewSettings().

◆ setViewMode()

void KisPresetChooser::setViewMode ( KisPresetChooser::ViewMode mode)

Sets a list of resources in the paintop list, when ever user press enter in the lineedit of paintop_presets_popup Class.

Definition at line 208 of file kis_preset_chooser.cpp.

209{
210 m_mode = mode;
212}

References m_mode, and updateViewSettings().

◆ setViewModeToDetail()

void KisPresetChooser::setViewModeToDetail ( )

Definition at line 219 of file kis_preset_chooser.cpp.

220{
222}
void setViewMode(ViewMode mode)
Sets a list of resources in the paintop list, when ever user press enter in the lineedit of paintop_p...

References DETAIL, and setViewMode().

◆ setViewModeToThumbnail()

void KisPresetChooser::setViewModeToThumbnail ( )

Definition at line 214 of file kis_preset_chooser.cpp.

References setViewMode(), and THUMBNAIL.

◆ showHideBrushNames

void KisPresetChooser::showHideBrushNames ( ListViewMode newViewMode)
slot

Shows/hides brush names when KisResourceItemListView used by KisResourceItemChooser changes it's ListViewMode. If this method is removed then the Details view brush names will still be displayed when KisResourceItemChooser is in horizontal layout.

Definition at line 321 of file kis_preset_chooser.cpp.

322{
323 switch (newViewMode) {
325 m_delegate->setShowText(true);
326 break;
327 }
328 default: {
329 m_delegate->setShowText(false);
330 }
331 }
332}
void setShowText(bool showText)

References Detail, m_delegate, and KisPresetDelegate::setShowText().

◆ showTaggingBar()

void KisPresetChooser::showTaggingBar ( bool show)

Sets the visibility of tagging klineEdits.

Definition at line 281 of file kis_preset_chooser.cpp.

282{
284}

References m_chooser, and KisResourceItemChooser::showTaggingBar().

◆ slotCurrentPresetChanged

void KisPresetChooser::slotCurrentPresetChanged ( )
privateslot

◆ slotResourceWasSelected

void KisPresetChooser::slotResourceWasSelected ( KoResourceSP resource)
privateslot

Definition at line 231 of file kis_preset_chooser.cpp.

232{
234 if (!resource) return;
235
236 KisPaintOpPresetSP preset = resource.dynamicCast<KisPaintOpPreset>();
238
240 preset->updateProxy(), SIGNAL(sigSettingsChanged()),
241 this, SLOT(slotCurrentPresetChanged()));
242}
KisSignalAutoConnectionsStore m_currentPresetConnections
void addUniqueConnection(Sender sender, Signal signal, Receiver receiver, Method method)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128

References KisSignalAutoConnectionsStore::addUniqueConnection(), KisSignalAutoConnectionsStore::clear(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_currentPresetConnections, and slotCurrentPresetChanged().

◆ updateViewSettings

void KisPresetChooser::updateViewSettings ( )
slot

Member Data Documentation

◆ m_chooser

KisResourceItemChooser* KisPresetChooser::m_chooser {0}
private

Definition at line 89 of file kis_preset_chooser.h.

89{0};

◆ m_currentPresetConnections

KisSignalAutoConnectionsStore KisPresetChooser::m_currentPresetConnections
private

Definition at line 96 of file kis_preset_chooser.h.

◆ m_delegate

KisPresetDelegate* KisPresetChooser::m_delegate {0}
private

Definition at line 90 of file kis_preset_chooser.h.

90{0};

◆ m_mode

ViewMode KisPresetChooser::m_mode
private

Definition at line 91 of file kis_preset_chooser.h.

◆ m_paintOpFilterModel

QPointer<PaintOpFilterModel> KisPresetChooser::m_paintOpFilterModel
private

Definition at line 94 of file kis_preset_chooser.h.


The documentation for this class was generated from the following files: