diff options
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/cinema_dialog.cc | 42 | ||||
| -rw-r--r-- | src/wx/cinema_dialog.h | 8 | ||||
| -rw-r--r-- | src/wx/dkdm_dialog.cc | 2 | ||||
| -rw-r--r-- | src/wx/kdm_timing_panel.cc | 57 | ||||
| -rw-r--r-- | src/wx/kdm_timing_panel.h | 20 | ||||
| -rw-r--r-- | src/wx/screens_panel.cc | 8 |
6 files changed, 67 insertions, 70 deletions
diff --git a/src/wx/cinema_dialog.cc b/src/wx/cinema_dialog.cc index 84fde5f41..771a59892 100644 --- a/src/wx/cinema_dialog.cc +++ b/src/wx/cinema_dialog.cc @@ -36,7 +36,7 @@ using namespace boost::placeholders; #endif -CinemaDialog::CinemaDialog(wxWindow* parent, wxString title, string name, vector<string> emails, string notes, int utc_offset_hour, int utc_offset_minute) +CinemaDialog::CinemaDialog(wxWindow* parent, wxString title, string name, vector<string> emails, string notes) : wxDialog (parent, wxID_ANY, title) { auto overall_sizer = new wxBoxSizer (wxVERTICAL); @@ -50,11 +50,6 @@ CinemaDialog::CinemaDialog(wxWindow* parent, wxString title, string name, vector sizer->Add (_name, wxGBPosition(r, 1)); ++r; - add_label_to_sizer (sizer, this, _("UTC offset (time zone)"), true, wxGBPosition(r, 0)); - _utc_offset = new wxChoice (this, wxID_ANY); - sizer->Add (_utc_offset, wxGBPosition(r, 1)); - ++r; - add_label_to_sizer (sizer, this, _("Notes"), true, wxGBPosition(r, 0)); _notes = new wxTextCtrl (this, wxID_ANY, std_to_wx(notes), wxDefaultPosition, wxSize(500, -1)); sizer->Add (_notes, wxGBPosition(r, 1)); @@ -83,17 +78,6 @@ CinemaDialog::CinemaDialog(wxWindow* parent, wxString title, string name, vector overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); } - /* Default to UTC */ - size_t sel = get_offsets (_offsets); - for (size_t i = 0; i < _offsets.size(); ++i) { - _utc_offset->Append (_offsets[i].name); - if (_offsets[i].hour == utc_offset_hour && _offsets[i].minute == utc_offset_minute) { - sel = i; - } - } - - _utc_offset->SetSelection (sel); - overall_sizer->Layout (); overall_sizer->SetSizeHints (this); @@ -122,30 +106,6 @@ CinemaDialog::emails() const } -int -CinemaDialog::utc_offset_hour () const -{ - int const sel = _utc_offset->GetSelection(); - if (sel < 0 || sel > int(_offsets.size())) { - return 0; - } - - return _offsets[sel].hour; -} - - -int -CinemaDialog::utc_offset_minute () const -{ - int const sel = _utc_offset->GetSelection(); - if (sel < 0 || sel > int(_offsets.size())) { - return 0; - } - - return _offsets[sel].minute; -} - - string CinemaDialog::notes () const { diff --git a/src/wx/cinema_dialog.h b/src/wx/cinema_dialog.h index 0b8362843..cd90f6dea 100644 --- a/src/wx/cinema_dialog.h +++ b/src/wx/cinema_dialog.h @@ -38,16 +38,12 @@ public: wxString, std::string name = "", std::vector<std::string> emails = std::vector<std::string>(), - std::string notes = "", - int utc_offset_hour = 0, - int utc_offset_minute = 0 + std::string notes = "" ); std::string name () const; std::string notes () const; std::vector<std::string> emails () const; - int utc_offset_hour () const; - int utc_offset_minute () const; private: void set_emails (std::vector<std::string>); @@ -56,6 +52,4 @@ private: wxTextCtrl* _notes; EditableList<std::string, EmailDialog>* _email_list; std::vector<std::string> _emails; - wxChoice* _utc_offset; - std::vector<Offset> _offsets; }; diff --git a/src/wx/dkdm_dialog.cc b/src/wx/dkdm_dialog.cc index 6a4913d86..6e1ef9745 100644 --- a/src/wx/dkdm_dialog.cc +++ b/src/wx/dkdm_dialog.cc @@ -160,7 +160,7 @@ DKDMDialog::make_clicked () list<KDMWithMetadataPtr> kdms; try { for (auto i: _recipients->recipients()) { - auto p = kdm_for_dkdm_recipient (film, _cpl->cpl(), i, _timing->from(), _timing->until()); + auto p = kdm_for_dkdm_recipient(film, _cpl->cpl(), i, _timing->from(), _timing->until()); if (p) { kdms.push_back (p); } diff --git a/src/wx/kdm_timing_panel.cc b/src/wx/kdm_timing_panel.cc index 0fd00de93..7759d3949 100644 --- a/src/wx/kdm_timing_panel.cc +++ b/src/wx/kdm_timing_panel.cc @@ -19,11 +19,13 @@ */ +#include "dcpomatic_choice.h" #include "kdm_timing_panel.h" #include "static_text.h" #include "time_picker.h" #include "wx_util.h" #include "lib/config.h" +#include <dcp/utc_offset.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/datectrl.h> @@ -105,6 +107,10 @@ KDMTimingPanel::KDMTimingPanel (wxWindow* parent) table->Add (_until_time, 0, wxALIGN_CENTER_VERTICAL); + add_label_to_sizer(table, this, _("UTC offset (time zone)"), true, 1, wxALIGN_CENTRE_VERTICAL); + _utc_offset = new Choice(this); + table->Add(_utc_offset, 0, wxALIGN_CENTRE_VERTICAL | wxLEFT, DCPOMATIC_SIZER_X_GAP); + overall_sizer->Add (table, 0, wxTOP, DCPOMATIC_SIZER_GAP); _warning = new StaticText (this, wxT("")); @@ -115,6 +121,17 @@ KDMTimingPanel::KDMTimingPanel (wxWindow* parent) _warning->SetForegroundColour (wxColour (255, 0, 0)); _warning->SetFont(font); + /* Default to UTC */ + size_t sel = 0; + for (size_t i = 0; i < _offsets.size(); ++i) { + _utc_offset->add(_offsets[i].name); + if (_offsets[i].hour == 0 && _offsets[i].minute == 0) { + sel = i; + } + } + + _utc_offset->set(sel); + /* I said I've been to the year 3000. Not much has changed but they live underwater. And your In-in-in-interop DCP is pretty fine. */ @@ -125,33 +142,38 @@ KDMTimingPanel::KDMTimingPanel (wxWindow* parent) _until_date->Bind (wxEVT_DATE_CHANGED, bind (&KDMTimingPanel::changed, this)); _from_time->Changed.connect (bind (&KDMTimingPanel::changed, this)); _until_time->Changed.connect (bind (&KDMTimingPanel::changed, this)); + _utc_offset->bind(&KDMTimingPanel::changed, this); SetSizer (overall_sizer); } -boost::posix_time::ptime +dcp::LocalTime KDMTimingPanel::from () const { - return posix_time (_from_date, _from_time); + return local_time(_from_date, _from_time, utc_offset()); } -boost::posix_time::ptime -KDMTimingPanel::posix_time (wxDatePickerCtrl* date_picker, TimePicker* time_picker) +dcp::LocalTime +KDMTimingPanel::local_time(wxDatePickerCtrl* date_picker, TimePicker* time_picker, dcp::UTCOffset offset) { auto const date = date_picker->GetValue (); - return boost::posix_time::ptime ( - boost::gregorian::date (date.GetYear(), date.GetMonth() + 1, date.GetDay()), - boost::posix_time::time_duration (time_picker->hours(), time_picker->minutes(), 0) + return dcp::LocalTime( + date.GetYear(), + date.GetMonth() + 1, + date.GetDay(), + time_picker->hours(), + time_picker->minutes(), + offset ); } -boost::posix_time::ptime +dcp::LocalTime KDMTimingPanel::until () const { - return posix_time (_until_date, _until_time); + return local_time(_until_date, _until_time, utc_offset()); } @@ -173,3 +195,20 @@ KDMTimingPanel::changed () const TimingChanged (); } + + +dcp::UTCOffset +KDMTimingPanel::utc_offset() const +{ + auto const sel = _utc_offset->get(); + if (!sel || *sel >= int(_offsets.size())) { + return {}; + } + + auto const& offset = _offsets[*sel]; + int const minute_scale = offset.hour < 0 ? -1 : 1; + + return { offset.hour, minute_scale * offset.minute }; +} + + diff --git a/src/wx/kdm_timing_panel.h b/src/wx/kdm_timing_panel.h index 7221ba722..f847992a7 100644 --- a/src/wx/kdm_timing_panel.h +++ b/src/wx/kdm_timing_panel.h @@ -18,6 +18,9 @@ */ + +#include "wx_util.h" +#include <dcp/utc_offset.h> #include <dcp/warnings.h> LIBDCP_DISABLE_WARNINGS #include <wx/wx.h> @@ -25,18 +28,19 @@ LIBDCP_ENABLE_WARNINGS #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/signals2.hpp> -class wxDatePickerCtrl; + +class Choice; class TimePicker; +class wxDatePickerCtrl; + class KDMTimingPanel : public wxPanel { public: explicit KDMTimingPanel (wxWindow* parent); - /** @return KDM from time in local time */ - boost::posix_time::ptime from () const; - /** @return KDM until time in local time */ - boost::posix_time::ptime until () const; + dcp::LocalTime from() const; + dcp::LocalTime until() const; bool valid () const; @@ -44,11 +48,15 @@ public: private: void changed () const; - static boost::posix_time::ptime posix_time (wxDatePickerCtrl *, TimePicker *); + dcp::UTCOffset utc_offset() const; + + static dcp::LocalTime local_time(wxDatePickerCtrl *, TimePicker *, dcp::UTCOffset offset); wxDatePickerCtrl* _from_date; wxDatePickerCtrl* _until_date; TimePicker* _from_time; TimePicker* _until_time; + Choice* _utc_offset; wxStaticText* _warning; + std::vector<Offset> _offsets; }; diff --git a/src/wx/screens_panel.cc b/src/wx/screens_panel.cc index 9d322e45e..2a82720b5 100644 --- a/src/wx/screens_panel.cc +++ b/src/wx/screens_panel.cc @@ -231,7 +231,7 @@ ScreensPanel::add_cinema_clicked () CinemaDialog dialog(GetParent(), _("Add Cinema")); if (dialog.ShowModal() == wxID_OK) { - auto cinema = make_shared<Cinema>(dialog.name(), dialog.emails(), dialog.notes(), dialog.utc_offset_hour(), dialog.utc_offset_minute()); + auto cinema = make_shared<Cinema>(dialog.name(), dialog.emails(), dialog.notes()); auto cinemas = sorted_cinemas(); @@ -299,16 +299,12 @@ ScreensPanel::edit_cinema_clicked () void ScreensPanel::edit_cinema(shared_ptr<Cinema> cinema) { - CinemaDialog dialog( - GetParent(), _("Edit cinema"), cinema->name, cinema->emails, cinema->notes, cinema->utc_offset_hour(), cinema->utc_offset_minute() - ); + CinemaDialog dialog(GetParent(), _("Edit cinema"), cinema->name, cinema->emails, cinema->notes); if (dialog.ShowModal() == wxID_OK) { cinema->name = dialog.name(); cinema->emails = dialog.emails(); cinema->notes = dialog.notes(); - cinema->set_utc_offset_hour(dialog.utc_offset_hour()); - cinema->set_utc_offset_minute(dialog.utc_offset_minute()); notify_cinemas_changed(); auto item = cinema_to_item(cinema); DCPOMATIC_ASSERT(item); |
