Fix dark mode for release notes.
authorCarl Hetherington <cth@carlh.net>
Sun, 16 Oct 2022 20:21:49 +0000 (22:21 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 18 Oct 2022 18:37:00 +0000 (20:37 +0200)
src/lib/release_notes.cc
src/lib/release_notes.h
src/tools/dcpomatic.cc
src/wx/html_dialog.cc
test/release_notes_test.cc

index 23671318435fba263b3901aa5d53adf5241902ee..d697384277a418566544c32d87c7522db0315ac5 100644 (file)
@@ -31,7 +31,7 @@ using boost::optional;
 
 
 optional<string>
-find_release_notes(optional<string> current)
+find_release_notes(bool dark, optional<string> current)
 {
        auto last = Config::instance()->last_release_notes_version();
        if (!current) {
@@ -43,14 +43,18 @@ find_release_notes(optional<string> current)
 
        Config::instance()->set_last_release_notes_version(*current);
 
-       const string header = String::compose("<h1>DCP-o-matic %1 release notes</h1>", *current);
+       string const colour = dark ? "white" : "black";
+       auto const span = String::compose("<span style=\"color: %1\">", colour);
+
+       const string header = String::compose("<h1>%1DCP-o-matic %2 release notes</span></h1>", 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.")
+                       + "</span>";
        }
 
        return {};
index a5026b432103c7a0045fe4c481b6bdfec4f469bf..d0837248b7494da6ab08443d5c97ce86f097b629 100644 (file)
@@ -23,4 +23,4 @@
 #include <string>
 
 
-extern boost::optional<std::string> find_release_notes(boost::optional<std::string> current = boost::optional<std::string>());
+extern boost::optional<std::string> find_release_notes(bool dark, boost::optional<std::string> current = boost::optional<std::string>());
index eec81d3c80e36ec394f86cd5bb87f8e3890578f9..001d1859eec93fd51219f229b02ee386ab333c89 100644 (file)
@@ -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();
index 19c3aaf2a11591987678cf666f105d66c5e7cbd1..c8138c8cd51cf65b7ca7ac06b9827f32ed4d816a 100644 (file)
@@ -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);
index 394de59598ccbe06f5e15da76f6dd4f314a6819f..c05ad2618288ec5b4f78eb599a6be603c89c3fc4 100644 (file)
@@ -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<bool>(notes));
        }
 }