Changeset View
Standalone View
ui/pageview.cpp
Show First 20 Lines • Show All 728 Lines • ▼ Show 20 Line(s) | 697 | #endif | |||
---|---|---|---|---|---|
729 | 729 | | |||
730 | // Setup undo and redo actions | 730 | // Setup undo and redo actions | ||
731 | QAction *kundo = KStandardAction::create( KStandardAction::Undo, d->document, SLOT(undo()), ac ); | 731 | QAction *kundo = KStandardAction::create( KStandardAction::Undo, d->document, SLOT(undo()), ac ); | ||
732 | QAction *kredo = KStandardAction::create( KStandardAction::Redo, d->document, SLOT(redo()), ac ); | 732 | QAction *kredo = KStandardAction::create( KStandardAction::Redo, d->document, SLOT(redo()), ac ); | ||
733 | connect(d->document, &Okular::Document::canUndoChanged, kundo, &QAction::setEnabled); | 733 | connect(d->document, &Okular::Document::canUndoChanged, kundo, &QAction::setEnabled); | ||
734 | connect(d->document, &Okular::Document::canRedoChanged, kredo, &QAction::setEnabled); | 734 | connect(d->document, &Okular::Document::canRedoChanged, kredo, &QAction::setEnabled); | ||
735 | kundo->setEnabled(false); | 735 | kundo->setEnabled(false); | ||
736 | kredo->setEnabled(false); | 736 | kredo->setEnabled(false); | ||
737 | | ||||
yurchor: Trailing spaces | |||||
738 | // Setup select all action for the current page | ||||
739 | QAction *selectCurrentPage = new QAction( i18n("Select All Text On Current Page"), this ); | ||||
740 | ac->addAction( QStringLiteral("edit_select_all_current_page"), selectCurrentPage ); | ||||
This icon is already used for the Select All action, and we don't want to re-use the same icon for two actions in the same menu. Let's remove it. ngraham: This icon is already used for the {nav Select All} action, and we don't want to re-use the same… | |||||
741 | connect( selectCurrentPage, &QAction::triggered, this, &PageView::slotSelectPage ); | ||||
ngraham: The correct text here would be "Select all text on current page" | |||||
742 | addAction( selectCurrentPage ); | ||||
743 | | ||||
ngraham: Erm, that's the shortcut used for printing. Did you test this? | |||||
shubham: What sequence should I use? | |||||
It doesn't have a shortcut at all. If you can't think of anything that doesn't conflict, then just don't give it one. ngraham: It doesn't have a shortcut at all. If you can't think of anything that doesn't conflict, then… | |||||
shubham: So better I will remove that. | |||||
Here is e.g. Alt-P, and a couple of F-Keys not used. loh.tar: Here is e.g. Alt-P, and a couple of F-Keys not used.
But perhaps exist in other software some… | |||||
yurchor: Trailing spaces | |||||
744 | if ( d->document->isOpened() ) | ||||
745 | { | ||||
746 | selectCurrentPage->setEnabled( true ); | ||||
747 | } | ||||
737 | } | 748 | } | ||
738 | 749 | | |||
739 | bool PageView::canFitPageWidth() const | 750 | bool PageView::canFitPageWidth() const | ||
740 | { | 751 | { | ||
741 | return Okular::Settings::viewMode() != Okular::Settings::EnumViewMode::Single || d->zoomMode != ZoomFitWidth; | 752 | return Okular::Settings::viewMode() != Okular::Settings::EnumViewMode::Single || d->zoomMode != ZoomFitWidth; | ||
742 | } | 753 | } | ||
743 | 754 | | |||
744 | void PageView::fitPageWidth( int page ) | 755 | void PageView::fitPageWidth( int page ) | ||
▲ Show 20 Lines • Show All 2564 Lines • ▼ Show 20 Line(s) | |||||
3309 | 3320 | | |||
3310 | void PageView::wheelEvent( QWheelEvent *e ) | 3321 | void PageView::wheelEvent( QWheelEvent *e ) | ||
3311 | { | 3322 | { | ||
3312 | // don't perform any mouse action when viewport is autoscrolling | 3323 | // don't perform any mouse action when viewport is autoscrolling | ||
3313 | if ( d->viewportMoveActive ) | 3324 | if ( d->viewportMoveActive ) | ||
3314 | return; | 3325 | return; | ||
3315 | 3326 | | |||
3316 | if ( !d->document->isOpened() ) | 3327 | if ( !d->document->isOpened() ) | ||
3317 | { | 3328 | { | ||
Lines below produce segmentation fault, can't figure out what's wrong here shubham: Lines below produce segmentation fault, can't figure out what's wrong here | |||||
This part of code actually just visualy selects the page, so that a context menu event can occur. shubham: This part of code actually just visualy selects the page, so that a context menu event can… | |||||
3318 | QAbstractScrollArea::wheelEvent( e ); | 3329 | QAbstractScrollArea::wheelEvent( e ); | ||
3319 | return; | 3330 | return; | ||
3320 | } | 3331 | } | ||
3321 | 3332 | | |||
3322 | int delta = e->delta(), | 3333 | int delta = e->delta(), | ||
3323 | vScroll = verticalScrollBar()->value(); | 3334 | vScroll = verticalScrollBar()->value(); | ||
3324 | e->accept(); | 3335 | e->accept(); | ||
3325 | if ( (e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier ) { | 3336 | if ( (e->modifiers() & Qt::ControlModifier) == Qt::ControlModifier ) { | ||
▲ Show 20 Lines • Show All 2239 Lines • ▼ Show 20 Line(s) | 5561 | { | |||
5565 | const QSize pageSize = QSize( currentPageItem->uncroppedWidth() + kcolWidthMargin, currentPageItem->uncroppedHeight() + krowHeightMargin ); | 5576 | const QSize pageSize = QSize( currentPageItem->uncroppedWidth() + kcolWidthMargin, currentPageItem->uncroppedHeight() + krowHeightMargin ); | ||
5566 | if ( verticalScrollBar()->isVisible() ) | 5577 | if ( verticalScrollBar()->isVisible() ) | ||
5567 | viewportSize.setWidth( viewportSize.width() + verticalScrollBar()->width() ); | 5578 | viewportSize.setWidth( viewportSize.width() + verticalScrollBar()->width() ); | ||
5568 | if ( horizontalScrollBar()->isVisible() ) | 5579 | if ( horizontalScrollBar()->isVisible() ) | ||
5569 | viewportSize.setHeight( viewportSize.height() + horizontalScrollBar()->height() ); | 5580 | viewportSize.setHeight( viewportSize.height() + horizontalScrollBar()->height() ); | ||
5570 | emit fitWindowToPage( viewportSize, pageSize ); | 5581 | emit fitWindowToPage( viewportSize, pageSize ); | ||
5571 | } | 5582 | } | ||
5572 | 5583 | | |||
5584 | void PageView::slotSelectPage() | ||||
5585 | { | ||||
5586 | // The code below selects the entire page and copies the text to a clipboard if mode is Text Select | ||||
yurchor: Trailing space | |||||
5587 | textSelectionClear(); | ||||
5588 | const int currentPage = d->document->viewport().pageNumber; | ||||
5589 | PageViewItem *item = d->items.at( currentPage ); | ||||
5590 | | ||||
yurchor: Trailing spaces | |||||
5591 | if (item) | ||||
5592 | { | ||||
yurchor: Trailing spaces | |||||
5593 | Okular::RegularAreaRect * area = textSelectionForItem( item ); | ||||
5594 | const QString text = item->page()->text( area ); | ||||
5595 | d->pagesWithTextSelection.insert( currentPage ); | ||||
5596 | d->document->setPageTextSelection( currentPage, area, palette().color( QPalette::Active, QPalette::Highlight ) ); | ||||
5597 | | ||||
5598 | if ( d->document->isAllowed( Okular::AllowCopy ) ) | ||||
yurchor: Trailing space | |||||
I don't think we should be copying to the clipboard. selectAll() isn't doing it, so this function doing it would be strage usability wise. aacid: I don't think we should be copying to the clipboard.
selectAll() isn't doing it, so this… | |||||
The other selection tools copy to clipboard. Maybe Select All should do so too, because the selection can not be used any other way than Menu -> Edit -> Copy. (Other way: e. g. right click -> Search With DuckDuckGo) davidhurka: The other selection tools copy to clipboard. Maybe Select All should do so too, because the… | |||||
Not convinced, for example kate doesn't do that either. open kate, type something, press ctrl+a to select it, it only gets selected, not copied to the clipboard but if you select it with the mouse it then gets copied to the clipboard. It'd be the same we're doing, so i think this consistency is good to maintain. aacid: Not convinced, for example kate doesn't do that either.
open kate, type something, press… | |||||
5599 | { | ||||
5600 | if ( !text.isEmpty() ) | ||||
5601 | { | ||||
yurchor: Trailing spaces | |||||
5602 | QClipboard *cb = QApplication::clipboard(); | ||||
5603 | if ( cb->supportsSelection() ) | ||||
5604 | { | ||||
5605 | cb->setText( text, QClipboard::Selection ); | ||||
5606 | } | ||||
5607 | | ||||
yurchor: Trailing spaces | |||||
5608 | } | ||||
5609 | return; | ||||
aacid: Why this return? | |||||
shubham: If removed, it causes crash. | |||||
Sorry but that's not a valid answer, you'll have to explain why sometimes you have to delete area and why sometimes not aacid: Sorry but that's not a valid answer, you'll have to explain why sometimes you have to delete… | |||||
5610 | } | ||||
5611 | delete area; | ||||
5612 | } | ||||
5613 | } | ||||
5614 | | ||||
5573 | void PageView::highlightSignatureFormWidget( const Okular::FormFieldSignature *form ) | 5615 | void PageView::highlightSignatureFormWidget( const Okular::FormFieldSignature *form ) | ||
5574 | { | 5616 | { | ||
5575 | QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd(); | 5617 | QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd(); | ||
5576 | for ( ; dIt != dEnd; ++dIt ) | 5618 | for ( ; dIt != dEnd; ++dIt ) | ||
5577 | { | 5619 | { | ||
5578 | foreach ( auto fw, (*dIt)->formWidgets() ) | 5620 | foreach ( auto fw, (*dIt)->formWidgets() ) | ||
5579 | { | 5621 | { | ||
5580 | if ( fw->formField() == form ) | 5622 | if ( fw->formField() == form ) | ||
Show All 17 Lines |
Trailing spaces