New user registration is currently disabled due to spam abuse / Регистрация новых пользователей в настоящее время приостановлена из-за злоупотреблений спаммерами

send article title to input line

General discussion

send article title to input line

Postby hukarere » Thu Sep 05, 2013 2:03 pm

Hi All,

When browsing an article, I often need to look up the same article in another dictionary group (e. g. switch from bilingual to monolingual dictionaries). However, when switching to another group, GoldenDict will display an article for the word specified in the input line, which will be different from the current article title if the article was selected from the word list rather than typed manually in the input line. For example, if I type 'ab' in the input line, then select 'abacus' from the word list, then switch to another dictionary group, GoldenDict will try to display the article for 'ab' instead of abacus, which will result in the 'word not found' error. To prevent this behaviour and make GoldenDict still display 'abacus' after switching the group, I usually have to:
(1) select the article title in the article window
(2) invoke context menu and select "send 'word' to input line".
This is rather annoying, so to speed up things a little bit I implemented a trivial patch that allows to do
(1) + (2) above as one action: either pressing Ctrl-I or selecting a new command, 'Send title to input line', from the context menu.

In case someone find this functionality useful, here is the trivial patch:
Code: Select all
diff --git a/articleview.cc b/articleview.cc
index 9cc7f8a..58311b9 100644
--- a/articleview.cc
+++ b/articleview.cc
@@ -68,6 +68,7 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
   goBackAction( this ),
   goForwardAction( this ),
   openSearchAction( this ),
+  sendCurrentArticleTitleToInputLineAction( this ),
   selectCurrentArticleAction( this ),
   copyAsTextAction( this ),
   inspectAction( this ),
@@ -149,6 +150,12 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm,
   connect( &selectCurrentArticleAction, SIGNAL( triggered() ),
            this, SLOT( selectCurrentArticle() ) );
 
+  sendCurrentArticleTitleToInputLineAction.setShortcut( QKeySequence( "Ctrl+I" ));
+  sendCurrentArticleTitleToInputLineAction.setText( tr( "Send title to input line" ) );
+  ui.definition->addAction( &sendCurrentArticleTitleToInputLineAction );
+  connect( &sendCurrentArticleTitleToInputLineAction, SIGNAL( triggered() ),
+           this, SLOT( sendCurrentArticleTitleToInputLine() ) );
+
   copyAsTextAction.setShortcut( QKeySequence( "Ctrl+Shift+C" ) );
   copyAsTextAction.setText( tr( "Copy as text" ) );
   ui.definition->addAction( &copyAsTextAction );
@@ -461,6 +468,12 @@ void ArticleView::selectCurrentArticle()
         QString( "gdSelectArticle( '%1' );" ).arg( getActiveArticleId() ) );
 }
 
+/* grg */
+void ArticleView::sendCurrentArticleTitleToInputLine()
+{
+  sendWordToInputLine(ui.definition->title());
+}
+
 bool ArticleView::isFramedArticle( QString const & ca )
 {
   if ( ca.isEmpty() )
@@ -1394,6 +1407,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
   }
 
   menu.addSeparator();
+  menu.addAction( &sendCurrentArticleTitleToInputLineAction );
   menu.addAction( &inspectAction );
 
   if ( !menu.isEmpty() )
diff --git a/articleview.hh b/articleview.hh
index bdaea3e..83aeee4 100644
--- a/articleview.hh
+++ b/articleview.hh
@@ -30,7 +30,7 @@ class ArticleView: public QFrame
   Ui::ArticleView ui;
 
   QAction pasteAction, articleUpAction, articleDownAction,
-          goBackAction, goForwardAction, openSearchAction, selectCurrentArticleAction,
+          goBackAction, goForwardAction, openSearchAction, sendCurrentArticleTitleToInputLineAction, selectCurrentArticleAction,
           copyAsTextAction, inspectAction;
   bool searchIsOpened;
   bool expandOptionalParts;
@@ -228,6 +228,9 @@ public slots:
   /// Selects an entire text of the current article
   void selectCurrentArticle();
 
+  /// Sends the title of the current article to the input line
+  void sendCurrentArticleTitleToInputLine();
+
 private slots:
 
   void loadFinished( bool ok );


This is just a workaround. Ideally, I would prefer to see GoldenDict select current article title automatically when switching groups, which would eliminate the need to press Ctrl-I or select the 'Send title to input line' command. This would be somewhat more dificult to implement, though, so I came up with this workaround.
hukarere
 
Posts: 2
Joined: Thu Sep 05, 2013 1:38 pm

Re: send article title to input line

Postby Tvangeste » Thu Sep 05, 2013 2:14 pm

Thank you, this is indeed genuine issue and I agree that it would be nice to improve the current situation.

Would you mind filing it in our Issue tracker, so that we, um, track it and won't forget?

https://github.com/goldendict/goldendict/issues
Tvangeste
 
Posts: 893
Joined: Thu Jun 02, 2011 11:42 am

Re: send article title to input line

Postby hukarere » Thu Sep 05, 2013 2:52 pm

Hello,

Tvangeste wrote:Thank you, this is indeed genuine issue and I agree that it would be nice to improve the current situation.

Would you mind filing it in our Issue tracker, so that we, um, track it and won't forget?

https://github.com/goldendict/goldendict/issues


Done. I added it as a new feature request 'Remember current article title after switching groups':
https://github.com/goldendict/goldendict/issues/398
hukarere
 
Posts: 2
Joined: Thu Sep 05, 2013 1:38 pm


Return to General

Who is online

Users browsing this forum: No registered users and 71 guests