add option to have clickable links inside the preview windows

This commit is contained in:
Jean-Francois Dockes 2018-04-16 10:47:52 +02:00
parent 2be261e00b
commit 2176d81e60
10 changed files with 166 additions and 148 deletions

View File

@ -2834,17 +2834,23 @@
version instead. </para>
</listitem>
<listitem><para><guilabel>Plain text to HTML line style</guilabel>:
when displaying plain text inside the preview window, &RCL;
tries to preserve some of the original text line breaks and
indentation. It can either use PRE HTML tags, which will
well preserve the indentation but will force horizontal
scrolling for long lines, or use BR tags to break at the
original line breaks, which will let the editor introduce
other line breaks according to the window width, but will
lose some of the original indentation. The third option has
been available in recent releases and is probably now the best
one: use PRE tags with line wrapping.</para>
<listitem><para><guilabel>Activate links in
preview</guilabel> if set, Recoll will turn HTTP links found
inside plain text into proper HTML anchors, and clicking a
link inside a preview window will start the default browser
on the link target.</para> </listitem>
<listitem><para><guilabel>Plain text to HTML line
style</guilabel>: when displaying plain text inside the
preview window, &RCL; tries to preserve some of the original
text line breaks and indentation. It can either use PRE HTML
tags, which will well preserve the indentation but will force
horizontal scrolling for long lines, or use BR tags to break
at the original line breaks, which will let the editor
introduce other line breaks according to the window width,
but will lose some of the original indentation. The third
option has been available in recent releases and is probably
now the best one: use PRE tags with line wrapping.</para>
</listitem>
<listitem><para><guilabel>Choose editor

View File

@ -88,6 +88,8 @@ void rwSettings(bool writing)
SETTING_RW(prefs.startWithAdvSearchOpen,
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
SETTING_RW(prefs.previewHtml, "/Recoll/prefs/previewHtml", Bool, true);
SETTING_RW(prefs.previewActiveLinks,
"/Recoll/prefs/previewActiveLinks", Bool, false);
QString advSearchClauses;
const int maxclauselistsize = 20;

View File

@ -90,6 +90,7 @@ class PrefsPack {
bool startWithAdvSearchOpen;
// Try to display html if it exists in the internfile stack.
bool previewHtml;
bool previewActiveLinks;
// Use <pre> tag to display highlighted text/plain inside html (else
// we use <br> at end of lines, which lets textedit wrap lines).
enum PlainPre {PP_BR, PP_PRE, PP_PREWRAP};

View File

@ -59,6 +59,7 @@
#include "rclhelp.h"
#include "preview_load.h"
#include "preview_plaintorich.h"
#include "rclmain_w.h"
static const QKeySequence closeKS(Qt::Key_Escape);
static const QKeySequence nextDocInTabKS(Qt::ShiftModifier+Qt::Key_Down);
@ -163,14 +164,10 @@ void Preview::init()
connect(new QShortcut(printTabKS, this), SIGNAL (activated()),
this, SIGNAL (printCurrentPreviewRequest()));
m_dynSearchActive = false;
m_canBeep = true;
if (prefs.pvwidth > 100) {
resize(prefs.pvwidth, prefs.pvheight);
}
m_loading = false;
currentChanged(pvTab->currentIndex());
m_justCreated = true;
}
void Preview::emitShowNext()
@ -195,7 +192,7 @@ void Preview::emitShowPrev()
void Preview::closeEvent(QCloseEvent *e)
{
LOGDEB("Preview::closeEvent. m_loading " << (m_loading) << "\n" );
LOGDEB("Preview::closeEvent. m_loading " << m_loading << "\n");
if (m_loading) {
CancelCheck::instance().setCancel();
e->ignore();
@ -226,10 +223,12 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
{
if (event->type() != QEvent::KeyPress) {
#if 0
LOGDEB("Preview::eventFilter(): " << (eventTypeToStr(event->type())) << "\n" );
LOGDEB("Preview::eventFilter(): " << eventTypeToStr(event->type()) <<
"\n");
if (event->type() == QEvent::MouseButtonRelease) {
QMouseEvent *mev = (QMouseEvent *)event;
LOGDEB("Mouse: GlobalY " << (mev->globalY()) << " y " << (mev->y()) << "\n" );
LOGDEB("Mouse: GlobalY " << mev->globalY() << " y " << mev->y() <<
"\n");
}
#endif
return false;
@ -240,7 +239,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
if (m_dynSearchActive) {
if (keyEvent->key() == Qt::Key_F3) {
LOGDEB2("Preview::eventFilter: got F3\n" );
LOGDEB2("Preview::eventFilter: got F3\n");
doSearch(searchTextCMB->currentText(), true,
(keyEvent->modifiers() & Qt::ShiftModifier) != 0);
return true;
@ -253,18 +252,18 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
if (keyEvent->key() == Qt::Key_Slash ||
(keyEvent->key() == Qt::Key_F &&
(keyEvent->modifiers() & Qt::ControlModifier))) {
LOGDEB2("Preview::eventFilter: got / or C-F\n" );
LOGDEB2("Preview::eventFilter: got / or C-F\n");
searchTextCMB->setFocus();
m_dynSearchActive = true;
return true;
} else if (keyEvent->key() == Qt::Key_Space) {
LOGDEB2("Preview::eventFilter: got Space\n" );
LOGDEB2("Preview::eventFilter: got Space\n");
int value = edit->verticalScrollBar()->value();
value += edit->verticalScrollBar()->pageStep();
edit->verticalScrollBar()->setValue(value);
return true;
} else if (keyEvent->key() == Qt::Key_Backspace) {
LOGDEB2("Preview::eventFilter: got Backspace\n" );
LOGDEB2("Preview::eventFilter: got Backspace\n");
int value = edit->verticalScrollBar()->value();
value -= edit->verticalScrollBar()->pageStep();
edit->verticalScrollBar()->setValue(value);
@ -278,7 +277,7 @@ bool Preview::eventFilter(QObject *target, QEvent *event)
void Preview::searchTextChanged(const QString & text)
{
LOGDEB1("Search line text changed. text: '" << ((const char *)text.toUtf8()) << "'\n" );
LOGDEB1("Search line text changed. text: '" << qs2utf8s(text) << "'\n");
m_searchTextFromIndex = -1;
if (text.isEmpty()) {
m_dynSearchActive = false;
@ -292,13 +291,13 @@ void Preview::searchTextChanged(const QString & text)
void Preview::searchTextFromIndex(int idx)
{
LOGDEB1("search line from index " << (idx) << "\n" );
LOGDEB1("search line from index " << idx << "\n");
m_searchTextFromIndex = idx;
}
PreviewTextEdit *Preview::currentEditor()
{
LOGDEB2("Preview::currentEditor()\n" );
LOGDEB2("Preview::currentEditor()\n");
QWidget *tw = pvTab->currentWidget();
PreviewTextEdit *edit = 0;
if (tw) {
@ -323,7 +322,9 @@ void Preview::emitSaveDocToFile()
void Preview::doSearch(const QString &_text, bool next, bool reverse,
bool wordOnly)
{
LOGDEB("Preview::doSearch: text [" << ((const char *)_text.toUtf8()) << "] idx " << (m_searchTextFromIndex) << " next " << (int(next)) << " rev " << (int(reverse)) << " word " << (int(wordOnly)) << "\n" );
LOGDEB("Preview::doSearch: text [" << qs2utf8s(_text) << "] idx " <<
m_searchTextFromIndex << " next " << next << " rev " << reverse <<
" word " << wordOnly << "\n");
QString text = _text;
bool matchCase = matchCheck->isChecked();
@ -335,7 +336,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
if (text.isEmpty() || m_searchTextFromIndex != -1) {
if (!edit->m_plaintorich->haveAnchors()) {
LOGDEB("NO ANCHORS\n" );
LOGDEB("NO ANCHORS\n");
return;
}
// The combobox indices are equal to the search ugroup indices
@ -346,7 +347,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
edit->m_plaintorich->nextAnchorNum(m_searchTextFromIndex);
}
QString aname = edit->m_plaintorich->curAnchorName();
LOGDEB("Calling scrollToAnchor(" << ((const char *)aname.toUtf8()) << ")\n" );
LOGDEB("Calling scrollToAnchor(" << qs2utf8s(aname) << ")\n");
edit->scrollToAnchor(aname);
// Position the cursor approximately at the anchor (top of
// viewport) so that searches start from here
@ -366,7 +367,7 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
edit->setTextCursor(cursor);
}
Chrono chron;
LOGDEB("Preview::doSearch: first find call\n" );
LOGDEB("Preview::doSearch: first find call\n");
QTextDocument::FindFlags flags = 0;
if (reverse)
flags |= QTextDocument::FindBackward;
@ -375,19 +376,21 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
if (matchCase)
flags |= QTextDocument::FindCaseSensitively;
bool found = edit->find(text, flags);
LOGDEB("Preview::doSearch: first find call return: found " << (found) << " " << (chron.secs()) << " S\n" );
LOGDEB("Preview::doSearch: first find call return: found " << found <<
" " << chron.secs() << " S\n");
// If not found, try to wrap around.
if (!found) {
LOGDEB("Preview::doSearch: wrapping around\n" );
LOGDEB("Preview::doSearch: wrapping around\n");
if (reverse) {
edit->moveCursor (QTextCursor::End);
} else {
edit->moveCursor (QTextCursor::Start);
}
LOGDEB("Preview::doSearch: 2nd find call\n" );
LOGDEB("Preview::doSearch: 2nd find call\n");
chron.restart();
found = edit->find(text, flags);
LOGDEB("Preview::doSearch: 2nd find call return found " << (found) << " " << (chron.secs()) << " S\n" );
LOGDEB("Preview::doSearch: 2nd find call return found " << found <<
" " << chron.secs() << " S\n");
}
if (found) {
@ -397,37 +400,37 @@ void Preview::doSearch(const QString &_text, bool next, bool reverse,
QApplication::beep();
m_canBeep = false;
}
LOGDEB("Preview::doSearch: return\n" );
LOGDEB("Preview::doSearch: return\n");
}
void Preview::nextPressed()
{
LOGDEB2("Preview::nextPressed\n" );
LOGDEB2("Preview::nextPressed\n");
doSearch(searchTextCMB->currentText(), true, false);
}
void Preview::prevPressed()
{
LOGDEB2("Preview::prevPressed\n" );
LOGDEB2("Preview::prevPressed\n");
doSearch(searchTextCMB->currentText(), true, true);
}
// Called when user clicks on tab
void Preview::currentChanged(int index)
{
LOGDEB2("PreviewTextEdit::currentChanged\n" );
LOGDEB2("PreviewTextEdit::currentChanged\n");
QWidget *tw = pvTab->widget(index);
PreviewTextEdit *edit =
tw->findChild<PreviewTextEdit*>("pvEdit");
LOGDEB1("Preview::currentChanged(). Editor: " << (edit) << "\n" );
LOGDEB1("Preview::currentChanged(). Editor: " << edit << "\n");
if (edit == 0) {
LOGERR("Editor child not found\n" );
LOGERR("Editor child not found\n");
return;
}
edit->setFocus();
// Disconnect the print signal and reconnect it to the current editor
LOGDEB("Disconnecting reconnecting print signal\n" );
LOGDEB("Disconnecting reconnecting print signal\n");
disconnect(this, SIGNAL(printCurrentPreviewRequest()), 0, 0);
connect(this, SIGNAL(printCurrentPreviewRequest()), edit, SLOT(print()));
edit->installEventFilter(this);
@ -438,7 +441,7 @@ void Preview::currentChanged(int index)
void Preview::closeCurrentTab()
{
LOGDEB1("Preview::closeCurrentTab: m_loading " << (m_loading) << "\n" );
LOGDEB1("Preview::closeCurrentTab: m_loading " << m_loading << "\n");
if (m_loading) {
CancelCheck::instance().setCancel();
return;
@ -455,7 +458,7 @@ void Preview::closeCurrentTab()
PreviewTextEdit *Preview::addEditorTab()
{
LOGDEB1("PreviewTextEdit::addEditorTab()\n" );
LOGDEB1("PreviewTextEdit::addEditorTab()\n");
QWidget *anon = new QWidget((QWidget *)pvTab);
QVBoxLayout *anonLayout = new QVBoxLayout(anon);
PreviewTextEdit *editor = new PreviewTextEdit(anon, "pvEdit", this);
@ -469,7 +472,7 @@ PreviewTextEdit *Preview::addEditorTab()
void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
{
LOGDEB1("Preview::setCurTabProps\n" );
LOGDEB1("Preview::setCurTabProps\n");
QString title;
string ctitle;
if (doc.getmeta(Rcl::Doc::keytt, &ctitle) && !ctitle.empty()) {
@ -491,7 +494,7 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
struct tm *tm = localtime(&mtime);
strftime(datebuf, 99, "%Y-%m-%d %H:%M:%S", tm);
}
LOGDEB("Doc.url: [" << (doc.url) << "]\n" );
LOGDEB("Doc.url: [" << doc.url << "]\n");
string url;
printableUrl(theconfig->getDefCharset(), doc.url, url);
string tiptxt = url + string("\n");
@ -511,10 +514,10 @@ void Preview::setCurTabProps(const Rcl::Doc &doc, int docnum)
bool Preview::makeDocCurrent(const Rcl::Doc& doc, int docnum, bool sametab)
{
LOGDEB("Preview::makeDocCurrent: " << (doc.url) << "\n" );
LOGDEB("Preview::makeDocCurrent: " << doc.url << "\n");
if (m_loading) {
LOGERR("Already loading\n" );
LOGERR("Already loading\n");
return false;
}
@ -603,7 +606,7 @@ public:
bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
{
LOGDEB1("Preview::loadDocInCurrentTab()\n" );
LOGDEB1("Preview::loadDocInCurrentTab()\n");
LoadGuard guard(&m_loading);
CancelCheck::instance().setCancel(false);
@ -641,7 +644,9 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
progress.show();
}
LOGDEB("loadDocInCurrentTab: after file load: cancel " << (CancelCheck::instance().cancelState()) << " status " << (lthr.status) << " text length " << (lthr.fdoc.text.length()) << "\n" );
LOGDEB("loadDocInCurrentTab: after file load: cancel " <<
CancelCheck::instance().cancelState() << " status " << lthr.status <<
" text length " << lthr.fdoc.text.length() << "\n");
if (CancelCheck::instance().cancelState())
return false;
@ -703,6 +708,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
editor->m_format = Qt::RichText;
bool inputishtml = !lthr.fdoc.mimetype.compare("text/html");
QStringList qrichlst;
editor->m_plaintorich->set_activatelinks(prefs.previewActiveLinks);
#if 1
if (highlightTerms) {
@ -710,10 +716,10 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
qApp->processEvents();
if (inputishtml) {
LOGDEB1("Preview: got html " << (lthr.fdoc.text) << "\n" );
LOGDEB1("Preview: got html " << lthr.fdoc.text << "\n");
editor->m_plaintorich->set_inputhtml(true);
} else {
LOGDEB1("Preview: got plain " << (lthr.fdoc.text) << "\n" );
LOGDEB1("Preview: got plain " << lthr.fdoc.text << "\n");
editor->m_plaintorich->set_inputhtml(false);
}
@ -744,7 +750,8 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
}
}
} else {
LOGDEB("Preview: no hilighting, loading " << (int(lthr.fdoc.text.size())) << " bytes\n" );
LOGDEB("Preview: no hilighting, loading " << lthr.fdoc.text.size() <<
" bytes\n");
// No plaintorich() call. In this case, either the text is
// html and the html quoting is hopefully correct, or it's
// plain-text and there is no need to escape special
@ -794,7 +801,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
if (progress.wasCanceled()) {
editor->append("<b>Cancelled !</b>");
LOGDEB("loadDocInCurrentTab: cancelled in editor load\n" );
LOGDEB("loadDocInCurrentTab: cancelled in editor load\n");
break;
}
}
@ -858,7 +865,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
// Position to the first query term
if (editor->m_plaintorich->haveAnchors()) {
QString aname = editor->m_plaintorich->curAnchorName();
LOGDEB2("Call movetoanchor(" << ((const char *)aname.toUtf8()) << ")\n" );
LOGDEB2("Call movetoanchor(" << qs2utf8s(aname) << ")\n");
editor->scrollToAnchor(aname);
// Position the cursor approximately at the anchor (top of
// viewport) so that searches start from here
@ -876,7 +883,7 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
editor->setFocus();
emit(previewExposed(this, m_searchId, docnum));
LOGDEB("loadDocInCurrentTab: returning true\n" );
LOGDEB("loadDocInCurrentTab: returning true\n");
return true;
}
@ -889,13 +896,27 @@ PreviewTextEdit::PreviewTextEdit(QWidget* parent, const char* nm, Preview *pv)
setObjectName(nm);
connect(this, SIGNAL(customContextMenuRequested(const QPoint&)),
this, SLOT(createPopupMenu(const QPoint&)));
connect(this, SIGNAL(anchorClicked(const QUrl &)),
this, SLOT(onAnchorClicked(const QUrl&)));
setOpenExternalLinks(false);
setOpenLinks(false);
}
void PreviewTextEdit::onAnchorClicked(const QUrl& url)
{
LOGDEB("PreviewTextEdit::onAnchorClicked: " << qs2utf8s(url.toString())
<< std::endl);
if (prefs.previewActiveLinks && m_preview->m_rclmain) {
Rcl::Doc doc;
doc.url = qs2utf8s(url.toString()).c_str();
doc.mimetype = "text/html";
m_preview->m_rclmain->startNativeViewer(doc);
}
}
void PreviewTextEdit::createPopupMenu(const QPoint& pos)
{
LOGDEB1("PreviewTextEdit::createPopupMenu()\n" );
LOGDEB1("PreviewTextEdit::createPopupMenu()\n");
QMenu *popup = new QMenu(this);
switch (m_curdsp) {
case PTE_DSPTXT:
@ -934,7 +955,7 @@ void PreviewTextEdit::createPopupMenu(const QPoint& pos)
// Display main text
void PreviewTextEdit::displayText()
{
LOGDEB1("PreviewTextEdit::displayText()\n" );
LOGDEB1("PreviewTextEdit::displayText()\n");
if (m_format == Qt::PlainText)
setPlainText(m_richtxt);
else
@ -945,7 +966,7 @@ void PreviewTextEdit::displayText()
// Display field values
void PreviewTextEdit::displayFields()
{
LOGDEB1("PreviewTextEdit::displayFields()\n" );
LOGDEB1("PreviewTextEdit::displayFields()\n");
QString txt = "<html><head></head><body>\n";
txt += "<b>" + QString::fromLocal8Bit(m_url.c_str());
@ -967,7 +988,7 @@ void PreviewTextEdit::displayFields()
void PreviewTextEdit::displayImage()
{
LOGDEB1("PreviewTextEdit::displayImage()\n" );
LOGDEB1("PreviewTextEdit::displayImage()\n");
if (m_image.isNull())
displayText();
@ -985,7 +1006,7 @@ void PreviewTextEdit::displayImage()
void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event)
{
LOGDEB2("PreviewTextEdit::mouseDoubleClickEvent\n" );
LOGDEB2("PreviewTextEdit::mouseDoubleClickEvent\n");
QTextEdit::mouseDoubleClickEvent(event);
if (textCursor().hasSelection() && m_preview)
m_preview->emitWordSelect(textCursor().selectedText());
@ -993,7 +1014,7 @@ void PreviewTextEdit::mouseDoubleClickEvent(QMouseEvent *event)
void PreviewTextEdit::print()
{
LOGDEB("PreviewTextEdit::print\n" );
LOGDEB("PreviewTextEdit::print\n");
if (!m_preview)
return;

View File

@ -51,6 +51,8 @@ class QPushButton;
class QCheckBox;
class Preview;
class PlainToRichQtPreview;
class QUrl;
class RclMain;
class PreviewTextEdit : public PREVIEW_PARENTCLASS {
Q_OBJECT;
@ -65,6 +67,7 @@ public slots:
virtual void displayImage();
virtual void print();
virtual void createPopupMenu(const QPoint& pos);
void onAnchorClicked(const QUrl& url);
friend class Preview;
@ -104,20 +107,17 @@ private:
class Preview : public QWidget {
Q_OBJECT;
public:
Q_OBJECT
public:
Preview(int sid, // Search Id
Preview(RclMain *m, int sid, // Search Id
const HighlightData& hdata) // Search terms etc. for highlighting
: QWidget(0), m_searchId(sid), m_searchTextFromIndex(-1), m_hData(hdata)
{
: QWidget(0), m_rclmain(m), m_searchId(sid), m_hData(hdata) {
init();
}
virtual void closeEvent(QCloseEvent *e );
virtual bool eventFilter(QObject *target, QEvent *event );
virtual void closeEvent(QCloseEvent *e);
virtual bool eventFilter(QObject *target, QEvent *event);
/**
* Arrange for the document to be displayed either by exposing the tab
@ -158,27 +158,28 @@ signals:
void saveDocToFile(Rcl::Doc);
private:
RclMain *m_rclmain{0};
// Identifier of search in main window. This is used to check that
// we make sense when requesting the next document when browsing
// successive search results in a tab.
int m_searchId;
bool m_dynSearchActive;
bool m_dynSearchActive{false};
// Index value the search text comes from. -1 if text was edited
int m_searchTextFromIndex;
int m_searchTextFromIndex{-1};
bool m_canBeep;
bool m_loading;
bool m_canBeep{true};
bool m_loading{false};
HighlightData m_hData;
bool m_justCreated; // First tab create is different
bool m_justCreated{true}; // First tab create is different
QTabWidget* pvTab;
QLabel* searchLabel;
QComboBox *searchTextCMB;
QPushButton* nextButton;
QPushButton* prevButton;
QPushButton* clearPB;
QCheckBox* matchCheck;
QTabWidget* pvTab{0};
QLabel* searchLabel{0};
QComboBox *searchTextCMB{0};
QPushButton* nextButton{0};
QPushButton* prevButton{0};
QPushButton* clearPB{0};
QCheckBox* matchCheck{0};
void init();
virtual void setCurTabProps(const Rcl::Doc& doc, int docnum);

View File

@ -150,7 +150,7 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
if (curPreview == 0) {
HighlightData hdata;
m_source->getTerms(hdata);
curPreview = new Preview(reslist->listId(), hdata);
curPreview = new Preview(this, reslist->listId(), hdata);
if (curPreview == 0) {
QMessageBox::warning(0, tr("Warning"),
@ -188,7 +188,7 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
*/
void RclMain::startPreview(Rcl::Doc doc)
{
Preview *preview = new Preview(0, HighlightData());
Preview *preview = new Preview(this, 0, HighlightData());
if (preview == 0) {
QMessageBox::warning(0, tr("Warning"),
tr("Can't create preview window"),

View File

@ -479,7 +479,8 @@ void RclMain::startManual(const string& index)
webhelp = path_cat(webhelp, "index.html");
bool has_wh = path_exists(webhelp);
LOGDEB("RclMain::startManual: help index is " << (index.empty()?"(null)":index) << "\n" );
LOGDEB("RclMain::startManual: help index is " <<
(index.empty() ? "(null)" : index) << "\n");
bool indexempty = index.empty();
#ifdef _WIN32

View File

@ -61,34 +61,7 @@ class RclMain : public QMainWindow, public Ui::RclMainBase {
public:
RclMain(QWidget * parent = 0)
: QMainWindow(parent),
curPreview(0),
asearchform(0),
uiprefs(0),
indexConfig(0),
indexSched(0),
cronTool(0),
rtiTool(0),
spellform(0),
fragbuts(0),
specidx(0),
periodictimer(0),
webcache(0),
restable(0),
displayingTable(0),
m_idNoStem(0),
m_idAllStem(0),
m_toolsTB(0), m_resTB(0),
m_filtFRM(0), m_filtCMB(0), m_filtBGRP(0), m_filtMN(0),
m_idxproc(0),
m_idxkilled(false),
m_catgbutvecidx(0),
m_sortspecnochange(false),
m_indexerState(IXST_UNKNOWN),
m_queryActive(false),
m_firstIndexing(false),
m_searchIsSimple(false),
m_pidfile(0) {
: QMainWindow(parent) {
setupUi(this);
init();
}
@ -163,7 +136,7 @@ public slots:
virtual void startPreview(int docnum, Rcl::Doc doc, int keymods);
virtual void startPreview(Rcl::Doc);
virtual void startNativeViewer(Rcl::Doc, int pagenum = -1,
QString term = QString());
QString term = QString());
virtual void openWith(Rcl::Doc, string);
virtual void saveDocToFile(Rcl::Doc);
virtual void previewNextInTab(Preview *, int sid, int docnum);
@ -207,53 +180,51 @@ protected:
private:
SnippetsW *m_snippets{0};
Preview *curPreview;
AdvSearch *asearchform;
UIPrefsDialog *uiprefs;
ConfIndexW *indexConfig;
IdxSchedW *indexSched;
CronToolW *cronTool;
RTIToolW *rtiTool;
SpellW *spellform;
FragButs *fragbuts;
SpecIdxW *specidx;
QTimer *periodictimer;
WebcacheEdit *webcache;
ResTable *restable;
bool displayingTable;
QAction *m_idNoStem;
QAction *m_idAllStem;
QToolBar *m_toolsTB;
QToolBar *m_resTB;
QFrame *m_filtFRM;
QComboBox *m_filtCMB;
QButtonGroup *m_filtBGRP;
QMenu *m_filtMN;
Preview *curPreview{0};
AdvSearch *asearchform{0};
UIPrefsDialog *uiprefs{0};
ConfIndexW *indexConfig{0};
IdxSchedW *indexSched{0};
CronToolW *cronTool{0};
RTIToolW *rtiTool{0};
SpellW *spellform{0};
FragButs *fragbuts{0};
SpecIdxW *specidx{0};
QTimer *periodictimer{0};
WebcacheEdit *webcache{0};
ResTable *restable{0};
bool displayingTable{false};
QAction *m_idNoStem{0};
QAction *m_idAllStem{0};
QToolBar *m_toolsTB{0};
QToolBar *m_resTB{0};
QFrame *m_filtFRM{0};
QComboBox *m_filtCMB{0};
QButtonGroup *m_filtBGRP{0};
QMenu *m_filtMN{0};
QFileSystemWatcher m_watcher;
vector<ExecCmd*> m_viewers;
ExecCmd *m_idxproc; // Indexing process
bool m_idxkilled; // Killed my process
ExecCmd *m_idxproc{0}; // Indexing process
bool m_idxkilled{false}; // Killed my process
TempFileInternal *m_idxreasontmp{nullptr};
map<QString, QAction*> m_stemLangToId;
vector<string> m_catgbutvec;
int m_catgbutvecidx;
int m_catgbutvecidx{0};
DocSeqFiltSpec m_filtspec;
bool m_sortspecnochange;
bool m_sortspecnochange{false};
DocSeqSortSpec m_sortspec;
std::shared_ptr<DocSequence> m_source;
IndexerState m_indexerState;
bool m_queryActive;
bool m_firstIndexing;
bool m_searchIsSimple; // Last search was started from simple
IndexerState m_indexerState{IXST_UNKNOWN};
bool m_queryActive{false};
bool m_firstIndexing{false};
// Last search was started from simple
bool m_searchIsSimple{false};
// If set on init, will be displayed either through ext app, or
// preview (if no ext app set)
QString m_urltoview;
RclTrayIcon *m_trayicon;
RclTrayIcon *m_trayicon{0};
// We sometimes take the indexer lock (e.g.: when editing the webcache)
Pidfile *m_pidfile;
Pidfile *m_pidfile{0};
virtual void init();
virtual void setupResTB(bool combo);

View File

@ -132,6 +132,19 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="previewActiveLinksCB">
<property name="text">
<string>Activate links in preview.</string>
</property>
<property name="toolTip">
<string>Make links inside the preview window clickable, and start an external browser when they are clicked.</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>

View File

@ -145,6 +145,7 @@ void UIPrefsDialog::setFromPrefs()
closeToTrayCB->setChecked(prefs.closeToTray);
showTempFileWarningCB->setChecked(prefs.showTempFileWarning == -1);
previewHtmlCB->setChecked(prefs.previewHtml);
previewActiveLinksCB->setChecked(prefs.previewActiveLinks);
switch (prefs.previewPlainPre) {
case PrefsPack::PP_BR:
plainBRRB->setChecked(1);
@ -330,6 +331,7 @@ void UIPrefsDialog::accept()
prefs.showTempFileWarning = showTempFileWarningCB->isChecked() ?
-1 : 1024;
prefs.previewHtml = previewHtmlCB->isChecked();
prefs.previewActiveLinks = previewActiveLinksCB->isChecked();
if (plainBRRB->isChecked()) {
prefs.previewPlainPre = PrefsPack::PP_BR;