summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-05-22 22:30:49 +0200
committerCarl Hetherington <cth@carlh.net>2021-06-28 20:44:47 +0200
commit8df7c0402e51fa42b03e6faabfb95f10787be740 (patch)
treeded0a5912c7eac3edc3f2a99c55a2d1c4c336398
parentecc74ec418e060fa163d25d08a62a6e81eece114 (diff)
Update task bar icon when GUI theme changes (#1986).
We have to keep the StatusDialog around the whole time as it seems to be the only thing we have that can receive wxEVT_SYS_COLOUR_CHANGED.
-rw-r--r--src/tools/dcpomatic_server.cc43
1 files changed, 26 insertions, 17 deletions
diff --git a/src/tools/dcpomatic_server.cc b/src/tools/dcpomatic_server.cc
index 80d4046a4..401fb1077 100644
--- a/src/tools/dcpomatic_server.cc
+++ b/src/tools/dcpomatic_server.cc
@@ -211,20 +211,16 @@ private:
std::shared_ptr<wxTimer> _timer;
};
+
+static StatusDialog* status_dialog = nullptr;
+
+
class TaskBarIcon : public wxTaskBarIcon
{
public:
TaskBarIcon ()
{
-#ifdef DCPOMATIC_WINDOWS
- wxIcon icon (std_to_wx ("id"));
-#else
- wxBitmap bitmap (bitmap_path("dcpomatic_small_black"), wxBITMAP_TYPE_PNG);
- wxIcon icon;
- icon.CopyFromBitmap (bitmap);
-#endif
-
- SetIcon (icon, std_to_wx ("DCP-o-matic Encode Server"));
+ set_icon ();
Bind (wxEVT_MENU, boost::bind (&TaskBarIcon::status, this), ID_status);
Bind (wxEVT_MENU, boost::bind (&TaskBarIcon::quit, this), ID_quit);
@@ -238,21 +234,33 @@ public:
return menu;
}
+ void set_icon ()
+ {
+#ifdef DCPOMATIC_WINDOWS
+ wxIcon icon (std_to_wx("id"));
+#else
+ string const colour = gui_is_dark() ? "white" : "black";
+ wxBitmap bitmap (
+ bitmap_path(String::compose("dcpomatic_small_%1", colour)),
+ wxBITMAP_TYPE_PNG
+ );
+ wxIcon icon;
+ icon.CopyFromBitmap (bitmap);
+#endif
+
+ SetIcon (icon, std_to_wx ("DCP-o-matic Encode Server"));
+ }
+
private:
void status ()
{
- if (!_status) {
- _status = new StatusDialog ();
- }
- _status->Show ();
+ status_dialog->Show ();
}
void quit ()
{
wxTheApp->ExitMainLoop ();
}
-
- StatusDialog* _status;
};
@@ -297,11 +305,12 @@ private:
*/
Config::instance();
+ status_dialog = new StatusDialog ();
#ifdef DCPOMATIC_LINUX
- StatusDialog* d = new StatusDialog ();
- d->Show ();
+ status_dialog->Show ();
#else
_icon = new TaskBarIcon;
+ status_dialog->Bind (wxEVT_SYS_COLOUR_CHANGED, boost::bind(&TaskBarIcon::set_icon, _icon));
#endif
_thread = thread (bind (&App::main_thread, this));