Merge branch 'dev' into metadata-exiv2

This commit is contained in:
Lawrence Lee
2023-04-19 21:14:54 -07:00
10 changed files with 124 additions and 45 deletions

View File

@@ -876,6 +876,7 @@ void Options::readFromFile(Glib::ustring fname)
if (keyFile.has_group("External Editor")) {
if (keyFile.has_key("External Editor", "Names")
|| keyFile.has_key("External Editor", "Commands")
|| keyFile.has_key("External Editor", "NativeCommands")
|| keyFile.has_key("External Editor", "IconsSerialized")) {
// Multiple external editors.
@@ -889,6 +890,11 @@ void Options::readFromFile(Glib::ustring fname)
std::vector<Glib::ustring>() :
static_cast<std::vector<Glib::ustring>>(
keyFile.get_string_list("External Editor", "Commands"));
const auto & native_commands =
!keyFile.has_key("External Editor", "NativeCommands") ?
std::vector<bool>() :
static_cast<std::vector<bool>>(
keyFile.get_boolean_list("External Editor", "NativeCommands"));
const auto & icons_serialized =
!keyFile.has_key("External Editor", "IconsSerialized") ?
std::vector<Glib::ustring>() :
@@ -902,6 +908,9 @@ void Options::readFromFile(Glib::ustring fname)
for (unsigned i = 0; i < commands.size(); i++) {
externalEditors[i].command = commands[i];
}
for (unsigned i = 0; i < native_commands.size(); i++) {
externalEditors[i].native_command = native_commands[i];
}
for (unsigned i = 0; i < icons_serialized.size(); i++) {
externalEditors[i].icon_serialized = icons_serialized[i];
}
@@ -941,7 +950,7 @@ void Options::readFromFile(Glib::ustring fname)
if (editorToSendTo == 1) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("GIMP", "\"" + executable + "\"", getIconSerialized(executable)));
externalEditors.emplace_back("GIMP", executable, true, getIconSerialized(executable));
} else {
for (auto ver = 12; ver >= 0; --ver) {
executable = Glib::build_filename(gimpDir, "bin", Glib::ustring::compose(Glib::ustring("gimp-2.%1.exe"), ver));
@@ -949,7 +958,7 @@ void Options::readFromFile(Glib::ustring fname)
if (editorToSendTo == 1) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("GIMP", "\"" + executable + "\"", getIconSerialized(executable)));
externalEditors.emplace_back("GIMP", executable, true, getIconSerialized(executable));
break;
}
}
@@ -964,7 +973,7 @@ void Options::readFromFile(Glib::ustring fname)
if (editorToSendTo == 2) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("Photoshop", "\"" + executable + "\"", getIconSerialized(executable)));
externalEditors.emplace_back("Photoshop", executable, true, getIconSerialized(executable));
}
if (keyFile.has_key("External Editor", "CustomEditor")) {
@@ -973,20 +982,20 @@ void Options::readFromFile(Glib::ustring fname)
if (editorToSendTo == 3) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("-", "\"" + executable + "\"", ""));
externalEditors.emplace_back("-", executable, true, "");
}
}
#elif defined __APPLE__
if (editorToSendTo == 1) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("GIMP", "open -a GIMP", "gimp"));
externalEditors.push_back(ExternalEditor("GIMP-dev", "open -a GIMP-dev", "gimp"));
externalEditors.emplace_back("GIMP", "open -a GIMP", true, "");
externalEditors.emplace_back("GIMP-dev", "open -a GIMP-dev", true, "");
if (editorToSendTo == 2) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("Photoshop", "open -a Photoshop", ""));
externalEditors.emplace_back("Photoshop", "open -a Photoshop", true, "");
if (keyFile.has_key("External Editor", "CustomEditor")) {
auto executable = keyFile.get_string("External Editor", "CustomEditor");
@@ -994,20 +1003,21 @@ void Options::readFromFile(Glib::ustring fname)
if (editorToSendTo == 3) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("-", executable, ""));
externalEditors.emplace_back("-", executable, true, "");
}
}
#else
const Glib::ustring gimp_icon_serialized = "('themed', <['gimp', 'gimp-symbolic']>)";
if (Glib::find_program_in_path("gimp").compare("")) {
if (editorToSendTo == 1) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("GIMP", "gimp", "gimp"));
externalEditors.emplace_back("GIMP", "gimp", true, gimp_icon_serialized);
} else if (Glib::find_program_in_path("gimp-remote").compare("")) {
if (editorToSendTo == 1) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("GIMP", "gimp-remote", "gimp"));
externalEditors.emplace_back("GIMP", "gimp-remote", true, gimp_icon_serialized);
}
if (keyFile.has_key("External Editor", "CustomEditor")) {
@@ -1016,7 +1026,7 @@ void Options::readFromFile(Glib::ustring fname)
if (editorToSendTo == 3) {
externalEditorIndex = externalEditors.size();
}
externalEditors.push_back(ExternalEditor("-", executable, ""));
externalEditors.emplace_back("-", executable, true, "");
}
}
#endif
@@ -2352,16 +2362,19 @@ void Options::saveToFile(Glib::ustring fname)
{
std::vector<Glib::ustring> names;
std::vector<Glib::ustring> commands;
std::vector<bool> native_commands;
std::vector<Glib::ustring> icons_serialized;
for (const auto & editor : externalEditors) {
names.push_back(editor.name);
commands.push_back(editor.command);
native_commands.push_back(editor.native_command);
icons_serialized.push_back(editor.icon_serialized);
}
keyFile.set_string_list("External Editor", "Names", names);
keyFile.set_string_list("External Editor", "Commands", commands);
keyFile.set_boolean_list("External Editor", "NativeCommands", native_commands);
keyFile.set_string_list("External Editor", "IconsSerialized", icons_serialized);
keyFile.set_integer("External Editor", "EditorIndex", externalEditorIndex);
@@ -3052,15 +3065,15 @@ Glib::ustring Options::getICCProfileCopyright()
return Glib::ustring::compose("Copyright RawTherapee %1, CC0", now.get_year());
}
ExternalEditor::ExternalEditor() {}
ExternalEditor::ExternalEditor() = default;
ExternalEditor::ExternalEditor(
const Glib::ustring &name, const Glib::ustring &command, const Glib::ustring &icon_serialized
): name(name), command(command), icon_serialized(icon_serialized) {}
const Glib::ustring &name, const Glib::ustring &command, bool native_command, const Glib::ustring &icon_serialized
): name(name), command(command), native_command(native_command), icon_serialized(icon_serialized) {}
bool ExternalEditor::operator==(const ExternalEditor &other) const
{
return this->name == other.name && this->command == other.command && this->icon_serialized == other.icon_serialized;
return this->name == other.name && this->command == other.command && this->native_command == other.native_command && this->icon_serialized == other.icon_serialized;
}
bool ExternalEditor::operator!=(const ExternalEditor &other) const