{
ExportDialog* d = new ExportDialog (this, _film->isdcf_name(true));
if (d->ShowModal() == wxID_OK) {
+ if (boost::filesystem::exists(d->path())) {
+ bool ok = confirm_dialog(
+ this,
+ wxString::Format (_("File %s already exists. Do you want to overwrite it?"), std_to_wx(d->path().string()).data())
+ );
+
+ if (!ok) {
+ d->Destroy ();
+ return;
+ }
+ }
+
shared_ptr<TranscodeJob> job (new TranscodeJob (_film));
if (d->format() == EXPORT_FORMAT_SUBTITLES_DCP) {
job->set_encoder (
_x264_crf_label[1]->SetFont(font);
add (_("Output file"), true);
- _file = new FilePickerCtrl (this, _("Select output file"), format_filters[0], false);
+ /* Don't warn overwrite here, because on Linux (at least) if we specify a filename like foo
+ the wxFileDialog will check that foo exists, but we will add an extension so we actually
+ need to check if foo.mov (or similar) exists. I can't find a way to make wxWidgets do this,
+ so disable its check and the caller will have to do it themselves.
+ */
+ _file = new FilePickerCtrl (this, _("Select output file"), format_filters[0], false, false);
_file->SetPath (_initial_name);
add (_file);
using namespace std;
using namespace boost;
-FilePickerCtrl::FilePickerCtrl (wxWindow* parent, wxString prompt, wxString wildcard, bool open)
+FilePickerCtrl::FilePickerCtrl (wxWindow* parent, wxString prompt, wxString wildcard, bool open, bool warn_overwrite)
: wxPanel (parent)
, _prompt (prompt)
, _wildcard (wildcard)
, _open (open)
+ , _warn_overwrite (warn_overwrite)
{
_sizer = new wxBoxSizer (wxHORIZONTAL);
void
FilePickerCtrl::browse_clicked ()
{
- wxFileDialog* d = new wxFileDialog (this, _prompt, wxEmptyString, wxEmptyString, _wildcard, _open ? wxFD_OPEN : wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+ long style = _open ? wxFD_OPEN : wxFD_SAVE;
+ if (_warn_overwrite) {
+ style |= wxFD_OVERWRITE_PROMPT;
+ }
+ wxFileDialog* d = new wxFileDialog (this, _prompt, wxEmptyString, wxEmptyString, _wildcard, style);
d->SetPath (_path);
if (d->ShowModal () == wxID_OK) {
SetPath (d->GetPath ());
class FilePickerCtrl : public wxPanel
{
public:
- FilePickerCtrl (wxWindow* parent, wxString prompt, wxString wildcard, bool open);
+ FilePickerCtrl (wxWindow* parent, wxString prompt, wxString wildcard, bool open, bool warn_overwrite);
wxString GetPath () const;
void SetPath (wxString);
wxString _prompt;
wxString _wildcard;
bool _open;
+ bool _warn_overwrite;
};
++r;
add_label_to_sizer (table, _panel, _("Configuration file"), true, wxGBPosition (r, 0));
- _config_file = new FilePickerCtrl (_panel, _("Select configuration file"), "*.xml", true);
+ _config_file = new FilePickerCtrl (_panel, _("Select configuration file"), "*.xml", true, true);
table->Add (_config_file, wxGBPosition (r, 1));
++r;
add_label_to_sizer (table, _panel, _("Cinema and screen database file"), true, wxGBPosition (r, 0));
- _cinemas_file = new FilePickerCtrl (_panel, _("Select cinema and screen database file"), "*.xml", true);
+ _cinemas_file = new FilePickerCtrl (_panel, _("Select cinema and screen database file"), "*.xml", true, true);
table->Add (_cinemas_file, wxGBPosition (r, 1));
Button* export_cinemas = new Button (_panel, _("Export..."));
table->Add (export_cinemas, wxGBPosition (r, 2));
++r;
add_label_to_sizer (table, _panel, _("Activity log file"), true, wxGBPosition (r, 0));
- _activity_log_file = new FilePickerCtrl (_panel, _("Select activity log file"), "*", true);
+ _activity_log_file = new FilePickerCtrl (_panel, _("Select activity log file"), "*", true, true);
table->Add (_activity_log_file, wxGBPosition(r, 1));
++r;
add_label_to_sizer (table, _panel, _("Debug log file"), true, wxGBPosition (r, 0));
- _debug_log_file = new FilePickerCtrl (_panel, _("Select debug log file"), "*", true);
+ _debug_log_file = new FilePickerCtrl (_panel, _("Select debug log file"), "*", true, true);
table->Add (_debug_log_file, wxGBPosition(r, 1));
++r;
++r;
add_label_to_sizer (table, _panel, _("Lock file"), true, wxGBPosition(r, 0));
- _lock_file = new FilePickerCtrl (_panel, _("Select lock file"), "*", true);
+ _lock_file = new FilePickerCtrl (_panel, _("Select lock file"), "*", true, true);
table->Add (_lock_file, wxGBPosition (r, 1));
++r;
#endif