merge branch 'user-dcp-profiles-dir'
This commit is contained in:
commit
09b5dca08d
@ -1795,51 +1795,51 @@ void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll)
|
||||
file_std_profiles.clear();
|
||||
|
||||
if (!loadAll) {
|
||||
profileDir.assign (rt_profile_dir);
|
||||
profileDir = { rt_profile_dir, Glib::build_filename(options.rtdir, "dcpprofiles") };
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rt_profile_dir.empty()) {
|
||||
std::deque<Glib::ustring> dirs = {
|
||||
rt_profile_dir
|
||||
};
|
||||
std::deque<Glib::ustring> dirs = {
|
||||
rt_profile_dir,
|
||||
Glib::build_filename(options.rtdir, "dcpprofiles")
|
||||
};
|
||||
|
||||
while (!dirs.empty()) {
|
||||
// Process directory
|
||||
const Glib::ustring dirname = dirs.back();
|
||||
dirs.pop_back();
|
||||
while (!dirs.empty()) {
|
||||
// Process directory
|
||||
const Glib::ustring dirname = dirs.back();
|
||||
dirs.pop_back();
|
||||
|
||||
std::unique_ptr<Glib::Dir> dir;
|
||||
std::unique_ptr<Glib::Dir> dir;
|
||||
|
||||
try {
|
||||
if (!Glib::file_test(dirname, Glib::FILE_TEST_IS_DIR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dir.reset(new Glib::Dir(dirname));
|
||||
} catch (Glib::Exception& exception) {
|
||||
try {
|
||||
if (!Glib::file_test(dirname, Glib::FILE_TEST_IS_DIR)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (const Glib::ustring& sname : *dir) {
|
||||
const Glib::ustring fname = Glib::build_filename(dirname, sname);
|
||||
dir.reset(new Glib::Dir(dirname));
|
||||
} catch (Glib::Exception& exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Glib::file_test(fname, Glib::FILE_TEST_IS_DIR)) {
|
||||
// File
|
||||
const auto lastdot = sname.rfind('.');
|
||||
for (const Glib::ustring& sname : *dir) {
|
||||
const Glib::ustring fname = Glib::build_filename(dirname, sname);
|
||||
|
||||
if (
|
||||
lastdot != Glib::ustring::npos
|
||||
&& lastdot <= sname.size() - 4
|
||||
&& !sname.casefold().compare(lastdot, 4, ".dcp")
|
||||
if (!Glib::file_test(fname, Glib::FILE_TEST_IS_DIR)) {
|
||||
// File
|
||||
const auto lastdot = sname.rfind('.');
|
||||
|
||||
if (
|
||||
lastdot != Glib::ustring::npos
|
||||
&& lastdot <= sname.size() - 4
|
||||
&& !sname.casefold().compare(lastdot, 4, ".dcp")
|
||||
) {
|
||||
const Glib::ustring cam_short_name = sname.substr(0, lastdot).uppercase();
|
||||
file_std_profiles[cam_short_name] = fname; // They will be loaded and cached on demand
|
||||
}
|
||||
} else {
|
||||
// Directory
|
||||
dirs.push_front(fname);
|
||||
const Glib::ustring cam_short_name = sname.substr(0, lastdot).uppercase();
|
||||
file_std_profiles[cam_short_name] = fname; // They will be loaded and cached on demand
|
||||
}
|
||||
} else {
|
||||
// Directory
|
||||
dirs.push_front(fname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1850,7 +1850,6 @@ void DCPStore::init(const Glib::ustring& rt_profile_dir, bool loadAll)
|
||||
|
||||
if (real != file_std_profiles.end()) {
|
||||
file_std_profiles[alias_name] = real->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1907,11 +1906,13 @@ DCPProfile* DCPStore::getStdProfile(const Glib::ustring& requested_cam_short_nam
|
||||
}
|
||||
|
||||
// profile not found, looking if we're in loadAll=false mode
|
||||
if (!profileDir.empty()) {
|
||||
const Glib::ustring fname = Glib::build_filename(profileDir, requested_cam_short_name + Glib::ustring(".dcp"));
|
||||
for (const auto &dir : profileDir) {
|
||||
if (!dir.empty()) {
|
||||
const Glib::ustring fname = Glib::build_filename(dir, requested_cam_short_name + Glib::ustring(".dcp"));
|
||||
|
||||
if (Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) {
|
||||
return getProfile(fname);
|
||||
if (Glib::file_test(fname, Glib::FILE_TEST_EXISTS)) {
|
||||
return getProfile(fname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ private:
|
||||
DCPStore() = default;
|
||||
|
||||
mutable MyMutex mutex;
|
||||
Glib::ustring profileDir;
|
||||
std::vector<Glib::ustring> profileDir;
|
||||
|
||||
// these contain standard profiles from RT. keys are all in uppercase, file path is value
|
||||
std::map<Glib::ustring, Glib::ustring> file_std_profiles;
|
||||
|
@ -334,6 +334,8 @@ public:
|
||||
fileStdProfilesFileNames.clear();
|
||||
if (loadAll) {
|
||||
loadProfiles(stdProfilesDir, nullptr, nullptr, &fileStdProfilesFileNames, true);
|
||||
Glib::ustring user_input_icc_dir = Glib::build_filename(options.rtdir, "iccprofiles", "input");
|
||||
loadProfiles(user_input_icc_dir, nullptr, nullptr, &fileStdProfilesFileNames, true);
|
||||
}
|
||||
|
||||
defaultMonitorProfile = settings->monitorProfile;
|
||||
|
Loading…
x
Reference in New Issue
Block a user