Debian Codegraph @

components/extension/donate/methods/bitcoin.cpp

raw symbols SCIP
1 /* fre:ac - free audio converter
2 * Copyright (C) 2001-2019 Robert Kausch <[email protected]>
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation, either version 2 of
7 * the License, or (at your option) any later version.
8 *
9 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
10 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
11 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */
12
13 #include "bitcoin.h"
14 #include "../dialog.h"
15
16 static PaymentMethod *MethodBitcoinFactory()
17 {
18 return new MethodBitcoin();
19 }
20
21 Bool methodBitcoinRegistered = DonateDialog::RegisterPaymentMethod(&MethodBitcoinFactory);
22
23 BoCA::MethodBitcoin::MethodBitcoin() : PaymentMethod("bitcoin")
24 {
25 layer = NIL;
26
27 /* Load Bitcoin logo.
28 */
29 Directory dir(Utilities::GetBoCADirectory().Append("freac.extension.donate"));
30
31 if (!dir.Exists()) dir = Utilities::GetBoCADirectory().Append("../freac/freac.extension.donate");
32
33 logo = ImageLoader::Load(String(dir).Append("/bitcoin/logo.png"));
34 }
35
36 BoCA::MethodBitcoin::~MethodBitcoin()
37 {
38 if (layer != NIL) Object::DeleteObject(layer);
39 }
40
41 Layer *BoCA::MethodBitcoin::GetLayer()
42 {
43 if (layer == NIL) layer = new LayerBitcoin();
44
45 return layer;
46 }
47
48 BoCA::LayerBitcoin::LayerBitcoin()
49 {
50 I18n *i18n = I18n::Get();
51
52 i18n->SetContext("Extensions::Donate::Bitcoin");
53
54 Directory dir(Utilities::GetBoCADirectory().Append("freac.extension.donate"));
55
56 if (!dir.Exists()) dir = Utilities::GetBoCADirectory().Append("../freac/freac.extension.donate");
57
58 link_qrcode = new Hyperlink(ImageLoader::Load(String(dir).Append("/bitcoin/qrcode.png")), "bitcoin:1Bdrs9J4sF5Mdu4L7qUacUjVdd1riuVDbT", Point(101, 4), Size(96, 96));
59 link_qrcode->SetOrientation(OR_UPPERRIGHT);
60
61 text_donate = new Text(i18n->TranslateString("Please scan or click the QR code or copy the following\naddress to donate Bitcoin:"), Point(7, 4));
62
63 cursor_bitcoin = new Cursor(Point(7, text_donate->GetUnscaledTextHeight() + 24), Size(210, 16));
64 cursor_bitcoin->SetText("1Bdrs9J4sF5Mdu4L7qUacUjVdd1riuVDbT");
65 cursor_bitcoin->SetSize(Size(cursor_bitcoin->GetUnscaledTextWidth(), cursor_bitcoin->GetUnscaledTextHeight()) + Size(1, 3));
66 cursor_bitcoin->Deactivate();
67
68 text_other = new Text(i18n->TranslateString("This address also accepts Bitcoin Cash and other forks."), Point(7, cursor_bitcoin->GetY() + cursor_bitcoin->GetUnscaledTextHeight() + 22));
69
70 cursor_bitcoin->SetX(7 + (Math::Max(text_donate->GetUnscaledTextWidth(), text_other->GetUnscaledTextWidth()) - cursor_bitcoin->GetWidth()) / 2);
71
72 Add(link_qrcode);
73
74 Add(text_donate);
75
76 Add(cursor_bitcoin);
77
78 Add(text_other);
79
80 SetSize(Size(Math::Max(text_donate->GetUnscaledTextWidth(), text_other->GetUnscaledTextWidth()) + 116, Math::Max(103, text_other->GetY() + text_other->GetUnscaledTextHeight() + 6)));
81 }
82
83 BoCA::LayerBitcoin::~LayerBitcoin()
84 {
85 DeleteObject(link_qrcode);
86
87 DeleteObject(text_donate);
88
89 DeleteObject(cursor_bitcoin);
90
91 DeleteObject(text_other);
92 }