Changeset View
Changeset View
Standalone View
Standalone View
dialogs/imagelib/effects/kpEffectsDialog.cpp
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 68 | : kpTransformPreviewDialog (kpTransformPreviewDialog::Preview, | |||
---|---|---|---|---|---|
78 | m_settingsLayout (nullptr), | 78 | m_settingsLayout (nullptr), | ||
79 | m_effectWidget (nullptr) | 79 | m_effectWidget (nullptr) | ||
80 | { | 80 | { | ||
81 | qCDebug(kpLogDialogs) << "kpEffectsDialog::kpEffectsDialog()"; | 81 | qCDebug(kpLogDialogs) << "kpEffectsDialog::kpEffectsDialog()"; | ||
82 | const bool e = updatesEnabled (); | 82 | const bool e = updatesEnabled (); | ||
83 | setUpdatesEnabled (false); | 83 | setUpdatesEnabled (false); | ||
84 | 84 | | |||
85 | 85 | | |||
86 | if (actOnSelection) | 86 | if (actOnSelection) { | ||
87 | setWindowTitle (i18nc ("@title:window", "More Image Effects (Selection)")); | 87 | setWindowTitle (i18nc ("@title:window", "More Image Effects (Selection)")); | ||
88 | else | 88 | } | ||
89 | else { | ||||
89 | setWindowTitle (i18nc ("@title:window", "More Image Effects")); | 90 | setWindowTitle (i18nc ("@title:window", "More Image Effects")); | ||
91 | } | ||||
90 | 92 | | |||
91 | 93 | | |||
92 | m_delayedUpdateTimer->setSingleShot (true); | 94 | m_delayedUpdateTimer->setSingleShot (true); | ||
93 | connect (m_delayedUpdateTimer, &QTimer::timeout, | 95 | connect (m_delayedUpdateTimer, &QTimer::timeout, | ||
94 | this, &kpEffectsDialog::slotUpdateWithWaitCursor); | 96 | this, &kpEffectsDialog::slotUpdateWithWaitCursor); | ||
95 | 97 | | |||
96 | 98 | | |||
97 | QWidget *effectContainer = new QWidget (mainWidget ()); | 99 | QWidget *effectContainer = new QWidget (mainWidget ()); | ||
98 | QHBoxLayout *containerLayout = new QHBoxLayout (effectContainer); | 100 | | ||
101 | auto *containerLayout = new QHBoxLayout (effectContainer); | ||||
99 | containerLayout->setContentsMargins(0, 0, 0, 0); | 102 | containerLayout->setContentsMargins(0, 0, 0, 0); | ||
100 | 103 | | |||
101 | QLabel *label = new QLabel (i18n ("&Effect:"), effectContainer); | 104 | QLabel *label = new QLabel (i18n ("&Effect:"), effectContainer); | ||
102 | 105 | | |||
103 | m_effectsComboBox = new QComboBox (effectContainer); | 106 | m_effectsComboBox = new QComboBox (effectContainer); | ||
104 | // Keep in alphabetical order. | 107 | // Keep in alphabetical order. | ||
105 | // TODO: What about translations? | 108 | // TODO: What about translations? | ||
106 | // sync: order in selectEffect(). | 109 | // sync: order in selectEffect(). | ||
Show All 40 Lines | 149 | { | |||
147 | s_lastWidth = width (); | 150 | s_lastWidth = width (); | ||
148 | s_lastHeight = height (); | 151 | s_lastHeight = height (); | ||
149 | } | 152 | } | ||
150 | 153 | | |||
151 | 154 | | |||
152 | // public virtual [base kpTransformPreviewDialog] | 155 | // public virtual [base kpTransformPreviewDialog] | ||
153 | bool kpEffectsDialog::isNoOp () const | 156 | bool kpEffectsDialog::isNoOp () const | ||
154 | { | 157 | { | ||
155 | if (!m_effectWidget) | 158 | if (!m_effectWidget) { | ||
156 | return true; | 159 | return true; | ||
160 | } | ||||
157 | 161 | | |||
158 | return m_effectWidget->isNoOp (); | 162 | return m_effectWidget->isNoOp (); | ||
159 | } | 163 | } | ||
160 | 164 | | |||
161 | // public | 165 | // public | ||
162 | kpEffectCommandBase *kpEffectsDialog::createCommand () const | 166 | kpEffectCommandBase *kpEffectsDialog::createCommand () const | ||
163 | { | 167 | { | ||
164 | if (!m_effectWidget) | 168 | if (!m_effectWidget) { | ||
165 | return nullptr; | 169 | return nullptr; | ||
170 | } | ||||
166 | 171 | | |||
167 | return m_effectWidget->createCommand (m_environ->commandEnvironment ()); | 172 | return m_effectWidget->createCommand (m_environ->commandEnvironment ()); | ||
168 | } | 173 | } | ||
169 | 174 | | |||
170 | 175 | | |||
171 | // protected virtual [base kpTransformPreviewDialog] | 176 | // protected virtual [base kpTransformPreviewDialog] | ||
172 | QSize kpEffectsDialog::newDimensions () const | 177 | QSize kpEffectsDialog::newDimensions () const | ||
173 | { | 178 | { | ||
174 | kpDocument *doc = document (); | 179 | kpDocument *doc = document (); | ||
175 | if (!doc) | 180 | if (!doc) { | ||
176 | return QSize (); | 181 | return {}; | ||
182 | } | ||||
177 | 183 | | |||
178 | return QSize (doc->width (m_actOnSelection), | 184 | return {doc->width (m_actOnSelection), doc->height (m_actOnSelection)}; | ||
179 | doc->height (m_actOnSelection)); | | |||
180 | } | 185 | } | ||
181 | 186 | | |||
182 | // protected virtual [base kpTransformPreviewDialog] | 187 | // protected virtual [base kpTransformPreviewDialog] | ||
183 | QImage kpEffectsDialog::transformPixmap (const QImage &pixmap, | 188 | QImage kpEffectsDialog::transformPixmap (const QImage &pixmap, | ||
184 | int targetWidth, int targetHeight) const | 189 | int targetWidth, int targetHeight) const | ||
185 | { | 190 | { | ||
186 | QImage pixmapWithEffect; | 191 | QImage pixmapWithEffect; | ||
187 | 192 | | |||
188 | if (m_effectWidget && !m_effectWidget->isNoOp ()) | 193 | if (m_effectWidget && !m_effectWidget->isNoOp ()) { | ||
189 | pixmapWithEffect = m_effectWidget->applyEffect (pixmap); | 194 | pixmapWithEffect = m_effectWidget->applyEffect (pixmap); | ||
190 | else | 195 | } | ||
196 | else { | ||||
191 | pixmapWithEffect = pixmap; | 197 | pixmapWithEffect = pixmap; | ||
198 | } | ||||
192 | 199 | | |||
193 | return kpPixmapFX::scale (pixmapWithEffect, targetWidth, targetHeight); | 200 | return kpPixmapFX::scale (pixmapWithEffect, targetWidth, targetHeight); | ||
194 | } | 201 | } | ||
195 | 202 | | |||
196 | 203 | | |||
197 | // public | 204 | // public | ||
198 | int kpEffectsDialog::selectedEffect () const | 205 | int kpEffectsDialog::selectedEffect () const | ||
199 | { | 206 | { | ||
200 | return m_effectsComboBox->currentIndex (); | 207 | return m_effectsComboBox->currentIndex (); | ||
201 | } | 208 | } | ||
202 | 209 | | |||
203 | // public slot | 210 | // public slot | ||
204 | void kpEffectsDialog::selectEffect (int which) | 211 | void kpEffectsDialog::selectEffect (int which) | ||
205 | { | 212 | { | ||
206 | #if DEBUG_KP_EFFECTS_DIALOG | 213 | #if DEBUG_KP_EFFECTS_DIALOG | ||
207 | qCDebug(kpLogDialogs) << "kpEffectsDialog::selectEffect(" << which << ")"; | 214 | qCDebug(kpLogDialogs) << "kpEffectsDialog::selectEffect(" << which << ")"; | ||
208 | #endif | 215 | #endif | ||
209 | 216 | | |||
210 | if (which < 0 || | 217 | if (which < 0 || | ||
211 | which >= m_effectsComboBox->count ()) | 218 | which >= m_effectsComboBox->count ()) | ||
212 | { | 219 | { | ||
213 | return; | 220 | return; | ||
214 | } | 221 | } | ||
215 | 222 | | |||
216 | if (which != m_effectsComboBox->currentIndex ()) | 223 | if (which != m_effectsComboBox->currentIndex ()) { | ||
217 | m_effectsComboBox->setCurrentIndex (which); | 224 | m_effectsComboBox->setCurrentIndex (which); | ||
225 | } | ||||
218 | 226 | | |||
219 | 227 | | |||
220 | delete m_effectWidget; | 228 | delete m_effectWidget; | ||
221 | m_effectWidget = nullptr; | 229 | m_effectWidget = nullptr; | ||
222 | 230 | | |||
223 | 231 | | |||
224 | m_settingsGroupBox->setWindowTitle(QString()); | 232 | m_settingsGroupBox->setWindowTitle(QString()); | ||
225 | 233 | | |||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |