]> git.lyx.org Git - features.git/commitdiff
Fix bug #6134: Reload context menu for graphics inset.
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 13 Aug 2009 17:21:59 +0000 (17:21 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Thu, 13 Aug 2009 17:21:59 +0000 (17:21 +0000)
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

lib/ui/stdcontext.inc
src/FuncCode.h
src/LyXAction.cpp
src/graphics/GraphicsCacheItem.cpp
src/graphics/GraphicsLoader.cpp
src/graphics/GraphicsLoader.h
src/insets/InsetGraphics.cpp
src/insets/RenderGraphic.cpp
src/insets/RenderGraphic.h

index aef2b4b71944d807a069400edc823846c57f383a..efb80d526fc1521fca964fcc9af3c7e511ea96a5 100644 (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
index 52ee7739b9eee5d0d3589943a653a4579b3abc95..b6c984c9a8a3e9aeb918f97bac1dd49b84734492 100644 (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
 };
index e1860cb3cedca55bf6f2a16fac10a3d0b3900c1c..b0a3a03571898fd3f8c2fb40b053ba030140b634 100644 (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
        };
index 0bac4b559ea801e694dea2de52467a861cef82dc..b9bc390b5262c2b9a8a6a711381977117ef58332 100644 (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;
index ecc9cd9e03959374d33b429257217ff351303ffe..ac5d614c6e5a0d370a08d2db22b56f77421597a1 100644 (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())
index 43fd85e69590f48493f23c9664317df9f1333f8e..65218505b0254121794466ab036f6992530d4234 100644 (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.
index 2ef6d47287368fecd8e458ae6e5aeee0eb54c6ea..686fa47940adb487c7b08ea82365e6f9b5ba3908 100644 (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;
 
index bca3a518f8dd2489f7ea2bce2810bf6f2499058f..fba651ccdcfdacb14f239432e6c7b56493d7772b 100644 (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)
 {
index 5edb7ce9400cac49cf38c3efc6c2cd87ddfb8ecb..b41b82e61aa1c33753dd18e29d0cb34b2dadecab 100644 (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; }