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

#include <kis_pattern_chooser.h>

+ Inheritance diagram for KisPatternChooser:

Public Slots

void setCurrentItem (int row)
 
void setCurrentPattern (KoResourceSP resource)
 

Signals

void resourceSelected (KoResourceSP resource)
 Emitted when a resource was selected.
 
void updateItemSize ()
 

Public Member Functions

KoResourceSP currentResource (bool includeHidden=false)
 
 KisPatternChooser (QWidget *parent=0)
 
void setGrayscalePreview (bool grayscale)
 
void setPreviewOrientation (Qt::Orientation orientation)
 determines whether the preview right or below the splitter
 
 ~KisPatternChooser () override
 

Private Slots

void update (KoResourceSP resource)
 

Private Attributes

KisResourceItemChooserm_itemChooser
 
KSqueezedTextLabel * m_lblName
 

Detailed Description

Definition at line 19 of file kis_pattern_chooser.h.

Constructor & Destructor Documentation

◆ KisPatternChooser()

KisPatternChooser::KisPatternChooser ( QWidget * parent = 0)

Definition at line 29 of file kis_pattern_chooser.cc.

30 : QFrame(parent)
31{
32 m_lblName = new KSqueezedTextLabel(this);
33 m_lblName->setTextElideMode(Qt::ElideMiddle);
34 m_lblName->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
35
38 m_itemChooser->setPreviewOrientation(Qt::Horizontal);
41
43 this, SLOT(update(KoResourceSP )));
44
46 this, SIGNAL(resourceSelected(KoResourceSP )));
47
48 QVBoxLayout *mainLayout = new QVBoxLayout(this);
49 mainLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
50 mainLayout->setContentsMargins(0, 0, 0, 0);
51 mainLayout->addWidget(m_lblName);
52 mainLayout->addWidget(m_itemChooser, 10);
53}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisResourceItemChooser * m_itemChooser
KSqueezedTextLabel * m_lblName
void update(KoResourceSP resource)
void resourceSelected(KoResourceSP resource)
Emitted when a resource was selected.
void setPreviewOrientation(Qt::Orientation orientation)
determines whether the preview right or below the splitter
void setPreviewTiled(bool tiled)
determines whether the preview should tile the resource's image or not
const QString Patterns

References connect(), m_itemChooser, m_lblName, ResourceType::Patterns, resourceSelected(), KisResourceItemChooser::setPreviewOrientation(), KisResourceItemChooser::setPreviewTiled(), KisResourceItemChooser::setSynced(), KisResourceItemChooser::showTaggingBar(), and update().

◆ ~KisPatternChooser()

KisPatternChooser::~KisPatternChooser ( )
override

Definition at line 55 of file kis_pattern_chooser.cc.

56{
57}

Member Function Documentation

◆ currentResource()

KoResourceSP KisPatternChooser::currentResource ( bool includeHidden = false)

Gets the currently selected resource

Returns
the selected resource, 0 is no resource is selected

Definition at line 59 of file kis_pattern_chooser.cc.

60{
61 KoResourceSP result = m_itemChooser->currentResource(includeHidden);
62
63 if (!result && includeHidden) {
65 if (rserver->resourceCount() > 0) {
68 result = rserver->firstResource();
69 }
70 }
71 return result;
72}
void setCurrentResource(KoResourceSP resource)
Sets the item representing the resource as selected.
int resourceCount() const
QSharedPointer< T > firstResource() const
Return the first resource available.
static KoResourceServerProvider * instance()
KoResourceServer< KoPattern > * patternServer

References KisResourceItemChooser::currentResource, KoResourceServer< T >::firstResource(), KoResourceServerProvider::instance(), m_itemChooser, KoResourceServerProvider::patternServer, KoResourceServer< T >::resourceCount(), and KisResourceItemChooser::setCurrentResource().

◆ resourceSelected

void KisPatternChooser::resourceSelected ( KoResourceSP resource)
signal

Emitted when a resource was selected.

◆ setCurrentItem

void KisPatternChooser::setCurrentItem ( int row)
slot

Definition at line 81 of file kis_pattern_chooser.cc.

82{
84 if (currentResource()) {
86 }
87}
KoResourceSP currentResource(bool includeHidden=false)

References currentResource(), m_itemChooser, KisResourceItemChooser::setCurrentItem(), and update().

◆ setCurrentPattern

void KisPatternChooser::setCurrentPattern ( KoResourceSP resource)
slot

◆ setGrayscalePreview()

void KisPatternChooser::setGrayscalePreview ( bool grayscale)

Definition at line 102 of file kis_pattern_chooser.cc.

103{
105}
void setGrayscalePreview(bool grayscale)
shows the preview converted to grayscale

References m_itemChooser, and KisResourceItemChooser::setGrayscalePreview().

◆ setPreviewOrientation()

void KisPatternChooser::setPreviewOrientation ( Qt::Orientation orientation)

determines whether the preview right or below the splitter

Definition at line 89 of file kis_pattern_chooser.cc.

90{
92}

References m_itemChooser, and KisResourceItemChooser::setPreviewOrientation().

◆ update

void KisPatternChooser::update ( KoResourceSP resource)
privateslot

Definition at line 94 of file kis_pattern_chooser.cc.

95{
96 if (!resource) return;
97
98 KoPatternSP pattern = resource.staticCast<KoPattern>();
99 m_lblName->setText(QString("%1 (%2 x %3)").arg(i18n(pattern->name().toUtf8().data())).arg(pattern->width()).arg(pattern->height()));
100}
Write API docs here.
Definition KoPattern.h:21

References m_lblName.

◆ updateItemSize

void KisPatternChooser::updateItemSize ( )
signal

Member Data Documentation

◆ m_itemChooser

KisResourceItemChooser* KisPatternChooser::m_itemChooser
private

Definition at line 53 of file kis_pattern_chooser.h.

◆ m_lblName

KSqueezedTextLabel* KisPatternChooser::m_lblName
private

Definition at line 52 of file kis_pattern_chooser.h.


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