Supporters update.
[dcpomatic.git] / src / wx / config_dialog.h
1 /*
2     Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21
22 #ifndef DCPOMATIC_CONFIG_DIALOG_H
23 #define DCPOMATIC_CONFIG_DIALOG_H
24
25
26 #include "editable_list.h"
27 #include "make_chain_dialog.h"
28 #include "wx_util.h"
29 #include "lib/config.h"
30 #include "lib/cross.h"
31 #include "lib/dcp_content_type.h"
32 #include "lib/exceptions.h"
33 #include "lib/filter.h"
34 #include "lib/log.h"
35 #include "lib/ratio.h"
36 #include "lib/util.h"
37 #include <dcp/certificate_chain.h>
38 #include <dcp/exceptions.h>
39 #include <dcp/locale_convert.h>
40 #include <dcp/warnings.h>
41 LIBDCP_DISABLE_WARNINGS
42 #include <wx/filepicker.h>
43 #include <wx/preferences.h>
44 #include <wx/spinctrl.h>
45 #include <wx/stdpaths.h>
46 #include <RtAudio.h>
47 LIBDCP_ENABLE_WARNINGS
48 #include <boost/filesystem.hpp>
49
50
51 class AudioMappingView;
52 class CheckBox;
53
54
55 class Page : public wxPreferencesPage
56 {
57 public:
58         Page (wxSize panel_size, int border);
59         virtual ~Page () {}
60
61         wxWindow* CreateWindow (wxWindow* parent) override;
62
63 protected:
64         wxWindow* create_window (wxWindow* parent);
65
66         int _border;
67         wxPanel* _panel;
68
69 private:
70         virtual void config_changed () = 0;
71         virtual void setup () = 0;
72
73         void config_changed_wrapper ();
74         void window_destroyed ();
75
76         wxSize _panel_size;
77         boost::signals2::scoped_connection _config_connection;
78         bool _window_exists;
79 };
80
81
82 class GeneralPage : public Page
83 {
84 public:
85         GeneralPage (wxSize panel_size, int border);
86
87         wxString GetName () const override;
88
89 #ifdef DCPOMATIC_OSX
90         wxBitmap GetLargeIcon () const override
91         {
92                 return wxBitmap(icon_path("general"), wxBITMAP_TYPE_PNG);
93         }
94 #endif
95
96 protected:
97         void add_language_controls (wxGridBagSizer* table, int& r);
98         void add_update_controls (wxGridBagSizer* table, int& r);
99         void config_changed () override;
100
101 private:
102         void setup_sensitivity ();
103         void set_language_changed ();
104         void language_changed ();
105         void check_for_updates_changed ();
106         void check_for_test_updates_changed ();
107
108         CheckBox* _set_language;
109         wxChoice* _language;
110         CheckBox* _check_for_updates;
111         CheckBox* _check_for_test_updates;
112 };
113
114
115 class CertificateChainEditor : public wxDialog
116 {
117 public:
118         CertificateChainEditor (
119                 wxWindow* parent,
120                 wxString title,
121                 int border,
122                 std::function<void (std::shared_ptr<dcp::CertificateChain>)> set,
123                 std::function<std::shared_ptr<const dcp::CertificateChain> (void)> get,
124                 std::function<bool (void)> nag_alter
125                 );
126
127         void add_button (wxWindow* button);
128
129 private:
130         void add_certificate ();
131         void remove_certificate ();
132         void export_certificate ();
133         void update_certificate_list ();
134         void remake_certificates ();
135         void update_sensitivity ();
136         void update_private_key ();
137         void import_private_key ();
138         void export_private_key ();
139         void export_chain ();
140
141         wxListCtrl* _certificates;
142         wxButton* _add_certificate;
143         wxButton* _export_certificate;
144         wxButton* _remove_certificate;
145         wxButton* _remake_certificates;
146         wxStaticText* _private_key;
147         wxButton* _import_private_key;
148         wxButton* _export_private_key;
149         wxButton* _export_chain;
150         wxStaticText* _private_key_bad;
151         wxSizer* _sizer;
152         wxBoxSizer* _button_sizer;
153         std::function<void (std::shared_ptr<dcp::CertificateChain>)> _set;
154         std::function<std::shared_ptr<const dcp::CertificateChain> (void)> _get;
155         std::function<bool (void)> _nag_alter;
156 };
157
158 class KeysPage : public Page
159 {
160 public:
161         KeysPage (wxSize panel_size, int border)
162                 : Page (panel_size, border)
163         {}
164
165         wxString GetName () const override;
166
167 #ifdef DCPOMATIC_OSX
168         wxBitmap GetLargeIcon () const override
169         {
170                 return wxBitmap(icon_path("keys"), wxBITMAP_TYPE_PNG);
171         }
172 #endif
173
174 private:
175
176         void setup () override;
177
178         void export_decryption_certificate ();
179         void config_changed () override {}
180         bool nag_alter_decryption_chain ();
181         void decryption_advanced ();
182         void signing_advanced ();
183         void export_decryption_chain_and_key ();
184         void import_decryption_chain_and_key ();
185         void remake_signing ();
186 };
187
188
189 class SoundPage : public Page
190 {
191 public:
192         SoundPage (wxSize panel_size, int border)
193                 : Page (panel_size, border)
194         {}
195
196         wxString GetName() const override;
197
198 #ifdef DCPOMATIC_OSX
199         wxBitmap GetLargeIcon () const override
200         {
201                 return wxBitmap(icon_path("sound"), wxBITMAP_TYPE_PNG);
202         }
203 #endif
204
205 private:
206
207         void setup () override;
208         void config_changed () override;
209         boost::optional<std::string> get_sound_output ();
210         void sound_changed ();
211         void sound_output_changed ();
212         void setup_sensitivity ();
213         void map_changed (AudioMapping m);
214         void reset_to_default ();
215
216         CheckBox* _sound;
217         wxChoice* _sound_output;
218         wxStaticText* _sound_output_details;
219         AudioMappingView* _map;
220         Button* _reset_to_default;
221 };
222
223
224 class LocationsPage : public Page
225 {
226 public:
227         LocationsPage (wxSize panel_size, int border);
228
229         wxString GetName () const override;
230
231 #ifdef DCPOMATIC_OSX
232         wxBitmap GetLargeIcon () const override;
233 #endif
234
235 private:
236         void setup () override;
237         void config_changed () override;
238         void content_directory_changed ();
239         void playlist_directory_changed ();
240         void kdm_directory_changed ();
241
242         wxDirPickerCtrl* _content_directory;
243         wxDirPickerCtrl* _playlist_directory;
244         wxDirPickerCtrl* _kdm_directory;
245 };
246
247 #endif