Merge with 'dev/newlocallab'...
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with RawTherapee. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "profilepanel.h"
|
||||
|
||||
@@ -22,9 +22,12 @@
|
||||
#include "multilangmgr.h"
|
||||
#include "options.h"
|
||||
#include "profilestorecombobox.h"
|
||||
#include "paramsedited.h"
|
||||
#include "pathutils.h"
|
||||
#include "rtimage.h"
|
||||
|
||||
#include "../rtengine/procparams.h"
|
||||
#include "../rtengine/procevents.h"
|
||||
|
||||
using namespace rtengine;
|
||||
using namespace rtengine::procparams;
|
||||
@@ -42,7 +45,7 @@ void ProfilePanel::cleanup ()
|
||||
delete partialProfileDlg;
|
||||
}
|
||||
|
||||
ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastFilename(""), imagePath(""), lastSavedPSE(nullptr), customPSE(nullptr)
|
||||
ProfilePanel::ProfilePanel () : storedPProfile(nullptr), lastSavedPSE(nullptr), customPSE(nullptr)
|
||||
{
|
||||
|
||||
tpc = nullptr;
|
||||
@@ -270,14 +273,43 @@ void ProfilePanel::restoreValue ()
|
||||
|
||||
void ProfilePanel::save_clicked (GdkEventButton* event)
|
||||
{
|
||||
|
||||
if (event->button != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gtk::FileChooserDialog dialog (getToplevelWindow (this), M("PROFILEPANEL_SAVEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||
bindCurrentFolder (dialog, options.loadSaveProfilePath);
|
||||
dialog.set_current_name (lastFilename);
|
||||
const PartialProfile* toSave;
|
||||
|
||||
if (isCustomSelected()) {
|
||||
toSave = custom;
|
||||
} else if (isLastSavedSelected()) {
|
||||
toSave = lastsaved;
|
||||
} else {
|
||||
const auto entry = profiles->getSelectedEntry();
|
||||
toSave = entry ? ProfileStore::getInstance()->getProfile(entry) : nullptr;
|
||||
}
|
||||
|
||||
// If it's a partial profile, it's more intuitive to first allow the user
|
||||
// to choose which parameters to save before showing the Save As dialog
|
||||
// #5491
|
||||
const auto isPartial = event->state & Gdk::CONTROL_MASK;
|
||||
if (isPartial) {
|
||||
if (!partialProfileDlg) {
|
||||
partialProfileDlg = new PartialPasteDlg(Glib::ustring(), parent);
|
||||
}
|
||||
|
||||
partialProfileDlg->set_title(M("PROFILEPANEL_SAVEPPASTE"));
|
||||
partialProfileDlg->updateSpotWidget(toSave->pparams);
|
||||
const auto response = partialProfileDlg->run();
|
||||
partialProfileDlg->hide();
|
||||
|
||||
if (response != Gtk::RESPONSE_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Gtk::FileChooserDialog dialog(getToplevelWindow(this), M("PROFILEPANEL_SAVEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||
bindCurrentFolder(dialog, options.loadSaveProfilePath);
|
||||
dialog.set_current_name(lastFilename);
|
||||
|
||||
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
||||
try {
|
||||
@@ -294,99 +326,60 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
||||
dialog.add_button(M("GENERAL_SAVE"), Gtk::RESPONSE_OK);
|
||||
|
||||
//Add filters, so that only certain file types can be selected:
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> filter_pp = Gtk::FileFilter::create();
|
||||
auto filter_pp = Gtk::FileFilter::create();
|
||||
filter_pp->set_name(M("FILECHOOSER_FILTER_PP"));
|
||||
filter_pp->add_pattern("*" + paramFileExtension);
|
||||
dialog.add_filter(filter_pp);
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> filter_any = Gtk::FileFilter::create();
|
||||
auto filter_any = Gtk::FileFilter::create();
|
||||
filter_any->set_name(M("FILECHOOSER_FILTER_ANY"));
|
||||
filter_any->add_pattern("*");
|
||||
dialog.add_filter(filter_any);
|
||||
|
||||
// dialog.set_do_overwrite_confirmation (true);
|
||||
|
||||
bool done = false;
|
||||
bool done = true;
|
||||
|
||||
do {
|
||||
if (dialog.run() == Gtk::RESPONSE_OK) {
|
||||
|
||||
std::string fname = dialog.get_filename();
|
||||
Glib::ustring ext = getExtension (fname);
|
||||
|
||||
if (("." + ext) != paramFileExtension) {
|
||||
if (("." + getExtension(fname)) != paramFileExtension) {
|
||||
fname += paramFileExtension;
|
||||
}
|
||||
|
||||
if (!confirmOverwrite (dialog, fname)) {
|
||||
if (!confirmOverwrite(dialog, fname)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
lastFilename = Glib::path_get_basename (fname);
|
||||
|
||||
const PartialProfile* toSave;
|
||||
|
||||
if (isCustomSelected()) {
|
||||
toSave = custom;
|
||||
} else if (isLastSavedSelected()) {
|
||||
toSave = lastsaved;
|
||||
} else {
|
||||
const ProfileStoreEntry* entry = profiles->getSelectedEntry();
|
||||
toSave = entry ? ProfileStore::getInstance()->getProfile (profiles->getSelectedEntry()) : nullptr;
|
||||
}
|
||||
lastFilename = Glib::path_get_basename(fname);
|
||||
|
||||
if (toSave) {
|
||||
if (event->state & Gdk::CONTROL_MASK) {
|
||||
// opening the partial paste dialog window
|
||||
if(!partialProfileDlg) {
|
||||
partialProfileDlg = new PartialPasteDlg (Glib::ustring (), parent);
|
||||
}
|
||||
partialProfileDlg->set_title(M("PROFILEPANEL_SAVEPPASTE"));
|
||||
partialProfileDlg->updateSpotWidget(toSave->pparams);
|
||||
int i = partialProfileDlg->run();
|
||||
partialProfileDlg->hide();
|
||||
int retCode;
|
||||
|
||||
if (i != Gtk::RESPONSE_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
// saving the partial profile
|
||||
if (isPartial) {
|
||||
// Build partial profile
|
||||
PartialProfile ppTemp(true);
|
||||
partialProfileDlg->applyPaste (ppTemp.pparams, ppTemp.pedited, toSave->pparams, toSave->pedited);
|
||||
int retCode = ppTemp.pparams->save (fname, "", true, ppTemp.pedited);
|
||||
partialProfileDlg->applyPaste(ppTemp.pparams, ppTemp.pedited, toSave->pparams, toSave->pedited);
|
||||
// Save partial profile
|
||||
retCode = ppTemp.pparams->save(fname, "", true, ppTemp.pedited);
|
||||
// Cleanup
|
||||
ppTemp.deleteInstance();
|
||||
|
||||
if (retCode) {
|
||||
writeFailed(dialog, fname);
|
||||
} else {
|
||||
done = true;
|
||||
bool ccPrevState = changeconn.block(true);
|
||||
ProfileStore::getInstance()->parseProfiles();
|
||||
changeconn.block (ccPrevState);
|
||||
}
|
||||
} else {
|
||||
// saving a full profile
|
||||
int retCode = toSave->pparams->save (fname);
|
||||
|
||||
if (retCode) {
|
||||
writeFailed(dialog, fname);
|
||||
} else {
|
||||
done = true;
|
||||
bool ccPrevState = changeconn.block(true);
|
||||
ProfileStore::getInstance()->parseProfiles();
|
||||
changeconn.block (ccPrevState);
|
||||
}
|
||||
// Save full profile
|
||||
retCode = toSave->pparams->save(fname);
|
||||
}
|
||||
|
||||
if (!retCode) {
|
||||
const auto ccPrevState = changeconn.block(true);
|
||||
ProfileStore::getInstance()->parseProfiles();
|
||||
changeconn.block(ccPrevState);
|
||||
} else {
|
||||
done = false;
|
||||
writeFailed(dialog, fname);
|
||||
}
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
} else {
|
||||
done = true;
|
||||
}
|
||||
} while (!done);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -467,7 +460,6 @@ void ProfilePanel::load_clicked (GdkEventButton* event)
|
||||
dialog.add_button(M("GENERAL_OPEN"), Gtk::RESPONSE_OK);
|
||||
|
||||
//Add filters, so that only certain file types can be selected:
|
||||
|
||||
Glib::RefPtr<Gtk::FileFilter> filter_pp = Gtk::FileFilter::create();
|
||||
filter_pp->set_name(M("FILECHOOSER_FILTER_PP"));
|
||||
filter_pp->add_pattern("*" + paramFileExtension);
|
||||
|
Reference in New Issue
Block a user