From: Carl Hetherington Date: Sun, 16 Oct 2022 20:21:49 +0000 (+0200) Subject: Fix dark mode for release notes. X-Git-Tag: v2.16.31~6^2~4 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=93a781c8b9d34effd376537268970193b9b01479 Fix dark mode for release notes. --- diff --git a/src/lib/release_notes.cc b/src/lib/release_notes.cc index 236713184..d69738427 100644 --- a/src/lib/release_notes.cc +++ b/src/lib/release_notes.cc @@ -31,7 +31,7 @@ using boost::optional; optional -find_release_notes(optional current) +find_release_notes(bool dark, optional current) { auto last = Config::instance()->last_release_notes_version(); if (!current) { @@ -43,14 +43,18 @@ find_release_notes(optional current) Config::instance()->set_last_release_notes_version(*current); - const string header = String::compose("

DCP-o-matic %1 release notes

", *current); + string const colour = dark ? "white" : "black"; + auto const span = String::compose("", colour); + + const string header = String::compose("

%1DCP-o-matic %2 release notes

", span, *current); if (!last) { - return header + + return header + span + _("In this version there are changes to the way that subtitles are positioned. " "Positioning should now be more correct, with respect to the standards, but you " "should check any subtitles in your project to make sure that they are placed " - "where you want them."); + "where you want them.") + + "
"; } return {}; diff --git a/src/lib/release_notes.h b/src/lib/release_notes.h index a5026b432..d0837248b 100644 --- a/src/lib/release_notes.h +++ b/src/lib/release_notes.h @@ -23,4 +23,4 @@ #include -extern boost::optional find_release_notes(boost::optional current = boost::optional()); +extern boost::optional find_release_notes(bool dark, boost::optional current = boost::optional()); diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index eec81d3c8..001d1859e 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -1746,7 +1746,7 @@ private: UpdateChecker::instance()->run (); } - auto release_notes = find_release_notes(); + auto release_notes = find_release_notes(gui_is_dark()); if (release_notes) { auto notes = new HTMLDialog(nullptr, _("Release notes"), std_to_wx(*release_notes), true); notes->Centre(); diff --git a/src/wx/html_dialog.cc b/src/wx/html_dialog.cc index 19c3aaf2a..c8138c8cd 100644 --- a/src/wx/html_dialog.cc +++ b/src/wx/html_dialog.cc @@ -52,6 +52,10 @@ HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html, bool ok h->SetPage (html); sizer->Add (h, 1, wxEXPAND | wxALL, 6); + if (gui_is_dark()) { + h->SetHTMLBackgroundColour(*wxBLACK); + } + h->Bind (wxEVT_HTML_LINK_CLICKED, boost::bind(&HTMLDialog::link_clicked, this, _1)); SetSizer (sizer); diff --git a/test/release_notes_test.cc b/test/release_notes_test.cc index 394de5959..c05ad2618 100644 --- a/test/release_notes_test.cc +++ b/test/release_notes_test.cc @@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(release_notes_test1) { for (auto version: { "2.16.19", "2.16.20", "2.18.0", "2.18.1devel6" }) { Config::instance()->unset_last_release_notes_version(); - auto notes = find_release_notes(string(version)); + auto notes = find_release_notes(true, string(version)); BOOST_CHECK(notes.get_value_or("").find("In this version there are changes to the way that subtitles are positioned.") != string::npos); } } @@ -43,7 +43,7 @@ BOOST_AUTO_TEST_CASE(release_notes_test2) { for (auto version: { "2.16.19", "2.16.20", "2.18.0", "2.18.1devel6" }) { Config::instance()->set_last_release_notes_version("2.16.19"); - auto notes = find_release_notes(string(version)); + auto notes = find_release_notes(false, string(version)); BOOST_CHECK(!static_cast(notes)); } }