Nag on 3rd successful DCP encode.
authorCarl Hetherington <cth@carlh.net>
Wed, 8 Aug 2018 16:04:26 +0000 (17:04 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 14 Aug 2018 10:18:18 +0000 (11:18 +0100)
graphics/me.jpg [new file with mode: 0644]
graphics/wscript
platform/osx/make_dmg.sh
platform/windows/wscript
src/lib/analytics.cc
src/lib/analytics.h
src/lib/state.h
src/tools/dcpomatic.cc
src/wx/html_dialog.cc [new file with mode: 0644]
src/wx/html_dialog.h [new file with mode: 0644]
src/wx/wscript

diff --git a/graphics/me.jpg b/graphics/me.jpg
new file mode 100644 (file)
index 0000000..59583b8
Binary files /dev/null and b/graphics/me.jpg differ
index 72418cb53420a7547024e41b2a8c5031178eb797..25fcd73c8d4a129953b493bd271f9d63a40ad3ad 100644 (file)
@@ -35,3 +35,4 @@ def build(bld):
         bld.install_files('${PREFIX}/share/dcpomatic2', 'select.png')
         bld.install_files('${PREFIX}/share/dcpomatic2', 'snap.png')
         bld.install_files('${PREFIX}/share/dcpomatic2', 'sequence.png')
+        bld.install_files('${PREFIX}/share/dcpomatic2', 'me.jpg')
index 2d3f5c47e227a4c9d0e460d350ee2becc8f4da74..c1844855b75c5c956e96653de59f33683f089d79 100644 (file)
@@ -136,6 +136,7 @@ function copy_resources {
     cp $ROOT/32/src/dcpomatic/graphics/select.png "$dest"
     cp $ROOT/32/src/dcpomatic/graphics/snap.png "$dest"
     cp $ROOT/32/src/dcpomatic/graphics/sequence.png "$dest"
+    cp $ROOT/32/src/dcpomatic/graphics/me.jpg "$dest"
 
     # i18n: DCP-o-matic .mo files
     for lang in de_DE es_ES fr_FR it_IT sv_SE nl_NL ru_RU pl_PL da_DK pt_PT pt_BR sk_SK cs_CZ uk_UA zh_CN ar_LB fi_FI el_GR; do
index e02d4c09f452a3db34a42232138e34059d27f5fa..bdfb27b7a64896acd8873caea7fcf61c8c440f70 100644 (file)
@@ -281,6 +281,7 @@ File "%graphics%/zoom_all.png"
 File "%graphics%/select.png"
 File "%graphics%/snap.png"
 File "%graphics%/sequence.png"
+File "%graphics%/me.jpg"
 
 SectionEnd
     """, file=f)
index 74c21a29c1c40a8f9e232422196c9a4024ff4d5e..a4582d7efa32175ba85469d3e8c0ca64fbf690cc 100644 (file)
@@ -26,6 +26,8 @@
 #include <boost/filesystem.hpp>
 #include <boost/algorithm/string.hpp>
 
+#include "i18n.h"
+
 using std::string;
 using dcp::raw_convert;
 using boost::algorithm::trim;
@@ -44,6 +46,35 @@ Analytics::successful_dcp_encode ()
 {
        ++_successful_dcp_encodes;
        write ();
+
+       if (_successful_dcp_encodes == 3) {
+               emit (
+                       boost::bind(
+                               boost::ref(Message),
+                               _("Congratulations!"),
+                               _(
+                                       "<h2>You have made 3 DCPs with DCP-o-matic!</h2>"
+                                       "<img width=\"20%\" src=\"memory:me.jpg\" align=\"center\">"
+                                        "<p>Hello. I'm Carl and I'm the "
+                                       "developer of DCP-o-matic. I work on it in my spare time (with the help "
+                                       "of a fine volunteer team of testers and translators) and I release it "
+                                       "as free software."
+
+                                       "<p>If you find DCP-o-matic useful, please consider a donation to the "
+                                       "project. Financial support will help me to spend more "
+                                       "time developing DCP-o-matic and making it better!"
+
+                                       "<p><ul>"
+                                       "<li><a href=\"https://dcpomatic.com/donate_amount?amount=40\">Go to Paypal to donate £40</a>"
+                                       "<li><a href=\"https://dcpomatic.com/donate_amount?amount=20\">Go to Paypal to donate £20</a>"
+                                       "<li><a href=\"https://dcpomatic.com/donate_amount?amount=10\">Go to Paypal to donate £10</a>"
+                                       "</ul>"
+
+                                       "<p>Thank you!"
+                                       )
+                               )
+                       );
+       }
 }
 
 void
index b439fca8c303fbf0b62ff958cae12274283fe94b..302a41a6e5db3ec2fe6208b96a7962d8bce95abf 100644 (file)
 */
 
 #include "state.h"
+#include "signaller.h"
+#include <boost/signals2.hpp>
 
-class Analytics : public State
+class Analytics : public State, public Signaller
 {
 public:
        Analytics ();
@@ -30,6 +32,8 @@ public:
        void write () const;
        void read ();
 
+       boost::signals2::signal<void (std::string, std::string)> Message;
+
        static Analytics* instance ();
 
 private:
index 2ba3cf173f69a0fd9a5d2b859a29c2e411f018f3..7843c34c86a06269fb33432c7ef04dd0fcc2b0ca 100644 (file)
@@ -18,6 +18,9 @@
 
 */
 
+#ifndef DCPOMATIC_STATE_H
+#define DCPOMATIC_STATE_H
+
 #include <boost/noncopyable.hpp>
 #include <boost/filesystem.hpp>
 #include <boost/optional.hpp>
@@ -34,3 +37,5 @@ public:
 protected:
        static boost::filesystem::path path (std::string file, bool create_directories = true);
 };
+
+#endif
index 6972b35c4e1ac097a781bee3dacaf2fe481add6c..fe23f8eafdb0a96af7378ee470854d1a3ba7e446 100644 (file)
 #include "wx/export_dialog.h"
 #include "wx/paste_dialog.h"
 #include "wx/focus_manager.h"
+#include "wx/html_dialog.h"
 #include "lib/film.h"
 #include "lib/config.h"
 #include "lib/util.h"
 #include "lib/video_content.h"
+#include "lib/analytics.h"
 #include "lib/content.h"
 #include "lib/version.h"
 #include "lib/signal_manager.h"
@@ -79,6 +81,7 @@
 #include <wx/cmdline.h>
 #include <wx/preferences.h>
 #include <wx/splash.h>
+#include <wx/wxhtml.h>
 #ifdef __WXMSW__
 #include <shellapi.h>
 #endif
@@ -277,6 +280,8 @@ public:
                _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this, _1));
                config_changed (Config::OTHER);
 
+               _analytics_message_connection = Analytics::instance()->Message.connect(boost::bind(&DOMFrame::analytics_message, this, _1, _2));
+
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_new, this),                ID_file_new);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this),               ID_file_open);
                Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_save, this),               ID_file_save);
@@ -1001,6 +1006,9 @@ private:
                */
                _config_changed_connection.disconnect ();
 
+               /* Also stop hearing about analytics-related stuff */
+               _analytics_message_connection.disconnect ();
+
                ev.Skip ();
        }
 
@@ -1291,6 +1299,13 @@ private:
                _film_viewer->forward_frame ();
        }
 
+       void analytics_message (string title, string html)
+       {
+               HTMLDialog* d = new HTMLDialog(this, std_to_wx(title), std_to_wx(html));
+               d->ShowModal();
+               d->Destroy();
+       }
+
        FilmEditor* _film_editor;
        FilmViewer* _film_viewer;
        VideoWaveformDialog* _video_waveform_dialog;
@@ -1305,6 +1320,7 @@ private:
        int _history_position;
        wxMenuItem* _history_separator;
        boost::signals2::scoped_connection _config_changed_connection;
+       boost::signals2::scoped_connection _analytics_message_connection;
        bool _update_news_requested;
        shared_ptr<Content> _clipboard;
 };
diff --git a/src/wx/html_dialog.cc b/src/wx/html_dialog.cc
new file mode 100644 (file)
index 0000000..b5f86e7
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+    Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+    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.
+
+    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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include "html_dialog.h"
+#include "wx_util.h"
+#include "lib/cross.h"
+#include <boost/filesystem.hpp>
+#include <wx/wxhtml.h>
+#include <wx/fs_mem.h>
+#include <iostream>
+
+HTMLDialog::HTMLDialog (wxWindow* parent, wxString title, wxString html)
+       : wxDialog (parent, wxID_ANY, title)
+{
+       wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
+
+       wxFileSystem::AddHandler(new wxMemoryFSHandler);
+
+       /* Add some resources that are used by HTML passed into this dialog */
+       wxMemoryFSHandler::AddFile(
+               "me.jpg",
+               wxBitmap(std_to_wx(boost::filesystem::path(shared_path() / "me.jpg").string()), wxBITMAP_TYPE_JPEG), wxBITMAP_TYPE_JPEG
+               );
+
+       wxHtmlWindow* h = new wxHtmlWindow (this);
+       h->SetPage (html);
+       sizer->Add (h, 1, wxEXPAND | wxALL, 6);
+
+       h->Bind (wxEVT_HTML_LINK_CLICKED, boost::bind(&HTMLDialog::link_clicked, this, _1));
+
+       SetSizer (sizer);
+       sizer->Layout ();
+
+       /* Set width */
+       SetSize (800, -1);
+
+       /* Set height */
+       SetSize (h->GetInternalRepresentation()->GetWidth(), h->GetInternalRepresentation()->GetHeight() + 64);
+}
+
+void
+HTMLDialog::link_clicked (wxHtmlLinkEvent& ev)
+{
+       wxLaunchDefaultBrowser(ev.GetLinkInfo().GetHref());
+}
diff --git a/src/wx/html_dialog.h b/src/wx/html_dialog.h
new file mode 100644 (file)
index 0000000..f5fc76e
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+    Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+
+    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.
+
+    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 DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#include <wx/wx.h>
+
+class wxHtmlLinkEvent;
+
+class HTMLDialog : public wxDialog
+{
+public:
+       HTMLDialog (wxWindow* parent, wxString title, wxString html);
+
+private:
+       void link_clicked (wxHtmlLinkEvent& ev);
+};
index 0a32d1dfefcc527f2fdffcb4da6e257162972cb4..36158fffe14c08ef6fc21bff89b93296e192dc28 100644 (file)
@@ -67,6 +67,7 @@ sources = """
           full_config_dialog.cc
           gain_calculator_dialog.cc
           hints_dialog.cc
+          html_dialog.cc
           job_view.cc
           job_view_dialog.cc
           job_manager_view.cc