GUI: preview: add Open popup entry and Open button for starting native viewer on current doc
This commit is contained in:
parent
34d43d1188
commit
824a1d3ebf
@ -95,6 +95,20 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="Line" name="line">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="editPB">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2005 J.F.Dockes
|
/* Copyright (C) 2005-2019 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -138,6 +138,7 @@ void Preview::init()
|
|||||||
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
|
connect(nextPB, SIGNAL(clicked()), this, SLOT(nextPressed()));
|
||||||
connect(prevPB, SIGNAL(clicked()), this, SLOT(prevPressed()));
|
connect(prevPB, SIGNAL(clicked()), this, SLOT(prevPressed()));
|
||||||
connect(clearPB, SIGNAL(clicked()), searchTextCMB, SLOT(clearEditText()));
|
connect(clearPB, SIGNAL(clicked()), searchTextCMB, SLOT(clearEditText()));
|
||||||
|
connect(editPB, SIGNAL(clicked()), this, SLOT(emitEditRequested()));
|
||||||
connect(pvTab, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
|
connect(pvTab, SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int)));
|
||||||
connect(pvTab, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
connect(pvTab, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int)));
|
||||||
|
|
||||||
@ -276,7 +277,7 @@ void Preview::searchTextFromIndex(int idx)
|
|||||||
m_searchTextFromIndex = idx;
|
m_searchTextFromIndex = idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save current document to file
|
|
||||||
void Preview::emitSaveDocToFile()
|
void Preview::emitSaveDocToFile()
|
||||||
{
|
{
|
||||||
PreviewTextEdit *ce = currentEditor();
|
PreviewTextEdit *ce = currentEditor();
|
||||||
@ -285,6 +286,14 @@ void Preview::emitSaveDocToFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Preview::emitEditRequested()
|
||||||
|
{
|
||||||
|
PreviewTextEdit *ce = currentEditor();
|
||||||
|
if (ce && !ce->m_dbdoc.url.empty()) {
|
||||||
|
emit editRequested(ce->m_dbdoc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Perform text search. If next is true, we look for the next match of the
|
// Perform text search. If next is true, we look for the next match of the
|
||||||
// current search, trying to advance and possibly wrapping around. If next is
|
// current search, trying to advance and possibly wrapping around. If next is
|
||||||
// false, the search string has been modified, we search for the new string,
|
// false, the search string has been modified, we search for the new string,
|
||||||
@ -924,11 +933,12 @@ void PreviewTextEdit::createPopupMenu(const QPoint& pos)
|
|||||||
popup->addAction(tr("Preserve indentation"),
|
popup->addAction(tr("Preserve indentation"),
|
||||||
m_preview, SLOT(togglePlainPre()));
|
m_preview, SLOT(togglePlainPre()));
|
||||||
}
|
}
|
||||||
// Need to check ipath until we fix the internfile bug that always
|
if (!m_dbdoc.url.empty()) {
|
||||||
// has it convert to html for top level docs
|
|
||||||
if (!m_dbdoc.url.empty() && !m_dbdoc.ipath.empty())
|
|
||||||
popup->addAction(tr("Save document to file"),
|
popup->addAction(tr("Save document to file"),
|
||||||
m_preview, SLOT(emitSaveDocToFile()));
|
m_preview, SLOT(emitSaveDocToFile()));
|
||||||
|
popup->addAction(tr("Open document"),
|
||||||
|
m_preview, SLOT(emitEditRequested()));
|
||||||
|
}
|
||||||
popup->popup(mapToGlobal(pos));
|
popup->popup(mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2006 J.F.Dockes
|
/* Copyright (C) 2006-2019 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -114,10 +114,10 @@ class Preview : public QDialog, public Ui::Preview {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Preview(RclMain *m, int sid, // Search Id
|
Preview(RclMain *m, int sid, // Search Id
|
||||||
const HighlightData& hdata) // Search terms etc. for highlighting
|
const HighlightData& hdata) // Search terms etc. for highlighting
|
||||||
: m_rclmain(m), m_searchId(sid), m_hData(hdata) {
|
: m_rclmain(m), m_searchId(sid), m_hData(hdata) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void closeEvent(QCloseEvent *e);
|
virtual void closeEvent(QCloseEvent *e);
|
||||||
@ -130,7 +130,7 @@ public:
|
|||||||
* paragraph when tab exposed etc.
|
* paragraph when tab exposed etc.
|
||||||
*/
|
*/
|
||||||
virtual bool makeDocCurrent(const Rcl::Doc& idoc, int docnum,
|
virtual bool makeDocCurrent(const Rcl::Doc& idoc, int docnum,
|
||||||
bool sametab = false);
|
bool sametab = false);
|
||||||
void emitWordSelect(QString);
|
void emitWordSelect(QString);
|
||||||
friend class PreviewTextEdit;
|
friend class PreviewTextEdit;
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ public slots:
|
|||||||
virtual void searchTextChanged(const QString& text);
|
virtual void searchTextChanged(const QString& text);
|
||||||
virtual void searchTextFromIndex(int);
|
virtual void searchTextFromIndex(int);
|
||||||
virtual void doSearch(const QString& str, bool next, bool reverse,
|
virtual void doSearch(const QString& str, bool next, bool reverse,
|
||||||
bool wo = false);
|
bool wo = false);
|
||||||
virtual void nextPressed();
|
virtual void nextPressed();
|
||||||
virtual void prevPressed();
|
virtual void prevPressed();
|
||||||
|
|
||||||
@ -151,6 +151,7 @@ public slots:
|
|||||||
virtual void emitShowPrev();
|
virtual void emitShowPrev();
|
||||||
|
|
||||||
virtual void emitSaveDocToFile();
|
virtual void emitSaveDocToFile();
|
||||||
|
virtual void emitEditRequested();
|
||||||
virtual void togglePlainPre();
|
virtual void togglePlainPre();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -161,6 +162,7 @@ signals:
|
|||||||
void previewExposed(Preview *w, int sid, int docnum);
|
void previewExposed(Preview *w, int sid, int docnum);
|
||||||
void printCurrentPreviewRequest();
|
void printCurrentPreviewRequest();
|
||||||
void saveDocToFile(Rcl::Doc);
|
void saveDocToFile(Rcl::Doc);
|
||||||
|
void editRequested(Rcl::Doc);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RclMain *m_rclmain;
|
RclMain *m_rclmain;
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2005 J.F.Dockes
|
/* Copyright (C) 2005-2019 J.F.Dockes
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
@ -33,10 +33,10 @@ void RclMain::previewClosed(Preview *w)
|
|||||||
{
|
{
|
||||||
LOGDEB("RclMain::previewClosed(" << w << ")\n");
|
LOGDEB("RclMain::previewClosed(" << w << ")\n");
|
||||||
if (w == curPreview) {
|
if (w == curPreview) {
|
||||||
LOGDEB("Active preview closed\n");
|
LOGDEB("Active preview closed\n");
|
||||||
curPreview = 0;
|
curPreview = 0;
|
||||||
} else {
|
} else {
|
||||||
LOGDEB("Old preview closed\n");
|
LOGDEB("Old preview closed\n");
|
||||||
}
|
}
|
||||||
delete w;
|
delete w;
|
||||||
}
|
}
|
||||||
@ -144,37 +144,39 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
|
|||||||
zg_send_event(ZGSEND_PREVIEW, doc);
|
zg_send_event(ZGSEND_PREVIEW, doc);
|
||||||
|
|
||||||
if (mod & Qt::ShiftModifier) {
|
if (mod & Qt::ShiftModifier) {
|
||||||
// User wants new preview window
|
// User wants new preview window
|
||||||
curPreview = 0;
|
curPreview = 0;
|
||||||
}
|
}
|
||||||
if (curPreview == 0) {
|
if (curPreview == 0) {
|
||||||
HighlightData hdata;
|
HighlightData hdata;
|
||||||
m_source->getTerms(hdata);
|
m_source->getTerms(hdata);
|
||||||
curPreview = new Preview(this, reslist->listId(), hdata);
|
curPreview = new Preview(this, reslist->listId(), hdata);
|
||||||
|
|
||||||
if (curPreview == 0) {
|
if (curPreview == 0) {
|
||||||
QMessageBox::warning(0, tr("Warning"),
|
QMessageBox::warning(0, tr("Warning"),
|
||||||
tr("Can't create preview window"),
|
tr("Can't create preview window"),
|
||||||
QMessageBox::Ok,
|
QMessageBox::Ok,
|
||||||
QMessageBox::NoButton);
|
QMessageBox::NoButton);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connect(new QShortcut(quitKeySeq, curPreview), SIGNAL (activated()),
|
connect(new QShortcut(quitKeySeq, curPreview), SIGNAL (activated()),
|
||||||
this, SLOT (fileExit()));
|
this, SLOT (fileExit()));
|
||||||
connect(curPreview, SIGNAL(previewClosed(Preview *)),
|
connect(curPreview, SIGNAL(previewClosed(Preview *)),
|
||||||
this, SLOT(previewClosed(Preview *)));
|
this, SLOT(previewClosed(Preview *)));
|
||||||
connect(curPreview, SIGNAL(wordSelect(QString)),
|
connect(curPreview, SIGNAL(wordSelect(QString)),
|
||||||
sSearch, SLOT(addTerm(QString)));
|
sSearch, SLOT(addTerm(QString)));
|
||||||
connect(curPreview, SIGNAL(showNext(Preview *, int, int)),
|
connect(curPreview, SIGNAL(showNext(Preview *, int, int)),
|
||||||
this, SLOT(previewNextInTab(Preview *, int, int)));
|
this, SLOT(previewNextInTab(Preview *, int, int)));
|
||||||
connect(curPreview, SIGNAL(showPrev(Preview *, int, int)),
|
connect(curPreview, SIGNAL(showPrev(Preview *, int, int)),
|
||||||
this, SLOT(previewPrevInTab(Preview *, int, int)));
|
this, SLOT(previewPrevInTab(Preview *, int, int)));
|
||||||
connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)),
|
connect(curPreview, SIGNAL(previewExposed(Preview *, int, int)),
|
||||||
this, SLOT(previewExposed(Preview *, int, int)));
|
this, SLOT(previewExposed(Preview *, int, int)));
|
||||||
connect(curPreview, SIGNAL(saveDocToFile(Rcl::Doc)),
|
connect(curPreview, SIGNAL(saveDocToFile(Rcl::Doc)),
|
||||||
this, SLOT(saveDocToFile(Rcl::Doc)));
|
this, SLOT(saveDocToFile(Rcl::Doc)));
|
||||||
curPreview->setWindowTitle(getQueryDescription());
|
connect(curPreview, SIGNAL(editRequested(Rcl::Doc)),
|
||||||
curPreview->show();
|
this, SLOT(startNativeViewer(Rcl::Doc)));
|
||||||
|
curPreview->setWindowTitle(getQueryDescription());
|
||||||
|
curPreview->show();
|
||||||
}
|
}
|
||||||
curPreview->makeDocCurrent(doc, docnum);
|
curPreview->makeDocCurrent(doc, docnum);
|
||||||
}
|
}
|
||||||
@ -190,16 +192,16 @@ void RclMain::startPreview(Rcl::Doc doc)
|
|||||||
{
|
{
|
||||||
Preview *preview = new Preview(this, 0, HighlightData());
|
Preview *preview = new Preview(this, 0, HighlightData());
|
||||||
if (preview == 0) {
|
if (preview == 0) {
|
||||||
QMessageBox::warning(0, tr("Warning"),
|
QMessageBox::warning(0, tr("Warning"),
|
||||||
tr("Can't create preview window"),
|
tr("Can't create preview window"),
|
||||||
QMessageBox::Ok,
|
QMessageBox::Ok,
|
||||||
QMessageBox::NoButton);
|
QMessageBox::NoButton);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
connect(new QShortcut(quitKeySeq, preview), SIGNAL (activated()),
|
connect(new QShortcut(quitKeySeq, preview), SIGNAL (activated()),
|
||||||
this, SLOT (fileExit()));
|
this, SLOT (fileExit()));
|
||||||
connect(preview, SIGNAL(wordSelect(QString)),
|
connect(preview, SIGNAL(wordSelect(QString)),
|
||||||
sSearch, SLOT(addTerm(QString)));
|
sSearch, SLOT(addTerm(QString)));
|
||||||
// Do the zeitgeist thing
|
// Do the zeitgeist thing
|
||||||
zg_send_event(ZGSEND_PREVIEW, doc);
|
zg_send_event(ZGSEND_PREVIEW, doc);
|
||||||
preview->show();
|
preview->show();
|
||||||
@ -225,28 +227,28 @@ void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt)
|
|||||||
", listId " << reslist->listId() << "\n");
|
", listId " << reslist->listId() << "\n");
|
||||||
|
|
||||||
if (w == 0) // ??
|
if (w == 0) // ??
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (sid != reslist->listId()) {
|
if (sid != reslist->listId()) {
|
||||||
QMessageBox::warning(0, "Recoll",
|
QMessageBox::warning(0, "Recoll",
|
||||||
tr("This search is not active any more"));
|
tr("This search is not active any more"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nxt)
|
if (nxt)
|
||||||
docnum++;
|
docnum++;
|
||||||
else
|
else
|
||||||
docnum--;
|
docnum--;
|
||||||
if (docnum < 0 || !m_source || docnum >= m_source->getResCnt()) {
|
if (docnum < 0 || !m_source || docnum >= m_source->getResCnt()) {
|
||||||
QApplication::beep();
|
QApplication::beep();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 from database"));
|
tr("Cannot retrieve document info from database"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
w->makeDocCurrent(doc, docnum, true);
|
w->makeDocCurrent(doc, docnum, true);
|
||||||
@ -259,8 +261,7 @@ void RclMain::previewExposed(Preview *, int sid, int docnum)
|
|||||||
LOGDEB2("RclMain::previewExposed: sid " << sid << " docnum " << docnum <<
|
LOGDEB2("RclMain::previewExposed: sid " << sid << " docnum " << docnum <<
|
||||||
", m_sid " << reslist->listId() << "\n");
|
", m_sid " << reslist->listId() << "\n");
|
||||||
if (sid != reslist->listId()) {
|
if (sid != reslist->listId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reslist->previewExposed(docnum);
|
reslist->previewExposed(docnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user