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>
</spacer>
</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>
</item>
</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
* it under the terms of the GNU General Public License as published by
* 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(prevPB, SIGNAL(clicked()), this, SLOT(prevPressed()));
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(tabCloseRequested(int)), this, SLOT(closeTab(int)));
@ -276,7 +277,7 @@ void Preview::searchTextFromIndex(int idx)
m_searchTextFromIndex = idx;
}
// Save current document to file
void Preview::emitSaveDocToFile()
{
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
// 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,
@ -924,11 +933,12 @@ void PreviewTextEdit::createPopupMenu(const QPoint& pos)
popup->addAction(tr("Preserve indentation"),
m_preview, SLOT(togglePlainPre()));
}
// Need to check ipath until we fix the internfile bug that always
// has it convert to html for top level docs
if (!m_dbdoc.url.empty() && !m_dbdoc.ipath.empty())
if (!m_dbdoc.url.empty()) {
popup->addAction(tr("Save document to file"),
m_preview, SLOT(emitSaveDocToFile()));
popup->addAction(tr("Open document"),
m_preview, SLOT(emitEditRequested()));
}
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
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@ -151,6 +151,7 @@ public slots:
virtual void emitShowPrev();
virtual void emitSaveDocToFile();
virtual void emitEditRequested();
virtual void togglePlainPre();
signals:
@ -161,6 +162,7 @@ signals:
void previewExposed(Preview *w, int sid, int docnum);
void printCurrentPreviewRequest();
void saveDocToFile(Rcl::Doc);
void editRequested(Rcl::Doc);
private:
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
* it under the terms of the GNU General Public License as published by
* 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)));
connect(curPreview, SIGNAL(saveDocToFile(Rcl::Doc)),
this, SLOT(saveDocToFile(Rcl::Doc)));
connect(curPreview, SIGNAL(editRequested(Rcl::Doc)),
this, SLOT(startNativeViewer(Rcl::Doc)));
curPreview->setWindowTitle(getQueryDescription());
curPreview->show();
}
@ -263,4 +265,3 @@ void RclMain::previewExposed(Preview *, int sid, int docnum)
}
reslist->previewExposed(docnum);
}