Partial profile save dialog order
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. Closes #5491
This commit is contained in:
@@ -275,6 +275,23 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
||||||
|
if (event->state & Gdk::CONTROL_MASK) {
|
||||||
|
if(!partialProfileDlg) {
|
||||||
|
partialProfileDlg = new PartialPasteDlg (Glib::ustring (), parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
partialProfileDlg->set_title(M("PROFILEPANEL_SAVEPPASTE"));
|
||||||
|
int i = partialProfileDlg->run();
|
||||||
|
partialProfileDlg->hide();
|
||||||
|
|
||||||
|
if (i != Gtk::RESPONSE_OK) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Gtk::FileChooserDialog dialog (getToplevelWindow (this), M("PROFILEPANEL_SAVEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
Gtk::FileChooserDialog dialog (getToplevelWindow (this), M("PROFILEPANEL_SAVEDLGLABEL"), Gtk::FILE_CHOOSER_ACTION_SAVE);
|
||||||
bindCurrentFolder (dialog, options.loadSaveProfilePath);
|
bindCurrentFolder (dialog, options.loadSaveProfilePath);
|
||||||
dialog.set_current_name (lastFilename);
|
dialog.set_current_name (lastFilename);
|
||||||
@@ -294,7 +311,6 @@ 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:
|
||||||
|
|
||||||
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);
|
||||||
@@ -305,8 +321,6 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
|||||||
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 = false;
|
bool done = false;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -337,45 +351,27 @@ void ProfilePanel::save_clicked (GdkEventButton* event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (toSave) {
|
if (toSave) {
|
||||||
|
int retCode;
|
||||||
if (event->state & Gdk::CONTROL_MASK) {
|
if (event->state & Gdk::CONTROL_MASK) {
|
||||||
// opening the partial paste dialog window
|
// Build partial profile
|
||||||
if(!partialProfileDlg) {
|
|
||||||
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 {
|
} else {
|
||||||
|
// Save full profile
|
||||||
|
retCode = toSave->pparams->save (fname);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!retCode) {
|
||||||
done = true;
|
done = true;
|
||||||
bool ccPrevState = changeconn.block(true);
|
bool ccPrevState = changeconn.block(true);
|
||||||
ProfileStore::getInstance()->parseProfiles();
|
ProfileStore::getInstance()->parseProfiles();
|
||||||
changeconn.block (ccPrevState);
|
changeconn.block (ccPrevState);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// saving a full profile
|
|
||||||
int retCode = toSave->pparams->save (fname);
|
|
||||||
|
|
||||||
if (retCode) {
|
|
||||||
writeFailed(dialog, fname);
|
writeFailed(dialog, fname);
|
||||||
} else {
|
|
||||||
done = true;
|
|
||||||
bool ccPrevState = changeconn.block(true);
|
|
||||||
ProfileStore::getInstance()->parseProfiles();
|
|
||||||
changeconn.block (ccPrevState);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
done = true;
|
done = true;
|
||||||
@@ -465,7 +461,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);
|
||||||
|
Reference in New Issue
Block a user