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

#include <kis_dlg_stroke_selection_properties.h>

+ Inheritance diagram for KisDlgStrokeSelection:

Public Member Functions

KoColor getFillSelectedColor () const
 
LinePosition getLinePosition () const
 
int getLineSize () const
 
StrokeSelectionOptions getParams () const
 
KoColor getSelectedColor () const
 
bool isBrushSelected () const
 
 KisDlgStrokeSelection (KisImageWSP image, KisViewManager *view, bool isVectorLayer)
 
 ~KisDlgStrokeSelection () override
 
- Public Member Functions inherited from KoDialog
QPushButton * button (ButtonCode id) const
 
QIcon buttonIcon (ButtonCode id) const
 
QString buttonText (ButtonCode id) const
 
QString buttonToolTip (ButtonCode id) const
 
QString buttonWhatsThis (ButtonCode id) const
 
ButtonCode defaultButton () const
 
QString helpLinkText () const
 
void incrementInitialSize (const QSize &size)
 
bool isButtonEnabled (ButtonCode id) const
 
 KoDialog (QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
 
QWidget * mainWidget ()
 
QSize minimumSizeHint () const override
 
void setButtonFocus (ButtonCode id)
 
void setButtonGuiItem (ButtonCode id, const KGuiItem &item)
 
void setButtonIcon (ButtonCode id, const QIcon &icon)
 
void setButtons (ButtonCodes buttonMask)
 
void setButtonsOrientation (Qt::Orientation orientation)
 
void setButtonText (ButtonCode id, const QString &text)
 
void setButtonToolTip (ButtonCode id, const QString &text)
 
void setButtonWhatsThis (ButtonCode id, const QString &text)
 
void setDefaultButton (ButtonCode id)
 
void setEscapeButton (ButtonCode id)
 
void setInitialSize (const QSize &size)
 
void setMainWidget (QWidget *widget)
 
void showButton (ButtonCode id, bool state)
 
void showButtonSeparator (bool state)
 
QSize sizeHint () const override
 
 ~KoDialog () override
 

Private Slots

void colorChanged (const QColor &newColor)
 
void colorFillChanged (const QColor &newColor)
 
void setColorButton ()
 
void setColorFillButton ()
 

Private Attributes

KisDisplayColorConverterm_converter {0}
 
KisImageWSP m_image
 
bool m_isVectorLayer {false}
 
WdgStrokeSelectionm_page {0}
 
KoCanvasResourceProviderm_resourceManager {0}
 

Additional Inherited Members

- Public Types inherited from KoDialog
enum  ButtonCode {
  None = 0x00000000 , Help = 0x00000001 , Default = 0x00000002 , Ok = 0x00000004 ,
  Apply = 0x00000008 , Try = 0x00000010 , Cancel = 0x00000020 , Close = 0x00000040 ,
  No = 0x00000080 , Yes = 0x00000100 , Reset = 0x00000200 , Details = 0x00000400 ,
  User1 = 0x00001000 , User2 = 0x00002000 , User3 = 0x00004000 , NoDefault = 0x00008000
}
 
enum  ButtonPopupMode { InstantPopup = 0 , DelayedPopup = 1 }
 
enum  CaptionFlag { NoCaptionFlags = 0 , AppNameCaption = 1 , ModifiedCaption = 2 , HIGCompliantCaption = AppNameCaption }
 
- Public Slots inherited from KoDialog
void delayedDestruct ()
 
void enableButton (ButtonCode id, bool state)
 
void enableButtonApply (bool state)
 
void enableButtonCancel (bool state)
 
void enableButtonOk (bool state)
 
void enableLinkedHelp (bool state)
 
bool isDetailsWidgetVisible () const
 
virtual void setCaption (const QString &caption)
 
virtual void setCaption (const QString &caption, bool modified)
 
void setDetailsWidget (QWidget *detailsWidget)
 
void setDetailsWidgetVisible (bool visible)
 
void setHelp (const QString &anchor, const QString &appname=QString())
 
void setHelpLinkText (const QString &text)
 
virtual void setPlainCaption (const QString &caption)
 
- Signals inherited from KoDialog
void aboutToShowDetails ()
 
void applyClicked ()
 
void buttonClicked (KoDialog::ButtonCode button)
 
void cancelClicked ()
 
void closeClicked ()
 
void defaultClicked ()
 
void finished ()
 
void helpClicked ()
 
void hidden ()
 
void layoutHintChanged ()
 
void noClicked ()
 
void okClicked ()
 
void resetClicked ()
 
void tryClicked ()
 
void user1Clicked ()
 
void user2Clicked ()
 
void user3Clicked ()
 
void yesClicked ()
 
- Static Public Member Functions inherited from KoDialog
static int groupSpacingHint ()
 
static QString makeStandardCaption (const QString &userCaption, QWidget *window=0, CaptionFlags flags=HIGCompliantCaption)
 
static int marginHint ()
 
static void resizeLayout (QLayout *lay, int margin, int spacing)
 
static void resizeLayout (QWidget *widget, int margin, int spacing)
 
static int spacingHint ()
 
- Protected Slots inherited from KoDialog
virtual void slotButtonClicked (int button)
 
- Protected Member Functions inherited from KoDialog
void closeEvent (QCloseEvent *e) override
 
void hideEvent (QHideEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
void showEvent (QShowEvent *e) override
 

Detailed Description

Definition at line 82 of file kis_dlg_stroke_selection_properties.h.

Constructor & Destructor Documentation

◆ KisDlgStrokeSelection()

KisDlgStrokeSelection::KisDlgStrokeSelection ( KisImageWSP image,
KisViewManager * view,
bool isVectorLayer )

Definition at line 42 of file kis_dlg_stroke_selection_properties.cpp.

44{
46 KisPropertiesConfigurationSP cfg = KisConfig(true).exportConfiguration("StrokeSelection");
47
51 setCaption(i18nc("@title:window", "Stroke Selection Properties"));
52 m_page = new WdgStrokeSelection(this);
53 m_page->m_isVectorLayer = isVectorLayer;
54 m_page->m_cfg = cfg;
55
56 m_image = image;
57
59
61 m_options.color = cfg->getColor("color");
62 m_options.colorLineSource = static_cast<ColorLineSource>(cfg->getInt("lineColorSource"));
63 m_page->lineColorBox->setCurrentIndex(static_cast<int>(m_options.colorLineSource));
64
65 m_page->colorSelector->setColor(getSelectedColor().toQColor());
66
67 m_options.brushSelected = cfg->getBool("useBrush", 0);
68 m_page->typeBox->setCurrentIndex(m_options.brushSelected? 0 : 1);
69
70 m_options.colorFillSource = static_cast<ColorFillSource>(cfg->getInt("colorFillSource", 0));
71 m_page->fillBox->setCurrentIndex(static_cast<int>(m_options.colorFillSource));
72 m_options.customColor = cfg->getColor("customColor");
73
75 m_page->colorFillSelector->setColor(m_options.customColor.toQColor());
76 }
77 else {
78 m_page->colorFillSelector->setColor(getFillSelectedColor().toQColor());
79 }
80
81 m_options.lineSize = cfg->getInt("lineSize", 1);
82 m_page->lineSize->setValue(m_options.lineSize);
83
84 m_options.lineDimension = cfg->getInt("lineDimension", 0);
85 m_page->sizeBox->setCurrentIndex(m_options.lineDimension);
86
87 connect(m_page, SIGNAL(colorSelectorChanged()), SLOT(setColorButton()));
88 connect(m_page, SIGNAL(colorFillSelectorChanged()), SLOT(setColorFillButton()));
89 connect(m_page->colorFillSelector, SIGNAL(changed(QColor)), SLOT(colorFillChanged(QColor)));
90 connect(m_page->colorSelector, SIGNAL(changed(QColor)), SLOT(colorChanged(QColor)));
91
93
94}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisDisplayColorConverter displayColorConverter
KisPropertiesConfigurationSP exportConfiguration(const QString &filterId, bool defaultValue=false) const
KoCanvasResourceProvider * m_resourceManager
void colorFillChanged(const QColor &newColor)
void colorChanged(const QColor &newColor)
KoCanvasResourceProvider * resourceManager() const
KisMainWindow * mainWindow() const
KisCanvas2 * canvasBase() const
Return the canvas base class.
QWidget * mainWindowAsQWidget() const
void toQColor(QColor *c) const
a convenience method for the above.
Definition KoColor.cpp:198
void setMainWidget(QWidget *widget)
Definition KoDialog.cpp:354
virtual void setCaption(const QString &caption)
Definition KoDialog.cpp:498
void setButtons(ButtonCodes buttonMask)
Definition KoDialog.cpp:195
void setDefaultButton(ButtonCode id)
Definition KoDialog.cpp:302
@ Ok
Show Ok button. (this button accept()s the dialog; result set to QDialog::Accepted)
Definition KoDialog.h:127
@ Cancel
Show Cancel-button. (this button reject()s the dialog; result set to QDialog::Rejected)
Definition KoDialog.h:130
KoDialog(QWidget *parent=0, Qt::WindowFlags f=Qt::WindowFlags())
Definition KoDialog.cpp:176
KisPropertiesConfigurationSP m_cfg

References StrokeSelectionOptions::brushSelected, KoDialog::Cancel, KisViewManager::canvasBase(), StrokeSelectionOptions::color, colorChanged(), colorFillChanged(), StrokeSelectionOptions::colorFillSource, StrokeSelectionOptions::colorLineSource, connect(), CustomColor, StrokeSelectionOptions::customColor, KisCanvas2::displayColorConverter, WdgStrokeSelection::enableControls(), KisConfig::exportConfiguration(), getFillSelectedColor(), getSelectedColor(), StrokeSelectionOptions::lineDimension, StrokeSelectionOptions::lineSize, WdgStrokeSelection::m_cfg, m_converter, m_image, WdgStrokeSelection::m_isVectorLayer, WdgStrokeSelection::m_options, m_page, m_resourceManager, KisViewManager::mainWindow(), KoDialog::Ok, KisMainWindow::resourceManager(), KoDialog::setButtons(), KoDialog::setCaption(), setColorButton(), setColorFillButton(), KoDialog::setDefaultButton(), KoDialog::setMainWidget(), and KoColor::toQColor().

◆ ~KisDlgStrokeSelection()

KisDlgStrokeSelection::~KisDlgStrokeSelection ( )
override

Definition at line 96 of file kis_dlg_stroke_selection_properties.cpp.

97{
99 m_options.lineSize = m_page->lineSize->value();
100
101 m_options.lineDimension = m_page->sizeBox->currentIndex();
102 m_options.colorLineSource = static_cast<ColorLineSource>(m_page->lineColorBox->currentIndex());
103
105 cfg->setProperty("lineSize", m_options.lineSize);
106 cfg->setProperty("colorFillSource", static_cast<int>(m_options.colorFillSource));
107 cfg->setProperty("useBrush", m_options.brushSelected);
108 cfg->setProperty("lineDimension", m_options.lineDimension);
109 cfg->setProperty("lineColorSource", static_cast<int>(m_options.colorLineSource));
110
111 QVariant colorVariant;
112 colorVariant.setValue(m_options.customColor);
113 cfg->setProperty("customColor", colorVariant);
114
115 colorVariant.setValue(m_options.color);
116 cfg->setProperty("color", colorVariant);
117
118 colorVariant.setValue(m_options.fillColor);
119 cfg->setProperty("fillColor", colorVariant);
120
121 KisConfig(false).setExportConfiguration("StrokeSelection", cfg);
122
123 delete m_page;
124}
void setExportConfiguration(const QString &filterId, KisPropertiesConfigurationSP properties) const

References StrokeSelectionOptions::brushSelected, StrokeSelectionOptions::color, StrokeSelectionOptions::colorFillSource, StrokeSelectionOptions::colorLineSource, StrokeSelectionOptions::customColor, StrokeSelectionOptions::fillColor, StrokeSelectionOptions::lineDimension, StrokeSelectionOptions::lineSize, WdgStrokeSelection::m_options, m_page, and KisConfig::setExportConfiguration().

Member Function Documentation

◆ colorChanged

void KisDlgStrokeSelection::colorChanged ( const QColor & newColor)
privateslot

Definition at line 226 of file kis_dlg_stroke_selection_properties.cpp.

227{
228 KisSignalsBlocker blocker(m_page->fillBox, m_page->lineColorBox);
229
230 if (m_page->fillBox->currentIndex() == static_cast<int>(ColorFillSource::PaintColor)) {
231 m_page->colorFillSelector->setColor(newColor);
232 }
233
237
238 if (tempColor.toQColor() == FGColor.toQColor()) {
239 m_page->lineColorBox->setCurrentIndex(static_cast<int>(ColorLineSource::FGColor));
240 }
241 else if (tempColor.toQColor() == BGColor.toQColor()) {
242 m_page->lineColorBox->setCurrentIndex(static_cast<int>(ColorLineSource::BGColor));
243 }
244 else {
245 m_page->lineColorBox->setCurrentIndex((int)ColorLineSource::CustomColor);
246 }
247 m_page->m_options.color = tempColor;
248}
KoColor approximateFromRenderedQColor(const QColor &c) const
@ BackgroundColor
The active background color selected for this canvas.
@ ForegroundColor
The active foreground color selected for this canvas.

References KisDisplayColorConverter::approximateFromRenderedQColor(), KoCanvasResource::BackgroundColor, BGColor, StrokeSelectionOptions::color, CustomColor, FGColor, KoCanvasResource::ForegroundColor, m_converter, WdgStrokeSelection::m_options, m_page, m_resourceManager, PaintColor, and KoCanvasResourceProvider::resource().

◆ colorFillChanged

void KisDlgStrokeSelection::colorFillChanged ( const QColor & newColor)
privateslot

Definition at line 250 of file kis_dlg_stroke_selection_properties.cpp.

251{
252 KisSignalsBlocker blocker(m_page->fillBox);
253
258
259 if (tempColor.toQColor() == FGColor.toQColor()) {
260 m_page->fillBox->setCurrentIndex(static_cast<int>(ColorFillSource::FGColor));
261
262 }
263 else if (tempColor.toQColor() == BGColor.toQColor()) {
264 m_page->fillBox->setCurrentIndex(static_cast<int>(ColorFillSource::BGColor));
265 }
266 else if (PaintColor.toQColor() != tempColor.toQColor() ) {
267 m_page->fillBox->setCurrentIndex((int)ColorFillSource::CustomColor);
268 m_page->m_options.customColor = tempColor;
269 }
270
271 m_page->m_options.fillColor = tempColor;
272}

References KisDisplayColorConverter::approximateFromRenderedQColor(), KoCanvasResource::BackgroundColor, BGColor, CustomColor, StrokeSelectionOptions::customColor, FGColor, StrokeSelectionOptions::fillColor, KoCanvasResource::ForegroundColor, m_converter, WdgStrokeSelection::m_options, m_page, m_resourceManager, PaintColor, and KoCanvasResourceProvider::resource().

◆ getFillSelectedColor()

◆ getLinePosition()

LinePosition KisDlgStrokeSelection::getLinePosition ( ) const

Definition at line 209 of file kis_dlg_stroke_selection_properties.cpp.

210{/* TODO
211 int index = m_page->linePosition->currentIndex();
212 switch(index)
213 {
214 case(0):
215 return linePosition::OUTSIDE;
216 case(1):
217 return linePosition::INSIDE;
218 case(2):
219 return linePosition::CENTER;
220 default:
221 return linePosition::CENTER;
222 }*/
224}

References Center.

◆ getLineSize()

int KisDlgStrokeSelection::getLineSize ( ) const

Definition at line 192 of file kis_dlg_stroke_selection_properties.cpp.

193{
194 int value = m_page->lineSize->value();
195
196 if (m_page->sizeBox->currentIndex() == 0) {
197 return value;
198 }
199 else if (m_page->sizeBox->currentIndex() == 1) {
201 return pixels;
202 }
203 else {
205 return pixels;
206 }
207}
float value(const T *src, size_t ch)
static qreal convertFromUnitToUnit(const qreal value, const KoUnit &fromUnit, const KoUnit &toUnit, qreal factor=1.0)
Definition KoUnit.cpp:295
@ Millimeter
Definition KoUnit.h:75
@ Inch
Definition KoUnit.h:77
@ Pixel
Definition KoUnit.h:82

References KoUnit::convertFromUnitToUnit(), KoUnit::Inch, m_page, KoUnit::Millimeter, KoUnit::Pixel, and value().

◆ getParams()

◆ getSelectedColor()

KoColor KisDlgStrokeSelection::getSelectedColor ( ) const

◆ isBrushSelected()

bool KisDlgStrokeSelection::isBrushSelected ( ) const

Definition at line 160 of file kis_dlg_stroke_selection_properties.cpp.

161{
162 return (static_cast<DrawType>(m_page->typeBox->currentIndex()) == DrawType::CurrentBrush);
163}

References CurrentBrush, and m_page.

◆ setColorButton

void KisDlgStrokeSelection::setColorButton ( )
privateslot

Definition at line 187 of file kis_dlg_stroke_selection_properties.cpp.

188{
189 m_page->colorSelector->setColor(getSelectedColor().toQColor());
190}

References getSelectedColor(), and m_page.

◆ setColorFillButton

void KisDlgStrokeSelection::setColorFillButton ( )
privateslot

Definition at line 182 of file kis_dlg_stroke_selection_properties.cpp.

183{
184 m_page->colorFillSelector->setColor(getFillSelectedColor().toQColor());
185}

References getFillSelectedColor(), and m_page.

Member Data Documentation

◆ m_converter

KisDisplayColorConverter* KisDlgStrokeSelection::m_converter {0}
private

Definition at line 102 of file kis_dlg_stroke_selection_properties.h.

102{0};

◆ m_image

KisImageWSP KisDlgStrokeSelection::m_image
private

Definition at line 100 of file kis_dlg_stroke_selection_properties.h.

◆ m_isVectorLayer

bool KisDlgStrokeSelection::m_isVectorLayer {false}
private

Definition at line 103 of file kis_dlg_stroke_selection_properties.h.

103{false};

◆ m_page

WdgStrokeSelection* KisDlgStrokeSelection::m_page {0}
private

Definition at line 99 of file kis_dlg_stroke_selection_properties.h.

99{0};

◆ m_resourceManager

KoCanvasResourceProvider* KisDlgStrokeSelection::m_resourceManager {0}
private

Definition at line 101 of file kis_dlg_stroke_selection_properties.h.

101{0};

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