From 91f14e0146f82a39ee8f9675e4878596c36fd21c Mon Sep 17 00:00:00 2001 From: Alberto Griggio Date: Fri, 9 Feb 2018 22:20:55 +0100 Subject: [PATCH] added option 'InspectorDelay' to delay generation of inspector previews --- rtgui/inspector.cc | 20 +++++++++++++++++++- rtgui/inspector.h | 5 +++++ rtgui/options.cc | 6 ++++++ rtgui/options.h | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/rtgui/inspector.cc b/rtgui/inspector.cc index 4084e300f..6da62cd3b 100644 --- a/rtgui/inspector.cc +++ b/rtgui/inspector.cc @@ -210,6 +210,23 @@ void Inspector::switchImage (const Glib::ustring &fullPath) return; } + if (delayconn.connected()) { + delayconn.disconnect(); + } + + next_image_path = fullPath; + if (!options.inspectorDelay) { + doSwitchImage(); + } else { + delayconn = Glib::signal_timeout().connect(sigc::mem_fun(*this, &Inspector::doSwitchImage), options.inspectorDelay); + } +} + + +bool Inspector::doSwitchImage() +{ + Glib::ustring fullPath = next_image_path; + // we first check the size of the list, it may have been changed in Preference if (images.size() > size_t(options.maxInspectorBuffers)) { // deleting the last entries @@ -225,7 +242,6 @@ void Inspector::switchImage (const Glib::ustring &fullPath) if (fullPath.empty()) { currImage = nullptr; queue_draw(); - return; } else { bool found = false; @@ -264,6 +280,8 @@ void Inspector::switchImage (const Glib::ustring &fullPath) } } } + + return true; } void Inspector::deleteBuffers () diff --git a/rtgui/inspector.h b/rtgui/inspector.h index f68912dc1..ac8f52ee2 100644 --- a/rtgui/inspector.h +++ b/rtgui/inspector.h @@ -48,9 +48,14 @@ private: double zoom; bool active; + sigc::connection delayconn; + Glib::ustring next_image_path; + bool on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr); void deleteBuffers(); + bool doSwitchImage(); + public: Inspector(); ~Inspector(); diff --git a/rtgui/options.cc b/rtgui/options.cc index dda61419f..2e8d20f96 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -426,6 +426,7 @@ void Options::setDefaults () #endif filledProfile = false; maxInspectorBuffers = 2; // a rather conservative value for low specced systems... + inspectorDelay = 0; serializeTiffRead = true; FileBrowserToolbarSingleRow = false; @@ -1056,6 +1057,10 @@ void Options::readFromFile (Glib::ustring fname) maxInspectorBuffers = keyFile.get_integer ("Performance", "MaxInspectorBuffers"); } + if (keyFile.has_key ("Performance", "InspectorDelay")) { + inspectorDelay = keyFile.get_integer("Performance", "InspectorDelay"); + } + if (keyFile.has_key ("Performance", "PreviewDemosaicFromSidecar")) { prevdemo = (prevdemo_t)keyFile.get_integer ("Performance", "PreviewDemosaicFromSidecar"); } @@ -1847,6 +1852,7 @@ void Options::saveToFile (Glib::ustring fname) keyFile.set_integer ("Performance", "SIMPLNRAUT", rtSettings.leveldnautsimpl); keyFile.set_integer ("Performance", "ClutCacheSize", clutCacheSize); keyFile.set_integer ("Performance", "MaxInspectorBuffers", maxInspectorBuffers); + keyFile.set_integer ("Performance", "InspectorDelay", inspectorDelay); keyFile.set_integer ("Performance", "PreviewDemosaicFromSidecar", prevdemo); keyFile.set_boolean ("Performance", "Daubechies", rtSettings.daubech); keyFile.set_boolean ("Performance", "SerializeTiffRead", serializeTiffRead); diff --git a/rtgui/options.h b/rtgui/options.h index a5eef1543..920968956 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -275,6 +275,7 @@ public: Glib::ustring clutsDir; int rgbDenoiseThreadLimit; // maximum number of threads for the denoising tool ; 0 = use the maximum available int maxInspectorBuffers; // maximum number of buffers (i.e. images) for the Inspector feature + int inspectorDelay; int clutCacheSize; bool filledProfile; // Used as reminder for the ProfilePanel "mode" prevdemo_t prevdemo; // Demosaicing method used for the <100% preview