some patches and ideas
Posted: 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:
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
- 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 );
- 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() )
- 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();
}
- 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;
}
}