implement mime exceptions to "use desktop open" so that we can use evince and pass page and search string parameters for pdf,ps and dvi even when all other mime types are passed to xdg-open

This commit is contained in:
Jean-Francois Dockes
2012-10-04 09:51:29 +02:00
parent 5b3cb69ee9
commit d5a6105795
12 changed files with 263 additions and 42 deletions
+7 -10
View File
@@ -398,7 +398,7 @@ void RclMain::initDbOpen()
}
// Start native viewer or preview for input Doc. This is used allow
// the using Recoll result docs with an ipath in another app. We act
// using Recoll result docs with an ipath in another app. We act
// as a proxy to extract the data and start a viewer.
// The Url are encoded as file://path#ipath
void RclMain::viewUrl()
@@ -428,7 +428,8 @@ void RclMain::viewUrl()
// preview.
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
string viewer = theconfig->getMimeViewerDef(doc.mimetype, apptag);
string viewer = theconfig->getMimeViewerDef(doc.mimetype, apptag,
prefs.useDesktopOpen);
if (viewer.empty()) {
startPreview(doc);
} else {
@@ -1502,14 +1503,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
{
LOGDEB(("RclMain::startNativeViewer: page %d\n", pagenum));
// Look for appropriate viewer
string cmdplusattr;
if (prefs.useDesktopOpen) {
cmdplusattr = theconfig->getMimeViewerDef("application/x-all", "");
} else {
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag);
}
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag,
prefs.useDesktopOpen);
if (cmdplusattr.empty()) {
QMessageBox::warning(0, "Recoll",
+1 -1
View File
@@ -920,7 +920,7 @@ void ResList::createPopupMenu(const QPoint& pos)
if (havedoc)
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
if (havedoc && !theconfig->getMimeViewerDef(doc.mimetype, apptag).empty()) {
if (havedoc && !theconfig->getMimeViewerDef(doc.mimetype, apptag, 0).empty()) {
popup->addAction(tr("&Open"), this, SLOT(menuEdit()));
}
popup->addAction(tr("Copy &File Name"), this, SLOT(menuCopyFN()));
+21
View File
@@ -177,6 +177,27 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="textLabelallex">
<property name="text">
<string>Exceptions</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="allExLE">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="viewActionPB">
<property name="text">
+6
View File
@@ -81,6 +81,8 @@ void UIPrefsDialog::init()
replAbsCB, SLOT(setEnabled(bool)));
connect(useDesktopOpenCB, SIGNAL(toggled(bool)),
viewActionPB, SLOT(setDisabled(bool)));
connect(useDesktopOpenCB, SIGNAL(toggled(bool)),
allExLE, SLOT(setEnabled(bool)));
setFromPrefs();
}
@@ -102,6 +104,8 @@ void UIPrefsDialog::setFromPrefs()
// External editor. Can use desktop prefs or internal
useDesktopOpenCB->setChecked(prefs.useDesktopOpen);
viewActionPB->setEnabled(!prefs.useDesktopOpen);
allExLE->setEnabled(prefs.useDesktopOpen);
allExLE->setText(QString::fromUtf8(theconfig->getMimeViewerAllEx().c_str()));
keepSortCB->setChecked(prefs.keepSort);
previewHtmlCB->setChecked(prefs.previewHtml);
@@ -242,6 +246,8 @@ void UIPrefsDialog::accept()
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
prefs.useDesktopOpen = useDesktopOpenCB->isChecked();
theconfig->setMimeViewerAllEx((const char*)allExLE->text().toUtf8());
prefs.keepSort = keepSortCB->isChecked();
prefs.previewHtml = previewHtmlCB->isChecked();