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

some patches and ideas

General discussion

some patches and ideas

Postby dmdmdm » Tue Dec 22, 2009 8:49 pm

hello,
please consider adding the ability to configure the size of the list in the wordfinder (to show more or less results than the default, or even all the entries which partially-match the term) and the size of the font of the articles (which is now hardcoded in article-style.css)
here are some patches (to 0.9 source) to support hebrew better, and to fix some problems with the scan popup:
show the article in RTL mode if the target language is hebrew:
Code: Select all
diff -u ./bgl.cc ../bgl.cc
--- ./bgl.cc   2009-05-07 20:14:56.000000000 +0300
+++ ../bgl.cc   2009-12-22 22:27:11.796875000 +0200
@@ -645,16 +645,22 @@
       result += "<h3>";
       result += postfixToSuperscript( i->second.first );
       result += "</h3>";
-      result += i->second.second;
+      if (dict.idxHeader.langTo==25960)
+        result += "<div style=\"text-align: right;\"><span dir=rtl>" + i->second.second + "</span></div>";
+      else
+        result +=  i->second.second ;
       result += cleaner;
   }
-

   for( i = alternateArticles.begin(); i != alternateArticles.end(); ++i )
   {
       result += "<h3>";
       result += postfixToSuperscript( i->second.first );
       result += "</h3>";
-      result += i->second.second;
+      if (dict.idxHeader.langTo==25960)
+        result += "<div style=\"text-align: right;\"><span dir=rtl>" + i->second.second + "</span></div>";
+      else
+        result +=  i->second.second ;
       result += cleaner;
   }
   // Do some cleanups in the text
support use of displayedHeadword alternate term, and hebrew "roots" (which are identified by 0x1A)
Code: Select all
diff -u ./bgl_babylon.cc ../bgl_babylon.cc
--- ./bgl_babylon.cc   2009-05-07 14:59:58.000000000 +0300
+++ ../bgl_babylon.cc   2009-12-22 22:20:59.390625000 +0200
@@ -22,7 +22,7 @@
  * program. */
 
 #include "bgl_babylon.hh"
-
+#include <algorithm>
 #include<stdlib.h>
 #include<string.h>
 #include<stdio.h>
@@ -288,6 +288,7 @@
   std::string temp;
   std::vector<std::string> alternates;
   std::string alternate;
+  std::string root;
 
   while( readBlock( block ) )
   {
@@ -316,6 +317,7 @@
         alternate.clear();
         headword.clear();
         displayedHeadword.clear();
+        root.clear();
         definition.clear();
         temp.clear();
         pos = 0;
@@ -348,6 +350,7 @@
             // Something
             pos += 2;
             ++a;
+            definition += " ";
           }
           else if ( (unsigned char)block.data[pos] >= 0x40 &&
                     len - a >= 2 &&
@@ -370,7 +373,7 @@
           else if ( (unsigned char)block.data[pos] == 0x18 )
           {
             // Displayed headword
-            unsigned length = (unsigned char)block.data[ pos + 1 ];
+              unsigned length = (unsigned char)block.data[ pos + 1 ];
 
             if ( length > len - a - 2 )
             {
@@ -467,15 +470,30 @@
               //break;
             } else if (block.data[pos] == 0x14) {
               pos++;
+            } else if ((unsigned char)block.data[pos] == 0x1A){
+                unsigned length = (unsigned char)block.data[ pos + 1 ];
+                if (length <= 10){// 0x1A identifies two different data types.
+                                  // data about the Hebrew root should be shorter then
+                                  // 10 bytes, and in the other data type the byte
+                          // after 0x1A is > 10 (at least it is in Bybylon's
+                          // Hebrew dictionaries).   
+                    root = std::string( block.data + pos + 2, length );
+                    std::reverse(root.begin(),root.end());
+                    definition += " (" + root + ")";
+                    pos += length + 2;
+                    a += length + 1;
+               }
+                else
+                    pos++;
             } else {
-              definition += block.data[pos++];
+                definition += block.data[pos++];
             }
           }else definition += block.data[pos++];
         }
         convertToUtf8( definition, TARGET_CHARSET );
 
         if ( displayedHeadword.size() )
-          convertToUtf8( displayedHeadword, TARGET_CHARSET );
+          convertToUtf8( displayedHeadword, SOURCE_CHARSET );
 
         // Alternate forms
         while( pos != block.length )
@@ -488,9 +506,14 @@
           alternate.clear();
         }
 
+        if (headword != displayedHeadword){
+                alternates.push_back(displayedHeadword);
+        }
         entry.headword = headword;
+
         entry.displayedHeadword = displayedHeadword;
         entry.definition = definition;
+
         entry.alternates = alternates;
 
         if( block.length ) free( block.data );
show the terms in the wordfinder in RTL if it's needed
Code: Select all
diff -u ./mainwindow.cc ../mainwindow.cc
--- ./mainwindow.cc   2009-05-24 22:51:46.000000000 +0300
+++ ../mainwindow.cc   2009-12-15 23:24:31.640625000 +0200
@@ -836,6 +836,10 @@
         i->setFont( f );
       }
     }
+    if (i->text().at(0).direction() == QChar::DirR)
+        i->setTextAlignment(Qt::AlignRight);
+    if (i->text().at(0).direction() == QChar::DirL)
+        i->setTextAlignment(Qt::AlignLeft);
   }
 
   while ( ui.wordList->count() > (int) results.size() )
display the scan-popup as frameless-onTop-Qt::Tool instead of Popup - solves some problems in Windows
Code: Select all
diff -u ./scanpopup.cc ../scanpopup.cc
--- ./scanpopup.cc   2009-05-18 22:01:50.000000000 +0300
+++ ../scanpopup.cc   2009-12-22 22:23:51.421875000 +0200
@@ -47,7 +47,7 @@
   ui.groupList->fill( groups );
   ui.groupList->setCurrentGroup( cfg.lastPopupGroupId );
 
-  setWindowFlags( Qt::Popup );
+  setWindowFlags( Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
 
   if ( cfg.lastPopupSize.isValid() )
     resize( cfg.lastPopupSize );
@@ -55,7 +55,7 @@
   #ifdef Q_OS_WIN32
   // On Windows, leaveEvent() doesn't seem to work with popups and we're trying
   // to emulate it.
-  setMouseTracking( true );
+  //setMouseTracking( true );
   #endif
 
   #if 0 // Experimental code to give window a non-rectangular shape (i.e.
@@ -216,8 +216,8 @@
   /// Too large strings make window expand which is probably not what user
   /// wants
   ui.word->setText( elideInputWord() );
-
-  if ( !isVisible() )

+  if ( !(isVisible() && !((windowFlags()^Qt::Window) & Qt::Popup)) )
   {
     // Decide where should the window land
     
@@ -252,9 +252,9 @@
       y = desktop.y() + ( desktop.height() - windowSize.height() ) / 2;
       
     move( x, y );
-
+   
     show();
-
+   
     mouseEnteredOnce = false; // Windows-only
 
     // This produced some funky mouse grip-related bugs so we commented it out
@@ -318,30 +318,7 @@
 
     move( pos() + delta );
   }
-  #ifdef Q_OS_WIN32
-  else
-  if ( !ui.pinButton->isChecked() )
-  {
-    if ( !mouseEnteredOnce )
-    {
-      // We're waiting for mouse to enter window
-      if ( geometry().contains( event->globalPos() ) )
-      {
-        mouseEnteredOnce = true;
-        hideTimer.stop();
-      }
-    }
-    else
-    {
-      // We're waiting for mouse to leave window
-      if ( !geometry().contains( event->globalPos() ) )
-      {
-        mouseEnteredOnce = false;
-        hideTimer.start();
-      }
-    }
-  }
-  #endif

 
   QDialog::mouseMoveEvent( event );
 }
@@ -423,7 +400,7 @@
 
   QMenu menu( this );
 
-  unsigned total = results.size() < 20 ? results.size() : 20;
+  unsigned total = results.size() < 40 ? results.size() : 40;
 
   for( unsigned x = 0; x < total; ++x )
   {
@@ -459,7 +436,7 @@
     hideTimer.stop();
   }
   else
-    setWindowFlags( Qt::Popup );
+      setWindowFlags( Qt::Tool | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
 
   show();
 }
show more results in the wordFinder
Code: Select all
diff -u ./wordfinder.cc ../wordfinder.cc
--- ./wordfinder.cc   2009-05-06 18:39:08.000000000 +0300
+++ ../wordfinder.cc   2009-11-29 23:59:32.765625000 +0200
@@ -109,8 +109,8 @@
     {
       sptr< Dictionary::WordSearchRequest > sr =
         ( searchType == PrefixMatch ) ?
-          (*inputDicts)[ x ]->prefixMatch( allWordWritings[ y ], 40 ) :
-          (*inputDicts)[ x ]->stemmedMatch( allWordWritings[ y ], 3, 3, 30 );
+          (*inputDicts)[ x ]->prefixMatch( allWordWritings[ y ], 400 ) :
+          (*inputDicts)[ x ]->stemmedMatch( allWordWritings[ y ], 3, 3, 300 );
   
       connect( sr.get(), SIGNAL( finished() ),
                this, SLOT( requestFinished() ), Qt::QueuedConnection );
@@ -404,7 +404,7 @@
       
       resultsArray.sort( SortByRankAndLength() );
 
-      maxSearchResults = 15;
+      //maxSearchResults = 15;
     }
   }
 
dmdmdm
 
Posts: 6
Joined: Sun Nov 08, 2009 5:53 am

Re: some patches and ideas

Postby ikm » Sun Dec 27, 2009 12:43 pm

Thanks, great patches. Applied all but the last one (this should be configurable rather than arbitrarily large), all changes are in Git.
ikm
Автор GoldenDict
 
Posts: 1592
Joined: Wed Feb 04, 2009 10:40 am

Re: some patches and ideas

Postby dmdmdm » Sun Dec 27, 2009 3:08 pm

Thanks. Please notice that i tested the "roots" patch only on Babylon's Hebrew-English and English-Hebrew dictionaries and Hebrew and English thesauruses, so it may need more testing (or restriction to these dictionaries only)
dmdmdm
 
Posts: 6
Joined: Sun Nov 08, 2009 5:53 am

Re: some patches and ideas

Postby nit_ar » Sun Dec 27, 2009 6:44 pm

Hello dmdmdm, ikm

Thanks for your work.

Are these patches suppose to solve the problems with displaying RTL languages (such as Hebrew) in scan-popup ?
(reported in viewtopic.php?f=6&t=659)

If so, when do you think a new windows binary will be available ?

nit_ar
nit_ar
 
Posts: 17
Joined: Sat Apr 25, 2009 3:30 pm

Re: some patches and ideas

Postby dmdmdm » Sun Dec 27, 2009 7:57 pm

Hi nit_ar,
It shows the terms with ">>" corretly and shows the text in RTL mode if the target language is hebrew - but only for babylon dictionaries (because the HTML output for display in the window is generated by the specific backend of the dictionary).
dmdmdm
 
Posts: 6
Joined: Sun Nov 08, 2009 5:53 am

Re: some patches and ideas

Postby nit_ar » Mon Dec 28, 2009 6:23 am

Hi dmdmdm,

For English to Hebrew translation, everything works fine for me, including scans and captures from screen.

The problem I have reported is for the case when translating from Hebrew to English - the RTL "captured" text is displayed as LTR and probably taken as such as a source since no translation is found for the swapped word.
nit_ar
 
Posts: 17
Joined: Sat Apr 25, 2009 3:30 pm

Re: some patches and ideas

Postby shula » Wed Jan 13, 2010 6:16 am

interestingly, the results from Even-Shushan (אבן שושן) dictionary (by Babylon) are correctly aligned, but other dictionaries aren't. see attached image
Attachments
gd-rtl-issue.PNG
gd-rtl-issue.PNG (25.22 KiB) Viewed 17895 times
shula
 
Posts: 14
Joined: Wed Jan 13, 2010 5:40 am

Re: some patches and ideas

Postby ikm » Wed Jan 13, 2010 10:45 am

Are those "other" dictionaries in Babylon format, too?
ikm
Автор GoldenDict
 
Posts: 1592
Joined: Wed Feb 04, 2009 10:40 am

Re: some patches and ideas

Postby shula » Wed Jan 13, 2010 11:05 am

ikm wrote:Are those "other" dictionaries in Babylon format, too?


all my dictionaries are in babylon-format.
shula
 
Posts: 14
Joined: Wed Jan 13, 2010 5:40 am

Re: some patches and ideas

Postby shula » Wed Jan 13, 2010 8:17 pm

almost everything is sorted out OK in the nightly builds (GoldenDict_02_01_2010_23_26.zip)

there are 3 very minor issues (with references to the attached screenshot):

1. sometimes i see "strange encoding" in the definition. i looks like a Latin-1 encoding whereas a CP1255 should be used. (#1)

2. this is the fixed requested by DMDMDMD, and it works! thanks! (#2)

3. the hebrew term is still left-aligned, LTR direction (#3)

4. if a term is in hebrew, and the content is too long, the the left pane need to be scrolled horizontally, or resized by the user. (#4)
(The reason behind it is that if the left pane contains LTR terms, it SHOULD display the list from left-to-right - most significant letters of words are on left side, but in RTL languages, only the end of the terms are displayed, hence the need to scroll or resize.
It's not a big deal! since all i have to do is resize, and GD remembers the settings)

5. there's a backslash before quotation marks (#5) (there should not be)
OTOH, there's no such backslash (which is OK) on the definition (right side).
again, doesn't seem a big deal to me.


a bit of fun:
אבא שלך לא זגג ואתה לא עשוי מזכוכית :-) i didn't invent it - it is in the dictionary :)))
shula
 
Posts: 14
Joined: Wed Jan 13, 2010 5:40 am

Next

Return to General

Who is online

Users browsing this forum: No registered users and 4 guests