/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
- This program is free software; you can redistribute it and/or modify
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <wx/hyperlink.h>
+
+#include "static_text.h"
#include "update_dialog.h"
#include "wx_util.h"
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
+#include <wx/hyperlink.h>
+LIBDCP_ENABLE_WARNINGS
+
using std::string;
+using boost::optional;
-UpdateDialog::UpdateDialog (wxWindow* parent, string stable, string test)
+
+UpdateDialog::UpdateDialog (wxWindow* parent, optional<string> stable, optional<string> test)
: wxDialog (parent, wxID_ANY, _("Update"))
{
- wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
+ auto overall_sizer = new wxBoxSizer (wxVERTICAL);
wxStaticText* message;
- if (test.empty ()) {
- message = new wxStaticText (this, wxID_ANY, _("A new version of DCP-o-matic is available."));
+ if ((stable || test) && !(stable && test)) {
+ message = new StaticText (this, _("A new version of DCP-o-matic is available."));
} else {
- message = new wxStaticText (this, wxID_ANY, _("New versions of DCP-o-matic are available."));
+ message = new StaticText (this, _("New versions of DCP-o-matic are available."));
}
- overall_sizer->Add (message, 1, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
+ overall_sizer->Add (message, 0, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
+
+ auto table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
- wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+ if (stable) {
+ add_label_to_sizer (table, this, _("Stable version ") + std_to_wx(stable.get()), true, 0, wxALIGN_CENTER_VERTICAL);
+ auto h = new wxHyperlinkCtrl (this, wxID_ANY, "dcpomatic.com/download", "https://dcpomatic.com/download");
+ table->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_DIALOG_BORDER);
+ }
- add_label_to_sizer (table, this, _("Stable version ") + std_to_wx (stable), true);
- wxHyperlinkCtrl* h = new wxHyperlinkCtrl (this, wxID_ANY, "dcpomatic.com/download", "http://dcpomatic.com/download");
- table->Add (h);
-
- if (!test.empty ()) {
- add_label_to_sizer (table, this, _("Test version ") + std_to_wx (test), true);
- wxHyperlinkCtrl* h = new wxHyperlinkCtrl (this, wxID_ANY, "dcpomatic.com/test-download", "http://dcpomatic.com/test-download");
- table->Add (h);
+ if (test) {
+ add_label_to_sizer (table, this, _("Test version ") + std_to_wx(test.get()), true, 0, wxALIGN_CENTER_VERTICAL);
+ auto h = new wxHyperlinkCtrl (this, wxID_ANY, "dcpomatic.com/test-download", "https://dcpomatic.com/test-download");
+ table->Add (h, 0, wxALIGN_CENTER_VERTICAL, DCPOMATIC_DIALOG_BORDER);
}
-
- overall_sizer->Add (table, 1, wxEXPAND | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
- wxSizer* buttons = CreateButtonSizer (wxOK);
+ overall_sizer->Add (table, 0, wxTOP | wxLEFT | wxRIGHT, DCPOMATIC_DIALOG_BORDER);
+
+ auto buttons = CreateButtonSizer (wxOK);
if (buttons) {
- overall_sizer->Add (buttons, 1, wxEXPAND | wxALL);
+ overall_sizer->Add (buttons, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
}
-
+
SetSizerAndFit (overall_sizer);
}