Double fallback implemented (see #4396)

If the user's default profile is not found, it'll fallback to the
bundled one. If this one is not found, it'll fall back to internal
values. No restart required. Only the GUI alert are localized.
This commit is contained in:
Hombre 2018-02-24 14:02:50 +01:00
parent ff021826c6
commit b430ca19a6
6 changed files with 149 additions and 62 deletions

View File

@ -868,8 +868,9 @@ NAVIGATOR_S;S:
NAVIGATOR_V;V:
NAVIGATOR_XY_FULL;Largeur = %1, Hauteur = %2
NAVIGATOR_XY_NA;x = n/d, y = n/d
OPTIONS_DEFIMG_MISSING;Le profil par défaut pour les <b>images standards</b> n'a pas été trouvé ou n'a pas été réglé.\n\nVérifiez également le dossier de vos profils, il peut être manquant ou endommagé\n\n"<b>%1</b>" sera utilisé à la place.
OPTIONS_DEFRAW_MISSING;Le profil par défaut pour les <b>images Raw</b> n'a pas été trouvé ou n'a pas été réglé.\n\nVérifiez également le dossier de vos profils, il peut être manquant ou endommagé\n\n"<b>%1</b>" sera utilisé à la place.
OPTIONS_BUNDLED_MISSING;Le profile fourni "<b>%1</b>" n'a pas été trouvé!\n\nVotre installation peut être endomagé.\n\nLes valeurs internes par défaut seront utilisées à la place.
OPTIONS_DEFIMG_MISSING;Le profil par défaut pour les <b>images standards</b> n'a pas été trouvé ou n'a pas été réglé.\n\nVérifiez le dossier de vos profils, il peut être manquant ou endommagé\n\n"<b>%1</b>" sera utilisé à la place.
OPTIONS_DEFRAW_MISSING;Le profil par défaut pour les <b>images Raw</b> n'a pas été trouvé ou n'a pas été réglé.\n\nVérifiez le dossier de vos profils, il peut être manquant ou endommagé\n\n"<b>%1</b>" sera utilisé à la place.
PARTIALPASTE_ADVANCEDGROUP;Réglages Avancés
PARTIALPASTE_BASICGROUP;Réglages de base
PARTIALPASTE_CACORRECTION;Aberration chromatique

View File

@ -869,6 +869,7 @@ NAVIGATOR_S;S:
NAVIGATOR_V;V:
NAVIGATOR_XY_FULL;Width: %1, Height: %2
NAVIGATOR_XY_NA;x: --, y: --
OPTIONS_BUNDLED_MISSING;The bundled profile "<b>%1</b>" could not be found!\n\nYour installation could be damaged.\n\nDefault internal values will be used instead.
OPTIONS_DEFIMG_MISSING;The default profile for <b>non-raw photos</b> could not be found or is not set.\n\nPlease check your profiles' directory, it may be missing or damaged.\n\n"<b>%1</b>" will be used instead.
OPTIONS_DEFRAW_MISSING;The default profile for <b>raw photos</b> could not be found or is not set.\n\nPlease check your profiles' directory, it may be missing or damaged.\n\n"<b>%1</b>" will be used instead.
PARTIALPASTE_ADVANCEDGROUP;Advanced Settings

View File

@ -163,6 +163,36 @@ int main (int argc, char **argv)
return -2;
}
if (options.is_defProfRawMissing()) {
options.defProfRaw = DEFPROFILE_RAW;
std::cerr << std::endl
<< "The default profile for raw photos could not be found or is not set." << std::endl
<< "Please check your profiles' directory, it may be missing or damaged." << std::endl
<< "\"" << DEFPROFILE_RAW << "\" will be used instead." << std::endl << std::endl;
}
if (options.is_bundledDefProfRawMissing()) {
std::cerr << std::endl
<< "The bundled profile \"" << options.defProfRaw << "\" could not be found!" << std::endl
<< "Your installation could be damaged." << std::endl
<< "Default internal values will be used instead." << std::endl << std::endl;
options.defProfRaw = DEFPROFILE_INTERNAL;
}
if (options.is_defProfImgMissing()) {
options.defProfImg = DEFPROFILE_IMG;
std::cerr << std::endl
<< "The default profile for non-raw photos could not be found or is not set." << std::endl
<< "Please check your profiles' directory, it may be missing or damaged." << std::endl
<< "\"" << DEFPROFILE_IMG << "\" will be used instead." << std::endl << std::endl;
}
if (options.is_bundledDefProfImgMissing()) {
std::cerr << std::endl
<< "The bundled profile " << options.defProfImg << " could not be found!" << std::endl
<< "Your installation could be damaged." << std::endl
<< "Default internal values will be used instead." << std::endl << std::endl;
options.defProfImg = DEFPROFILE_INTERNAL;
}
rtengine::setPaths();
TIFFSetWarningHandler (nullptr); // avoid annoying message boxes

View File

@ -52,8 +52,7 @@ Glib::ustring paramFileExtension = ".pp3";
Options::Options ()
{
defProfRawMissing = false;
defProfImgMissing = false;
defProfError = 0;
setDefaults ();
}
@ -2194,58 +2193,50 @@ void Options::load (bool lightweight)
if (options.defProfRaw.empty()) {
options.defProfRaw = DEFPROFILE_RAW;
} else {
Glib::ustring tmpFName = options.findProfilePath (options.defProfRaw);
if (!tmpFName.empty()) {
if (!options.findProfilePath (options.defProfRaw).empty()) {
if (options.rtSettings.verbose) {
printf ("Default profile for raw images \"%s\" found\n", options.defProfRaw.c_str());
std::cout << "Default profile for raw images \"" << options.defProfRaw << "\" found" << std::endl;
}
} else {
if (options.defProfRaw != DEFPROFILE_RAW) {
if (options.rtSettings.verbose) {
printf ("Default profile for raw images \"%s\" not found or not set -> using RawTherapee's default raw profile\n", options.defProfRaw.c_str());
options.setDefProfRawMissing(true);
Glib::ustring dpr(DEFPROFILE_RAW);
if (options.findProfilePath (dpr).empty()) {
options.setBundledDefProfRawMissing(true);
}
options.defProfRaw = DEFPROFILE_RAW;
} else {
if (options.rtSettings.verbose) {
printf ("Default profile for raw images \"%s\" not found or not set -> using Internal values\n", options.defProfRaw.c_str());
}
options.defProfRaw = DEFPROFILE_INTERNAL;
options.setBundledDefProfRawMissing(true);
}
options.defProfRawMissing = true;
}
}
if (options.defProfImg.empty()) {
options.defProfImg = DEFPROFILE_IMG;
} else {
Glib::ustring tmpFName = options.findProfilePath (options.defProfImg);
if (!tmpFName.empty()) {
if (!options.findProfilePath (options.defProfImg).empty()) {
if (options.rtSettings.verbose) {
printf ("Default profile for non-raw images \"%s\" found\n", options.defProfImg.c_str());
std::cout << "Default profile for non-raw images \"" << options.defProfImg << "\" found" << std::endl;
}
} else {
if (options.defProfImg != DEFPROFILE_IMG) {
if (options.rtSettings.verbose) {
printf ("Default profile for non-raw images \"%s\" not found or not set -> using RawTherapee's default non-raw profile\n", options.defProfImg.c_str());
options.setDefProfImgMissing(true);
Glib::ustring dpi(DEFPROFILE_IMG);
if (options.findProfilePath (dpi).empty()) {
options.setBundledDefProfImgMissing(true);
}
options.defProfImg = DEFPROFILE_IMG;
} else {
if (options.rtSettings.verbose) {
printf ("Default profile for non-raw images \"%s\" not found or not set -> using Internal values\n", options.defProfImg.c_str());
}
options.defProfImg = DEFPROFILE_INTERNAL;
options.setBundledDefProfImgMissing(true);
}
options.defProfImgMissing = true;
}
}
//We handle languages using a hierarchy of translations. The top of the hierarchy is default. This includes a default translation for all items
// We handle languages using a hierarchy of translations. The top of the hierarchy is default. This includes a default translation for all items
// (most likely using simple English). The next level is the language: for instance, English, French, Chinese, etc. This file should contain a
// generic translation for all items which differ from default. Finally there is the locale. This is region-specific items which differ from the
// language file. These files must be name in the format <Language> (<LC>), where Language is the name of the language which it inherits from,
// and LC is the local code. Some examples of this would be English (US) (American English), French (FR) (Franch French), French (CA) (Canadian
// and LC is the local code. Some examples of this would be English (US) (American English), French (FR) (France French), French (CA) (Canadian
// French), etc.
//
// Each level will only contain the differences between itself and its parent translation. For instance, English (UK) or English (CA) may
@ -2346,3 +2337,63 @@ bool Options::is_extention_enabled (Glib::ustring ext)
return false;
}
Glib::ustring Options::getUserProfilePath()
{
return userProfilePath;
}
Glib::ustring Options::getGlobalProfilePath()
{
return globalProfilePath;
}
bool Options::is_defProfRawMissing()
{
return defProfError & rtengine::toUnderlying(DefProfError::defProfRawMissing);
}
bool Options::is_defProfImgMissing()
{
return defProfError & rtengine::toUnderlying(DefProfError::defProfImgMissing);
}
void Options::setDefProfRawMissing (bool value)
{
if (value) {
defProfError |= rtengine::toUnderlying(DefProfError::defProfRawMissing);
} else {
defProfError &= ~rtengine::toUnderlying(DefProfError::defProfRawMissing);
}
}
void Options::setDefProfImgMissing (bool value)
{
if (value) {
defProfError |= rtengine::toUnderlying(DefProfError::defProfImgMissing);
} else {
defProfError &= ~rtengine::toUnderlying(DefProfError::defProfImgMissing);
}
}
bool Options::is_bundledDefProfRawMissing()
{
return defProfError & rtengine::toUnderlying(DefProfError::bundledDefProfRawMissing);
}
bool Options::is_bundledDefProfImgMissing()
{
return defProfError & rtengine::toUnderlying(DefProfError::bundledDefProfImgMissing);
}
void Options::setBundledDefProfRawMissing (bool value)
{
if (value) {
defProfError |= rtengine::toUnderlying(DefProfError::bundledDefProfRawMissing);
} else {
defProfError &= ~rtengine::toUnderlying(DefProfError::bundledDefProfRawMissing);
}
}
void Options::setBundledDefProfImgMissing (bool value)
{
if (value) {
defProfError |= rtengine::toUnderlying(DefProfError::bundledDefProfImgMissing);
} else {
defProfError &= ~rtengine::toUnderlying(DefProfError::bundledDefProfImgMissing);
}
}

View File

@ -90,8 +90,13 @@ public:
};
private:
bool defProfRawMissing;
bool defProfImgMissing;
enum class DefProfError : short {
defProfRawMissing = 1 << 0,
bundledDefProfRawMissing = 1 << 1,
defProfImgMissing = 1 << 2,
bundledDefProfImgMissing = 1 << 3
};
short defProfError;
Glib::ustring userProfilePath;
Glib::ustring globalProfilePath;
bool checkProfilePath (Glib::ustring &path);
@ -344,9 +349,9 @@ public:
Options ();
Options* copyFrom (Options* other);
void filterOutParsedExtensions ();
void setDefaults ();
Options* copyFrom (Options* other);
void filterOutParsedExtensions ();
void setDefaults ();
void readFromFile (Glib::ustring fname);
void saveToFile (Glib::ustring fname);
static void load (bool lightweight = false);
@ -354,34 +359,20 @@ public:
// if multiUser=false, send back the global profile path
Glib::ustring getPreferredProfilePath();
Glib::ustring getUserProfilePath()
{
return userProfilePath;
}
Glib::ustring getGlobalProfilePath()
{
return globalProfilePath;
}
Glib::ustring getUserProfilePath();
Glib::ustring getGlobalProfilePath();
Glib::ustring findProfilePath (Glib::ustring &profName);
bool is_parse_extention (Glib::ustring fname);
bool has_retained_extention (Glib::ustring fname);
bool is_extention_enabled (Glib::ustring ext);
bool is_defProfRawMissing()
{
return defProfRawMissing;
}
bool is_defProfImgMissing()
{
return defProfImgMissing;
}
void setDefProfRawMissing (bool value)
{
defProfRawMissing = value;
}
void setDefProfImgMissing (bool value)
{
defProfImgMissing = value;
}
bool is_parse_extention (Glib::ustring fname);
bool has_retained_extention (Glib::ustring fname);
bool is_extention_enabled (Glib::ustring ext);
bool is_defProfRawMissing();
bool is_bundledDefProfRawMissing();
bool is_defProfImgMissing();
bool is_bundledDefProfImgMissing();
void setDefProfRawMissing (bool value);
void setBundledDefProfRawMissing (bool value);
void setDefProfImgMissing (bool value);
void setBundledDefProfImgMissing (bool value);
};
extern Options options;

View File

@ -349,15 +349,28 @@ void RTWindow::showErrors()
{
// alerting users if the default raw and image profiles are missing
if (options.is_defProfRawMissing()) {
options.defProfRaw = DEFPROFILE_RAW;
Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_DEFRAW_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
msgd.run ();
}
if (options.is_bundledDefProfRawMissing()) {
Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_BUNDLED_MISSING"), options.defProfRaw), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
msgd.run ();
options.defProfRaw = DEFPROFILE_INTERNAL;
}
if (options.is_defProfImgMissing()) {
options.defProfImg = DEFPROFILE_IMG;
Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_DEFIMG_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
msgd.run ();
}
if (options.is_bundledDefProfImgMissing()) {
Gtk::MessageDialog msgd (*this, Glib::ustring::compose (M ("OPTIONS_BUNDLED_MISSING"), options.defProfImg), true, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
msgd.run ();
options.defProfImg = DEFPROFILE_INTERNAL;
}
}
bool RTWindow::on_configure_event (GdkEventConfigure* event)
{
if (!is_maximized() && is_visible()) {