mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-24 00:14:06 +00:00
Add "Copy as text" feature (issue #311)
This commit is contained in:
parent
680c201b88
commit
1f5270c619
|
@ -57,6 +57,7 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
|
|||
goForwardAction( this ),
|
||||
openSearchAction( this ),
|
||||
selectCurrentArticleAction( this ),
|
||||
copyAsTextAction( this ),
|
||||
searchIsOpened( false ),
|
||||
dictionaryBarToggled( dictionaryBarToggled_ ),
|
||||
groupComboBox( groupComboBox_ )
|
||||
|
@ -133,6 +134,12 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
|
|||
connect( &selectCurrentArticleAction, SIGNAL( triggered() ),
|
||||
this, SLOT( selectCurrentArticle() ) );
|
||||
|
||||
copyAsTextAction.setShortcut( QKeySequence( "Ctrl+Shift+C" ) );
|
||||
copyAsTextAction.setText( tr( "Copy as text" ) );
|
||||
ui.definition->addAction( ©AsTextAction );
|
||||
connect( ©AsTextAction, SIGNAL( triggered() ),
|
||||
this, SLOT( copyAsText() ) );
|
||||
|
||||
ui.definition->installEventFilter( this );
|
||||
ui.searchFrame->installEventFilter( this );
|
||||
|
||||
|
@ -1395,6 +1402,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
|
|||
if ( selectedText.size() )
|
||||
{
|
||||
menu.addAction( ui.definition->pageAction( QWebPage::Copy ) );
|
||||
menu.addAction( ©AsTextAction );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1887,6 +1895,13 @@ void ArticleView::switchExpandOptionalParts()
|
|||
reload();
|
||||
}
|
||||
|
||||
void ArticleView::copyAsText()
|
||||
{
|
||||
QString text = ui.definition->selectedText();
|
||||
if( !text.isEmpty() )
|
||||
QApplication::clipboard()->setText( text );
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
|
||||
void ArticleView::readTag( const QString & from, QString & to, int & count )
|
||||
|
|
|
@ -28,7 +28,8 @@ class ArticleView: public QFrame
|
|||
Ui::ArticleView ui;
|
||||
|
||||
QAction pasteAction, articleUpAction, articleDownAction,
|
||||
goBackAction, goForwardAction, openSearchAction, selectCurrentArticleAction;
|
||||
goBackAction, goForwardAction, openSearchAction, selectCurrentArticleAction,
|
||||
copyAsTextAction;
|
||||
bool searchIsOpened;
|
||||
bool expandOptionalParts;
|
||||
QString articleToJump;
|
||||
|
@ -263,6 +264,9 @@ private slots:
|
|||
/// Handles audio player error message
|
||||
void audioPlayerError( QString const & message );
|
||||
|
||||
/// Copy current selection as plain text
|
||||
void copyAsText();
|
||||
|
||||
private:
|
||||
|
||||
/// Deduces group from the url. If there doesn't seem to be any group,
|
||||
|
|
Loading…
Reference in a new issue