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