X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Fscreens_panel.cc;h=3abe1f970cd925bfacc7c611a1c6c4cf70bd4b68;hp=0638763fe364ce0743b05320d070819ad8674be4;hb=ad5c8849fc3ef5aad88201f28db5474a60db4436;hpb=3828baf56467224f5d44049bf1e7a7ed11f43a05 diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc index 0638763fe..3abe1f970 100644 --- a/src/wx/screens_panel.cc +++ b/src/wx/screens_panel.cc @@ -52,42 +52,42 @@ ScreensPanel::ScreensPanel (wxWindow* parent) add_cinemas (); - wxGridSizer* target_buttons = new wxGridSizer (2, DCPOMATIC_BUTTON_STACK_GAP * 2, DCPOMATIC_SIZER_Y_GAP); + wxBoxSizer* target_buttons = new wxBoxSizer (wxVERTICAL); _add_cinema = new wxButton (this, wxID_ANY, _("Add Cinema...")); - target_buttons->Add (_add_cinema, 1, wxEXPAND); - _add_screen = new wxButton (this, wxID_ANY, _("Add Screen...")); - target_buttons->Add (_add_screen, 1, wxEXPAND); + target_buttons->Add (_add_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); _edit_cinema = new wxButton (this, wxID_ANY, _("Edit Cinema...")); - target_buttons->Add (_edit_cinema, 1, wxEXPAND); - _edit_screen = new wxButton (this, wxID_ANY, _("Edit Screen...")); - target_buttons->Add (_edit_screen, 1, wxEXPAND); + target_buttons->Add (_edit_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); _remove_cinema = new wxButton (this, wxID_ANY, _("Remove Cinema")); - target_buttons->Add (_remove_cinema, 1, wxEXPAND); + target_buttons->Add (_remove_cinema, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); + _add_screen = new wxButton (this, wxID_ANY, _("Add Screen...")); + target_buttons->Add (_add_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); + _edit_screen = new wxButton (this, wxID_ANY, _("Edit Screen...")); + target_buttons->Add (_edit_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); _remove_screen = new wxButton (this, wxID_ANY, _("Remove Screen")); - target_buttons->Add (_remove_screen, 1, wxEXPAND); + target_buttons->Add (_remove_screen, 1, wxEXPAND | wxBOTTOM, DCPOMATIC_BUTTON_STACK_GAP); targets->Add (target_buttons, 0, 0); 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 @@ -147,7 +147,7 @@ ScreensPanel::add_screen (shared_ptr c, shared_ptr s) void ScreensPanel::add_cinema_clicked () { - CinemaDialog* d = new CinemaDialog (this, _("Add Cinema")); + CinemaDialog* d = new CinemaDialog (GetParent(), _("Add Cinema")); if (d->ShowModal () == wxID_OK) { shared_ptr c (new Cinema (d->name(), d->emails(), d->notes(), d->utc_offset_hour(), d->utc_offset_minute())); Config::instance()->add_cinema (c); @@ -167,7 +167,7 @@ ScreensPanel::edit_cinema_clicked () pair > c = *_selected_cinemas.begin(); CinemaDialog* d = new CinemaDialog ( - this, _("Edit cinema"), c.second->name, c.second->emails, c.second->notes, c.second->utc_offset_hour(), c.second->utc_offset_minute() + GetParent(), _("Edit cinema"), c.second->name, c.second->emails, c.second->notes, c.second->utc_offset_hour(), c.second->utc_offset_minute() ); if (d->ShowModal () == wxID_OK) { @@ -203,11 +203,25 @@ ScreensPanel::add_screen_clicked () shared_ptr c = _selected_cinemas.begin()->second; - ScreenDialog* d = new ScreenDialog (this, _("Add Screen")); + 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); @@ -229,16 +243,33 @@ ScreensPanel::edit_screen_clicked () pair > s = *_selected_screens.begin(); - ScreenDialog* d = new ScreenDialog (this, _("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 (); + 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) { + 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 (); + d->Destroy (); }