GUI: preview: add Open popup entry and Open button for starting native viewer on current doc

This commit is contained in:
Jean-Francois Dockes 2019-05-14 09:41:08 +02:00
parent 34d43d1188
commit 824a1d3ebf
4 changed files with 91 additions and 64 deletions

View File

@ -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>

View File

@ -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));
} }

View File

@ -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
@ -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;

View File

@ -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
@ -173,6 +173,8 @@ void RclMain::startPreview(int docnum, Rcl::Doc doc, int mod)
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)));
connect(curPreview, SIGNAL(editRequested(Rcl::Doc)),
this, SLOT(startNativeViewer(Rcl::Doc)));
curPreview->setWindowTitle(getQueryDescription()); curPreview->setWindowTitle(getQueryDescription());
curPreview->show(); curPreview->show();
} }
@ -263,4 +265,3 @@ void RclMain::previewExposed(Preview *, int sid, int docnum)
} }
reslist->previewExposed(docnum); reslist->previewExposed(docnum);
} }