Changeset View
Changeset View
Standalone View
Standalone View
mainWindow/kpMainWindow.cpp
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | 102 | { | |||
---|---|---|---|---|---|
113 | if (cfg.hasKey (kpSettingOpenImagesInSameWindow)) | 113 | if (cfg.hasKey (kpSettingOpenImagesInSameWindow)) | ||
114 | { | 114 | { | ||
115 | d->configOpenImagesInSameWindow = cfg.readEntry (kpSettingOpenImagesInSameWindow, false); | 115 | d->configOpenImagesInSameWindow = cfg.readEntry (kpSettingOpenImagesInSameWindow, false); | ||
116 | } | 116 | } | ||
117 | else | 117 | else | ||
118 | { | 118 | { | ||
119 | d->configOpenImagesInSameWindow = false; | 119 | d->configOpenImagesInSameWindow = false; | ||
120 | qCDebug(kpLogMainWindow) << "\tconfigOpenImagesInSameWindow: first time" | 120 | qCDebug(kpLogMainWindow) << "\tconfigOpenImagesInSameWindow: first time" | ||
121 | << " - writing default: " << d->configOpenImagesInSameWindow | 121 | << " - writing default: " << d->configOpenImagesInSameWindow; | ||
122 | << endl; | | |||
123 | // TODO: More hidden options have to write themselves out on startup, | 122 | // TODO: More hidden options have to write themselves out on startup, | ||
124 | // not on use, to be discoverable (e.g. printing centered on page). | 123 | // not on use, to be discoverable (e.g. printing centered on page). | ||
125 | cfg.writeEntry (kpSettingOpenImagesInSameWindow, | 124 | cfg.writeEntry (kpSettingOpenImagesInSameWindow, | ||
126 | d->configOpenImagesInSameWindow); | 125 | d->configOpenImagesInSameWindow); | ||
127 | cfg.sync (); | 126 | cfg.sync (); | ||
128 | } | 127 | } | ||
129 | 128 | | |||
130 | d->configPrintImageCenteredOnPage = cfg.readEntry (kpSettingPrintImageCenteredOnPage, true); | 129 | d->configPrintImageCenteredOnPage = cfg.readEntry (kpSettingPrintImageCenteredOnPage, true); | ||
Show All 19 Lines | 144 | { | |||
150 | d->configThumbnailShown = cfg.readEntry (kpSettingThumbnailShown, false); | 149 | d->configThumbnailShown = cfg.readEntry (kpSettingThumbnailShown, false); | ||
151 | d->configThumbnailGeometry = cfg.readEntry (kpSettingThumbnailGeometry, QRect ()); | 150 | d->configThumbnailGeometry = cfg.readEntry (kpSettingThumbnailGeometry, QRect ()); | ||
152 | d->configZoomedThumbnail = cfg.readEntry (kpSettingThumbnailZoomed, true); | 151 | d->configZoomedThumbnail = cfg.readEntry (kpSettingThumbnailZoomed, true); | ||
153 | d->configThumbnailShowRectangle = cfg.readEntry (kpSettingThumbnailShowRectangle, true); | 152 | d->configThumbnailShowRectangle = cfg.readEntry (kpSettingThumbnailShowRectangle, true); | ||
154 | 153 | | |||
155 | qCDebug(kpLogMainWindow) << "\t\tThumbnail Settings: shown=" << d->configThumbnailShown | 154 | qCDebug(kpLogMainWindow) << "\t\tThumbnail Settings: shown=" << d->configThumbnailShown | ||
156 | << " geometry=" << d->configThumbnailGeometry | 155 | << " geometry=" << d->configThumbnailGeometry | ||
157 | << " zoomed=" << d->configZoomedThumbnail | 156 | << " zoomed=" << d->configZoomedThumbnail | ||
158 | << " showRectangle=" << d->configThumbnailShowRectangle | 157 | << " showRectangle=" << d->configThumbnailShowRectangle; | ||
159 | << endl; | | |||
160 | } | 158 | } | ||
161 | 159 | | |||
162 | //--------------------------------------------------------------------- | 160 | //--------------------------------------------------------------------- | ||
163 | 161 | | |||
164 | void kpMainWindow::finalizeGUI(KXMLGUIClient *client) | 162 | void kpMainWindow::finalizeGUI(KXMLGUIClient *client) | ||
165 | { | 163 | { | ||
166 | if ( client == this ) | 164 | if ( client == this ) | ||
167 | { | 165 | { | ||
168 | const QList<QMenu *> menuToHide = findChildren<QMenu *>("toolToolBarHiddenMenu"); | 166 | const QList<QMenu *> menuToHide = findChildren<QMenu *>("toolToolBarHiddenMenu"); | ||
169 | // should only contain one but... | 167 | // should only contain one but... | ||
170 | foreach (QMenu *menu, menuToHide) | 168 | for (auto *menu : menuToHide) | ||
171 | { | 169 | { | ||
172 | menu->menuAction()->setVisible(false); | 170 | menu->menuAction()->setVisible(false); | ||
173 | } | 171 | } | ||
174 | } | 172 | } | ||
175 | } | 173 | } | ||
176 | 174 | | |||
177 | //--------------------------------------------------------------------- | 175 | //--------------------------------------------------------------------- | ||
178 | 176 | | |||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | |||||
377 | 375 | | |||
378 | kpMainWindow::~kpMainWindow () | 376 | kpMainWindow::~kpMainWindow () | ||
379 | { | 377 | { | ||
380 | d->isFullyConstructed = false; | 378 | d->isFullyConstructed = false; | ||
381 | 379 | | |||
382 | // Get the kpTool to finish up. This makes sure that the kpTool destructor | 380 | // Get the kpTool to finish up. This makes sure that the kpTool destructor | ||
383 | // will not need to access any other class (that might be deleted before | 381 | // will not need to access any other class (that might be deleted before | ||
384 | // the destructor is called by the QObject child-deletion mechanism). | 382 | // the destructor is called by the QObject child-deletion mechanism). | ||
385 | if (tool ()) | 383 | if (tool ()) { | ||
386 | tool ()->endInternal (); | 384 | tool ()->endInternal (); | ||
385 | } | ||||
387 | 386 | | |||
388 | // Delete document & views. | 387 | // Delete document & views. | ||
389 | // Note: This will disconnects signals from the current kpTool, so kpTool | 388 | // Note: This will disconnects signals from the current kpTool, so kpTool | ||
390 | // must not be destructed yet. | 389 | // must not be destructed yet. | ||
391 | setDocument (nullptr); | 390 | setDocument (nullptr); | ||
392 | 391 | | |||
393 | delete d->commandHistory; d->commandHistory = nullptr; | 392 | delete d->commandHistory; d->commandHistory = nullptr; | ||
394 | delete d->scrollView; d->scrollView = nullptr; | 393 | delete d->scrollView; d->scrollView = nullptr; | ||
Show All 10 Lines | 403 | { | |||
405 | return d->document; | 404 | return d->document; | ||
406 | } | 405 | } | ||
407 | 406 | | |||
408 | //--------------------------------------------------------------------- | 407 | //--------------------------------------------------------------------- | ||
409 | 408 | | |||
410 | // public | 409 | // public | ||
411 | kpDocumentEnvironment *kpMainWindow::documentEnvironment () | 410 | kpDocumentEnvironment *kpMainWindow::documentEnvironment () | ||
412 | { | 411 | { | ||
413 | if (!d->documentEnvironment) | 412 | if (!d->documentEnvironment) { | ||
414 | d->documentEnvironment = new kpDocumentEnvironment (this); | 413 | d->documentEnvironment = new kpDocumentEnvironment (this); | ||
414 | } | ||||
415 | 415 | | |||
416 | return d->documentEnvironment; | 416 | return d->documentEnvironment; | ||
417 | } | 417 | } | ||
418 | 418 | | |||
419 | //--------------------------------------------------------------------- | 419 | //--------------------------------------------------------------------- | ||
420 | 420 | | |||
421 | // public | 421 | // public | ||
422 | kpViewManager *kpMainWindow::viewManager () const | 422 | kpViewManager *kpMainWindow::viewManager () const | ||
Show All 32 Lines | |||||
455 | { | 455 | { | ||
456 | return d->commandHistory; | 456 | return d->commandHistory; | ||
457 | } | 457 | } | ||
458 | 458 | | |||
459 | //--------------------------------------------------------------------- | 459 | //--------------------------------------------------------------------- | ||
460 | 460 | | |||
461 | kpCommandEnvironment *kpMainWindow::commandEnvironment () | 461 | kpCommandEnvironment *kpMainWindow::commandEnvironment () | ||
462 | { | 462 | { | ||
463 | if (!d->commandEnvironment) | 463 | if (!d->commandEnvironment) { | ||
464 | d->commandEnvironment = new kpCommandEnvironment (this); | 464 | d->commandEnvironment = new kpCommandEnvironment (this); | ||
465 | } | ||||
465 | 466 | | |||
466 | return d->commandEnvironment; | 467 | return d->commandEnvironment; | ||
467 | } | 468 | } | ||
468 | 469 | | |||
469 | //--------------------------------------------------------------------- | 470 | //--------------------------------------------------------------------- | ||
470 | 471 | | |||
471 | // private | 472 | // private | ||
472 | void kpMainWindow::setupActions () | 473 | void kpMainWindow::setupActions () | ||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 503 | { | |||
569 | } | 570 | } | ||
570 | d->exportFirstTime = true; | 571 | d->exportFirstTime = true; | ||
571 | 572 | | |||
572 | 573 | | |||
573 | // not a close operation? | 574 | // not a close operation? | ||
574 | if (d->document) | 575 | if (d->document) | ||
575 | { | 576 | { | ||
576 | qCDebug(kpLogMainWindow) << "\treparenting doc that may have been created into a" | 577 | qCDebug(kpLogMainWindow) << "\treparenting doc that may have been created into a" | ||
577 | << " different mainWindiow" << endl; | 578 | << " different mainWindiow"; | ||
578 | d->document->setEnviron (documentEnvironment ()); | 579 | d->document->setEnviron (documentEnvironment ()); | ||
579 | 580 | | |||
580 | d->viewManager = new kpViewManager (this); | 581 | d->viewManager = new kpViewManager (this); | ||
581 | 582 | | |||
582 | d->mainView = new kpZoomedView (d->document, d->toolToolBar, d->viewManager, | 583 | d->mainView = new kpZoomedView (d->document, d->toolToolBar, d->viewManager, | ||
583 | nullptr/*buddyView*/, | 584 | nullptr/*buddyView*/, | ||
584 | d->scrollView, | 585 | d->scrollView, | ||
585 | d->scrollView->viewport ()); | 586 | d->scrollView->viewport ()); | ||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Line(s) | |||||
683 | qCDebug(kpLogMainWindow) << "\tupdating mainWindow elements"; | 684 | qCDebug(kpLogMainWindow) << "\tupdating mainWindow elements"; | ||
684 | 685 | | |||
685 | slotImageMenuUpdateDueToSelection (); | 686 | slotImageMenuUpdateDueToSelection (); | ||
686 | recalculateStatusBar (); | 687 | recalculateStatusBar (); | ||
687 | slotUpdateCaption (); // Untitled to start with | 688 | slotUpdateCaption (); // Untitled to start with | ||
688 | slotEnableReload (); | 689 | slotEnableReload (); | ||
689 | slotEnableSettingsShowPath (); | 690 | slotEnableSettingsShowPath (); | ||
690 | 691 | | |||
691 | if (d->commandHistory) | 692 | if (d->commandHistory) { | ||
692 | d->commandHistory->clear (); | 693 | d->commandHistory->clear (); | ||
694 | } | ||||
693 | 695 | | |||
694 | qCDebug(kpLogMainWindow) << "\tdocument and views ready to go!"; | 696 | qCDebug(kpLogMainWindow) << "\tdocument and views ready to go!"; | ||
695 | } | 697 | } | ||
696 | 698 | | |||
697 | //--------------------------------------------------------------------- | 699 | //--------------------------------------------------------------------- | ||
698 | 700 | | |||
699 | // private virtual [base QWidget] | 701 | // private virtual [base QWidget] | ||
700 | void kpMainWindow::dragEnterEvent (QDragEnterEvent *e) | 702 | void kpMainWindow::dragEnterEvent (QDragEnterEvent *e) | ||
Show All 26 Lines | 715 | { | |||
727 | } | 729 | } | ||
728 | else if (!(urls = e->mimeData ()->urls ()).isEmpty ()) | 730 | else if (!(urls = e->mimeData ()->urls ()).isEmpty ()) | ||
729 | { | 731 | { | ||
730 | // LOTODO: kpSetOverrideCursorSaver cursorSaver (Qt::waitCursor); | 732 | // LOTODO: kpSetOverrideCursorSaver cursorSaver (Qt::waitCursor); | ||
731 | // | 733 | // | ||
732 | // However, you would need to prefix all possible error/warning | 734 | // However, you would need to prefix all possible error/warning | ||
733 | // dialogs that might be called, with Qt::arrowCursor e.g. in | 735 | // dialogs that might be called, with Qt::arrowCursor e.g. in | ||
734 | // kpDocument and probably a lot more places. | 736 | // kpDocument and probably a lot more places. | ||
735 | foreach (const QUrl &u, urls) | 737 | for (const auto &u : urls) | ||
736 | open (u); | 738 | open (u); | ||
737 | } | 739 | } | ||
738 | else if (e->mimeData ()->hasText ()) | 740 | else if (e->mimeData ()->hasText ()) | ||
739 | { | 741 | { | ||
740 | const QString text = e->mimeData ()->text (); | 742 | const QString text = e->mimeData ()->text (); | ||
741 | 743 | | |||
742 | QPoint selTopLeft = KP_INVALID_POINT; | 744 | QPoint selTopLeft = KP_INVALID_POINT; | ||
743 | const QPoint globalPos = QWidget::mapToGlobal (e->pos ()); | 745 | const QPoint globalPos = QWidget::mapToGlobal (e->pos ()); | ||
Show All 14 Lines | 755 | { | |||
758 | if (d->mainView && d->scrollView) | 760 | if (d->mainView && d->scrollView) | ||
759 | { | 761 | { | ||
760 | qCDebug(kpLogMainWindow) << "\t\t\tmainView->globalRect=" | 762 | qCDebug(kpLogMainWindow) << "\t\t\tmainView->globalRect=" | ||
761 | << kpWidgetMapper::toGlobal (d->mainView, d->mainView->rect ()) | 763 | << kpWidgetMapper::toGlobal (d->mainView, d->mainView->rect ()) | ||
762 | << " scrollView->globalRect=" | 764 | << " scrollView->globalRect=" | ||
763 | << kpWidgetMapper::toGlobal (d->scrollView, | 765 | << kpWidgetMapper::toGlobal (d->scrollView, | ||
764 | QRect (0, 0, | 766 | QRect (0, 0, | ||
765 | d->scrollView->viewport()->width (), | 767 | d->scrollView->viewport()->width (), | ||
766 | d->scrollView->viewport()->height ())) | 768 | d->scrollView->viewport()->height ())); | ||
767 | << endl; | | |||
768 | } | 769 | } | ||
769 | if (d->thumbnailView && | 770 | if (d->thumbnailView && | ||
770 | kpWidgetMapper::toGlobal (d->thumbnailView, d->thumbnailView->rect ()) | 771 | kpWidgetMapper::toGlobal (d->thumbnailView, d->thumbnailView->rect ()) | ||
771 | .contains (globalPos)) | 772 | .contains (globalPos)) | ||
772 | { | 773 | { | ||
773 | // TODO: Code will never get executed. | 774 | // TODO: Code will never get executed. | ||
774 | // Thumbnail doesn't accept drops. | 775 | // Thumbnail doesn't accept drops. | ||
775 | view = d->thumbnailView; | 776 | view = d->thumbnailView; | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 847 | { | |||
856 | } | 857 | } | ||
857 | } | 858 | } | ||
858 | 859 | | |||
859 | //--------------------------------------------------------------------- | 860 | //--------------------------------------------------------------------- | ||
860 | 861 | | |||
861 | // private slot | 862 | // private slot | ||
862 | void kpMainWindow::slotDocumentRestored () | 863 | void kpMainWindow::slotDocumentRestored () | ||
863 | { | 864 | { | ||
864 | if (d->document) | 865 | if (d->document) { | ||
865 | d->document->setModified (false); | 866 | d->document->setModified (false); | ||
867 | } | ||||
866 | slotUpdateCaption (); | 868 | slotUpdateCaption (); | ||
867 | } | 869 | } | ||
868 | 870 | | |||
869 | //--------------------------------------------------------------------- | 871 | //--------------------------------------------------------------------- | ||
870 | 872 | |