Fixed #164: Add an option to copy the entire article (Ctrl+A)

This commit is contained in:
Tvangeste 2013-01-18 14:22:24 +01:00
parent 160db20a04
commit 3784ac18d7
2 changed files with 16 additions and 5 deletions

View file

@ -106,6 +106,11 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
ui.definition->pageAction( QWebPage::Copy )->setShortcut( QKeySequence::Copy );
ui.definition->addAction( ui.definition->pageAction( QWebPage::Copy ) );
QAction * selectAll = ui.definition->pageAction( QWebPage::SelectAll );
selectAll->setShortcut( QKeySequence::SelectAll );
selectAll->setShortcutContext( Qt::WidgetWithChildrenShortcut );
ui.definition->addAction( selectAll );
ui.definition->setContextMenuPolicy( Qt::CustomContextMenu );
ui.definition->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
@ -1109,10 +1114,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
}
}
if ( selectedText.size() )
menu.addAction( ui.definition->pageAction( QWebPage::Copy ) );
if( menu.isEmpty() && !cfg.preferences.storeHistory)
if( selectedText.isEmpty() && !cfg.preferences.storeHistory)
{
addHeaderToHistoryAction = new QAction( tr( "&Add \"%1\" to history" ).
arg( ui.definition->title() ),
@ -1120,6 +1122,15 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
menu.addAction( addHeaderToHistoryAction );
}
if ( selectedText.size() )
{
menu.addAction( ui.definition->pageAction( QWebPage::Copy ) );
}
else
{
menu.addAction( ui.definition->pageAction( QWebPage::SelectAll ) );
}
map< QAction *, QString > tableOfContents;
// Add table of contents

View file

@ -192,7 +192,7 @@ void HistoryPaneWidget::onSelectionChanged( QItemSelection const & selection )
return;
itemSelectionChanged = true;
emitHistoryItemRequested( selection.front().bottomRight() );
emitHistoryItemRequested( selection.front().topLeft() );
}
void HistoryPaneWidget::onItemClicked( QModelIndex const & idx )