use normal text/html ext app for viewing help
This commit is contained in:
parent
27fbdc6a12
commit
e9aad2d453
@ -43,74 +43,6 @@ bool getStemLangs(list<string>& langs)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *htmlbrowserlist =
|
|
||||||
"opera konqueror firefox mozilla netscape";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Search for and launch an html browser for the documentation. If the
|
|
||||||
* user has set a preference, we use it directly instead of guessing.
|
|
||||||
*/
|
|
||||||
bool startHelpBrowser(const string &iurl)
|
|
||||||
{
|
|
||||||
string url;
|
|
||||||
if (iurl.empty()) {
|
|
||||||
url = path_cat(rclconfig->getDatadir(), "doc");
|
|
||||||
url = path_cat(url, "usermanual.html");
|
|
||||||
url = string("file://") + url;
|
|
||||||
} else
|
|
||||||
url = iurl;
|
|
||||||
|
|
||||||
// If the user set a preference with an absolute path then things are
|
|
||||||
// simple
|
|
||||||
if (!prefs.htmlBrowser.isEmpty() && prefs.htmlBrowser.find('/') != -1) {
|
|
||||||
if (access(prefs.htmlBrowser.ascii(), X_OK) != 0) {
|
|
||||||
LOGERR(("startHelpBrowser: %s not found or not executable\n",
|
|
||||||
prefs.htmlBrowser.ascii()));
|
|
||||||
}
|
|
||||||
string cmd = string(prefs.htmlBrowser.ascii()) + " " + url + "&";
|
|
||||||
if (system(cmd.c_str()) == 0)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
string searched;
|
|
||||||
if (prefs.htmlBrowser.isEmpty()) {
|
|
||||||
searched = htmlbrowserlist;
|
|
||||||
} else {
|
|
||||||
searched = prefs.htmlBrowser.ascii();
|
|
||||||
}
|
|
||||||
list<string> blist;
|
|
||||||
stringToTokens(searched, blist, " ");
|
|
||||||
|
|
||||||
const char *path = getenv("PATH");
|
|
||||||
if (path == 0)
|
|
||||||
path = "/bin:/usr/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin";
|
|
||||||
|
|
||||||
list<string> pathl;
|
|
||||||
stringToTokens(path, pathl, ":");
|
|
||||||
|
|
||||||
// For each browser name, search path and exec/stop if found
|
|
||||||
for (list<string>::const_iterator bit = blist.begin();
|
|
||||||
bit != blist.end(); bit++) {
|
|
||||||
for (list<string>::const_iterator pit = pathl.begin();
|
|
||||||
pit != pathl.end(); pit++) {
|
|
||||||
string exefile = path_cat(*pit, *bit);
|
|
||||||
LOGDEB1(("startHelpBrowser: trying %s\n", exefile.c_str()));
|
|
||||||
if (access(exefile.c_str(), X_OK) == 0) {
|
|
||||||
string cmd = exefile + " " + url + "&";
|
|
||||||
if (system(cmd.c_str()) == 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOGERR(("startHelpBrowser: no html browser found. Looked for: %s\n",
|
|
||||||
searched.c_str()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The global preferences structure
|
// The global preferences structure
|
||||||
PrefsPack prefs;
|
PrefsPack prefs;
|
||||||
|
|
||||||
@ -142,7 +74,6 @@ void rwSettings(bool writing)
|
|||||||
SETTING_RW(prefs.pvwidth, "/Recoll/geometry/pvwidth", Num, 0);
|
SETTING_RW(prefs.pvwidth, "/Recoll/geometry/pvwidth", Num, 0);
|
||||||
SETTING_RW(prefs.pvheight, "/Recoll/geometry/pvheight", Num, 0);
|
SETTING_RW(prefs.pvheight, "/Recoll/geometry/pvheight", Num, 0);
|
||||||
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Num, 1);
|
SETTING_RW(prefs.ssearchTyp, "/Recoll/prefs/simpleSearchTyp", Num, 1);
|
||||||
SETTING_RW(prefs.htmlBrowser, "/Recoll/prefs/htmlBrowser", , "");
|
|
||||||
SETTING_RW(prefs.startWithAdvSearchOpen,
|
SETTING_RW(prefs.startWithAdvSearchOpen,
|
||||||
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
|
"/Recoll/prefs/startWithAdvSearchOpen", Bool, false);
|
||||||
SETTING_RW(prefs.startWithSortToolOpen,
|
SETTING_RW(prefs.startWithSortToolOpen,
|
||||||
|
|||||||
@ -74,7 +74,6 @@ class PrefsPack {
|
|||||||
int pvwidth; // Preview window geom
|
int pvwidth; // Preview window geom
|
||||||
int pvheight;
|
int pvheight;
|
||||||
int ssearchTyp;
|
int ssearchTyp;
|
||||||
QString htmlBrowser;
|
|
||||||
bool useDesktopOpen; // typically xdg-open, instead of mimeview settings
|
bool useDesktopOpen; // typically xdg-open, instead of mimeview settings
|
||||||
bool keepSort; // remember sort status between invocations
|
bool keepSort; // remember sort status between invocations
|
||||||
bool sortActive; // Remembered sort state.
|
bool sortActive; // Remembered sort state.
|
||||||
|
|||||||
@ -87,7 +87,7 @@ RclConfig* RclConfig::getMainConfig()
|
|||||||
RclHistory *g_dynconf;
|
RclHistory *g_dynconf;
|
||||||
int recollNeedsExit;
|
int recollNeedsExit;
|
||||||
int startIndexingAfterConfig;
|
int startIndexingAfterConfig;
|
||||||
static RclMain *mainWindow;
|
RclMain *mainWindow;
|
||||||
static string recollsharedir;
|
static string recollsharedir;
|
||||||
|
|
||||||
bool maybeOpenDb(string &reason, bool force)
|
bool maybeOpenDb(string &reason, bool force)
|
||||||
|
|||||||
@ -827,13 +827,35 @@ void RclMain::saveDocToFile(int docnum)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Look for html browser. We make a special effort for html because it's
|
||||||
|
* used for reading help */
|
||||||
|
static bool lookForHtmlBrowser(string &exefile)
|
||||||
|
{
|
||||||
|
static const char *htmlbrowserlist =
|
||||||
|
"opera konqueror firefox mozilla netscape epiphany";
|
||||||
|
list<string> blist;
|
||||||
|
stringToTokens(htmlbrowserlist, blist, " ");
|
||||||
|
|
||||||
|
const char *path = getenv("PATH");
|
||||||
|
if (path == 0)
|
||||||
|
path = "/bin:/usr/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin";
|
||||||
|
|
||||||
|
// Look for each browser
|
||||||
|
for (list<string>::const_iterator bit = blist.begin();
|
||||||
|
bit != blist.end(); bit++) {
|
||||||
|
if (ExecCmd::which(*bit, exefile, path))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
exefile.clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void RclMain::startNativeViewer(int docnum)
|
void RclMain::startNativeViewer(int docnum)
|
||||||
{
|
{
|
||||||
Rcl::Doc doc;
|
Rcl::Doc doc;
|
||||||
if (!resList->getDoc(docnum, doc)) {
|
if (!resList->getDoc(docnum, doc)) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll", tr("Cannot retrieve document info"
|
||||||
tr("Cannot retrieve document info"
|
" from database"));
|
||||||
" from database"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
startNativeViewer(doc);
|
startNativeViewer(doc);
|
||||||
@ -868,7 +890,8 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
string cmdpath;
|
string cmdpath;
|
||||||
if (prefs.useDesktopOpen) {
|
if (prefs.useDesktopOpen) {
|
||||||
// Findfilter searches the recoll filters directory in
|
// Findfilter searches the recoll filters directory in
|
||||||
// addition to the path
|
// addition to the path. We store a copy of xdg-open there, to be
|
||||||
|
// used as last resort
|
||||||
cmdpath = rclconfig->findFilter(lcmd.front());
|
cmdpath = rclconfig->findFilter(lcmd.front());
|
||||||
// Substitute path for cmd
|
// Substitute path for cmd
|
||||||
if (!cmdpath.empty()) {
|
if (!cmdpath.empty()) {
|
||||||
@ -880,6 +903,12 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
ExecCmd::which(lcmd.front(), cmdpath);
|
ExecCmd::which(lcmd.front(), cmdpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Specialcase text/html because of the help browser need
|
||||||
|
if (cmdpath.empty() && !doc.mimetype.compare("text/html")) {
|
||||||
|
if (lookForHtmlBrowser(cmdpath)) {
|
||||||
|
cmd = cmdpath + " %u";
|
||||||
|
}
|
||||||
|
}
|
||||||
if (cmdpath.empty()) {
|
if (cmdpath.empty()) {
|
||||||
QString mt = QString::fromAscii(doc.mimetype.c_str());
|
QString mt = QString::fromAscii(doc.mimetype.c_str());
|
||||||
QString message = tr("The viewer specified in mimeconf for %1: %2"
|
QString message = tr("The viewer specified in mimeconf for %1: %2"
|
||||||
@ -895,9 +924,9 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
uiprefs->showViewAction(mt);
|
uiprefs->showViewAction(mt);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
break;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For files with an ipath, we do things differently depending if the
|
// For files with an ipath, we do things differently depending if the
|
||||||
@ -953,11 +982,15 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
|
|||||||
|
|
||||||
void RclMain::startManual()
|
void RclMain::startManual()
|
||||||
{
|
{
|
||||||
QString msg = tr("Starting help browser ");
|
QString msg = tr("Starting html help browser ");
|
||||||
if (prefs.htmlBrowser != QString(""))
|
|
||||||
msg += prefs.htmlBrowser;
|
|
||||||
statusBar()->message(msg, 3000);
|
statusBar()->message(msg, 3000);
|
||||||
startHelpBrowser();
|
Rcl::Doc doc;
|
||||||
|
doc.url = "file://";
|
||||||
|
doc.url = path_cat(doc.url, rclconfig->getDatadir());
|
||||||
|
doc.url = path_cat(doc.url, "doc");
|
||||||
|
doc.url = path_cat(doc.url, "usermanual.html");
|
||||||
|
doc.mimetype = "text/html";
|
||||||
|
startNativeViewer(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search for document 'like' the selected one. We ask rcldb/xapian to find
|
// Search for document 'like' the selected one. We ask rcldb/xapian to find
|
||||||
|
|||||||
@ -29,6 +29,8 @@
|
|||||||
// Open the database if needed. We now force a close/open by default
|
// Open the database if needed. We now force a close/open by default
|
||||||
extern bool maybeOpenDb(std::string &reason, bool force = true);
|
extern bool maybeOpenDb(std::string &reason, bool force = true);
|
||||||
|
|
||||||
|
class RclMain;
|
||||||
|
extern RclMain *mainWindow;
|
||||||
extern RclConfig *rclconfig;
|
extern RclConfig *rclconfig;
|
||||||
extern Rcl::Db *rcldb;
|
extern Rcl::Db *rcldb;
|
||||||
extern int recollNeedsExit;
|
extern int recollNeedsExit;
|
||||||
|
|||||||
@ -276,43 +276,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</hbox>
|
</hbox>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QLayoutWidget">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>layout36</cstring>
|
|
||||||
</property>
|
|
||||||
<hbox>
|
|
||||||
<property name="name">
|
|
||||||
<cstring>unnamed</cstring>
|
|
||||||
</property>
|
|
||||||
<widget class="QLabel">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>textLabel1_3</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>HTML help browser</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLineEdit">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>helpBrowserLE</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget class="QPushButton">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>helpBrowserPB</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Select file</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</hbox>
|
|
||||||
</widget>
|
|
||||||
<widget class="QLayoutWidget">
|
<widget class="QLayoutWidget">
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>layout37</cstring>
|
<cstring>layout37</cstring>
|
||||||
|
|||||||
@ -67,7 +67,6 @@ void UIPrefsDialog::init()
|
|||||||
|
|
||||||
connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
|
connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
|
||||||
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
||||||
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
|
||||||
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
||||||
connect(extraDbLE,SIGNAL(textChanged(const QString&)), this,
|
connect(extraDbLE,SIGNAL(textChanged(const QString&)), this,
|
||||||
SLOT(extraDbTextChanged(const QString&)));
|
SLOT(extraDbTextChanged(const QString&)));
|
||||||
@ -123,7 +122,6 @@ void UIPrefsDialog::setFromPrefs()
|
|||||||
s.setNum(reslistFontSize));
|
s.setNum(reslistFontSize));
|
||||||
}
|
}
|
||||||
rlfTE->setText(prefs.reslistformat);
|
rlfTE->setText(prefs.reslistformat);
|
||||||
helpBrowserLE->setText(prefs.htmlBrowser);
|
|
||||||
|
|
||||||
// Stemming language combobox
|
// Stemming language combobox
|
||||||
stemLangCMB->clear();
|
stemLangCMB->clear();
|
||||||
@ -194,8 +192,6 @@ void UIPrefsDialog::accept()
|
|||||||
}
|
}
|
||||||
prefs.creslistformat = (const char*)prefs.reslistformat.utf8();
|
prefs.creslistformat = (const char*)prefs.reslistformat.utf8();
|
||||||
|
|
||||||
prefs.htmlBrowser = helpBrowserLE->text();
|
|
||||||
|
|
||||||
if (stemLangCMB->currentItem() == 0) {
|
if (stemLangCMB->currentItem() == 0) {
|
||||||
prefs.queryStemLang = "";
|
prefs.queryStemLang = "";
|
||||||
} else if (stemLangCMB->currentItem() == 1) {
|
} else if (stemLangCMB->currentItem() == 1) {
|
||||||
@ -296,17 +292,6 @@ void UIPrefsDialog::resetReslistFont()
|
|||||||
QString().setNum(this->font().pointSize()));
|
QString().setNum(this->font().pointSize()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPrefsDialog::showBrowserDialog()
|
|
||||||
{
|
|
||||||
QString s = QFileDialog::getOpenFileName("/usr",
|
|
||||||
"",
|
|
||||||
this,
|
|
||||||
"open file dialog",
|
|
||||||
"Choose a file");
|
|
||||||
if (!s.isEmpty())
|
|
||||||
helpBrowserLE->setText(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UIPrefsDialog::showViewAction()
|
void UIPrefsDialog::showViewAction()
|
||||||
{
|
{
|
||||||
if (m_viewAction== 0) {
|
if (m_viewAction== 0) {
|
||||||
|
|||||||
@ -68,7 +68,6 @@ public slots:
|
|||||||
virtual void showViewAction();
|
virtual void showViewAction();
|
||||||
virtual void showViewAction(const QString& mt);
|
virtual void showViewAction(const QString& mt);
|
||||||
virtual void resetReslistFont();
|
virtual void resetReslistFont();
|
||||||
virtual void showBrowserDialog();
|
|
||||||
virtual void extraDbTextChanged(const QString& text);
|
virtual void extraDbTextChanged(const QString& text);
|
||||||
virtual void addExtraDbPB_clicked();
|
virtual void addExtraDbPB_clicked();
|
||||||
virtual void delExtraDbPB_clicked();
|
virtual void delExtraDbPB_clicked();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user