Changeset View
Changeset View
Standalone View
Standalone View
widgets/imagelib/effects/kpEffectBlurSharpenWidget.cpp
Show All 40 Lines | |||||
41 | #include <QLabel> | 41 | #include <QLabel> | ||
42 | #include <QSpinBox> | 42 | #include <QSpinBox> | ||
43 | 43 | | |||
44 | 44 | | |||
45 | kpEffectBlurSharpenWidget::kpEffectBlurSharpenWidget (bool actOnSelection, | 45 | kpEffectBlurSharpenWidget::kpEffectBlurSharpenWidget (bool actOnSelection, | ||
46 | QWidget *parent) | 46 | QWidget *parent) | ||
47 | : kpEffectWidgetBase (actOnSelection, parent) | 47 | : kpEffectWidgetBase (actOnSelection, parent) | ||
48 | { | 48 | { | ||
49 | QGridLayout *lay = new QGridLayout (this); | 49 | auto *lay = new QGridLayout (this); | ||
50 | lay->setContentsMargins(0, 0, 0, 0); | 50 | lay->setContentsMargins(0, 0, 0, 0); | ||
51 | 51 | | |||
52 | 52 | auto *amountLabel = new QLabel (i18n ("&Amount:"), this); | |||
53 | QLabel *amountLabel = new QLabel (i18n ("&Amount:"), this); | | |||
54 | m_amountInput = new kpIntNumInput (this); | 53 | m_amountInput = new kpIntNumInput (this); | ||
55 | m_amountInput->setRange (-kpEffectBlurSharpen::MaxStrength/*- for blur*/, | 54 | m_amountInput->setRange (-kpEffectBlurSharpen::MaxStrength/*- for blur*/, | ||
56 | +kpEffectBlurSharpen::MaxStrength/*+ for sharpen*/); | 55 | +kpEffectBlurSharpen::MaxStrength/*+ for sharpen*/); | ||
57 | 56 | | |||
58 | m_typeLabel = new QLabel (this); | 57 | m_typeLabel = new QLabel (this); | ||
59 | 58 | | |||
60 | // Make sure <m_typeLabel> doesn't expand when the effect type changes, | 59 | // Make sure <m_typeLabel> doesn't expand when the effect type changes, | ||
61 | // as otherwise, that would cause the preview pixmap label in the | 60 | // as otherwise, that would cause the preview pixmap label in the | ||
62 | // "More Effects" dialog (which our widget is inside) to contract, | 61 | // "More Effects" dialog (which our widget is inside) to contract, | ||
63 | // which would look a bit weird. | 62 | // which would look a bit weird. | ||
64 | // | 63 | // | ||
65 | // We do this by setting the label to every possible string it could | 64 | // We do this by setting the label to every possible string it could | ||
66 | // contain and fixing its height to the maximum seen size hint height. | 65 | // contain and fixing its height to the maximum seen size hint height. | ||
67 | 66 | | |||
68 | int h = m_typeLabel->sizeHint ().height (); | 67 | auto h = m_typeLabel->sizeHint ().height (); | ||
69 | qCDebug(kpLogWidgets) << "initial size hint height=" << h; | 68 | qCDebug(kpLogWidgets) << "initial size hint height=" << h; | ||
70 | 69 | | |||
71 | m_typeLabel->setText ( | 70 | m_typeLabel->setText ( | ||
72 | kpEffectBlurSharpenCommand::nameForType (kpEffectBlurSharpen::Blur)); | 71 | kpEffectBlurSharpenCommand::nameForType (kpEffectBlurSharpen::Blur)); | ||
73 | h = qMax (h, m_typeLabel->sizeHint ().height ()); | 72 | h = qMax (h, m_typeLabel->sizeHint ().height ()); | ||
74 | 73 | | |||
75 | m_typeLabel->setText ( | 74 | m_typeLabel->setText ( | ||
76 | kpEffectBlurSharpenCommand::nameForType (kpEffectBlurSharpen::Sharpen)); | 75 | kpEffectBlurSharpenCommand::nameForType (kpEffectBlurSharpen::Sharpen)); | ||
Show All 23 Lines | |||||
100 | 99 | | |||
101 | connect (m_amountInput, &kpIntNumInput::valueChanged, | 100 | connect (m_amountInput, &kpIntNumInput::valueChanged, | ||
102 | this, &kpEffectBlurSharpenWidget::settingsChangedDelayed); | 101 | this, &kpEffectBlurSharpenWidget::settingsChangedDelayed); | ||
103 | 102 | | |||
104 | connect (m_amountInput, &kpIntNumInput::valueChanged, | 103 | connect (m_amountInput, &kpIntNumInput::valueChanged, | ||
105 | this, &kpEffectBlurSharpenWidget::slotUpdateTypeLabel); | 104 | this, &kpEffectBlurSharpenWidget::slotUpdateTypeLabel); | ||
106 | } | 105 | } | ||
107 | 106 | | |||
108 | kpEffectBlurSharpenWidget::~kpEffectBlurSharpenWidget () | 107 | kpEffectBlurSharpenWidget::~kpEffectBlurSharpenWidget () = default; | ||
109 | { | | |||
110 | } | | |||
111 | 108 | | |||
112 | 109 | | |||
113 | // public virtual [base kpEffectWidgetBase] | 110 | // public virtual [base kpEffectWidgetBase] | ||
114 | QString kpEffectBlurSharpenWidget::caption () const | 111 | QString kpEffectBlurSharpenWidget::caption () const | ||
115 | { | 112 | { | ||
116 | return QString(); | 113 | return QString(); | ||
117 | } | 114 | } | ||
118 | 115 | | |||
Show All 21 Lines | |||||
140 | } | 137 | } | ||
141 | 138 | | |||
142 | 139 | | |||
143 | // protected slot | 140 | // protected slot | ||
144 | void kpEffectBlurSharpenWidget::slotUpdateTypeLabel () | 141 | void kpEffectBlurSharpenWidget::slotUpdateTypeLabel () | ||
145 | { | 142 | { | ||
146 | QString text = kpEffectBlurSharpenCommand::nameForType (type ()); | 143 | QString text = kpEffectBlurSharpenCommand::nameForType (type ()); | ||
147 | 144 | | |||
148 | qCDebug(kpLogWidgets) << "kpEffectBlurSharpenWidget::slotUpdateTypeLabel() text=" | 145 | qCDebug(kpLogWidgets) << "kpEffectBlurSharpenWidget::slotUpdateTypeLabel() text=" << text; | ||
149 | << text << endl; | | |||
150 | const int h = m_typeLabel->height (); | 146 | const int h = m_typeLabel->height (); | ||
151 | m_typeLabel->setText (text); | 147 | m_typeLabel->setText (text); | ||
152 | if (m_typeLabel->height () != h) | 148 | if (m_typeLabel->height () != h) | ||
153 | { | 149 | { | ||
154 | qCCritical(kpLogWidgets) << "Label changed height despite the hack in ctor:" | 150 | qCCritical(kpLogWidgets) << "Label changed height despite the hack in ctor:" | ||
155 | << "was=" << h | 151 | << "was=" << h | ||
156 | << "now=" << m_typeLabel->height (); | 152 | << "now=" << m_typeLabel->height (); | ||
157 | } | 153 | } | ||
158 | } | 154 | } | ||
159 | 155 | | |||
160 | 156 | | |||
161 | // protected | 157 | // protected | ||
162 | kpEffectBlurSharpen::Type kpEffectBlurSharpenWidget::type () const | 158 | kpEffectBlurSharpen::Type kpEffectBlurSharpenWidget::type () const | ||
163 | { | 159 | { | ||
164 | if (m_amountInput->value () == 0) | 160 | if (m_amountInput->value () == 0) { | ||
165 | return kpEffectBlurSharpen::None; | 161 | return kpEffectBlurSharpen::None; | ||
166 | else if (m_amountInput->value () < 0) | 162 | } | ||
163 | | ||||
164 | if (m_amountInput->value () < 0) { | ||||
167 | return kpEffectBlurSharpen::Blur; | 165 | return kpEffectBlurSharpen::Blur; | ||
168 | else | 166 | } | ||
167 | | ||||
169 | return kpEffectBlurSharpen::Sharpen; | 168 | return kpEffectBlurSharpen::Sharpen; | ||
170 | } | 169 | } | ||
171 | 170 | | |||
172 | // protected | 171 | // protected | ||
173 | int kpEffectBlurSharpenWidget::strength () const | 172 | int kpEffectBlurSharpenWidget::strength () const | ||
174 | { | 173 | { | ||
175 | return qAbs (m_amountInput->value ()); | 174 | return qAbs (m_amountInput->value ()); | ||
176 | } | 175 | } | ||
177 | 176 | | |||
178 | 177 | |