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 | auto *containerLayout = new QHBoxLayout (effectContainer); | ||
99 | containerLayout->setMargin (0); | 101 | containerLayout->setMargin (0); | ||
100 | 102 | | |||
101 | QLabel *label = new QLabel (i18n ("&Effect:"), effectContainer); | 103 | QLabel *label = new QLabel (i18n ("&Effect:"), effectContainer); | ||
102 | 104 | | |||
103 | m_effectsComboBox = new QComboBox (effectContainer); | 105 | m_effectsComboBox = new QComboBox (effectContainer); | ||
104 | // Keep in alphabetical order. | 106 | // Keep in alphabetical order. | ||
105 | // TODO: What about translations? | 107 | // TODO: What about translations? | ||
106 | // sync: order in selectEffect(). | 108 | // sync: order in selectEffect(). | ||
Show All 40 Lines | 148 | { | |||
147 | s_lastWidth = width (); | 149 | s_lastWidth = width (); | ||
148 | s_lastHeight = height (); | 150 | s_lastHeight = height (); | ||
149 | } | 151 | } | ||
150 | 152 | | |||
151 | 153 | | |||
152 | // public virtual [base kpTransformPreviewDialog] | 154 | // public virtual [base kpTransformPreviewDialog] | ||
153 | bool kpEffectsDialog::isNoOp () const | 155 | bool kpEffectsDialog::isNoOp () const | ||
154 | { | 156 | { | ||
155 | if (!m_effectWidget) | 157 | if (!m_effectWidget) { | ||
156 | return true; | 158 | return true; | ||
159 | } | ||||
157 | 160 | | |||
158 | return m_effectWidget->isNoOp (); | 161 | return m_effectWidget->isNoOp (); | ||
159 | } | 162 | } | ||
160 | 163 | | |||
161 | // public | 164 | // public | ||
162 | kpEffectCommandBase *kpEffectsDialog::createCommand () const | 165 | kpEffectCommandBase *kpEffectsDialog::createCommand () const | ||
163 | { | 166 | { | ||
164 | if (!m_effectWidget) | 167 | if (!m_effectWidget) { | ||
165 | return nullptr; | 168 | return nullptr; | ||
169 | } | ||||
166 | 170 | | |||
167 | return m_effectWidget->createCommand (m_environ->commandEnvironment ()); | 171 | return m_effectWidget->createCommand (m_environ->commandEnvironment ()); | ||
168 | } | 172 | } | ||
169 | 173 | | |||
170 | 174 | | |||
171 | // protected virtual [base kpTransformPreviewDialog] | 175 | // protected virtual [base kpTransformPreviewDialog] | ||
172 | QSize kpEffectsDialog::newDimensions () const | 176 | QSize kpEffectsDialog::newDimensions () const | ||
173 | { | 177 | { | ||
174 | kpDocument *doc = document (); | 178 | kpDocument *doc = document (); | ||
175 | if (!doc) | 179 | if (!doc) { | ||
176 | return QSize (); | 180 | return {}; | ||
181 | } | ||||
177 | 182 | | |||
178 | return QSize (doc->width (m_actOnSelection), | 183 | return {doc->width (m_actOnSelection), doc->height (m_actOnSelection)}; | ||
179 | doc->height (m_actOnSelection)); | | |||
180 | } | 184 | } | ||
181 | 185 | | |||
182 | // protected virtual [base kpTransformPreviewDialog] | 186 | // protected virtual [base kpTransformPreviewDialog] | ||
183 | QImage kpEffectsDialog::transformPixmap (const QImage &pixmap, | 187 | QImage kpEffectsDialog::transformPixmap (const QImage &pixmap, | ||
184 | int targetWidth, int targetHeight) const | 188 | int targetWidth, int targetHeight) const | ||
185 | { | 189 | { | ||
186 | QImage pixmapWithEffect; | 190 | QImage pixmapWithEffect; | ||
187 | 191 | | |||
188 | if (m_effectWidget && !m_effectWidget->isNoOp ()) | 192 | if (m_effectWidget && !m_effectWidget->isNoOp ()) { | ||
189 | pixmapWithEffect = m_effectWidget->applyEffect (pixmap); | 193 | pixmapWithEffect = m_effectWidget->applyEffect (pixmap); | ||
190 | else | 194 | } | ||
195 | else { | ||||
191 | pixmapWithEffect = pixmap; | 196 | pixmapWithEffect = pixmap; | ||
197 | } | ||||
192 | 198 | | |||
193 | return kpPixmapFX::scale (pixmapWithEffect, targetWidth, targetHeight); | 199 | return kpPixmapFX::scale (pixmapWithEffect, targetWidth, targetHeight); | ||
194 | } | 200 | } | ||
195 | 201 | | |||
196 | 202 | | |||
197 | // public | 203 | // public | ||
198 | int kpEffectsDialog::selectedEffect () const | 204 | int kpEffectsDialog::selectedEffect () const | ||
199 | { | 205 | { | ||
200 | return m_effectsComboBox->currentIndex (); | 206 | return m_effectsComboBox->currentIndex (); | ||
201 | } | 207 | } | ||
202 | 208 | | |||
203 | // public slot | 209 | // public slot | ||
204 | void kpEffectsDialog::selectEffect (int which) | 210 | void kpEffectsDialog::selectEffect (int which) | ||
205 | { | 211 | { | ||
206 | #if DEBUG_KP_EFFECTS_DIALOG | 212 | #if DEBUG_KP_EFFECTS_DIALOG | ||
207 | qCDebug(kpLogDialogs) << "kpEffectsDialog::selectEffect(" << which << ")"; | 213 | qCDebug(kpLogDialogs) << "kpEffectsDialog::selectEffect(" << which << ")"; | ||
208 | #endif | 214 | #endif | ||
209 | 215 | | |||
210 | if (which < 0 || | 216 | if (which < 0 || | ||
211 | which >= m_effectsComboBox->count ()) | 217 | which >= m_effectsComboBox->count ()) | ||
212 | { | 218 | { | ||
213 | return; | 219 | return; | ||
214 | } | 220 | } | ||
215 | 221 | | |||
216 | if (which != m_effectsComboBox->currentIndex ()) | 222 | if (which != m_effectsComboBox->currentIndex ()) { | ||
217 | m_effectsComboBox->setCurrentIndex (which); | 223 | m_effectsComboBox->setCurrentIndex (which); | ||
224 | } | ||||
218 | 225 | | |||
219 | 226 | | |||
220 | delete m_effectWidget; | 227 | delete m_effectWidget; | ||
221 | m_effectWidget = nullptr; | 228 | m_effectWidget = nullptr; | ||
222 | 229 | | |||
223 | 230 | | |||
224 | m_settingsGroupBox->setWindowTitle(QString()); | 231 | m_settingsGroupBox->setWindowTitle(QString()); | ||
225 | 232 | | |||
▲ Show 20 Lines • Show All 106 Lines • Show Last 20 Lines |