From: Carl Hetherington Date: Sun, 14 Apr 2019 20:07:32 +0000 (+0100) Subject: Add donation nag after 20 successful DCP encodes. X-Git-Tag: v2.13.146~6 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=183b5597f73b85c0d6d29db8f6ed519386d07aa9 Add donation nag after 20 successful DCP encodes. --- diff --git a/graphics/me.jpg b/graphics/me.jpg new file mode 100644 index 000000000..59583b8a0 Binary files /dev/null and b/graphics/me.jpg differ diff --git a/graphics/wscript b/graphics/wscript index f8a1183a1..9eb95f0b9 100644 --- a/graphics/wscript +++ b/graphics/wscript @@ -35,5 +35,6 @@ 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') bld.install_files('${PREFIX}/share/dcpomatic2', 'tick.png') bld.install_files('${PREFIX}/share/dcpomatic2', 'no_tick.png') diff --git a/platform/osx/make_dmg.sh b/platform/osx/make_dmg.sh index 4afb54700..d7aaade8c 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 tr_TR; do diff --git a/platform/windows/wscript b/platform/windows/wscript index b1665bfa9..b130acf2c 100644 --- a/platform/windows/wscript +++ b/platform/windows/wscript @@ -300,6 +300,7 @@ File "%graphics%/zoom_all.png" File "%graphics%/select.png" File "%graphics%/snap.png" File "%graphics%/sequence.png" +File "%graphics%/me.jpg" File "%graphics%/tick.png" File "%graphics%/no_tick.png" diff --git a/src/lib/analytics.cc b/src/lib/analytics.cc index 74c21a29c..0bb8ada8c 100644 --- a/src/lib/analytics.cc +++ b/src/lib/analytics.cc @@ -20,12 +20,15 @@ #include "analytics.h" #include "exceptions.h" +#include "compose.hpp" #include #include #include #include #include +#include "i18n.h" + using std::string; using dcp::raw_convert; using boost::algorithm::trim; @@ -44,6 +47,35 @@ Analytics::successful_dcp_encode () { ++_successful_dcp_encodes; write (); + + if (_successful_dcp_encodes == 20) { + emit ( + boost::bind( + boost::ref(Message), + _("Congratulations!"), + String::compose (_( + "

You have made %1 DCPs with DCP-o-matic!

" + "" + "

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." + + "

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!" + + "

" + + "

Thank you!"), _successful_dcp_encodes + ) + ) + ); + } } void diff --git a/src/lib/analytics.h b/src/lib/analytics.h index b439fca8c..be41e3a1b 100644 --- a/src/lib/analytics.h +++ b/src/lib/analytics.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2018 Carl Hetherington + Copyright (C) 2018-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -19,8 +19,10 @@ */ #include "state.h" +#include "signaller.h" +#include -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 Message; + static Analytics* instance (); private: diff --git a/src/lib/state.h b/src/lib/state.h index b60c66673..251124a43 100644 --- a/src/lib/state.h +++ b/src/lib/state.h @@ -18,6 +18,9 @@ */ +#ifndef DCPOMATIC_STATE_H +#define DCPOMATIC_STATE_H + #include #include #include @@ -35,3 +38,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 1db6b2d0f..cd21d8080 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -46,10 +46,12 @@ #include "wx/export_dialog.h" #include "wx/paste_dialog.h" #include "wx/focus_manager.h" +#include "wx/html_dialog.h" #include "wx/initial_setup_dialog.h" #include "wx/send_i18n_dialog.h" #include "wx/i18n_hook.h" #include "lib/film.h" +#include "lib/analytics.h" #include "lib/emailer.h" #include "lib/config.h" #include "lib/util.h" @@ -87,6 +89,7 @@ #include #include #include +#include #ifdef __WXMSW__ #include #endif @@ -290,6 +293,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); @@ -1105,6 +1110,9 @@ private: */ _config_changed_connection.disconnect (); + /* Also stop hearing about analytics-related stuff */ + _analytics_message_connection.disconnect (); + ev.Skip (); } @@ -1403,6 +1411,13 @@ private: _film_viewer->seek_by (_film_viewer->one_video_frame(), true); } + 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; boost::shared_ptr _film_viewer; StandardControls* _controls; @@ -1418,6 +1433,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 _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 + + 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 . + +*/ + +#include "html_dialog.h" +#include "wx_util.h" +#include "lib/cross.h" +#include +#include +#include +#include + +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 + + 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 . + +*/ + +#include + +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 183466106..47c9d1b3e 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -71,6 +71,7 @@ sources = """ gain_calculator_dialog.cc gdc_certificate_panel.cc hints_dialog.cc + html_dialog.cc initial_setup_dialog.cc instant_i18n_dialog.cc i18n_hook.cc