Merge branch 'relative_clut_path' into dev

This commit is contained in:
Flössie
2017-02-14 20:50:01 +01:00
2 changed files with 58 additions and 33 deletions

View File

@@ -307,12 +307,17 @@ std::shared_ptr<rtengine::HaldCLUT> rtengine::CLUTStore::getClut(const Glib::ust
{
std::shared_ptr<rtengine::HaldCLUT> result;
if (!cache.get(filename, result)) {
const Glib::ustring full_filename =
!Glib::path_is_absolute(filename)
? Glib::ustring(Glib::build_filename(options.clutsDir, filename))
: filename;
if (!cache.get(full_filename, result)) {
std::unique_ptr<rtengine::HaldCLUT> clut(new rtengine::HaldCLUT);
if (clut->load(filename)) {
if (clut->load(full_filename)) {
result = std::move(clut);
cache.insert(filename, result);
cache.insert(full_filename, result);
}
}

View File

@@ -11,19 +11,31 @@ using namespace rtengine::procparams;
namespace
{
Glib::ustring stripPrefixDir(const Glib::ustring& filename, const Glib::ustring& dir)
{
const Glib::ustring full_dir =
!Glib::str_has_suffix(dir, G_DIR_SEPARATOR_S)
? dir + G_DIR_SEPARATOR_S
: dir;
return
Glib::str_has_prefix(filename, full_dir)
? filename.substr(full_dir.size())
: filename;
}
bool notifySlowParseDir (const std::chrono::system_clock::time_point& startedAt)
{
static enum
{
Undecided,
Cancel,
Continue
}
decision = Undecided;
enum Decision {
UNDECIDED,
CANCEL,
CONTINUE
};
if (decision == Cancel) {
static Decision decision = UNDECIDED;
if (decision == CANCEL) {
return false;
} else if (decision == Continue) {
} else if (decision == CONTINUE) {
return true;
}
@@ -34,10 +46,10 @@ bool notifySlowParseDir (const std::chrono::system_clock::time_point& startedAt)
Gtk::MessageDialog dialog(M("TP_FILMSIMULATION_SLOWPARSEDIR"), false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
if (dialog.run() == Gtk::RESPONSE_YES) {
decision = Cancel;
decision = CANCEL;
return false;
} else {
decision = Continue;
decision = CONTINUE;
return true;
}
}
@@ -116,14 +128,22 @@ void FilmSimulation::read( const rtengine::procparams::ProcParams* pp, const Par
setEnabled(pp->filmSimulation.enabled);
if (!pp->filmSimulation.clutFilename.empty()) {
m_clutComboBox->setSelectedClut( pp->filmSimulation.clutFilename );
m_clutComboBox->setSelectedClut(
!Glib::path_is_absolute(pp->filmSimulation.clutFilename)
? Glib::ustring(Glib::build_filename(options.clutsDir, pp->filmSimulation.clutFilename))
: pp->filmSimulation.clutFilename
);
}
m_strength->setValue(pp->filmSimulation.strength);
if (pedited) {
set_inconsistent (multiImage && !pedited->filmSimulation.enabled);
m_strength->setEditedState (pedited->filmSimulation.strength ? Edited : UnEdited);
m_strength->setEditedState(
pedited->filmSimulation.strength
? Edited
: UnEdited
);
if (!pedited->filmSimulation.clutFilename) {
m_clutComboBox->setSelectedClut("NULL");
@@ -154,10 +174,10 @@ void FilmSimulation::write( rtengine::procparams::ProcParams* pp, ParamsEdited*
}
pp->filmSimulation.enabled = getEnabled();
Glib::ustring clutFName = m_clutComboBox->getSelectedClut();
const Glib::ustring clutFName = m_clutComboBox->getSelectedClut();
if (clutFName != "NULL") { // We do not want to set "NULL" in clutFilename, even if "unedited"
pp->filmSimulation.clutFilename = clutFName;
pp->filmSimulation.clutFilename = stripPrefixDir(clutFName, options.clutsDir);
}
pp->filmSimulation.strength = m_strength->getValue();