changed the external viewer definition dialogs

This commit is contained in:
Jean-Francois Dockes 2013-02-25 16:23:29 +01:00
parent 5419665741
commit 628010f7dc
8 changed files with 217 additions and 158 deletions

View File

@ -868,7 +868,13 @@ bool RclConfig::setMimeViewerDef(const string& mt, const string& def)
{
if (mimeview == 0)
return false;
if (!mimeview->set(mt, def, "view")) {
bool status;
if (!def.empty())
status = mimeview->set(mt, def, "view");
else
status = mimeview->erase(mt, "view");
if (!status) {
m_reason = string("RclConfig:: cant set value. Readonly?");
return false;
}

View File

@ -167,40 +167,6 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="useDesktopOpenCB">
<property name="text">
<string>Use desktop preferences to choose document editor.</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="textLabelallex">
<property name="text">
<string>Exceptions</string>
</property>
<property name="toolTip">
<string>Mime types that should not be passed to xdg-open even when "Use desktop preferences" is set.&lt;br&gt; Useful to pass page number and search string options to, e.g. evince.</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">

View File

@ -84,10 +84,6 @@ void UIPrefsDialog::init()
ssAutoSpaceCB, SLOT(setDisabled(bool)));
connect(ssAutoAllCB, SIGNAL(toggled(bool)),
ssAutoSpaceCB, SLOT(setChecked(bool)));
connect(useDesktopOpenCB, SIGNAL(toggled(bool)),
viewActionPB, SLOT(setDisabled(bool)));
connect(useDesktopOpenCB, SIGNAL(toggled(bool)),
allExLE, SLOT(setEnabled(bool)));
setFromPrefs();
}
@ -108,12 +104,6 @@ void UIPrefsDialog::setFromPrefs()
initStartAdvCB->setChecked(prefs.startWithAdvSearchOpen);
// 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);
switch (prefs.previewPlainPre) {
@ -255,8 +245,6 @@ void UIPrefsDialog::accept()
replAbsCB->isChecked();
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
prefs.useDesktopOpen = useDesktopOpenCB->isChecked();
theconfig->setMimeViewerAllEx((const char*)allExLE->text().toUtf8());
prefs.keepSort = keepSortCB->isChecked();
prefs.previewHtml = previewHtmlCB->isChecked();

View File

@ -6,107 +6,151 @@
<rect>
<x>0</x>
<y>0</y>
<width>446</width>
<height>180</height>
<width>632</width>
<height>726</height>
</rect>
</property>
<property name="windowTitle">
<string>Native Viewers</string>
</property>
<layout class="QHBoxLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout">
<widget class="QLabel" name="textLabel1">
<property name="text">
<string>Select one or several mime types then use the controls in the bottom frame to change how they are processed.</string>
</property>
<property name="wordWrap">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useDesktopCB">
<property name="text">
<string>Use Desktop preferences by default</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="actionsLV">
<property name="toolTip">
<string>Select one or several file types, then use the controls in the frame below to change how they are processed</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>2</number>
</property>
<property name="allColumnsShowFocus" stdset="0">
<bool>true</bool>
</property>
<property name="showSortIndicator" stdset="0">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>150</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<column/>
<column/>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QCheckBox" name="setExceptCB">
<property name="text">
<string>Exception to Desktop preferences</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Action (empty -> recoll default)</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="newActionLE"/>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="chgActPB">
<property name="text">
<string>Apply to current selection</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="textLabel1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closePB">
<property name="text">
<string>Select one or several mime types then click &quot;Change Action&quot;&lt;br&gt;You can also close this dialog and check &quot;Use desktop preferences&quot;&lt;br&gt;in the main panel to ignore this list and use your desktop defaults.</string>
</property>
<property name="wordWrap">
<bool>false</bool>
<string>Close</string>
</property>
</widget>
</item>
<item>
<widget class="QTableWidget" name="actionsLV">
<property name="toolTip">
<string>Select one or several file types, then click Change Action to modify the program used to open them</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>true</bool>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="columnCount">
<number>2</number>
</property>
<property name="allColumnsShowFocus" stdset="0">
<bool>true</bool>
</property>
<property name="showSortIndicator" stdset="0">
<bool>true</bool>
</property>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>150</number>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="verticalHeaderVisible">
<bool>false</bool>
</attribute>
<attribute name="horizontalHeaderShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderStretchLastSection">
<bool>true</bool>
</attribute>
<attribute name="horizontalHeaderDefaultSectionSize">
<number>150</number>
</attribute>
<column/>
<column/>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QPushButton" name="chgActPB">
<property name="text">
<string>Change Action</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closePB">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>

View File

@ -14,6 +14,9 @@
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
@ -38,12 +41,28 @@ using namespace std;
void ViewAction::init()
{
connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
connect(chgActPB, SIGNAL(clicked()),
this, SLOT(editActions()));
connect(chgActPB, SIGNAL(clicked()), this, SLOT(editActions()));
connect(actionsLV,SIGNAL(itemDoubleClicked(QTableWidgetItem *)),
this, SLOT(onItemDoubleClicked(QTableWidgetItem *)));
useDesktopCB->setChecked(prefs.useDesktopOpen);
onUseDesktopCBToggled(prefs.useDesktopOpen);
connect(useDesktopCB, SIGNAL(stateChanged(int)),
this, SLOT(onUseDesktopCBToggled(int)));
connect(setExceptCB, SIGNAL(stateChanged(int)),
this, SLOT(onSetExceptCBToggled(int)));
resize(QSize(640, 480).expandedTo(minimumSizeHint()));
}
void ViewAction::onUseDesktopCBToggled(int onoff)
{
prefs.useDesktopOpen = onoff != 0;
fillLists();
resize(QSize(640, 250).expandedTo(minimumSizeHint()));
setExceptCB->setEnabled(prefs.useDesktopOpen);
}
void ViewAction::onSetExceptCBToggled(int onoff)
{
newActionLE->setEnabled(onoff != 0);
}
void ViewAction::fillLists()
@ -54,12 +73,25 @@ void ViewAction::fillLists()
theconfig->getMimeViewerDefs(defs);
actionsLV->setRowCount(defs.size());
int row = 0;
set<string> viewerXs;
if (prefs.useDesktopOpen) {
string s = theconfig->getMimeViewerAllEx();
stringToStrings(s, viewerXs);
}
for (vector<pair<string, string> >::const_iterator it = defs.begin();
it != defs.end(); it++) {
actionsLV->setItem(row, 0,
new QTableWidgetItem(QString::fromAscii(it->first.c_str())));
actionsLV->setItem(row, 1,
new QTableWidgetItem(QString::fromAscii(it->second.c_str())));
if (!prefs.useDesktopOpen ||
viewerXs.find(it->first) != viewerXs.end()) {
actionsLV->setItem(
row, 1,
new QTableWidgetItem(QString::fromAscii(it->second.c_str())));
} else {
actionsLV->setItem(
row, 1, new QTableWidgetItem(tr("Desktop Default")));
}
row++;
}
QStringList labels(tr("MIME type"));
@ -78,6 +110,7 @@ void ViewAction::selectMT(const QString& mt)
actionsLV->setCurrentItem(*it, QItemSelectionModel::Columns);
}
}
void ViewAction::onItemDoubleClicked(QTableWidgetItem * item)
{
actionsLV->clearSelection();
@ -90,21 +123,30 @@ void ViewAction::onItemDoubleClicked(QTableWidgetItem * item)
void ViewAction::editActions()
{
QString action0;
int except0 = -1;
set<string> viewerXs;
string s = theconfig->getMimeViewerAllEx();
stringToStrings(s, viewerXs);
list<string> mtypes;
bool dowarnmultiple = true;
for (int row = 0; row < actionsLV->rowCount(); row++) {
QTableWidgetItem *item0 = actionsLV->item(row, 0);
if (!item0->isSelected())
continue;
mtypes.push_back((const char *)item0->text().toLocal8Bit());
string mtype = (const char *)item0->text().toLocal8Bit();
mtypes.push_back(mtype);
QTableWidgetItem *item1 = actionsLV->item(row, 1);
QString action = item1->text();
int except = viewerXs.find(mtype) != viewerXs.end();
if (action0.isEmpty()) {
action0 = action;
except0 = except;
} else {
if (action != action0 && dowarnmultiple) {
if ((action != action0 || except != except0) && dowarnmultiple) {
switch (QMessageBox::warning(0, "Recoll",
tr("Changing actions with "
tr("Changing entries with "
"different current values"),
"Continue",
"Cancel",
@ -118,17 +160,26 @@ void ViewAction::editActions()
if (action0.isEmpty())
return;
bool ok;
QString newaction = QInputDialog::getText(this, "Recoll", "Edit action:",
QLineEdit::Normal,
action0, &ok);
if (!ok || newaction.isEmpty() )
return;
string sact = (const char *)newaction.toLocal8Bit();
for (list<string>::const_iterator it = mtypes.begin();
it != mtypes.end(); it++) {
theconfig->setMimeViewerDef(*it, sact);
string sact = (const char *)newActionLE->text().toLocal8Bit();
trimstring(sact);
for (list<string>::const_iterator mit = mtypes.begin();
mit != mtypes.end(); mit++) {
set<string>::iterator xit = viewerXs.find(*mit);
if (setExceptCB->isChecked()) {
if (xit == viewerXs.end()) {
viewerXs.insert(*mit);
}
} else {
if (xit != viewerXs.end()) {
viewerXs.erase(xit);
}
}
// An empty action will restore the default (erase from
// topmost conftree)
theconfig->setMimeViewerDef(*mit, sact);
}
s = stringsToString(viewerXs);
theconfig->setMimeViewerAllEx(s);
fillLists();
}

View File

@ -43,6 +43,8 @@ public:
public slots:
virtual void editActions();
virtual void onItemDoubleClicked(QTableWidgetItem *);
virtual void onUseDesktopCBToggled(int);
virtual void onSetExceptCBToggled(int);
private:
virtual void init();
virtual void fillLists();

View File

@ -49,7 +49,7 @@
<li><a href="recoll_XMP/index.html">Indexing PDF
XMP-metadata</a>: a nice exemple of customizing a Recoll
configuration and the PDF filter to use additional
metadata.</li>
metadata, by Jeffrey Dick.</li>
<li><a href="perfs.html">Index size and indexing performance
data.</a></li>
<li><a href="custom.html">Result list format samples.</a></li>

View File

@ -80,9 +80,11 @@ journal =
&lt; '
---
> ' |
168a200,203
168a200,205
> # replace latex with html markup
> l2html |
> # replace "Subject" with "Abstract"
> sed -e s/\&lt;meta\ name=\"Subject\"/\&lt;meta\ name=\"Abstract\"/g |
> # add markup="html" to author meta element
> sed -e s/\&lt;meta\ name=\"Author\"/\&lt;meta\ name=\"Author\"\ markup=\"html\"/g
</pre>