Make optional the space character hack used to fix Tamil text display inside anchors: the space is sometimes a problem with cut & paste

This commit is contained in:
Jean-Francois Dockes 2019-10-02 08:53:50 +02:00
parent 352dba0c77
commit b64751e138
4 changed files with 1110 additions and 1066 deletions

View File

@ -22,6 +22,7 @@
#include <QString>
#include <QStringList>
#include <QSettings>
#include "preview_plaintorich.h"
@ -43,6 +44,8 @@ void PlainToRichQtPreview::clear()
m_lastanchor = 0;
m_groupanchors.clear();
m_groupcuranchors.clear();
QSettings settings("Recoll.org", "recoll");
m_spacehack = settings.value("anchorSpcHack", 0).toBool();
}
bool PlainToRichQtPreview::haveAnchors()
@ -82,9 +85,12 @@ string PlainToRichQtPreview::startMatch(unsigned int grpidx)
// Tamil text (qt bug?). Just inserting a space character after
// the opening <a tag, before the text, clears the problem, reason
// unknown. We also inverted the <span and <a tags to avoid
// highlighting the spurious space.
// highlighting the spurious space. The space hack only work in a
// <pre> section. Also: having <a name=xxx></a> before the match
// term causes the same problem (so not a possible fix).
string hackspace = m_spacehack? " " : "";
string startmarker{
"<a name='" + termAnchorName(m_lastanchor) + "'> " +
"<a name='" + termAnchorName(m_lastanchor) + "'>" + hackspace +
"<span style='" + qs2utf8s(prefs.qtermstyle) + "'>"
};
return startmarker;

View File

@ -50,6 +50,7 @@ private:
// in the query (the map key is and index into HighlightData.groups).
std::map<unsigned int, std::vector<int> > m_groupanchors;
std::map<unsigned int, unsigned int> m_groupcuranchors;
bool m_spacehack{false};
};
/* A thread to convert to rich text (mark search terms) */

File diff suppressed because it is too large Load Diff

View File

@ -42,6 +42,7 @@
#include <qlist.h>
#include <QTimer>
#include <QListWidget>
#include <QSettings>
#include "recoll.h"
#include "guiutils.h"
@ -103,6 +104,10 @@ void UIPrefsDialog::init()
// Update dialog state from stored prefs
void UIPrefsDialog::setFromPrefs()
{
// Most values are stored in the prefs struct. Some rarely used
// ones go directly through the settings
QSettings settings("Recoll.org", "recoll");
// Entries per result page spinbox
pageLenSB->setValue(prefs.respagesize);
collapseDupsCB->setChecked(prefs.collapseDuplicates);
@ -144,6 +149,7 @@ void UIPrefsDialog::setFromPrefs()
closeToTrayCB->setEnabled(showTrayIconCB->checkState());
closeToTrayCB->setChecked(prefs.closeToTray);
showTempFileWarningCB->setChecked(prefs.showTempFileWarning == -1);
anchorTamilHackCB->setChecked(settings.value("anchorSpcHack", 0).toBool());
previewHtmlCB->setChecked(prefs.previewHtml);
previewActiveLinksCB->setChecked(prefs.previewActiveLinks);
switch (prefs.previewPlainPre) {
@ -262,6 +268,9 @@ void UIPrefsDialog::setupReslistFontPB()
void UIPrefsDialog::accept()
{
// Most values are stored in the prefs struct. Some rarely used
// ones go directly through the settings
QSettings settings("Recoll.org", "recoll");
prefs.noBeeps = noBeepsCB->isChecked();
prefs.ssearchNoComplete = ssNoCompleteCB->isChecked();
prefs.ssearchStartOnComplete = ssSearchOnCompleteCB->isChecked();
@ -330,6 +339,7 @@ void UIPrefsDialog::accept()
prefs.closeToTray = closeToTrayCB->isChecked();
prefs.showTempFileWarning = showTempFileWarningCB->isChecked() ?
-1 : 1024;
settings.setValue("anchorSpcHack", anchorTamilHackCB->isChecked());
prefs.previewHtml = previewHtmlCB->isChecked();
prefs.previewActiveLinks = previewActiveLinksCB->isChecked();