Changeset View
Changeset View
Standalone View
Standalone View
mainWindow/kpMainWindow_View_Thumbnail.cpp
Show First 20 Lines • Show All 60 Lines • ▼ Show 20 Line(s) | 56 | { | |||
---|---|---|---|---|---|
61 | 61 | | |||
62 | d->actionShowThumbnail = ac->add <KToggleAction> ("view_show_thumbnail"); | 62 | d->actionShowThumbnail = ac->add <KToggleAction> ("view_show_thumbnail"); | ||
63 | d->actionShowThumbnail->setText (i18n ("Show T&humbnail")); | 63 | d->actionShowThumbnail->setText (i18n ("Show T&humbnail")); | ||
64 | // TODO: This doesn't work when the thumbnail has focus. | 64 | // TODO: This doesn't work when the thumbnail has focus. | ||
65 | // Testcase: Press CTRL+H twice on a fresh KolourPaint. | 65 | // Testcase: Press CTRL+H twice on a fresh KolourPaint. | ||
66 | // The second CTRL+H doesn't close the thumbnail. | 66 | // The second CTRL+H doesn't close the thumbnail. | ||
67 | ac->setDefaultShortcut (d->actionShowThumbnail, Qt::CTRL + Qt::Key_H); | 67 | ac->setDefaultShortcut (d->actionShowThumbnail, Qt::CTRL + Qt::Key_H); | ||
68 | //d->actionShowThumbnail->setCheckedState (KGuiItem(i18n ("Hide T&humbnail"))); | 68 | //d->actionShowThumbnail->setCheckedState (KGuiItem(i18n ("Hide T&humbnail"))); | ||
69 | connect (d->actionShowThumbnail, SIGNAL (triggered(bool)), | 69 | connect (d->actionShowThumbnail, &KToggleAction::triggered, | ||
70 | SLOT (slotShowThumbnailToggled())); | 70 | this, &kpMainWindow::slotShowThumbnailToggled); | ||
71 | 71 | | |||
72 | // Please do not use setCheckedState() here - it wouldn't make sense | 72 | // Please do not use setCheckedState() here - it wouldn't make sense | ||
73 | d->actionZoomedThumbnail = ac->add <KToggleAction> ("view_zoomed_thumbnail"); | 73 | d->actionZoomedThumbnail = ac->add <KToggleAction> ("view_zoomed_thumbnail"); | ||
74 | d->actionZoomedThumbnail->setText (i18n ("Zoo&med Thumbnail Mode")); | 74 | d->actionZoomedThumbnail->setText (i18n ("Zoo&med Thumbnail Mode")); | ||
75 | connect (d->actionZoomedThumbnail, SIGNAL (triggered(bool)), | 75 | connect (d->actionZoomedThumbnail, &KToggleAction::triggered, | ||
76 | SLOT (slotZoomedThumbnailToggled())); | 76 | this, &kpMainWindow::slotZoomedThumbnailToggled); | ||
77 | 77 | | |||
78 | // For consistency with the above action, don't use setCheckedState() | 78 | // For consistency with the above action, don't use setCheckedState() | ||
79 | // | 79 | // | ||
80 | // Also, don't use "Show Thumbnail Rectangle" because if entire doc | 80 | // Also, don't use "Show Thumbnail Rectangle" because if entire doc | ||
81 | // can be seen in scrollView, checking option won't "Show" anything | 81 | // can be seen in scrollView, checking option won't "Show" anything | ||
82 | // since rect _surrounds_ entire doc (hence, won't be rendered). | 82 | // since rect _surrounds_ entire doc (hence, won't be rendered). | ||
83 | d->actionShowThumbnailRectangle = ac->add <KToggleAction> ("view_show_thumbnail_rectangle"); | 83 | d->actionShowThumbnailRectangle = ac->add <KToggleAction> ("view_show_thumbnail_rectangle"); | ||
84 | d->actionShowThumbnailRectangle->setText (i18n ("Enable Thumbnail &Rectangle")); | 84 | d->actionShowThumbnailRectangle->setText (i18n ("Enable Thumbnail &Rectangle")); | ||
85 | connect (d->actionShowThumbnailRectangle, SIGNAL (triggered(bool)), | 85 | connect (d->actionShowThumbnailRectangle, &KToggleAction::triggered, | ||
86 | SLOT (slotThumbnailShowRectangleToggled())); | 86 | this, &kpMainWindow::slotThumbnailShowRectangleToggled); | ||
87 | } | 87 | } | ||
88 | 88 | | |||
89 | // private | 89 | // private | ||
90 | void kpMainWindow::enableViewMenuThumbnailDocumentActions (bool enable) | 90 | void kpMainWindow::enableViewMenuThumbnailDocumentActions (bool enable) | ||
91 | { | 91 | { | ||
92 | d->actionShowThumbnail->setEnabled (enable); | 92 | d->actionShowThumbnail->setEnabled (enable); | ||
93 | enableThumbnailOptionActions (enable); | 93 | enableThumbnailOptionActions (enable); | ||
94 | } | 94 | } | ||
Show All 39 Lines | |||||
134 | #if DEBUG_KP_MAIN_WINDOW | 134 | #if DEBUG_KP_MAIN_WINDOW | ||
135 | qCDebug(kpLogMainWindow) << "kpMainWindow::notifyThumbnailGeometryChanged()"; | 135 | qCDebug(kpLogMainWindow) << "kpMainWindow::notifyThumbnailGeometryChanged()"; | ||
136 | #endif | 136 | #endif | ||
137 | 137 | | |||
138 | if (!d->thumbnailSaveConfigTimer) | 138 | if (!d->thumbnailSaveConfigTimer) | ||
139 | { | 139 | { | ||
140 | d->thumbnailSaveConfigTimer = new QTimer (this); | 140 | d->thumbnailSaveConfigTimer = new QTimer (this); | ||
141 | d->thumbnailSaveConfigTimer->setSingleShot (true); | 141 | d->thumbnailSaveConfigTimer->setSingleShot (true); | ||
142 | connect (d->thumbnailSaveConfigTimer, SIGNAL (timeout()), | 142 | connect (d->thumbnailSaveConfigTimer, &QTimer::timeout, | ||
143 | this, SLOT (slotSaveThumbnailGeometry())); | 143 | this, &kpMainWindow::slotSaveThumbnailGeometry); | ||
144 | } | 144 | } | ||
145 | 145 | | |||
146 | // (single shot) | 146 | // (single shot) | ||
147 | d->thumbnailSaveConfigTimer->start (500/*msec*/); | 147 | d->thumbnailSaveConfigTimer->start (500/*msec*/); | ||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | // private slot | 150 | // private slot | ||
151 | void kpMainWindow::slotSaveThumbnailGeometry () | 151 | void kpMainWindow::slotSaveThumbnailGeometry () | ||
▲ Show 20 Lines • Show All 279 Lines • ▼ Show 20 Line(s) | 374 | #endif | |||
431 | #if DEBUG_KP_MAIN_WINDOW | 431 | #if DEBUG_KP_MAIN_WINDOW | ||
432 | qCDebug(kpLogMainWindow) << "\t\tshowing thumbnail"; | 432 | qCDebug(kpLogMainWindow) << "\t\tshowing thumbnail"; | ||
433 | #endif | 433 | #endif | ||
434 | d->thumbnail->show (); | 434 | d->thumbnail->show (); | ||
435 | 435 | | |||
436 | #if DEBUG_KP_MAIN_WINDOW | 436 | #if DEBUG_KP_MAIN_WINDOW | ||
437 | qCDebug(kpLogMainWindow) << "\t\tconnecting signal thumbnail::windowClosed to destroy slot"; | 437 | qCDebug(kpLogMainWindow) << "\t\tconnecting signal thumbnail::windowClosed to destroy slot"; | ||
438 | #endif | 438 | #endif | ||
439 | connect (d->thumbnail, SIGNAL (windowClosed()), | 439 | connect (d->thumbnail, &kpThumbnail::windowClosed, | ||
440 | this, SLOT (slotDestroyThumbnailInitatedByUser())); | 440 | this, &kpMainWindow::slotDestroyThumbnailInitatedByUser); | ||
441 | #if DEBUG_KP_MAIN_WINDOW | 441 | #if DEBUG_KP_MAIN_WINDOW | ||
442 | qCDebug(kpLogMainWindow) << "\t\tDONE"; | 442 | qCDebug(kpLogMainWindow) << "\t\tDONE"; | ||
443 | #endif | 443 | #endif | ||
444 | } | 444 | } | ||
445 | else | 445 | else | ||
446 | { | 446 | { | ||
447 | #if DEBUG_KP_MAIN_WINDOW | 447 | #if DEBUG_KP_MAIN_WINDOW | ||
448 | qCDebug(kpLogMainWindow) << "\tdestroying thumbnail d->thumbnail=" | 448 | qCDebug(kpLogMainWindow) << "\tdestroying thumbnail d->thumbnail=" | ||
449 | << d->thumbnail << endl; | 449 | << d->thumbnail << endl; | ||
450 | #endif | 450 | #endif | ||
451 | 451 | | |||
452 | if (d->thumbnailSaveConfigTimer && d->thumbnailSaveConfigTimer->isActive ()) | 452 | if (d->thumbnailSaveConfigTimer && d->thumbnailSaveConfigTimer->isActive ()) | ||
453 | { | 453 | { | ||
454 | d->thumbnailSaveConfigTimer->stop (); | 454 | d->thumbnailSaveConfigTimer->stop (); | ||
455 | slotSaveThumbnailGeometry (); | 455 | slotSaveThumbnailGeometry (); | ||
456 | } | 456 | } | ||
457 | 457 | | |||
458 | // Must be done before hiding the thumbnail to avoid triggering | 458 | // Must be done before hiding the thumbnail to avoid triggering | ||
459 | // this signal - re-entering this code. | 459 | // this signal - re-entering this code. | ||
460 | disconnect (d->thumbnail, SIGNAL (windowClosed()), | 460 | disconnect (d->thumbnail, &kpThumbnail::windowClosed, | ||
461 | this, SLOT (slotDestroyThumbnailInitatedByUser())); | 461 | this, &kpMainWindow::slotDestroyThumbnailInitatedByUser); | ||
462 | 462 | | |||
463 | // Avoid change/flicker of caption due to view delete | 463 | // Avoid change/flicker of caption due to view delete | ||
464 | // (destroyThumbnailView()) | 464 | // (destroyThumbnailView()) | ||
465 | d->thumbnail->hide (); | 465 | d->thumbnail->hide (); | ||
466 | 466 | | |||
467 | destroyThumbnailView (); | 467 | destroyThumbnailView (); | ||
468 | 468 | | |||
469 | d->thumbnail->deleteLater (); d->thumbnail = nullptr; | 469 | d->thumbnail->deleteLater (); d->thumbnail = nullptr; | ||
470 | } | 470 | } | ||
471 | } | 471 | } |