merge with dev
This commit is contained in:
commit
b3106f3b8b
@ -275,9 +275,27 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gtk::FileChooserDialog dialog (getToplevelWindow (this), M("PROFILEPANEL_SAVEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
// If it's a partial profile, it's more intuitive to first allow the user
|
||||||
bindCurrentFolder (dialog, options.loadSaveProfilePath);
|
// to choose which parameters to save before showing the Save As dialog
|
||||||
dialog.set_current_name (lastFilename);
|
// #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"));
|
||||||
|
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
|
//Add the user's default (or global if multiuser=false) profile path to the Shortcut list
|
||||||
try {
|
try {
|
||||||
@ -294,36 +312,32 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
|||||||
dialog.add_button(M("GENERAL_SAVE"), Gtk::RESPONSE_OK);
|
dialog.add_button(M("GENERAL_SAVE"), Gtk::RESPONSE_OK);
|
||||||
|
|
||||||
//Add filters, so that only certain file types can be selected:
|
//Add filters, so that only certain file types can be selected:
|
||||||
|
auto filter_pp = Gtk::FileFilter::create();
|
||||||
Glib::RefPtr<Gtk::FileFilter> filter_pp = Gtk::FileFilter::create();
|
|
||||||
filter_pp->set_name(M("FILECHOOSER_FILTER_PP"));
|
filter_pp->set_name(M("FILECHOOSER_FILTER_PP"));
|
||||||
filter_pp->add_pattern("*" + paramFileExtension);
|
filter_pp->add_pattern("*" + paramFileExtension);
|
||||||
dialog.add_filter(filter_pp);
|
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->set_name(M("FILECHOOSER_FILTER_ANY"));
|
||||||
filter_any->add_pattern("*");
|
filter_any->add_pattern("*");
|
||||||
dialog.add_filter(filter_any);
|
dialog.add_filter(filter_any);
|
||||||
|
|
||||||
// dialog.set_do_overwrite_confirmation (true);
|
bool done = true;
|
||||||
|
|
||||||
bool done = false;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (dialog.run() == Gtk::RESPONSE_OK) {
|
if (dialog.run() == Gtk::RESPONSE_OK) {
|
||||||
|
|
||||||
std::string fname = dialog.get_filename();
|
std::string fname = dialog.get_filename();
|
||||||
Glib::ustring ext = getExtension (fname);
|
|
||||||
|
|
||||||
if (("." + ext) != paramFileExtension) {
|
if (("." + getExtension(fname)) != paramFileExtension) {
|
||||||
fname += paramFileExtension;
|
fname += paramFileExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!confirmOverwrite (dialog, fname)) {
|
if (!confirmOverwrite(dialog, fname)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastFilename = Glib::path_get_basename (fname);
|
lastFilename = Glib::path_get_basename(fname);
|
||||||
|
|
||||||
const PartialProfile* toSave;
|
const PartialProfile* toSave;
|
||||||
|
|
||||||
@ -332,60 +346,36 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
|||||||
} else if (isLastSavedSelected()) {
|
} else if (isLastSavedSelected()) {
|
||||||
toSave = lastsaved;
|
toSave = lastsaved;
|
||||||
} else {
|
} else {
|
||||||
const ProfileStoreEntry* entry = profiles->getSelectedEntry();
|
const auto entry = profiles->getSelectedEntry();
|
||||||
toSave = entry ? ProfileStore::getInstance()->getProfile (profiles->getSelectedEntry()) : nullptr;
|
toSave = entry ? ProfileStore::getInstance()->getProfile(entry) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toSave) {
|
if (toSave) {
|
||||||
if (event->state & Gdk::CONTROL_MASK) {
|
int retCode;
|
||||||
// opening the partial paste dialog window
|
if (isPartial) {
|
||||||
if(!partialProfileDlg) {
|
// Build partial profile
|
||||||
partialProfileDlg = new PartialPasteDlg (Glib::ustring (), parent);
|
|
||||||
}
|
|
||||||
partialProfileDlg->set_title(M("PROFILEPANEL_SAVEPPASTE"));
|
|
||||||
int i = partialProfileDlg->run();
|
|
||||||
partialProfileDlg->hide();
|
|
||||||
|
|
||||||
if (i != Gtk::RESPONSE_OK) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// saving the partial profile
|
|
||||||
PartialProfile ppTemp(true);
|
PartialProfile ppTemp(true);
|
||||||
partialProfileDlg->applyPaste (ppTemp.pparams, ppTemp.pedited, toSave->pparams, toSave->pedited);
|
partialProfileDlg->applyPaste(ppTemp.pparams, ppTemp.pedited, toSave->pparams, toSave->pedited);
|
||||||
int retCode = ppTemp.pparams->save (fname, "", true, ppTemp.pedited);
|
// Save partial profile
|
||||||
|
retCode = ppTemp.pparams->save(fname, "", true, ppTemp.pedited);
|
||||||
|
// Cleanup
|
||||||
ppTemp.deleteInstance();
|
ppTemp.deleteInstance();
|
||||||
|
|
||||||
if (retCode) {
|
|
||||||
writeFailed(dialog, fname);
|
|
||||||
} else {
|
|
||||||
done = true;
|
|
||||||
bool ccPrevState = changeconn.block(true);
|
|
||||||
ProfileStore::getInstance()->parseProfiles();
|
|
||||||
changeconn.block (ccPrevState);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// saving a full profile
|
// Save full profile
|
||||||
int retCode = toSave->pparams->save (fname);
|
retCode = toSave->pparams->save(fname);
|
||||||
|
}
|
||||||
if (retCode) {
|
|
||||||
writeFailed(dialog, fname);
|
if (!retCode) {
|
||||||
} else {
|
const auto ccPrevState = changeconn.block(true);
|
||||||
done = true;
|
ProfileStore::getInstance()->parseProfiles();
|
||||||
bool ccPrevState = changeconn.block(true);
|
changeconn.block(ccPrevState);
|
||||||
ProfileStore::getInstance()->parseProfiles();
|
} else {
|
||||||
changeconn.block (ccPrevState);
|
done = false;
|
||||||
}
|
writeFailed(dialog, fname);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
done = true;
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
done = true;
|
|
||||||
}
|
}
|
||||||
} while (!done);
|
} while (!done);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -465,7 +455,6 @@ void ProfilePanel::load_clicked (GdkEventButton* event)
|
|||||||
dialog.add_button(M("GENERAL_OPEN"), Gtk::RESPONSE_OK);
|
dialog.add_button(M("GENERAL_OPEN"), Gtk::RESPONSE_OK);
|
||||||
|
|
||||||
//Add filters, so that only certain file types can be selected:
|
//Add filters, so that only certain file types can be selected:
|
||||||
|
|
||||||
Glib::RefPtr<Gtk::FileFilter> filter_pp = Gtk::FileFilter::create();
|
Glib::RefPtr<Gtk::FileFilter> filter_pp = Gtk::FileFilter::create();
|
||||||
filter_pp->set_name(M("FILECHOOSER_FILTER_PP"));
|
filter_pp->set_name(M("FILECHOOSER_FILTER_PP"));
|
||||||
filter_pp->add_pattern("*" + paramFileExtension);
|
filter_pp->add_pattern("*" + paramFileExtension);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user