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

#include <dlg_layersize.h>

+ Inheritance diagram for DlgLayerSize:

Signals

void sigDesiredSizeChanged (qint32 width, qint32 height, double resolution)
 
- 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 ()
 

Public Member Functions

qint32 desiredHeight ()
 
qint32 desiredWidth ()
 
 DlgLayerSize (QWidget *parent, const char *name, int width, int height, double resolution)
 
KisFilterStrategyfilterType ()
 
 ~DlgLayerSize () 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
 

Static Public Attributes

static const QString PARAM_HEIGHT_UNIT = DlgLayerSize::PARAM_PREFIX + "_heightunit"
 
static const QString PARAM_KEEP_AR = DlgLayerSize::PARAM_PREFIX + "_keepar"
 
static const QString PARAM_KEEP_PROP = DlgLayerSize::PARAM_PREFIX + "_keepprop"
 
static const QString PARAM_PREFIX = "layersizedlg"
 
static const QString PARAM_WIDTH_UNIT = DlgLayerSize::PARAM_PREFIX + "_widthunit"
 

Private Slots

void slotAspectChanged (bool keep)
 
void slotHeightChanged (double h)
 
void slotWidthChanged (double w)
 

Private Member Functions

void updateHeightUIValue (double value)
 
void updateWidthUIValue (double value)
 

Private Attributes

KisDocumentAwareSpinBoxUnitManager_heightUnitManager
 
KisDocumentAwareSpinBoxUnitManager_widthUnitManager
 
const double m_aspectRatio
 
int m_height
 
bool m_keepAspect
 
const int m_originalHeight
 
const int m_originalWidth
 
WdgLayerSizem_page
 
const double m_resolution
 
int m_width
 

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)
 
- 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 31 of file dlg_layersize.h.

Constructor & Destructor Documentation

◆ DlgLayerSize()

DlgLayerSize::DlgLayerSize ( QWidget * parent,
const char * name,
int width,
int height,
double resolution )

Definition at line 33 of file dlg_layersize.cc.

35 : KoDialog(parent)
36 , m_aspectRatio(((double) width) / height)
37 , m_originalWidth(width)
38 , m_originalHeight(height)
39 , m_width(width)
40 , m_height(height)
41 , m_resolution(resolution)
42 , m_keepAspect(true)
43{
44 setCaption(i18n("Layer Size"));
45 setObjectName(name);
48
49 m_page = new WdgLayerSize(this);
50 Q_CHECK_PTR(m_page);
51 m_page->layout()->setContentsMargins(0, 0, 0, 0);
52 m_page->setObjectName(name);
53
54 KisConfig cfg(true);
55
58
61
62 m_page->newWidthDouble->setUnitManager(_widthUnitManager);
63 m_page->newHeightDouble->setUnitManager(_heightUnitManager);
64 m_page->newWidthDouble->setDisplayUnit(false);
65 m_page->newHeightDouble->setDisplayUnit(false);
66
67 m_page->newWidthDouble->setValue(width);
68 m_page->newWidthDouble->setFocus();
69 m_page->newHeightDouble->setValue(height);
70
71 m_page->filterCmb->setIDList(KisFilterStrategyRegistry::instance()->listKeys());
72 m_page->filterCmb->setToolTip(KisFilterStrategyRegistry::instance()->formattedDescriptions());
73 m_page->filterCmb->allowAuto(true);
74
75 if (lastUsedFilter) { // Restore or Init..
76 m_page->filterCmb->setCurrent(lastUsedFilter->id());
77 } else {
78 m_page->filterCmb->setCurrent(KisCmbIDList::AutoOptionID);
79 }
80
81 m_page->newWidthUnit->setModel(_widthUnitManager);
82 m_page->newHeightUnit->setModel(_heightUnitManager);
83
84 QString unitw = cfg.readEntry<QString>(PARAM_WIDTH_UNIT, "px");
85 QString unith = cfg.readEntry<QString>(PARAM_HEIGHT_UNIT, "px");
86
89
90 const int wUnitIndex = _widthUnitManager->getsUnitSymbolList().indexOf(unitw);
91 const int hUnitIndex = _widthUnitManager->getsUnitSymbolList().indexOf(unith);
92
93 m_page->newWidthUnit->setCurrentIndex(wUnitIndex);
94 m_page->newHeightUnit->setCurrentIndex(hUnitIndex);
95
96 m_keepAspect = cfg.readEntry(PARAM_KEEP_AR,true);
97 m_page->aspectRatioBtn->setKeepAspectRatio(m_keepAspect);
98 m_page->constrainProportionsCkb->setChecked(cfg.readEntry(PARAM_KEEP_PROP,true));
99
101 connect(this, SIGNAL(okClicked()), this, SLOT(accept()));
102
103 connect(m_page->aspectRatioBtn, SIGNAL(keepAspectRatioChanged(bool)), this, SLOT(slotAspectChanged(bool)));
104 connect(m_page->constrainProportionsCkb, SIGNAL(toggled(bool)), this, SLOT(slotAspectChanged(bool)));
105
106 connect(m_page->newWidthDouble, SIGNAL(valueChangedPt(double)), this, SLOT(slotWidthChanged(double)));
107 connect(m_page->newHeightDouble, SIGNAL(valueChangedPt(double)), this, SLOT(slotHeightChanged(double)));
108
109 connect(m_page->newWidthUnit, SIGNAL(currentIndexChanged(int)), _widthUnitManager, SLOT(selectApparentUnitFromIndex(int)));
110 connect(m_page->newHeightUnit, SIGNAL(currentIndexChanged(int)), _heightUnitManager, SLOT(selectApparentUnitFromIndex(int)));
111 connect(_widthUnitManager, SIGNAL(unitChanged(int)), m_page->newWidthUnit, SLOT(setCurrentIndex(int)));
112 connect(_heightUnitManager, SIGNAL(unitChanged(int)), m_page->newHeightUnit, SLOT(setCurrentIndex(int)));
113
114 connect(this, &DlgLayerSize::sigDesiredSizeChanged, [this](qint32 width, qint32 height, double){
116 m_page->filterCmb->setAutoHint(filterStrategy->name());
117 });
118}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisDocumentAwareSpinBoxUnitManager * _widthUnitManager
static const QString PARAM_WIDTH_UNIT
static const QString PARAM_HEIGHT_UNIT
void slotWidthChanged(double w)
void slotHeightChanged(double h)
const double m_resolution
KisDocumentAwareSpinBoxUnitManager * _heightUnitManager
const int m_originalHeight
const int m_originalWidth
void sigDesiredSizeChanged(qint32 width, qint32 height, double resolution)
const double m_aspectRatio
void slotAspectChanged(bool keep)
static const QString PARAM_KEEP_PROP
WdgLayerSize * m_page
static const QString PARAM_KEEP_AR
static const KoID AutoOptionID
The KisDocumentAwareSpinBoxUnitManager class is a KisSpinBoxUnitManager that is able to connect to th...
static KisFilterStrategyRegistry * instance()
KisFilterStrategy * autoFilterStrategy(QSize originalSize, QSize desiredSize) const
void setApparentUnitFromSymbol(QString pSymbol)
virtual QStringList getsUnitSymbolList(bool withName=false) const
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
void okClicked()
static KisFilterStrategy * lastUsedFilter

References _heightUnitManager, _widthUnitManager, KisFilterStrategyRegistry::autoFilterStrategy(), KisCmbIDList::AutoOptionID, KoDialog::Cancel, connect(), KisSpinBoxUnitManager::getsUnitSymbolList(), KisFilterStrategy::id(), KisFilterStrategyRegistry::instance(), lastUsedFilter, m_keepAspect, m_originalHeight, m_originalWidth, m_page, KisFilterStrategy::name(), KoDialog::Ok, KoDialog::okClicked(), PARAM_HEIGHT_UNIT, PARAM_KEEP_AR, PARAM_KEEP_PROP, PARAM_WIDTH_UNIT, KisDocumentAwareSpinBoxUnitManager::PIX_DIR_Y, KisConfig::readEntry(), KisSpinBoxUnitManager::setApparentUnitFromSymbol(), KoDialog::setButtons(), KoDialog::setCaption(), KoDialog::setDefaultButton(), KoDialog::setMainWidget(), sigDesiredSizeChanged(), slotAspectChanged(), slotHeightChanged(), and slotWidthChanged().

◆ ~DlgLayerSize()

DlgLayerSize::~DlgLayerSize ( )
override

Definition at line 120 of file dlg_layersize.cc.

121{
122
123 KisConfig cfg(false);
124
125 cfg.writeEntry<bool>(PARAM_KEEP_AR, m_page->aspectRatioBtn->keepAspectRatio());
126 cfg.writeEntry<bool>(PARAM_KEEP_PROP, m_page->constrainProportionsCkb->isChecked());
127
128 cfg.writeEntry<QString>(PARAM_WIDTH_UNIT, _widthUnitManager->getApparentUnitSymbol());
130
131 delete m_page;
132}

References _heightUnitManager, _widthUnitManager, KisSpinBoxUnitManager::getApparentUnitSymbol(), m_page, PARAM_HEIGHT_UNIT, PARAM_KEEP_AR, PARAM_KEEP_PROP, PARAM_WIDTH_UNIT, and KisConfig::writeEntry().

Member Function Documentation

◆ desiredHeight()

qint32 DlgLayerSize::desiredHeight ( )

Definition at line 139 of file dlg_layersize.cc.

140{
141 return (qint32)m_height;
142}

References m_height.

◆ desiredWidth()

qint32 DlgLayerSize::desiredWidth ( )

Definition at line 134 of file dlg_layersize.cc.

135{
136 return (qint32)m_width;
137}

References m_width.

◆ filterType()

KisFilterStrategy * DlgLayerSize::filterType ( )

Definition at line 144 of file dlg_layersize.cc.

145{
146 KoID filterID = m_page->filterCmb->currentItem();
147
148 KisFilterStrategy *filter;
149 if (filterID == KisCmbIDList::AutoOptionID) {
151 } else {
152 filter = KisFilterStrategyRegistry::instance()->value(filterID.id());
153 lastUsedFilter = filter; // Save for next time!
154 }
155
156 return filter;
157}
qint32 desiredHeight()
qint32 desiredWidth()
const T value(const QString &id) const
Definition KoID.h:30
QString id() const
Definition KoID.cpp:63

References KisFilterStrategyRegistry::autoFilterStrategy(), KisCmbIDList::AutoOptionID, desiredHeight(), desiredWidth(), KoID::id(), KisFilterStrategyRegistry::instance(), lastUsedFilter, m_originalHeight, m_originalWidth, m_page, and KoGenericRegistry< T >::value().

◆ sigDesiredSizeChanged

void DlgLayerSize::sigDesiredSizeChanged ( qint32 width,
qint32 height,
double resolution )
signal

◆ slotAspectChanged

void DlgLayerSize::slotAspectChanged ( bool keep)
privateslot

Definition at line 195 of file dlg_layersize.cc.

196{
197 m_page->aspectRatioBtn->blockSignals(true);
198 m_page->constrainProportionsCkb->blockSignals(true);
199
200 m_page->aspectRatioBtn->setKeepAspectRatio(keep);
201 m_page->constrainProportionsCkb->setChecked(keep);
202
203 m_page->aspectRatioBtn->blockSignals(false);
204 m_page->constrainProportionsCkb->blockSignals(false);
205
206 m_keepAspect = keep;
207
208 if (keep) {
209 // values may be out of sync, so we need to reset it to defaults
212
215 }
216}
void updateHeightUIValue(double value)
void updateWidthUIValue(double value)

References m_height, m_keepAspect, m_originalHeight, m_originalWidth, m_page, m_width, updateHeightUIValue(), and updateWidthUIValue().

◆ slotHeightChanged

void DlgLayerSize::slotHeightChanged ( double h)
privateslot

Definition at line 178 of file dlg_layersize.cc.

179{
180
181 //this slot receives values in pt from the unitspinbox, so just use the resolution.
183 m_height = qRound(resValue);
184
185 if (m_keepAspect) {
186 m_width = qRound(m_height * m_aspectRatio);
187 m_page->newWidthDouble->blockSignals(true);
188 m_page->newWidthDouble->changeValue(h * m_aspectRatio);
189 m_page->newWidthDouble->blockSignals(false);
190 }
191
193}
qreal getConversionFactor(int dim, QString psymbol) const override

References _heightUnitManager, desiredHeight(), desiredWidth(), KisDocumentAwareSpinBoxUnitManager::getConversionFactor(), KisSpinBoxUnitManager::LENGTH, m_aspectRatio, m_height, m_keepAspect, m_page, m_resolution, m_width, and sigDesiredSizeChanged().

◆ slotWidthChanged

void DlgLayerSize::slotWidthChanged ( double w)
privateslot

Definition at line 161 of file dlg_layersize.cc.

162{
163
164 //this slot receives values in pt from the unitspinbox, so just use the resolution.
166 m_width = qRound(resValue);
167
168 if (m_keepAspect) {
169 m_height = qRound(m_width / m_aspectRatio);
170 m_page->newHeightDouble->blockSignals(true);
171 m_page->newHeightDouble->changeValue(w / m_aspectRatio);
172 m_page->newHeightDouble->blockSignals(false);
173 }
174
176}

References _widthUnitManager, desiredHeight(), desiredWidth(), KisDocumentAwareSpinBoxUnitManager::getConversionFactor(), KisSpinBoxUnitManager::LENGTH, m_aspectRatio, m_height, m_keepAspect, m_page, m_resolution, m_width, and sigDesiredSizeChanged().

◆ updateHeightUIValue()

void DlgLayerSize::updateHeightUIValue ( double value)
private

Definition at line 226 of file dlg_layersize.cc.

227{
228 m_page->newHeightDouble->blockSignals(true);
230 m_page->newHeightDouble->changeValue(resValue);
231 m_page->newHeightDouble->blockSignals(false);
232}
float value(const T *src, size_t ch)

References _heightUnitManager, KisDocumentAwareSpinBoxUnitManager::getConversionFactor(), KisSpinBoxUnitManager::LENGTH, m_page, and value().

◆ updateWidthUIValue()

void DlgLayerSize::updateWidthUIValue ( double value)
private

Definition at line 218 of file dlg_layersize.cc.

219{
220 m_page->newWidthDouble->blockSignals(true);
222 m_page->newWidthDouble->changeValue(resValue);
223 m_page->newWidthDouble->blockSignals(false);
224}

References _widthUnitManager, KisDocumentAwareSpinBoxUnitManager::getConversionFactor(), KisSpinBoxUnitManager::LENGTH, m_page, and value().

Member Data Documentation

◆ _heightUnitManager

KisDocumentAwareSpinBoxUnitManager* DlgLayerSize::_heightUnitManager
private

Definition at line 73 of file dlg_layersize.h.

◆ _widthUnitManager

KisDocumentAwareSpinBoxUnitManager* DlgLayerSize::_widthUnitManager
private

Definition at line 72 of file dlg_layersize.h.

◆ m_aspectRatio

const double DlgLayerSize::m_aspectRatio
private

Definition at line 66 of file dlg_layersize.h.

◆ m_height

int DlgLayerSize::m_height
private

Definition at line 68 of file dlg_layersize.h.

◆ m_keepAspect

bool DlgLayerSize::m_keepAspect
private

Definition at line 70 of file dlg_layersize.h.

◆ m_originalHeight

const int DlgLayerSize::m_originalHeight
private

Definition at line 67 of file dlg_layersize.h.

◆ m_originalWidth

const int DlgLayerSize::m_originalWidth
private

Definition at line 67 of file dlg_layersize.h.

◆ m_page

WdgLayerSize* DlgLayerSize::m_page
private

Definition at line 65 of file dlg_layersize.h.

◆ m_resolution

const double DlgLayerSize::m_resolution
private

Definition at line 69 of file dlg_layersize.h.

◆ m_width

int DlgLayerSize::m_width
private

Definition at line 68 of file dlg_layersize.h.

◆ PARAM_HEIGHT_UNIT

const QString DlgLayerSize::PARAM_HEIGHT_UNIT = DlgLayerSize::PARAM_PREFIX + "_heightunit"
static

Definition at line 40 of file dlg_layersize.h.

◆ PARAM_KEEP_AR

const QString DlgLayerSize::PARAM_KEEP_AR = DlgLayerSize::PARAM_PREFIX + "_keepar"
static

Definition at line 41 of file dlg_layersize.h.

◆ PARAM_KEEP_PROP

const QString DlgLayerSize::PARAM_KEEP_PROP = DlgLayerSize::PARAM_PREFIX + "_keepprop"
static

Definition at line 42 of file dlg_layersize.h.

◆ PARAM_PREFIX

const QString DlgLayerSize::PARAM_PREFIX = "layersizedlg"
static

Definition at line 38 of file dlg_layersize.h.

◆ PARAM_WIDTH_UNIT

const QString DlgLayerSize::PARAM_WIDTH_UNIT = DlgLayerSize::PARAM_PREFIX + "_widthunit"
static

Definition at line 39 of file dlg_layersize.h.


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