Changeset View
Changeset View
Standalone View
Standalone View
ui/pageview.cpp
Show First 20 Lines • Show All 2788 Lines • ▼ Show 20 Line(s) | 2787 | { | |||
---|---|---|---|---|---|
2789 | textToClipboard->setText( i18n("Copy forbidden by DRM") ); | 2789 | textToClipboard->setText( i18n("Copy forbidden by DRM") ); | ||
2790 | } | 2790 | } | ||
2791 | #ifdef HAVE_SPEECH | 2791 | #ifdef HAVE_SPEECH | ||
2792 | if ( Okular::Settings::useTTS() ) | 2792 | if ( Okular::Settings::useTTS() ) | ||
2793 | speakText = menu.addAction( QIcon::fromTheme(QStringLiteral("text-speak")), i18n( "Speak Text" ) ); | 2793 | speakText = menu.addAction( QIcon::fromTheme(QStringLiteral("text-speak")), i18n( "Speak Text" ) ); | ||
2794 | #endif | 2794 | #endif | ||
2795 | if ( copyAllowed ) | 2795 | if ( copyAllowed ) | ||
2796 | { | 2796 | { | ||
2797 | addSearchWithinDocumentAction( &menu, selectedText ); | ||||
2797 | addWebShortcutsMenu( &menu, selectedText ); | 2798 | addWebShortcutsMenu( &menu, selectedText ); | ||
2798 | } | 2799 | } | ||
2799 | } | 2800 | } | ||
2800 | menu.addAction( new OKMenuTitle( &menu, i18n( "Image (%1 by %2 pixels)", selectionRect.width(), selectionRect.height() ) ) ); | 2801 | menu.addAction( new OKMenuTitle( &menu, i18n( "Image (%1 by %2 pixels)", selectionRect.width(), selectionRect.height() ) ) ); | ||
2801 | imageToClipboard = menu.addAction( QIcon::fromTheme(QStringLiteral("image-x-generic")), i18n( "Copy to Clipboard" ) ); | 2802 | imageToClipboard = menu.addAction( QIcon::fromTheme(QStringLiteral("image-x-generic")), i18n( "Copy to Clipboard" ) ); | ||
2802 | imageToFile = menu.addAction( QIcon::fromTheme(QStringLiteral("document-save")), i18n( "Save to File..." ) ); | 2803 | imageToFile = menu.addAction( QIcon::fromTheme(QStringLiteral("document-save")), i18n( "Save to File..." ) ); | ||
2803 | QAction *choice = menu.exec( e->globalPos() ); | 2804 | QAction *choice = menu.exec( e->globalPos() ); | ||
2804 | // check if the user really selected an action | 2805 | // check if the user really selected an action | ||
▲ Show 20 Lines • Show All 267 Lines • ▼ Show 20 Line(s) | |||||
3072 | #endif | 3073 | #endif | ||
3073 | if ( !d->document->isAllowed( Okular::AllowCopy ) ) | 3074 | if ( !d->document->isAllowed( Okular::AllowCopy ) ) | ||
3074 | { | 3075 | { | ||
3075 | textToClipboard->setEnabled( false ); | 3076 | textToClipboard->setEnabled( false ); | ||
3076 | textToClipboard->setText( i18n("Copy forbidden by DRM") ); | 3077 | textToClipboard->setText( i18n("Copy forbidden by DRM") ); | ||
3077 | } | 3078 | } | ||
3078 | else | 3079 | else | ||
3079 | { | 3080 | { | ||
3081 | addSearchWithinDocumentAction(menu, d->selectedText()); | ||||
3080 | addWebShortcutsMenu( menu, d->selectedText() ); | 3082 | addWebShortcutsMenu( menu, d->selectedText() ); | ||
3081 | } | 3083 | } | ||
3082 | 3084 | | |||
3083 | // if the right-click was over a link add "Follow This link" instead of "Go to" | 3085 | // if the right-click was over a link add "Follow This link" instead of "Go to" | ||
3084 | if (!mouseClickOverLink) | 3086 | if (!mouseClickOverLink) | ||
3085 | { | 3087 | { | ||
3086 | url = UrlUtils::getUrl( d->selectedText() ); | 3088 | url = UrlUtils::getUrl( d->selectedText() ); | ||
3087 | if ( !url.isEmpty() ) | 3089 | if ( !url.isEmpty() ) | ||
▲ Show 20 Lines • Show All 1275 Lines • ▼ Show 20 Line(s) | 4364 | { | |||
4363 | const QStringList searchProviders = filterData.preferredSearchProviders(); | 4365 | const QStringList searchProviders = filterData.preferredSearchProviders(); | ||
4364 | 4366 | | |||
4365 | if ( !searchProviders.isEmpty() ) | 4367 | if ( !searchProviders.isEmpty() ) | ||
4366 | { | 4368 | { | ||
4367 | QMenu *webShortcutsMenu = new QMenu( menu ); | 4369 | QMenu *webShortcutsMenu = new QMenu( menu ); | ||
4368 | webShortcutsMenu->setIcon( QIcon::fromTheme( QStringLiteral("preferences-web-browser-shortcuts") ) ); | 4370 | webShortcutsMenu->setIcon( QIcon::fromTheme( QStringLiteral("preferences-web-browser-shortcuts") ) ); | ||
4369 | 4371 | | |||
4370 | const QString squeezedText = KStringHandler::rsqueeze( searchText, 21 ); | 4372 | const QString squeezedText = KStringHandler::rsqueeze( searchText, 21 ); | ||
4371 | webShortcutsMenu->setTitle( i18n( "Search for '%1' with", squeezedText ) ); | 4373 | webShortcutsMenu->setTitle( i18n( "Search for '%1' with", squeezedText ) ); | ||
ngraham: This grammar change makes it wrong for all the other entries.
Maybe the new "Search for <text>… | |||||
I was thinking about that because even if you don't have any external provider, you should have the option to search within the document. I didn't want to change to much the existing code, my fault. I will update taking into consideration your suggestion. andisa: I was thinking about that because even if you don't have any external provider, you should have… | |||||
4372 | 4374 | | |||
4373 | QAction *action = nullptr; | 4375 | QAction *action = nullptr; | ||
4374 | 4376 | | |||
The icon should be document-preview (document-open is used for actions that open documents) ngraham: The icon should be `document-preview` (`document-open` is used for actions that open documents) | |||||
4375 | foreach( const QString &searchProvider, searchProviders ) | 4377 | foreach( const QString &searchProvider, searchProviders ) | ||
4376 | { | 4378 | { | ||
4377 | action = new QAction( searchProvider, webShortcutsMenu ); | 4379 | action = new QAction( searchProvider, webShortcutsMenu ); | ||
4378 | action->setIcon( QIcon::fromTheme( filterData.iconNameForPreferredSearchProvider( searchProvider ) ) ); | 4380 | action->setIcon( QIcon::fromTheme( filterData.iconNameForPreferredSearchProvider( searchProvider ) ) ); | ||
4379 | action->setData( filterData.queryForPreferredSearchProvider( searchProvider ) ); | 4381 | action->setData( filterData.queryForPreferredSearchProvider( searchProvider ) ); | ||
4380 | connect( action, &QAction::triggered, this, &PageView::slotHandleWebShortcutAction ); | 4382 | connect( action, &QAction::triggered, this, &PageView::slotHandleWebShortcutAction ); | ||
4381 | webShortcutsMenu->addAction( action ); | 4383 | webShortcutsMenu->addAction( action ); | ||
4382 | } | 4384 | } | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 4405 | { | |||
4438 | connect( processLink, &QAction::triggered, [this, link]() { | 4440 | connect( processLink, &QAction::triggered, [this, link]() { | ||
4439 | d->document->processAction( link ); | 4441 | d->document->processAction( link ); | ||
4440 | }); | 4442 | }); | ||
4441 | return menu; | 4443 | return menu; | ||
4442 | } | 4444 | } | ||
4443 | return nullptr; | 4445 | return nullptr; | ||
4444 | } | 4446 | } | ||
4445 | 4447 | | |||
4448 | void PageView::addSearchWithinDocumentAction(QMenu *menu, const QString &searchText) | ||||
4449 | { | ||||
4450 | const QString squeezedText = KStringHandler::rsqueeze( searchText, 21 ); | ||||
4451 | QAction *action = new QAction(i18n("Search for '%1' in open document", squeezedText), menu); | ||||
4452 | action->setIcon( QIcon::fromTheme( QStringLiteral("document-preview") ) ); | ||||
4453 | connect(action, &QAction::triggered, [this, searchText]{Q_EMIT triggerSearch(searchText);}); | ||||
4454 | menu->addAction( action ); | ||||
4455 | } | ||||
4456 | | ||||
4446 | //BEGIN private SLOTS | 4457 | //BEGIN private SLOTS | ||
4447 | void PageView::slotRelayoutPages() | 4458 | void PageView::slotRelayoutPages() | ||
4448 | // called by: notifySetup, viewportResizeEvent, slotViewMode, slotContinuousToggled, updateZoom | 4459 | // called by: notifySetup, viewportResizeEvent, slotViewMode, slotContinuousToggled, updateZoom | ||
4449 | { | 4460 | { | ||
4450 | // set an empty container if we have no pages | 4461 | // set an empty container if we have no pages | ||
4451 | const int pageCount = d->items.count(); | 4462 | const int pageCount = d->items.count(); | ||
4452 | if ( pageCount < 1 ) | 4463 | if ( pageCount < 1 ) | ||
4453 | { | 4464 | { | ||
▲ Show 20 Lines • Show All 1129 Lines • Show Last 20 Lines |
This grammar change makes it wrong for all the other entries.
Maybe the new "Search for <text> in open document" menu item should be in the base level of the context menu, and not inside the sub-menu.