created mimeview and the viewer conf edit dialog
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.9 2006-12-04 08:17:24 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: preview_w.cpp,v 1.10 2006-12-14 13:53:43 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -452,9 +452,11 @@ class LoadThread : public QThread {
|
||||
}
|
||||
virtual void run() {
|
||||
DebugLog::getdbl()->setloglevel(loglevel);
|
||||
if (!maketmpdir(tmpdir)) {
|
||||
string reason;
|
||||
if (!maketmpdir(tmpdir, reason)) {
|
||||
QMessageBox::critical(0, "Recoll",
|
||||
Preview::tr("Cannot create temporary directory"));
|
||||
LOGERR(("Preview: %s\n", reason.c_str()));
|
||||
*statusp = -1;
|
||||
return;
|
||||
}
|
||||
@@ -639,7 +641,7 @@ bool Preview::loadFileInCurrentTab(string fn, size_t sz, const Rcl::Doc &idoc,
|
||||
|
||||
l = MIN(CHUNKL, richTxt.length() - pos);
|
||||
// Avoid breaking inside a tag. Our tags are short (ie: <br>)
|
||||
if (pos + l != richTxt.length()) {
|
||||
if (pos + l != (int)richTxt.length()) {
|
||||
for (int i = -15; i < 0; i++) {
|
||||
if (richTxt[pos+l+i] == '<') {
|
||||
l = l+i;
|
||||
|
||||
+27
-1
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.13 2006-12-07 07:07:35 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: rclmain_w.cpp,v 1.14 2006-12-14 13:53:43 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -65,6 +65,7 @@ using std::pair;
|
||||
#include "transcode.h"
|
||||
#include "refcntr.h"
|
||||
#include "ssearch_w.h"
|
||||
#include "execmd.h"
|
||||
|
||||
#include "rclmain_w.h"
|
||||
#include "moc_rclmain_w.cpp"
|
||||
@@ -659,6 +660,31 @@ void RclMain::startNativeViewer(int docnum)
|
||||
+ doc.mimetype.c_str());
|
||||
return;
|
||||
}
|
||||
list<string> lcmd;
|
||||
if (!stringToStrings(cmd, lcmd)) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
tr("Bad viewer command line for %1: [%2]\n"
|
||||
"Please check the mimeconf file")
|
||||
.arg(QString::fromAscii(doc.mimetype.c_str()))
|
||||
.arg(QString::fromLocal8Bit(cmd.c_str())));
|
||||
return;
|
||||
}
|
||||
string cmdpath;
|
||||
if (!ExecCmd::which(lcmd.front(), cmdpath)) {
|
||||
QString message = tr("The viewer specified in mimeconf for %1: %2"
|
||||
" is not found.\nDo you want to start the "
|
||||
" preferences dialog ?")
|
||||
.arg(QString::fromAscii(doc.mimetype.c_str()))
|
||||
.arg(QString::fromLocal8Bit(lcmd.front().c_str()));
|
||||
|
||||
switch(QMessageBox::warning(0, "Recoll", message,
|
||||
"Yes", "No", 0, 0, 1)) {
|
||||
case 0: showUIPrefs();break;
|
||||
case 1:
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
string fn = urltolocalpath(doc.url);
|
||||
string url = url_encode(doc.url, 7);
|
||||
|
||||
@@ -12,7 +12,8 @@ HEADERS += \
|
||||
sort_w.h \
|
||||
searchclause_w.h \
|
||||
ssearch_w.h \
|
||||
uiprefs_w.h
|
||||
uiprefs_w.h \
|
||||
viewaction_w.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
@@ -28,7 +29,8 @@ SOURCES += \
|
||||
sort_w.cpp \
|
||||
searchclause_w.cpp \
|
||||
ssearch_w.cpp \
|
||||
uiprefs_w.cpp
|
||||
uiprefs_w.cpp \
|
||||
viewaction_w.cpp
|
||||
|
||||
FORMS = \
|
||||
advsearch.ui \
|
||||
@@ -37,7 +39,8 @@ FORMS = \
|
||||
rclmain.ui \
|
||||
sort.ui \
|
||||
ssearchb.ui \
|
||||
uiprefs.ui
|
||||
uiprefs.ui \
|
||||
viewaction.ui
|
||||
|
||||
IMAGES = images/asearch.png \
|
||||
images/history.png \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.15 2006-12-08 07:11:17 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: ssearch_w.cpp,v 1.16 2006-12-14 13:53:43 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -65,9 +65,6 @@ void SSearch::searchTextChanged( const QString & text )
|
||||
} else {
|
||||
searchPB->setEnabled(true);
|
||||
clearqPB->setEnabled(true);
|
||||
string u8 = (const char *)queryText->currentText().utf8();
|
||||
if (prefs.autoSearchOnWS && !u8.empty() && u8[u8.length()-1] == ' ')
|
||||
startSimpleSearch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,11 +224,11 @@ bool SSearch::eventFilter(QObject *target, QEvent *event)
|
||||
completion();
|
||||
m_escape = false;
|
||||
return true;
|
||||
} else {
|
||||
m_escape = false;
|
||||
} else if (ke->key() == Qt::Key_Space) {
|
||||
if (prefs.autoSearchOnWS)
|
||||
startSimpleSearch();
|
||||
}
|
||||
m_escape = false;
|
||||
}
|
||||
return QWidget::eventFilter(target, event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+729
-704
File diff suppressed because it is too large
Load Diff
+17
-2
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.12 2006-12-04 08:17:24 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.13 2006-12-14 13:53:43 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -55,10 +55,13 @@ static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.12 2006-12-04 08:17:24 dockes E
|
||||
#include "rcldb.h"
|
||||
#include "pathut.h"
|
||||
#include "uiprefs_w.h"
|
||||
#include "viewaction_w.h"
|
||||
|
||||
void UIPrefsDialog::init()
|
||||
{
|
||||
|
||||
m_viewAction = 0;
|
||||
|
||||
connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
|
||||
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
||||
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
|
||||
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
||||
@@ -253,6 +256,18 @@ void UIPrefsDialog::showBrowserDialog()
|
||||
helpBrowserLE->setText(s);
|
||||
}
|
||||
|
||||
void UIPrefsDialog::showViewAction()
|
||||
{
|
||||
if (m_viewAction== 0) {
|
||||
m_viewAction = new ViewAction(0);
|
||||
m_viewAction->show();
|
||||
} else {
|
||||
// Close and reopen, in hope that makes us visible...
|
||||
m_viewAction->close();
|
||||
m_viewAction->show();
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////
|
||||
// External / extra search indexes setup
|
||||
// TBD: a way to remove entry from 'all' list (del button?)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* @(#$Id: uiprefs_w.h,v 1.5 2006-12-04 09:56:27 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||
/* @(#$Id: uiprefs_w.h,v 1.6 2006-12-14 13:53:43 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -17,7 +17,7 @@
|
||||
*/
|
||||
#ifndef _UIPREFS_W_H_INCLUDED_
|
||||
#define _UIPREFS_W_H_INCLUDED_
|
||||
/* @(#$Id: uiprefs_w.h,v 1.5 2006-12-04 09:56:27 dockes Exp $ (C) 2005 J.F.Dockes */
|
||||
/* @(#$Id: uiprefs_w.h,v 1.6 2006-12-14 13:53:43 dockes Exp $ (C) 2005 J.F.Dockes */
|
||||
#include <qvariant.h>
|
||||
#include <qdialog.h>
|
||||
|
||||
@@ -44,6 +44,8 @@ class DummyUIPrefsDialogBase : public QDialog, protected Ui::UIPrefsDialogBase
|
||||
#endif
|
||||
//MOC_SKIP_END
|
||||
|
||||
class ViewAction;
|
||||
|
||||
class UIPrefsDialog : public DummyUIPrefsDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -63,6 +65,7 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual void showFontDialog();
|
||||
virtual void showViewAction();
|
||||
virtual void resetReslistFont();
|
||||
virtual void showBrowserDialog();
|
||||
virtual void extraDbTextChanged( const QString & text );
|
||||
@@ -79,8 +82,10 @@ signals:
|
||||
protected slots:
|
||||
virtual void accept();
|
||||
virtual void reject();
|
||||
private:
|
||||
private:
|
||||
void setFromPrefs();
|
||||
ViewAction *m_viewAction;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
|
||||
<class>ViewActionBase</class>
|
||||
<widget class="QDialog">
|
||||
<property name="name">
|
||||
<cstring>ViewActionBase</cstring>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>224</width>
|
||||
<height>132</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
<string>Form1</string>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout3</cstring>
|
||||
</property>
|
||||
<vbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QListView">
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>File type</string>
|
||||
</property>
|
||||
<property name="clickable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="resizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Action</string>
|
||||
</property>
|
||||
<property name="clickable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="resizable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</column>
|
||||
<property name="name">
|
||||
<cstring>actionsLV</cstring>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>Sunken</enum>
|
||||
</property>
|
||||
<property name="selectionMode">
|
||||
<enum>Extended</enum>
|
||||
</property>
|
||||
<property name="showSortIndicator">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="resizeMode">
|
||||
<enum>AllColumns</enum>
|
||||
</property>
|
||||
<property name="toolTip" stdset="0">
|
||||
<string>Select one or several file types, then click Change Action to modify the program used to open them</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLayoutWidget">
|
||||
<property name="name">
|
||||
<cstring>layout1</cstring>
|
||||
</property>
|
||||
<hbox>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>chgActPB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Change Action</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton">
|
||||
<property name="name">
|
||||
<cstring>closePB</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
</vbox>
|
||||
</widget>
|
||||
</hbox>
|
||||
</widget>
|
||||
<layoutdefaults spacing="6" margin="11"/>
|
||||
</UI>
|
||||
@@ -0,0 +1,113 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: viewaction_w.cpp,v 1.1 2006-12-14 13:53:43 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||
#endif
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
#include <qcombobox.h>
|
||||
#include <qspinbox.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlistview.h>
|
||||
#include <qlayout.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qinputdialog.h>
|
||||
|
||||
#include "recoll.h"
|
||||
#include "debuglog.h"
|
||||
#include "guiutils.h"
|
||||
|
||||
#include "viewaction_w.h"
|
||||
|
||||
void ViewAction::init()
|
||||
{
|
||||
connect(closePB, SIGNAL(clicked()), this, SLOT(close()));
|
||||
connect(chgActPB, SIGNAL(clicked()), this, SLOT(editAction()));
|
||||
fillLists();
|
||||
actionsLV->setColumnWidth(0, 150);
|
||||
actionsLV->setColumnWidth(1, 150);
|
||||
resize(550,350);
|
||||
}
|
||||
void ViewAction::fillLists()
|
||||
{
|
||||
actionsLV->clear();
|
||||
vector<pair<string, string> > defs;
|
||||
rclconfig->getMimeViewerDefs(defs);
|
||||
for (vector<pair<string, string> >::const_iterator it = defs.begin();
|
||||
it != defs.end(); it++) {
|
||||
new QListViewItem(actionsLV,
|
||||
QString::fromAscii(it->first.c_str()),
|
||||
QString::fromAscii(it->second.c_str()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ViewAction::editAction()
|
||||
{
|
||||
QString action0;
|
||||
list<string> mtypes;
|
||||
bool dowarnmultiple = true;
|
||||
|
||||
QListViewItemIterator it(actionsLV);
|
||||
while (it.current()) {
|
||||
QListViewItem *item = it.current();
|
||||
if (!item->isSelected()) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
mtypes.push_back((const char *)item->text(0).utf8());
|
||||
QString action = (const char *)item->text(1).utf8();
|
||||
if (action0.isEmpty()) {
|
||||
action0 = action;
|
||||
} else {
|
||||
if (action != action0 && dowarnmultiple) {
|
||||
switch (QMessageBox::warning(0, "Recoll",
|
||||
tr("Changing actions with different"
|
||||
"current values"),
|
||||
"Continue",
|
||||
"Cancel",
|
||||
0, 0, 1)) {
|
||||
case 0: dowarnmultiple = false;break;
|
||||
case 1: return;
|
||||
}
|
||||
}
|
||||
}
|
||||
++it;
|
||||
}
|
||||
if (action0.isEmpty())
|
||||
return;
|
||||
|
||||
bool ok;
|
||||
QString text = QInputDialog::getText(
|
||||
"Recoll", "Edit action:",
|
||||
QLineEdit::Normal,
|
||||
action0, &ok, this);
|
||||
if (!ok || text.isEmpty() )
|
||||
return;
|
||||
|
||||
string sact = (const char *)text.utf8();
|
||||
for (list<string>::const_iterator it = mtypes.begin();
|
||||
it != mtypes.end(); it++) {
|
||||
rclconfig->setMimeViewerDef(*it, sact);
|
||||
}
|
||||
fillLists();
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
#ifndef _VIEWACTION_W_H_INCLUDED_
|
||||
#define _VIEWACTION_W_H_INCLUDED_
|
||||
/* @(#$Id: viewaction_w.h,v 1.1 2006-12-14 13:53:43 dockes Exp $ (C) 2006 J.F.Dockes */
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <qvariant.h>
|
||||
#include <qdialog.h>
|
||||
|
||||
#if (QT_VERSION < 0x040000)
|
||||
#include "viewaction.h"
|
||||
#else
|
||||
#include "ui_viewaction.h"
|
||||
#endif
|
||||
|
||||
class QDialog;
|
||||
|
||||
//MOC_SKIP_BEGIN
|
||||
#if QT_VERSION < 0x040000
|
||||
class DummyViewActionBase : public ViewActionBase
|
||||
{
|
||||
public: DummyViewActionBase(QWidget* parent = 0) : ViewActionBase(parent) {}
|
||||
};
|
||||
#else
|
||||
class DummyViewActionBase : public QDialog, public Ui::ViewActionBase
|
||||
{
|
||||
public:
|
||||
DummyViewActionBase(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
};
|
||||
#endif
|
||||
//MOC_SKIP_END
|
||||
|
||||
class ViewAction : public DummyViewActionBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ViewAction(QDialog* parent = 0)
|
||||
: DummyViewActionBase(parent)
|
||||
{
|
||||
init();
|
||||
}
|
||||
~ViewAction() {}
|
||||
|
||||
public slots:
|
||||
virtual void editAction();
|
||||
|
||||
private:
|
||||
virtual void init();
|
||||
virtual void fillLists();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* _VIEWACTION_W_H_INCLUDED_ */
|
||||
Reference in New Issue
Block a user