Put * in the title bar when the DCP-o-matic project is modified (#1938).
authorCarl Hetherington <cth@carlh.net>
Sun, 16 Jan 2022 16:35:15 +0000 (17:35 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 28 Apr 2022 23:44:15 +0000 (01:44 +0200)
src/lib/film.cc
src/lib/film.h
src/tools/dcpomatic.cc

index 1ea03a8d9a68684a4e6bd6cfefb690b564c28a29..e49b7f78e7ed026cf14beb3bd8d96b0f311cb121 100644 (file)
@@ -482,7 +482,7 @@ Film::write_metadata (boost::filesystem::path path) const
 
 /** Write state to our `metadata' file */
 void
-Film::write_metadata () const
+Film::write_metadata ()
 {
        DCPOMATIC_ASSERT (directory());
        boost::filesystem::create_directories (directory().get());
@@ -2178,8 +2178,12 @@ Film::set_sign_language_video_language (optional<dcp::LanguageTag> lang)
 
 
 void
-Film::set_dirty (bool dirty) const
+Film::set_dirty (bool dirty)
 {
+       auto const changed = dirty != _dirty;
        _dirty = dirty;
+       if (changed) {
+               emit (boost::bind(boost::ref(DirtyChange), _dirty));
+       }
 }
 
index 9be6c57710d2ed145d9664fbaca2803108cd69cd..d42eb5626b71dad5050e3fa5335002611f59edf1 100644 (file)
@@ -131,7 +131,7 @@ public:
 
        void use_template (std::string name);
        std::list<std::string> read_metadata (boost::optional<boost::filesystem::path> path = boost::optional<boost::filesystem::path> ());
-       void write_metadata () const;
+       void write_metadata ();
        void write_metadata (boost::filesystem::path path) const;
        void write_template (boost::filesystem::path path) const;
        std::shared_ptr<xmlpp::Document> metadata (bool with_content_paths = true) const;
@@ -481,6 +481,8 @@ public:
        */
        mutable boost::signals2::signal<void ()> LengthChange;
 
+       boost::signals2::signal<void (bool)> DirtyChange;
+
        /** Emitted when we have something important to tell the user */
        boost::signals2::signal<void (std::string)> Message;
 
@@ -507,7 +509,7 @@ private:
        void audio_analysis_finished ();
        void check_settings_consistency ();
        void maybe_set_container_and_resolution ();
-       void set_dirty (bool dirty) const;
+       void set_dirty (bool dirty);
 
        /** Log to write to */
        std::shared_ptr<Log> _log;
index a14a27343f21236399f8436c6f5e4ab451cde87d..8455163bb608970691441b689b98df902cd4232a 100644 (file)
@@ -495,6 +495,7 @@ public:
                if (_film) {
                        _film->Change.connect (boost::bind (&DOMFrame::film_change, this, _1));
                        _film->Message.connect (boost::bind(&DOMFrame::film_message, this, _1));
+                       _film->DirtyChange.connect (boost::bind(&DOMFrame::set_title, this));
                        dcpomatic_log = _film->log ();
                }
                set_title ();
@@ -1528,8 +1529,13 @@ private:
        void set_title ()
        {
                auto s = wx_to_std(_("DCP-o-matic"));
-               if (_film && _film->directory()) {
-                       s += " - " + _film->directory()->string();
+               if (_film) {
+                       if (_film->directory()) {
+                               s += " - " + _film->directory()->string();
+                       }
+                       if (_film->dirty()) {
+                               s += " *";
+                       }
                }
 
                SetTitle (std_to_wx(s));