Fix bug #6134: Reload context menu for graphics inset.

This shouldn't be necessary, but sometimes it is.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31014 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2009-08-13 17:21:59 +00:00
parent 603a1c545c
commit 770aa71839
9 changed files with 35 additions and 0 deletions

View File

@ -358,6 +358,7 @@ Menuset
Menu "context-graphics"
Item "Settings...|S" "inset-settings"
Item "Reload...|U" "graphics-reload"
Separator
Item "Edit Externally...|x" "inset-edit"
Separator

View File

@ -440,6 +440,7 @@ enum FuncCode
// 340
LFUN_BRANCHES_RENAME, // spitz 20090709
LFUN_BUFFER_CLOSE_ALL, // vfr 20090806
LFUN_GRAPHICS_RELOAD, // vfr 20090810
LFUN_LASTACTION // end of the table
};

View File

@ -3403,6 +3403,16 @@ void LyXAction::init()
*/
{ LFUN_SECTION_SELECT, "section-select", ReadOnly, Edit },
/*!
* \var lyx::FuncCode lyx::LFUN_GRAPHICS_RELOAD
* \li Action: Reloads the image if necessary.
* \li Syntax: graphics-reload
* \li Origin: vfr, 10 Aug 2009
* \endvar
*/
{ LFUN_GRAPHICS_RELOAD, "graphics-reload", ReadOnly | AtPoint, Edit },
{ LFUN_NOACTION, "", Noop, Hidden }
#ifndef DOXYGEN_SHOULD_SKIP_THIS
};

View File

@ -349,6 +349,8 @@ static string const findTargetFormat(string const & from)
bool CacheItem::Impl::tryDisplayFormat(FileName & filename, string & from)
{
// First, check that the file exists!
// force a refresh.
filename_.lastModified();
if (!filename_.isReadableFile()) {
if (status_ != ErrorNoFile) {
status_ = ErrorNoFile;

View File

@ -279,6 +279,12 @@ void Loader::startLoading() const
}
void Loader::reload() const
{
pimpl_->cached_item_->startLoading();
}
void Loader::startMonitoring() const
{
if (!pimpl_->cached_item_.get())

View File

@ -68,6 +68,10 @@ public:
*/
void startLoading() const;
/** Tries to reload the image.
*/
void reload() const;
/** Monitor any changes to the file.
* There is no point monitoring the file before startLoading() is
* invoked.

View File

@ -216,6 +216,10 @@ void InsetGraphics::doDispatch(Cursor & cur, FuncRequest & cmd)
cur.bv().updateDialog("graphics", params2string(params(), buffer()));
break;
case LFUN_GRAPHICS_RELOAD:
graphic_->reload();
break;
default:
Inset::doDispatch(cur, cmd);
break;
@ -230,6 +234,7 @@ bool InsetGraphics::getStatus(Cursor & cur, FuncRequest const & cmd,
case LFUN_INSET_EDIT:
case LFUN_INSET_MODIFY:
case LFUN_INSET_DIALOG_UPDATE:
case LFUN_GRAPHICS_RELOAD:
flag.setEnabled(true);
return true;

View File

@ -52,6 +52,10 @@ RenderBase * RenderGraphic::clone(Inset const * inset) const
return new RenderGraphic(*this, inset);
}
void RenderGraphic::reload() const
{
loader_.reload();
}
void RenderGraphic::update(graphics::Params const & params)
{

View File

@ -35,6 +35,8 @@ public:
/// Refresh the info about which file to display and how to display it.
void update(graphics::Params const & params);
/// Reloads the image if necessary
void reload() const;
/// equivalent to dynamic_cast
virtual RenderGraphic * asGraphic() { return this; }