X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fscreens_panel.cc;h=908e94f4dab8b0bbb5d2f46796705f0a76d63846;hb=5e75cc2551aed1b05f06e39d1e4728882f644217;hp=6643632642b0ff6b6dd223e7621f4e0d2c6f8b80;hpb=f60e199caede4404af4efe144200e1b5ac26b347;p=dcpomatic.git diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc index 664363264..908e94f4d 100644 --- a/src/wx/screens_panel.cc +++ b/src/wx/screens_panel.cc @@ -71,23 +71,23 @@ ScreensPanel::ScreensPanel (wxWindow* parent) sizer->Add (targets, 1, wxEXPAND); - _search->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ScreensPanel::search_changed, this)); - _targets->Bind (wxEVT_COMMAND_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this); + _search->Bind (wxEVT_TEXT, boost::bind (&ScreensPanel::search_changed, this)); + _targets->Bind (wxEVT_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this); - _add_cinema->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::add_cinema_clicked, this)); - _edit_cinema->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::edit_cinema_clicked, this)); - _remove_cinema->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::remove_cinema_clicked, this)); + _add_cinema->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::add_cinema_clicked, this)); + _edit_cinema->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::edit_cinema_clicked, this)); + _remove_cinema->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::remove_cinema_clicked, this)); - _add_screen->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::add_screen_clicked, this)); - _edit_screen->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::edit_screen_clicked, this)); - _remove_screen->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&ScreensPanel::remove_screen_clicked, this)); + _add_screen->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::add_screen_clicked, this)); + _edit_screen->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::edit_screen_clicked, this)); + _remove_screen->Bind (wxEVT_BUTTON, boost::bind (&ScreensPanel::remove_screen_clicked, this)); SetSizer (sizer); } ScreensPanel::~ScreensPanel () { - _targets->Unbind (wxEVT_COMMAND_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this); + _targets->Unbind (wxEVT_TREE_SEL_CHANGED, &ScreensPanel::selection_changed_shim, this); } void @@ -177,7 +177,7 @@ ScreensPanel::edit_cinema_clicked () c.second->set_utc_offset_hour (d->utc_offset_hour ()); c.second->set_utc_offset_minute (d->utc_offset_minute ()); _targets->SetItemText (c.first, std_to_wx (d->name())); - Config::instance()->changed (); + Config::instance()->changed (Config::CINEMAS); } d->Destroy (); @@ -205,9 +205,23 @@ ScreensPanel::add_screen_clicked () ScreenDialog* d = new ScreenDialog (GetParent(), _("Add Screen")); if (d->ShowModal () != wxID_OK) { + d->Destroy (); return; } + BOOST_FOREACH (shared_ptr i, c->screens ()) { + if (i->name == d->name()) { + error_dialog ( + GetParent(), + wxString::Format ( + _("You cannot add a screen called '%s' as the cinema already has a screen with this name."), + std_to_wx(d->name()).data() + ) + ); + return; + } + } + shared_ptr s (new Screen (d->name(), d->recipient(), d->trusted_devices())); c->add_screen (s); optional id = add_screen (c, s); @@ -215,7 +229,7 @@ ScreensPanel::add_screen_clicked () _targets->Expand (id.get ()); } - Config::instance()->changed (); + Config::instance()->changed (Config::CINEMAS); d->Destroy (); } @@ -230,15 +244,32 @@ ScreensPanel::edit_screen_clicked () pair > s = *_selected_screens.begin(); ScreenDialog* d = new ScreenDialog (GetParent(), _("Edit screen"), s.second->name, s.second->notes, s.second->recipient, s.second->trusted_devices); - if (d->ShowModal () == wxID_OK) { - s.second->name = d->name (); - s.second->notes = d->notes (); - s.second->recipient = d->recipient (); - s.second->trusted_devices = d->trusted_devices (); - _targets->SetItemText (s.first, std_to_wx (d->name())); - Config::instance()->changed (); + if (d->ShowModal () != wxID_OK) { + d->Destroy (); + return; + } + + shared_ptr c = s.second->cinema; + BOOST_FOREACH (shared_ptr i, c->screens ()) { + if (i != s.second && i->name == d->name()) { + error_dialog ( + GetParent(), + wxString::Format ( + _("You cannot change this screen's name to '%s' as the cinema already has a screen with this name."), + std_to_wx(d->name()).data() + ) + ); + return; + } } + s.second->name = d->name (); + s.second->notes = d->notes (); + s.second->recipient = d->recipient (); + s.second->trusted_devices = d->trusted_devices (); + _targets->SetItemText (s.first, std_to_wx (d->name())); + Config::instance()->changed (Config::CINEMAS); + d->Destroy (); } @@ -264,7 +295,7 @@ ScreensPanel::remove_screen_clicked () _targets->Delete (i->first); } - Config::instance()->changed (); + Config::instance()->changed (Config::CINEMAS); } list >