Changeset View
Changeset View
Standalone View
Standalone View
ui/pageview.cpp
Show First 20 Lines • Show All 293 Lines • ▼ Show 20 Line(s) | |||||
294 | * 550 - events: mouse, keyboard, drag | 294 | * 550 - events: mouse, keyboard, drag | ||
295 | * 170 - slotRelayoutPages: set contents of the scrollview on continuous/single modes | 295 | * 170 - slotRelayoutPages: set contents of the scrollview on continuous/single modes | ||
296 | * 100 - zoom: zooming pages in different ways, keeping update the toolbar actions, etc.. | 296 | * 100 - zoom: zooming pages in different ways, keeping update the toolbar actions, etc.. | ||
297 | * other misc functions: only slotRequestVisiblePixmaps and pickItemOnPoint noticeable, | 297 | * other misc functions: only slotRequestVisiblePixmaps and pickItemOnPoint noticeable, | ||
298 | * and many insignificant stuff like this comment :-) | 298 | * and many insignificant stuff like this comment :-) | ||
299 | */ | 299 | */ | ||
300 | PageView::PageView( QWidget *parent, Okular::Document *document ) | 300 | PageView::PageView( QWidget *parent, Okular::Document *document ) | ||
301 | : QAbstractScrollArea( parent ) | 301 | : QAbstractScrollArea( parent ) | ||
302 | , Okular::View( QLatin1String( "PageView" ) ) | 302 | , Okular::View( QStringLiteral( "PageView" ) ) | ||
303 | { | 303 | { | ||
304 | // create and initialize private storage structure | 304 | // create and initialize private storage structure | ||
305 | d = new PageViewPrivate( this ); | 305 | d = new PageViewPrivate( this ); | ||
306 | d->document = document; | 306 | d->document = document; | ||
307 | d->aRotateClockwise = nullptr; | 307 | d->aRotateClockwise = nullptr; | ||
308 | d->aRotateCounterClockwise = nullptr; | 308 | d->aRotateCounterClockwise = nullptr; | ||
309 | d->aRotateOriginal = nullptr; | 309 | d->aRotateOriginal = nullptr; | ||
310 | d->aViewMode = nullptr; | 310 | d->aViewMode = nullptr; | ||
▲ Show 20 Lines • Show All 2460 Lines • ▼ Show 20 Line(s) | 2761 | { | |||
2771 | rects.append( Okular::NormalizedRect( relativeRect, item->uncroppedWidth(), item->uncroppedHeight() ) ); | 2771 | rects.append( Okular::NormalizedRect( relativeRect, item->uncroppedWidth(), item->uncroppedHeight() ) ); | ||
2772 | selectedText += okularPage->text( &rects ); | 2772 | selectedText += okularPage->text( &rects ); | ||
2773 | } | 2773 | } | ||
2774 | } | 2774 | } | ||
2775 | } | 2775 | } | ||
2776 | 2776 | | |||
2777 | // popup that ask to copy:text and copy/save:image | 2777 | // popup that ask to copy:text and copy/save:image | ||
2778 | QMenu menu( this ); | 2778 | QMenu menu( this ); | ||
2779 | menu.setObjectName("PopupMenu"); | 2779 | menu.setObjectName(QStringLiteral("PopupMenu")); | ||
2780 | QAction *textToClipboard = nullptr; | 2780 | QAction *textToClipboard = nullptr; | ||
2781 | #ifdef HAVE_SPEECH | 2781 | #ifdef HAVE_SPEECH | ||
2782 | QAction *speakText = nullptr; | 2782 | QAction *speakText = nullptr; | ||
2783 | #endif | 2783 | #endif | ||
2784 | QAction *imageToClipboard = nullptr; | 2784 | QAction *imageToClipboard = nullptr; | ||
2785 | QAction *imageToFile = nullptr; | 2785 | QAction *imageToFile = nullptr; | ||
2786 | if ( d->document->supportsSearching() && !selectedText.isEmpty() ) | 2786 | if ( d->document->supportsSearching() && !selectedText.isEmpty() ) | ||
2787 | { | 2787 | { | ||
2788 | menu.addAction( new OKMenuTitle( &menu, i18np( "Text (1 character)", "Text (%1 characters)", selectedText.length() ) ) ); | 2788 | menu.addAction( new OKMenuTitle( &menu, i18np( "Text (1 character)", "Text (%1 characters)", selectedText.length() ) ) ); | ||
2789 | textToClipboard = menu.addAction( QIcon::fromTheme(QStringLiteral("edit-copy")), i18n( "Copy to Clipboard" ) ); | 2789 | textToClipboard = menu.addAction( QIcon::fromTheme(QStringLiteral("edit-copy")), i18n( "Copy to Clipboard" ) ); | ||
2790 | textToClipboard->setObjectName("CopyTextToClipboard"); | 2790 | textToClipboard->setObjectName(QStringLiteral("CopyTextToClipboard")); | ||
2791 | bool copyAllowed = d->document->isAllowed( Okular::AllowCopy ); | 2791 | bool copyAllowed = d->document->isAllowed( Okular::AllowCopy ); | ||
2792 | if ( !copyAllowed ) | 2792 | if ( !copyAllowed ) | ||
2793 | { | 2793 | { | ||
2794 | textToClipboard->setEnabled( false ); | 2794 | textToClipboard->setEnabled( false ); | ||
2795 | textToClipboard->setText( i18n("Copy forbidden by DRM") ); | 2795 | textToClipboard->setText( i18n("Copy forbidden by DRM") ); | ||
2796 | } | 2796 | } | ||
2797 | #ifdef HAVE_SPEECH | 2797 | #ifdef HAVE_SPEECH | ||
2798 | if ( Okular::Settings::useTTS() ) | 2798 | if ( Okular::Settings::useTTS() ) | ||
▲ Show 20 Lines • Show All 290 Lines • ▼ Show 20 Line(s) | 3078 | #endif | |||
3089 | // if the right-click was over a link add "Follow This link" instead of "Go to" | 3089 | // if the right-click was over a link add "Follow This link" instead of "Go to" | ||
3090 | if (!mouseClickOverLink) | 3090 | if (!mouseClickOverLink) | ||
3091 | { | 3091 | { | ||
3092 | url = UrlUtils::getUrl( d->selectedText() ); | 3092 | url = UrlUtils::getUrl( d->selectedText() ); | ||
3093 | if ( !url.isEmpty() ) | 3093 | if ( !url.isEmpty() ) | ||
3094 | { | 3094 | { | ||
3095 | const QString squeezedText = KStringHandler::rsqueeze( url, 30 ); | 3095 | const QString squeezedText = KStringHandler::rsqueeze( url, 30 ); | ||
3096 | httpLink = menu->addAction( i18n( "Go to '%1'", squeezedText ) ); | 3096 | httpLink = menu->addAction( i18n( "Go to '%1'", squeezedText ) ); | ||
3097 | httpLink->setObjectName("GoToAction"); | 3097 | httpLink->setObjectName(QStringLiteral("GoToAction")); | ||
3098 | } | 3098 | } | ||
3099 | } | 3099 | } | ||
3100 | } | 3100 | } | ||
3101 | 3101 | | |||
3102 | if ( menu ) { | 3102 | if ( menu ) { | ||
3103 | menu->setObjectName("PopupMenu"); | 3103 | menu->setObjectName(QStringLiteral("PopupMenu")); | ||
3104 | 3104 | | |||
3105 | QAction *choice = menu->exec( e->globalPos() ); | 3105 | QAction *choice = menu->exec( e->globalPos() ); | ||
3106 | // check if the user really selected an action | 3106 | // check if the user really selected an action | ||
3107 | if ( choice ) | 3107 | if ( choice ) | ||
3108 | { | 3108 | { | ||
3109 | if ( choice == textToClipboard ) | 3109 | if ( choice == textToClipboard ) | ||
3110 | copyTextSelection(); | 3110 | copyTextSelection(); | ||
3111 | #ifdef HAVE_SPEECH | 3111 | #ifdef HAVE_SPEECH | ||
▲ Show 20 Lines • Show All 1291 Lines • ▼ Show 20 Line(s) | 4400 | { | |||
4403 | const double nY = item->absToPageY(eventPos.y()); | 4403 | const double nY = item->absToPageY(eventPos.y()); | ||
4404 | const Okular::ObjectRect * rect = item->page()->objectRect( Okular::ObjectRect::Action, nX, nY, item->uncroppedWidth(), item->uncroppedHeight() ); | 4404 | const Okular::ObjectRect * rect = item->page()->objectRect( Okular::ObjectRect::Action, nX, nY, item->uncroppedWidth(), item->uncroppedHeight() ); | ||
4405 | if ( rect ) | 4405 | if ( rect ) | ||
4406 | { | 4406 | { | ||
4407 | QMenu *menu = new QMenu(this); | 4407 | QMenu *menu = new QMenu(this); | ||
4408 | const Okular::Action * link = static_cast< const Okular::Action * >( rect->object() ); | 4408 | const Okular::Action * link = static_cast< const Okular::Action * >( rect->object() ); | ||
4409 | // creating the menu and its actions | 4409 | // creating the menu and its actions | ||
4410 | QAction * processLink = menu->addAction( i18n( "Follow This Link" ) ); | 4410 | QAction * processLink = menu->addAction( i18n( "Follow This Link" ) ); | ||
4411 | processLink->setObjectName("ProcessLinkAction"); | 4411 | processLink->setObjectName(QStringLiteral("ProcessLinkAction")); | ||
4412 | if ( link->actionType() == Okular::Action::Sound ) { | 4412 | if ( link->actionType() == Okular::Action::Sound ) { | ||
4413 | processLink->setText( i18n( "Play this Sound" ) ); | 4413 | processLink->setText( i18n( "Play this Sound" ) ); | ||
4414 | if ( Okular::AudioPlayer::instance()->state() == Okular::AudioPlayer::PlayingState ) { | 4414 | if ( Okular::AudioPlayer::instance()->state() == Okular::AudioPlayer::PlayingState ) { | ||
4415 | QAction * actStopSound = menu->addAction( i18n( "Stop Sound" ) ); | 4415 | QAction * actStopSound = menu->addAction( i18n( "Stop Sound" ) ); | ||
4416 | connect( actStopSound, &QAction::triggered, []() { | 4416 | connect( actStopSound, &QAction::triggered, []() { | ||
4417 | Okular::AudioPlayer::instance()->stopPlaybacks(); | 4417 | Okular::AudioPlayer::instance()->stopPlaybacks(); | ||
4418 | }); | 4418 | }); | ||
4419 | } | 4419 | } | ||
4420 | } | 4420 | } | ||
4421 | 4421 | | |||
4422 | 4422 | | |||
4423 | if ( dynamic_cast< const Okular::BrowseAction * >( link ) ) | 4423 | if ( dynamic_cast< const Okular::BrowseAction * >( link ) ) | ||
4424 | { | 4424 | { | ||
4425 | QAction * actCopyLinkLocation = menu->addAction( QIcon::fromTheme( QStringLiteral("edit-copy") ), i18n( "Copy Link Address" ) ); | 4425 | QAction * actCopyLinkLocation = menu->addAction( QIcon::fromTheme( QStringLiteral("edit-copy") ), i18n( "Copy Link Address" ) ); | ||
4426 | actCopyLinkLocation->setObjectName("CopyLinkLocationAction"); | 4426 | actCopyLinkLocation->setObjectName(QStringLiteral("CopyLinkLocationAction")); | ||
4427 | connect( actCopyLinkLocation, &QAction::triggered, [ link ]() { | 4427 | connect( actCopyLinkLocation, &QAction::triggered, [ link ]() { | ||
4428 | const Okular::BrowseAction * browseLink = static_cast< const Okular::BrowseAction * >( link ); | 4428 | const Okular::BrowseAction * browseLink = static_cast< const Okular::BrowseAction * >( link ); | ||
4429 | QClipboard *cb = QApplication::clipboard(); | 4429 | QClipboard *cb = QApplication::clipboard(); | ||
4430 | cb->setText( browseLink->url().toDisplayString(), QClipboard::Clipboard ); | 4430 | cb->setText( browseLink->url().toDisplayString(), QClipboard::Clipboard ); | ||
4431 | if ( cb->supportsSelection() ) | 4431 | if ( cb->supportsSelection() ) | ||
4432 | cb->setText( browseLink->url().toDisplayString(), QClipboard::Selection ); | 4432 | cb->setText( browseLink->url().toDisplayString(), QClipboard::Selection ); | ||
4433 | } ); | 4433 | } ); | ||
4434 | } | 4434 | } | ||
▲ Show 20 Lines • Show All 1146 Lines • Show Last 20 Lines |