summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-04-14 21:07:32 +0100
committerCarl Hetherington <cth@carlh.net>2019-04-14 21:07:32 +0100
commit183b5597f73b85c0d6d29db8f6ed519386d07aa9 (patch)
tree65e865ac842b9241377af62a263a7fa5eb0d1e55 /src/lib
parent985e727e001e1a92ae035364a9cbf1ff99522ff1 (diff)
Add donation nag after 20 successful DCP encodes.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/analytics.cc32
-rw-r--r--src/lib/analytics.h8
-rw-r--r--src/lib/state.h5
3 files changed, 43 insertions, 2 deletions
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 <dcp/raw_convert.h>
#include <libcxml/cxml.h>
#include <libxml++/libxml++.h>
#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 +47,35 @@ Analytics::successful_dcp_encode ()
{
++_successful_dcp_encodes;
write ();
+
+ if (_successful_dcp_encodes == 20) {
+ emit (
+ boost::bind(
+ boost::ref(Message),
+ _("Congratulations!"),
+ String::compose (_(
+ "<h2>You have made %1 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!"), _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 <cth@carlh.net>
+ Copyright (C) 2018-2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -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 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 <boost/noncopyable.hpp>
#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
@@ -35,3 +38,5 @@ public:
protected:
static boost::filesystem::path path (std::string file, bool create_directories = true);
};
+
+#endif