diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-08-08 17:04:26 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-08-14 11:18:18 +0100 |
| commit | eb370b3058dacc1b21ee8f576af5d6189670673e (patch) | |
| tree | 3c34e38250ab4966914cd4f52d8a9a6d4f78c6da | |
| parent | 350b8076eb7ef0a40c5a803a7b58a732c694252d (diff) | |
Nag on 3rd successful DCP encode.
| -rw-r--r-- | graphics/me.jpg | bin | 0 -> 274885 bytes | |||
| -rw-r--r-- | graphics/wscript | 1 | ||||
| -rw-r--r-- | platform/osx/make_dmg.sh | 1 | ||||
| -rw-r--r-- | platform/windows/wscript | 1 | ||||
| -rw-r--r-- | src/lib/analytics.cc | 31 | ||||
| -rw-r--r-- | src/lib/analytics.h | 6 | ||||
| -rw-r--r-- | src/lib/state.h | 5 | ||||
| -rw-r--r-- | src/tools/dcpomatic.cc | 16 | ||||
| -rw-r--r-- | src/wx/html_dialog.cc | 62 | ||||
| -rw-r--r-- | src/wx/html_dialog.h | 32 | ||||
| -rw-r--r-- | src/wx/wscript | 1 |
11 files changed, 155 insertions, 1 deletions
diff --git a/graphics/me.jpg b/graphics/me.jpg Binary files differnew file mode 100644 index 000000000..59583b8a0 --- /dev/null +++ b/graphics/me.jpg diff --git a/graphics/wscript b/graphics/wscript index 72418cb53..25fcd73c8 100644 --- a/graphics/wscript +++ b/graphics/wscript @@ -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') diff --git a/platform/osx/make_dmg.sh b/platform/osx/make_dmg.sh index 2d3f5c47e..c1844855b 100644 --- a/platform/osx/make_dmg.sh +++ b/platform/osx/make_dmg.sh @@ -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 diff --git a/platform/windows/wscript b/platform/windows/wscript index e02d4c09f..bdfb27b7a 100644 --- a/platform/windows/wscript +++ b/platform/windows/wscript @@ -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) diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index 74c21a29c..a4582d7ef 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -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 diff --git a/src/lib/analytics.h b/src/lib/analytics.h index b439fca8c..302a41a6e 100644 --- a/src/lib/analytics.h +++ b/src/lib/analytics.h @@ -19,8 +19,10 @@ */ #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: diff --git a/src/lib/state.h b/src/lib/state.h index 2ba3cf173..7843c34c8 100644 --- a/src/lib/state.h +++ b/src/lib/state.h @@ -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 diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 6972b35c4..fe23f8eaf 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -45,10 +45,12 @@ #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 index 000000000..b5f86e7a1 --- /dev/null +++ b/src/wx/html_dialog.cc @@ -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 index 000000000..f5fc76e4f --- /dev/null +++ b/src/wx/html_dialog.h @@ -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); +}; diff --git a/src/wx/wscript b/src/wx/wscript index 0a32d1dfe..36158fffe 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -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 |
