diff --git a/CMakeLists.txt b/CMakeLists.txt index 333e292f0..13ba209bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,6 +231,10 @@ if(NOT DEFINED APPDATADIR) endif() endif() +if(DEFINED LENSFUNDBDIR AND NOT IS_ABSOLUTE "${LENSFUNDBDIR}") + set(LENSFUNDBDIR "${DATADIR}/${LENSFUNDBDIR}") +endif() + # Enforce absolute paths for non-bundle builds: if(NOT BUILD_BUNDLE) foreach(path BINDIR DATADIR LIBDIR DOCDIR CREDITSDIR LICENCEDIR) diff --git a/rtengine/init.cc b/rtengine/init.cc index 7ef40f43a..7ac4ca35b 100644 --- a/rtengine/init.cc +++ b/rtengine/init.cc @@ -51,7 +51,7 @@ int init (const Settings* s, Glib::ustring baseDir, Glib::ustring userSettingsDi Color::init (); PerceptualToneCurve::init (); RawImageSource::init (); - LFDatabase::init(); + LFDatabase::init(s->lensfunDbDirectory); delete lcmsMutex; lcmsMutex = new MyMutex; dfm.init( s->darkFramesPath ); diff --git a/rtengine/rtlensfun.cc b/rtengine/rtlensfun.cc index 87a7272e9..a352613ab 100644 --- a/rtengine/rtlensfun.cc +++ b/rtengine/rtlensfun.cc @@ -175,7 +175,7 @@ float LFCamera::getCropFactor() const Glib::ustring LFCamera::getDisplayString() const { if (data_) { - return Glib::ustring::compose("%1 %2", getMake(), getModel()); + return getMake() + ' ' + getModel(); } else { return "---"; } @@ -211,7 +211,7 @@ Glib::ustring LFLens::getMake() const Glib::ustring LFLens::getLens() const { if (data_) { - return Glib::ustring::compose("%1 %2", data_->Maker, data_->Model); + return Glib::ustring(data_->Maker) + ' ' + data_->Model; } else { return "---"; } @@ -253,10 +253,27 @@ bool LFLens::hasDistortionCorrection() const LFDatabase LFDatabase::instance_; -bool LFDatabase::init() +bool LFDatabase::init(const Glib::ustring &dbdir) { instance_.data_ = lfDatabase::Create(); - return instance_.data_->Load() != LF_NO_ERROR; + + if (settings->verbose) { + std::cout << "Loading lensfun database from "; + if (dbdir.empty()) { + std::cout << "the default directories"; + } else { + std::cout << "'" << dbdir << "'"; + } + std::cout << "..." << std::flush; + } + + bool ok = dbdir.empty() ? (instance_.data_->Load() == LF_NO_ERROR) : instance_.data_->LoadDirectory(dbdir.c_str()); + + if (settings->verbose) { + std::cout << (ok ? "OK" : "FAIL") << std::endl; + } + + return ok; } diff --git a/rtengine/rtlensfun.h b/rtengine/rtlensfun.h index 5774968ee..a4ff17ae9 100644 --- a/rtengine/rtlensfun.h +++ b/rtengine/rtlensfun.h @@ -100,7 +100,7 @@ class LFDatabase final : public NonCopyable { public: - static bool init(); + static bool init(const Glib::ustring &dbdir); static const LFDatabase *getInstance(); ~LFDatabase(); diff --git a/rtengine/settings.h b/rtengine/settings.h index 663354453..b13c1165a 100644 --- a/rtengine/settings.h +++ b/rtengine/settings.h @@ -100,6 +100,8 @@ public: double reduclow; + Glib::ustring lensfunDbDirectory; ///< The directory containing the lensfun database. If empty, the system defaults will be used (as described in http://lensfun.sourceforge.net/manual/dbsearch.html) + /** Creates a new instance of Settings. * @return a pointer to the new Settings instance. */ static Settings* create (); diff --git a/rtgui/config.h.in b/rtgui/config.h.in index cab481278..fdf64b73c 100644 --- a/rtgui/config.h.in +++ b/rtgui/config.h.in @@ -25,5 +25,6 @@ #define DOC_SEARCH_PATH "${DOCDIR}" #define CREDITS_SEARCH_PATH "${CREDITSDIR}" #define LICENCE_SEARCH_PATH "${LICENCEDIR}" +#define LENSFUN_DB_PATH "${LENSFUNDBDIR}" #endif diff --git a/rtgui/options.cc b/rtgui/options.cc index b13ace249..2b23e6ef6 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -24,6 +24,7 @@ #include "addsetids.h" #include "guiutils.h" #include "version.h" +#include "config.h" #ifdef _OPENMP #include @@ -744,6 +745,8 @@ void Options::setDefaults () lastLensProfileDir = ""; gimpPluginShowInfoDialog = true; maxRecentFolders = 15; + + rtSettings.lensfunDbDirectory = LENSFUN_DB_PATH; } Options* Options::copyFrom (Options* other) @@ -1920,6 +1923,12 @@ void Options::readFromFile (Glib::ustring fname) } } + if (keyFile.has_group ("Lensfun")) { + if (keyFile.has_key ("Lensfun", "DBDirectory")) { + rtSettings.lensfunDbDirectory = keyFile.get_string ("Lensfun", "DBDirectory"); + } + } + // -------------------------------------------------------------------------------------------------------- filterOutParsedExtensions (); @@ -2302,6 +2311,8 @@ void Options::saveToFile (Glib::ustring fname) keyFile.set_string ("Dialogs", "LastLensProfileDir", lastLensProfileDir); keyFile.set_boolean ("Dialogs", "GimpPluginShowInfoDialog", gimpPluginShowInfoDialog); + keyFile.set_string ("Lensfun", "DBDirectory", rtSettings.lensfunDbDirectory); + keyData = keyFile.to_data (); } catch (Glib::KeyFileError &e) { diff --git a/rtgui/paramsedited.cc b/rtgui/paramsedited.cc index ac6bbcdef..0fac5c97d 100644 --- a/rtgui/paramsedited.cc +++ b/rtgui/paramsedited.cc @@ -3603,7 +3603,7 @@ bool RAWParamsEdited::isUnchanged() const bool LensProfParamsEdited::isUnchanged() const { - return lcpFile; + return lcpFile && useVign && lfLens; } bool RetinexParamsEdited::isUnchanged() const