Changeset View
Changeset View
Standalone View
Standalone View
widgets/kpDocumentSaveDialog.cpp
- This file was moved from widgets/kpDocumentSaveOptionsWidget.cpp.
Context not available. | |||||
28 | #define DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET 0 | 28 | #define DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET 0 | ||
---|---|---|---|---|---|
29 | 29 | | |||
30 | 30 | | |||
31 | #include "widgets/kpDocumentSaveOptionsWidget.h" | 31 | #include "widgets/kpDocumentSaveDialog.h" | ||
32 | 32 | | |||
33 | #include "kpDefs.h" | 33 | #include "kpDefs.h" | ||
34 | #include "document/kpDocument.h" | 34 | #include "document/kpDocument.h" | ||
Context not available. | |||||
41 | #include "kpLogCategories.h" | 41 | #include "kpLogCategories.h" | ||
42 | #include <KSharedConfig> | 42 | #include <KSharedConfig> | ||
43 | #include <KConfigGroup> | 43 | #include <KConfigGroup> | ||
44 | #include <KFileWidget> | ||||
44 | 45 | | |||
45 | #include <QApplication> | 46 | #include <QApplication> | ||
47 | #include <QDialogButtonBox> | ||||
46 | #include <QBoxLayout> | 48 | #include <QBoxLayout> | ||
47 | #include <QBuffer> | 49 | #include <QBuffer> | ||
48 | #include <QComboBox> | 50 | #include <QComboBox> | ||
Context not available. | |||||
56 | #include <QTimer> | 58 | #include <QTimer> | ||
57 | 59 | | |||
58 | 60 | | |||
59 | kpDocumentSaveOptionsWidget::kpDocumentSaveOptionsWidget ( | 61 | kpDocumentSaveDialog::kpDocumentSaveDialog ( | ||
62 | const QString &url, | ||||
60 | const QImage &docPixmap, | 63 | const QImage &docPixmap, | ||
61 | const kpDocumentSaveOptions &saveOptions, | 64 | const kpDocumentSaveOptions &saveOptions, | ||
62 | const kpDocumentMetaInfo &metaInfo, | 65 | const kpDocumentMetaInfo &metaInfo, | ||
63 | QWidget *parent) | 66 | QWidget *parent) | ||
64 | : QWidget (parent), | 67 | : QDialog (parent) | ||
65 | m_visualParent (parent) | | |||
66 | { | 68 | { | ||
67 | init (); | 69 | init (QUrl(url)); | ||
68 | setDocumentSaveOptions (saveOptions); | 70 | setDocumentSaveOptions (saveOptions); | ||
69 | setDocumentPixmap (docPixmap); | 71 | setDocumentPixmap (docPixmap); | ||
70 | setDocumentMetaInfo (metaInfo); | 72 | setDocumentMetaInfo (metaInfo); | ||
71 | } | 73 | } | ||
72 | 74 | | |||
73 | kpDocumentSaveOptionsWidget::kpDocumentSaveOptionsWidget ( | 75 | kpDocumentSaveDialog::kpDocumentSaveDialog ( | ||
74 | QWidget *parent) | 76 | QWidget *parent) | ||
75 | : QWidget (parent), | 77 | : QDialog (parent) | ||
76 | m_visualParent (parent) | | |||
77 | { | 78 | { | ||
78 | init (); | 79 | init (QUrl()); | ||
79 | } | 80 | } | ||
80 | 81 | | |||
81 | // private | 82 | // private | ||
82 | void kpDocumentSaveOptionsWidget::init () | 83 | void kpDocumentSaveDialog::init (const QUrl &startUrl) | ||
83 | { | 84 | { | ||
85 | setLayout(new QVBoxLayout); | ||||
86 | | ||||
87 | m_fileWidget = new KFileWidget(startUrl); | ||||
88 | m_fileWidget->setOperationMode( KFileWidget::Saving ); | ||||
89 | m_fileWidget->setMode( KFile::Files | KFile::Directory ); | ||||
90 | | ||||
91 | connect(m_fileWidget, &KFileWidget::accepted, [&]() { | ||||
92 | m_fileWidget->accept(); | ||||
93 | | ||||
94 | // We have to do this manually for some reason | ||||
95 | accept(); | ||||
96 | }); | ||||
97 | connect (m_fileWidget, &KFileWidget::filterChanged, this, &kpDocumentSaveDialog::setMimeType); | ||||
98 | | ||||
99 | layout()->addWidget(m_fileWidget); | ||||
100 | | ||||
101 | // Normal file dialog buttons | ||||
102 | QDialogButtonBox *buttonBox = new QDialogButtonBox; | ||||
103 | buttonBox->addButton(m_fileWidget->okButton(), QDialogButtonBox::AcceptRole); | ||||
104 | buttonBox->addButton(m_fileWidget->cancelButton(), QDialogButtonBox::RejectRole); | ||||
105 | connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); | ||||
106 | connect(buttonBox, &QDialogButtonBox::accepted, m_fileWidget, &KFileWidget::slotOk); | ||||
107 | layout()->addWidget(buttonBox); | ||||
108 | | ||||
84 | m_documentPixmap = nullptr; | 109 | m_documentPixmap = nullptr; | ||
85 | m_previewDialog = nullptr; | 110 | m_previewDialog = nullptr; | ||
86 | m_visualParent = nullptr; | | |||
87 | 111 | | |||
88 | 112 | | |||
89 | m_colorDepthLabel = new QLabel (i18n ("Convert &to:"), this); | 113 | m_colorDepthLabel = new QLabel (i18n ("Convert &to:"), this); | ||
Context not available. | |||||
107 | 131 | | |||
108 | m_qualityLabel->setBuddy (m_qualityInput); | 132 | m_qualityLabel->setBuddy (m_qualityInput); | ||
109 | 133 | | |||
134 | QWidget *optionsWidget = new QWidget(this); | ||||
135 | QHBoxLayout *optionsLayout = new QHBoxLayout; | ||||
136 | optionsLayout->addSpacerItem(new QSpacerItem(0, 30)); | ||||
137 | optionsWidget->setLayout(optionsLayout); | ||||
138 | optionsLayout->setContentsMargins(0, 0, 0, 0); | ||||
110 | 139 | | |||
111 | auto *lay = new QHBoxLayout (this); | 140 | optionsLayout->addWidget (m_colorDepthLabel, 0/*stretch*/, Qt::AlignLeft); | ||
112 | lay->setContentsMargins(0, 0, 0, 0); | 141 | optionsLayout->addWidget (m_colorDepthCombo, 0/*stretch*/); | ||
113 | 142 | | |||
114 | lay->addWidget (m_colorDepthLabel, 0/*stretch*/, Qt::AlignLeft); | 143 | optionsLayout->addWidget (m_colorDepthSpaceWidget, 1/*stretch*/); | ||
115 | lay->addWidget (m_colorDepthCombo, 0/*stretch*/); | | |||
116 | 144 | | |||
117 | lay->addWidget (m_colorDepthSpaceWidget, 1/*stretch*/); | 145 | optionsLayout->addWidget (m_qualityLabel, 0/*stretch*/, Qt::AlignLeft); | ||
146 | optionsLayout->addWidget (m_qualityInput, 2/*stretch*/); | ||||
118 | 147 | | |||
119 | lay->addWidget (m_qualityLabel, 0/*stretch*/, Qt::AlignLeft); | 148 | optionsLayout->addWidget (m_previewButton, 0/*stretch*/, Qt::AlignRight); | ||
120 | lay->addWidget (m_qualityInput, 2/*stretch*/); | | |||
121 | 149 | | |||
122 | lay->addWidget (m_previewButton, 0/*stretch*/, Qt::AlignRight); | 150 | // I don't like the default position it gets, so just do it old style | ||
151 | // buttonBox->addButton(m_previewButton, QDialogButtonBox::ApplyRole); | ||||
123 | 152 | | |||
124 | 153 | | |||
154 | m_fileWidget->setCustomWidget(QString(), optionsWidget); | ||||
155 | // To make the "automatically select extension" checkbox appear below the file type selection | ||||
156 | // m_fileWidget->setCustomWidget(optionsWidget); | ||||
157 | | ||||
125 | connect (m_colorDepthCombo, | 158 | connect (m_colorDepthCombo, | ||
126 | static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), | 159 | static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), | ||
127 | this, &kpDocumentSaveOptionsWidget::slotColorDepthSelected); | 160 | this, &kpDocumentSaveDialog::slotColorDepthSelected); | ||
128 | 161 | | |||
129 | connect (m_colorDepthCombo, | 162 | connect (m_colorDepthCombo, | ||
130 | static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), | 163 | static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), | ||
131 | this, &kpDocumentSaveOptionsWidget::updatePreview); | 164 | this, &kpDocumentSaveDialog::updatePreview); | ||
132 | 165 | | |||
133 | connect (m_qualityInput, | 166 | connect (m_qualityInput, | ||
134 | static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), | 167 | static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), | ||
135 | this, &kpDocumentSaveOptionsWidget::updatePreviewDelayed); | 168 | this, &kpDocumentSaveDialog::updatePreviewDelayed); | ||
136 | 169 | | |||
137 | connect (m_previewButton, &QPushButton::toggled, | 170 | connect (m_previewButton, &QPushButton::toggled, | ||
138 | this, &kpDocumentSaveOptionsWidget::showPreview); | 171 | this, &kpDocumentSaveDialog::showPreview); | ||
139 | 172 | | |||
140 | 173 | | |||
141 | m_updatePreviewDelay = 200/*ms*/; | 174 | m_updatePreviewDelay = 200/*ms*/; | ||
Context not available. | |||||
143 | m_updatePreviewTimer = new QTimer (this); | 176 | m_updatePreviewTimer = new QTimer (this); | ||
144 | m_updatePreviewTimer->setSingleShot (true); | 177 | m_updatePreviewTimer->setSingleShot (true); | ||
145 | connect (m_updatePreviewTimer, &QTimer::timeout, | 178 | connect (m_updatePreviewTimer, &QTimer::timeout, | ||
146 | this, &kpDocumentSaveOptionsWidget::updatePreview); | 179 | this, &kpDocumentSaveDialog::updatePreview); | ||
147 | 180 | | |||
148 | m_updatePreviewDialogLastRelativeGeometryTimer = new QTimer (this); | 181 | m_updatePreviewDialogLastRelativeGeometryTimer = new QTimer (this); | ||
149 | connect (m_updatePreviewDialogLastRelativeGeometryTimer, | 182 | connect (m_updatePreviewDialogLastRelativeGeometryTimer, | ||
150 | &QTimer::timeout, | 183 | &QTimer::timeout, | ||
151 | this, &kpDocumentSaveOptionsWidget::updatePreviewDialogLastRelativeGeometry); | 184 | this, &kpDocumentSaveDialog::updatePreviewDialogLastRelativeGeometry); | ||
152 | 185 | | |||
153 | setMode (None); | 186 | setMode (None); | ||
154 | 187 | | |||
155 | slotColorDepthSelected (); | 188 | slotColorDepthSelected (); | ||
156 | } | 189 | } | ||
157 | 190 | | |||
158 | kpDocumentSaveOptionsWidget::~kpDocumentSaveOptionsWidget () | 191 | kpDocumentSaveDialog::~kpDocumentSaveDialog () | ||
159 | { | 192 | { | ||
160 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 193 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
161 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::<dtor>()"; | 194 | qCDebug(kpLogWidgets) << "kpDocumentSaveDialog::<dtor>()"; | ||
162 | #endif | 195 | #endif | ||
163 | hidePreview (); | 196 | hidePreview (); | ||
164 | 197 | | |||
165 | delete m_documentPixmap; | 198 | delete m_documentPixmap; | ||
166 | } | 199 | } | ||
167 | 200 | | |||
168 | 201 | void kpDocumentSaveDialog::setLocalOnly(bool localOnly) | |||
169 | // public | | |||
170 | void kpDocumentSaveOptionsWidget::setVisualParent (QWidget *visualParent) | | |||
171 | { | 202 | { | ||
172 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 203 | if (localOnly) { | ||
173 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::setVisualParent(" | 204 | m_fileWidget->setMode (KFile::File | KFile::LocalOnly); | ||
174 | << visualParent << ")" << endl; | 205 | } else { | ||
175 | #endif | 206 | m_fileWidget->setMode (KFile::File); | ||
176 | 207 | } | |||
177 | m_visualParent = visualParent; | | |||
178 | } | 208 | } | ||
179 | 209 | | |||
210 | const QUrl kpDocumentSaveDialog::selectedUrl() const | ||||
211 | { | ||||
212 | return m_fileWidget->selectedUrl(); | ||||
213 | } | ||||
180 | 214 | | |||
181 | // protected | 215 | // protected | ||
182 | bool kpDocumentSaveOptionsWidget::mimeTypeHasConfigurableColorDepth () const | 216 | bool kpDocumentSaveDialog::mimeTypeHasConfigurableColorDepth () const | ||
183 | { | 217 | { | ||
184 | return kpDocumentSaveOptions::mimeTypeHasConfigurableColorDepth (mimeType ()); | 218 | return kpDocumentSaveOptions::mimeTypeHasConfigurableColorDepth (mimeType ()); | ||
185 | } | 219 | } | ||
186 | 220 | | |||
187 | // protected | 221 | // protected | ||
188 | bool kpDocumentSaveOptionsWidget::mimeTypeHasConfigurableQuality () const | 222 | bool kpDocumentSaveDialog::mimeTypeHasConfigurableQuality () const | ||
189 | { | 223 | { | ||
190 | return kpDocumentSaveOptions::mimeTypeHasConfigurableQuality (mimeType ()); | 224 | return kpDocumentSaveOptions::mimeTypeHasConfigurableQuality (mimeType ()); | ||
191 | } | 225 | } | ||
192 | 226 | | |||
193 | 227 | | |||
194 | // public | 228 | // public | ||
195 | QString kpDocumentSaveOptionsWidget::mimeType () const | 229 | QString kpDocumentSaveDialog::mimeType () const | ||
196 | { | 230 | { | ||
197 | return m_baseDocumentSaveOptions.mimeType (); | 231 | return m_baseDocumentSaveOptions.mimeType (); | ||
198 | } | 232 | } | ||
199 | 233 | | |||
200 | // public slots | 234 | // public slots | ||
201 | void kpDocumentSaveOptionsWidget::setMimeType (const QString &string) | 235 | void kpDocumentSaveDialog::setMimeType (const QString &string) | ||
202 | { | 236 | { | ||
203 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 237 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
204 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::setMimeType(" << string | 238 | qCDebug(kpLogWidgets) << "kpDocumentSaveDialog::setMimeType(" << string | ||
205 | << ") maxColorDepth=" | 239 | << ") maxColorDepth=" | ||
206 | << kpDocumentSaveOptions::mimeTypeMaximumColorDepth (string) | 240 | << kpDocumentSaveOptions::mimeTypeMaximumColorDepth (string) | ||
207 | << endl; | 241 | << endl; | ||
208 | #endif | 242 | #endif | ||
209 | 243 | | |||
244 | m_fileWidget->setMimeFilter(kpDocumentSaveOptions::availableMimeTypes(), string); | ||||
245 | | ||||
210 | const int newMimeTypeMaxDepth = | 246 | const int newMimeTypeMaxDepth = | ||
211 | kpDocumentSaveOptions::mimeTypeMaximumColorDepth (string); | 247 | kpDocumentSaveOptions::mimeTypeMaximumColorDepth (string); | ||
212 | 248 | | |||
Context not available. | |||||
279 | 315 | | |||
280 | 316 | | |||
281 | // public | 317 | // public | ||
282 | int kpDocumentSaveOptionsWidget::colorDepth () const | 318 | int kpDocumentSaveDialog::colorDepth () const | ||
283 | { | 319 | { | ||
284 | if (mode () & ColorDepth) | 320 | if (mode () & ColorDepth) | ||
285 | { | 321 | { | ||
Context not available. | |||||
309 | } | 345 | } | ||
310 | 346 | | |||
311 | // public | 347 | // public | ||
312 | bool kpDocumentSaveOptionsWidget::dither () const | 348 | bool kpDocumentSaveDialog::dither () const | ||
313 | { | 349 | { | ||
314 | if (mode () & ColorDepth) | 350 | if (mode () & ColorDepth) | ||
315 | { | 351 | { | ||
Context not available. | |||||
321 | } | 357 | } | ||
322 | 358 | | |||
323 | // protected static | 359 | // protected static | ||
324 | int kpDocumentSaveOptionsWidget::colorDepthComboItemFromColorDepthAndDither ( | 360 | int kpDocumentSaveDialog::colorDepthComboItemFromColorDepthAndDither ( | ||
325 | int depth, bool dither) | 361 | int depth, bool dither) | ||
326 | { | 362 | { | ||
327 | switch (depth) { | 363 | switch (depth) { | ||
Context not available. | |||||
346 | } | 382 | } | ||
347 | 383 | | |||
348 | // public slots | 384 | // public slots | ||
349 | void kpDocumentSaveOptionsWidget::setColorDepthDither (int newDepth, bool newDither) | 385 | void kpDocumentSaveDialog::setColorDepthDither (int newDepth, bool newDither) | ||
350 | { | 386 | { | ||
351 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 387 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
352 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::setColorDepthDither(" | 388 | qCDebug(kpLogWidgets) << "kpDocumentSaveDialog::setColorDepthDither(" | ||
353 | << "depth=" << newDepth | 389 | << "depth=" << newDepth | ||
354 | << ",dither=" << newDither | 390 | << ",dither=" << newDither | ||
355 | << ")" << endl; | 391 | << ")" << endl; | ||
Context not available. | |||||
375 | 411 | | |||
376 | 412 | | |||
377 | // protected slot | 413 | // protected slot | ||
378 | void kpDocumentSaveOptionsWidget::slotColorDepthSelected () | 414 | void kpDocumentSaveDialog::slotColorDepthSelected () | ||
379 | { | 415 | { | ||
380 | if (mode () & ColorDepth) | 416 | if (mode () & ColorDepth) | ||
381 | { | 417 | { | ||
Context not available. | |||||
390 | } | 426 | } | ||
391 | 427 | | |||
392 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 428 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
393 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::slotColorDepthSelected()" | 429 | qCDebug(kpLogWidgets) << "kpDocumentSaveDialog::slotColorDepthSelected()" | ||
394 | << " mode&ColorDepth=" << (mode () & ColorDepth) | 430 | << " mode&ColorDepth=" << (mode () & ColorDepth) | ||
395 | << " colorDepthComboLastSelectedItem=" | 431 | << " colorDepthComboLastSelectedItem=" | ||
396 | << m_colorDepthComboLastSelectedItem | 432 | << m_colorDepthComboLastSelectedItem | ||
Context not available. | |||||
400 | 436 | | |||
401 | 437 | | |||
402 | // public | 438 | // public | ||
403 | int kpDocumentSaveOptionsWidget::quality () const | 439 | int kpDocumentSaveDialog::quality () const | ||
404 | { | 440 | { | ||
405 | if (mode () & Quality) | 441 | if (mode () & Quality) | ||
406 | { | 442 | { | ||
Context not available. | |||||
411 | } | 447 | } | ||
412 | 448 | | |||
413 | // public | 449 | // public | ||
414 | void kpDocumentSaveOptionsWidget::setQuality (int newQuality) | 450 | void kpDocumentSaveDialog::setQuality (int newQuality) | ||
415 | { | 451 | { | ||
416 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 452 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
417 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::setQuality(" | 453 | qCDebug(kpLogWidgets) << "kpDocumentSaveDialog::setQuality(" | ||
418 | << newQuality << ")" << endl; | 454 | << newQuality << ")" << endl; | ||
419 | #endif | 455 | #endif | ||
420 | 456 | | |||
Context not available. | |||||
426 | 462 | | |||
427 | 463 | | |||
428 | // public | 464 | // public | ||
429 | kpDocumentSaveOptions kpDocumentSaveOptionsWidget::documentSaveOptions () const | 465 | kpDocumentSaveOptions kpDocumentSaveDialog::documentSaveOptions () const | ||
430 | { | 466 | { | ||
431 | return kpDocumentSaveOptions (mimeType (), colorDepth (), dither (), quality ()); | 467 | return kpDocumentSaveOptions (mimeType (), colorDepth (), dither (), quality ()); | ||
432 | } | 468 | } | ||
433 | 469 | | |||
434 | // public | 470 | // public | ||
435 | void kpDocumentSaveOptionsWidget::setDocumentSaveOptions ( | 471 | void kpDocumentSaveDialog::setDocumentSaveOptions ( | ||
436 | const kpDocumentSaveOptions &saveOptions) | 472 | const kpDocumentSaveOptions &saveOptions) | ||
437 | { | 473 | { | ||
438 | setMimeType (saveOptions.mimeType ()); | 474 | setMimeType (saveOptions.mimeType ()); | ||
Context not available. | |||||
442 | 478 | | |||
443 | 479 | | |||
444 | // public | 480 | // public | ||
445 | void kpDocumentSaveOptionsWidget::setDocumentPixmap (const QImage &documentPixmap) | 481 | void kpDocumentSaveDialog::setDocumentPixmap (const QImage &documentPixmap) | ||
446 | { | 482 | { | ||
447 | delete m_documentPixmap; | 483 | delete m_documentPixmap; | ||
448 | m_documentPixmap = new QImage (documentPixmap); | 484 | m_documentPixmap = new QImage (documentPixmap); | ||
Context not available. | |||||
451 | } | 487 | } | ||
452 | 488 | | |||
453 | // public | 489 | // public | ||
454 | void kpDocumentSaveOptionsWidget::setDocumentMetaInfo ( | 490 | void kpDocumentSaveDialog::setDocumentMetaInfo ( | ||
455 | const kpDocumentMetaInfo &metaInfo) | 491 | const kpDocumentMetaInfo &metaInfo) | ||
456 | { | 492 | { | ||
457 | m_documentMetaInfo = metaInfo; | 493 | m_documentMetaInfo = metaInfo; | ||
Context not available. | |||||
461 | 497 | | |||
462 | 498 | | |||
463 | // public | 499 | // public | ||
464 | kpDocumentSaveOptionsWidget::Mode kpDocumentSaveOptionsWidget::mode () const | 500 | kpDocumentSaveDialog::Mode kpDocumentSaveDialog::mode () const | ||
465 | { | 501 | { | ||
466 | return m_mode; | 502 | return m_mode; | ||
467 | } | 503 | } | ||
468 | 504 | | |||
469 | // public | 505 | // public | ||
470 | void kpDocumentSaveOptionsWidget::setMode (Mode mode) | 506 | void kpDocumentSaveDialog::setMode (Mode mode) | ||
471 | { | 507 | { | ||
472 | m_mode = mode; | 508 | m_mode = mode; | ||
473 | 509 | | |||
Context not available. | |||||
492 | // we change the height of "this", causing the text on the labels | 528 | // we change the height of "this", causing the text on the labels | ||
493 | // to move but the first instance of the text doesn't get erased. | 529 | // to move but the first instance of the text doesn't get erased. | ||
494 | // Qt bug. | 530 | // Qt bug. | ||
495 | QTimer::singleShot (0, this, &kpDocumentSaveOptionsWidget::repaintLabels); | 531 | QTimer::singleShot (0, this, &kpDocumentSaveDialog::repaintLabels); | ||
496 | } | 532 | } | ||
497 | 533 | | |||
498 | // protected slot | 534 | // protected slot | ||
499 | void kpDocumentSaveOptionsWidget::repaintLabels () | 535 | void kpDocumentSaveDialog::repaintLabels () | ||
500 | { | 536 | { | ||
501 | if (mode () != Quality) { | 537 | if (mode () != Quality) { | ||
502 | m_colorDepthLabel->repaint (); | 538 | m_colorDepthLabel->repaint (); | ||
Context not available. | |||||
508 | 544 | | |||
509 | 545 | | |||
510 | // protected slot | 546 | // protected slot | ||
511 | void kpDocumentSaveOptionsWidget::showPreview (bool yes) | 547 | void kpDocumentSaveDialog::showPreview (bool yes) | ||
512 | { | 548 | { | ||
513 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 549 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
514 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::showPreview(" << yes << ")" | 550 | qCDebug(kpLogWidgets) << "kpDocumentSaveDialog::showPreview(" << yes << ")" | ||
515 | << " m_previewDialog=" << bool (m_previewDialog) | 551 | << " m_previewDialog=" << bool (m_previewDialog) | ||
516 | << endl; | 552 | << endl; | ||
517 | #endif | 553 | #endif | ||
Context not available. | |||||
520 | return; | 556 | return; | ||
521 | } | 557 | } | ||
522 | 558 | | |||
523 | if (!m_visualParent) { | | |||
524 | return; | | |||
525 | } | | |||
526 | | ||||
527 | if (yes) | 559 | if (yes) | ||
528 | { | 560 | { | ||
529 | m_previewDialog = new kpDocumentSaveOptionsPreviewDialog( m_visualParent ); | 561 | m_previewDialog = new kpDocumentSaveOptionsPreviewDialog( this ); | ||
530 | m_previewDialog->setObjectName( QStringLiteral( "previewSaveDialog" ) ); | 562 | m_previewDialog->setObjectName( QStringLiteral( "previewSaveDialog" ) ); | ||
531 | updatePreview (); | 563 | updatePreview (); | ||
532 | 564 | | |||
533 | connect (m_previewDialog, &kpDocumentSaveOptionsPreviewDialog::finished, | 565 | connect (m_previewDialog, &kpDocumentSaveOptionsPreviewDialog::finished, | ||
534 | this, &kpDocumentSaveOptionsWidget::hidePreview); | 566 | this, &kpDocumentSaveDialog::hidePreview); | ||
535 | 567 | | |||
536 | 568 | | |||
537 | KConfigGroup cfg (KSharedConfig::openConfig (), kpSettingsGroupPreviewSave); | 569 | KConfigGroup cfg (KSharedConfig::openConfig (), kpSettingsGroupPreviewSave); | ||
Context not available. | |||||
568 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 600 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
569 | qCDebug(kpLogWidgets) << "\tpreviewDialogLastRelativeGeometry=" | 601 | qCDebug(kpLogWidgets) << "\tpreviewDialogLastRelativeGeometry=" | ||
570 | << m_previewDialogLastRelativeGeometry | 602 | << m_previewDialogLastRelativeGeometry | ||
571 | << " visualParent->rect()=" << m_visualParent->rect () | 603 | << " this->rect()=" << this->rect () | ||
572 | << endl; | 604 | << endl; | ||
573 | #endif | 605 | #endif | ||
574 | 606 | | |||
575 | QRect relativeGeometry; | 607 | QRect relativeGeometry; | ||
576 | if (!m_previewDialogLastRelativeGeometry.isEmpty () && | 608 | if (!m_previewDialogLastRelativeGeometry.isEmpty () && | ||
577 | m_visualParent->rect ().intersects (m_previewDialogLastRelativeGeometry)) | 609 | this->rect ().intersects (m_previewDialogLastRelativeGeometry)) | ||
578 | { | 610 | { | ||
579 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 611 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
580 | qCDebug(kpLogWidgets) << "\tok"; | 612 | qCDebug(kpLogWidgets) << "\tok"; | ||
Context not available. | |||||
589 | const int margin = 20; | 621 | const int margin = 20; | ||
590 | 622 | | |||
591 | relativeGeometry = | 623 | relativeGeometry = | ||
592 | QRect (m_visualParent->width () - | 624 | QRect (this->width () - | ||
593 | m_previewDialog->preferredMinimumSize ().width () - | 625 | m_previewDialog->preferredMinimumSize ().width () - | ||
594 | margin, | 626 | margin, | ||
595 | margin * 2, // Avoid folder combo | 627 | margin * 2, // Avoid folder combo | ||
Context not available. | |||||
599 | 631 | | |||
600 | 632 | | |||
601 | const QRect globalGeometry = | 633 | const QRect globalGeometry = | ||
602 | kpWidgetMapper::toGlobal (m_visualParent, | 634 | kpWidgetMapper::toGlobal (this, | ||
603 | relativeGeometry); | 635 | relativeGeometry); | ||
604 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 636 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
605 | qCDebug(kpLogWidgets) << "\trelativeGeometry=" << relativeGeometry | 637 | qCDebug(kpLogWidgets) << "\trelativeGeometry=" << relativeGeometry | ||
Context not available. | |||||
624 | updatePreviewDialogLastRelativeGeometry (); | 656 | updatePreviewDialogLastRelativeGeometry (); | ||
625 | 657 | | |||
626 | connect (m_previewDialog, &kpDocumentSaveOptionsPreviewDialog::moved, | 658 | connect (m_previewDialog, &kpDocumentSaveOptionsPreviewDialog::moved, | ||
627 | this, &kpDocumentSaveOptionsWidget::updatePreviewDialogLastRelativeGeometry); | 659 | this, &kpDocumentSaveDialog::updatePreviewDialogLastRelativeGeometry); | ||
628 | 660 | | |||
629 | connect (m_previewDialog, &kpDocumentSaveOptionsPreviewDialog::resized, | 661 | connect (m_previewDialog, &kpDocumentSaveOptionsPreviewDialog::resized, | ||
630 | this, &kpDocumentSaveOptionsWidget::updatePreviewDialogLastRelativeGeometry); | 662 | this, &kpDocumentSaveDialog::updatePreviewDialogLastRelativeGeometry); | ||
631 | 663 | | |||
632 | m_updatePreviewDialogLastRelativeGeometryTimer->start (200/*ms*/); | 664 | m_updatePreviewDialogLastRelativeGeometryTimer->start (200/*ms*/); | ||
633 | } | 665 | } | ||
Context not available. | |||||
644 | qCDebug(kpLogWidgets) << "\tsaving preview geometry " | 676 | qCDebug(kpLogWidgets) << "\tsaving preview geometry " | ||
645 | << m_previewDialogLastRelativeGeometry | 677 | << m_previewDialogLastRelativeGeometry | ||
646 | << " (Qt would have us believe " | 678 | << " (Qt would have us believe " | ||
647 | << kpWidgetMapper::fromGlobal (m_visualParent, | 679 | << kpWidgetMapper::fromGlobal (this, | ||
648 | QRect (m_previewDialog->x (), m_previewDialog->y (), | 680 | QRect (m_previewDialog->x (), m_previewDialog->y (), | ||
649 | m_previewDialog->width (), m_previewDialog->height ())) | 681 | m_previewDialog->width (), m_previewDialog->height ())) | ||
650 | << ")" | 682 | << ")" | ||
Context not available. | |||||
657 | } | 689 | } | ||
658 | 690 | | |||
659 | // protected slot | 691 | // protected slot | ||
660 | void kpDocumentSaveOptionsWidget::hidePreview () | 692 | void kpDocumentSaveDialog::hidePreview () | ||
661 | { | 693 | { | ||
662 | if (m_previewButton->isChecked ()) { | 694 | if (m_previewButton->isChecked ()) { | ||
663 | m_previewButton->toggle (); | 695 | m_previewButton->toggle (); | ||
Context not available. | |||||
666 | 698 | | |||
667 | 699 | | |||
668 | // protected slot | 700 | // protected slot | ||
669 | void kpDocumentSaveOptionsWidget::updatePreviewDelayed () | 701 | void kpDocumentSaveDialog::updatePreviewDelayed () | ||
670 | { | 702 | { | ||
671 | // (single shot) | 703 | // (single shot) | ||
672 | m_updatePreviewTimer->start (m_updatePreviewDelay); | 704 | m_updatePreviewTimer->start (m_updatePreviewDelay); | ||
673 | } | 705 | } | ||
674 | 706 | | |||
675 | // protected slot | 707 | // protected slot | ||
676 | void kpDocumentSaveOptionsWidget::updatePreview () | 708 | void kpDocumentSaveDialog::updatePreview () | ||
677 | { | 709 | { | ||
678 | if (!m_previewDialog || !m_documentPixmap) { | 710 | if (!m_previewDialog || !m_documentPixmap) { | ||
679 | return; | 711 | return; | ||
Context not available. | |||||
724 | } | 756 | } | ||
725 | 757 | | |||
726 | // protected slot | 758 | // protected slot | ||
727 | void kpDocumentSaveOptionsWidget::updatePreviewDialogLastRelativeGeometry () | 759 | void kpDocumentSaveDialog::updatePreviewDialogLastRelativeGeometry () | ||
728 | { | 760 | { | ||
729 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 761 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
730 | qCDebug(kpLogWidgets) << "kpDocumentSaveOptionsWidget::" | 762 | qCDebug(kpLogWidgets) << "kpDocumentSaveDialog::" | ||
731 | << "updatePreviewDialogLastRelativeGeometry()" | 763 | << "updatePreviewDialogLastRelativeGeometry()" | ||
732 | << endl; | 764 | << endl; | ||
733 | #endif | 765 | #endif | ||
Context not available. | |||||
735 | if (m_previewDialog && m_previewDialog->isVisible ()) | 767 | if (m_previewDialog && m_previewDialog->isVisible ()) | ||
736 | { | 768 | { | ||
737 | m_previewDialogLastRelativeGeometry = | 769 | m_previewDialogLastRelativeGeometry = | ||
738 | kpWidgetMapper::fromGlobal (m_visualParent, | 770 | kpWidgetMapper::fromGlobal (this, | ||
739 | QRect (m_previewDialog->x (), m_previewDialog->y (), | 771 | QRect (m_previewDialog->x (), m_previewDialog->y (), | ||
740 | m_previewDialog->width (), m_previewDialog->height ())); | 772 | m_previewDialog->width (), m_previewDialog->height ())); | ||
741 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | 773 | #if DEBUG_KP_DOCUMENT_SAVE_OPTIONS_WIDGET | ||
Context not available. |