818ab4def911545f714138859779832495f436f2
[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 #ifndef DCPOMATIC_CONFIG_DIALOG_H
22 #define DCPOMATIC_CONFIG_DIALOG_H
23
24 #include "wx_util.h"
25 #include "editable_list.h"
26 #include "make_chain_dialog.h"
27 #include "lib/config.h"
28 #include "lib/ratio.h"
29 #include "lib/filter.h"
30 #include "lib/dcp_content_type.h"
31 #include "lib/log.h"
32 #include "lib/util.h"
33 #include "lib/cross.h"
34 #include "lib/exceptions.h"
35 #include "lib/warnings.h"
36 #include <dcp/locale_convert.h>
37 #include <dcp/exceptions.h>
38 #include <dcp/certificate_chain.h>
39 DCPOMATIC_DISABLE_WARNINGS
40 #include <wx/stdpaths.h>
41 #include <wx/preferences.h>
42 #include <wx/spinctrl.h>
43 #include <wx/filepicker.h>
44 DCPOMATIC_ENABLE_WARNINGS
45 #include <RtAudio.h>
46 #include <boost/filesystem.hpp>
47 #include <iostream>
48
49 class AudioMappingView;
50
51 class Page : public wxPreferencesPage
52 {
53 public:
54         Page (wxSize panel_size, int border);
55         virtual ~Page () {}
56
57         wxWindow* CreateWindow (wxWindow* parent);
58
59 protected:
60         wxWindow* create_window (wxWindow* parent);
61
62         int _border;
63         wxPanel* _panel;
64
65 private:
66         virtual void config_changed () = 0;
67         virtual void setup () = 0;
68
69         void config_changed_wrapper ();
70         void window_destroyed ();
71
72         wxSize _panel_size;
73         boost::signals2::scoped_connection _config_connection;
74         bool _window_exists;
75 };
76
77 class GeneralPage : public Page
78 {
79 public:
80         GeneralPage (wxSize panel_size, int border);
81
82         wxString GetName () const;
83
84 #ifdef DCPOMATIC_OSX
85         wxBitmap GetLargeIcon () const
86         {
87                 return wxBitmap ("general", wxBITMAP_TYPE_PNG_RESOURCE);
88         }
89 #endif
90
91 protected:
92         void add_language_controls (wxGridBagSizer* table, int& r);
93         void add_update_controls (wxGridBagSizer* table, int& r);
94         virtual void config_changed ();
95
96 private:
97         void setup_sensitivity ();
98         void set_language_changed ();
99         void language_changed ();
100         void check_for_updates_changed ();
101         void check_for_test_updates_changed ();
102
103         wxCheckBox* _set_language;
104         wxChoice* _language;
105         wxCheckBox* _check_for_updates;
106         wxCheckBox* _check_for_test_updates;
107 };
108
109 class CertificateChainEditor : public wxDialog
110 {
111 public:
112         CertificateChainEditor (
113                 wxWindow* parent,
114                 wxString title,
115                 int border,
116                 boost::function<void (std::shared_ptr<dcp::CertificateChain>)> set,
117                 boost::function<std::shared_ptr<const dcp::CertificateChain> (void)> get,
118                 boost::function<bool (void)> nag_alter
119                 );
120
121         void add_button (wxWindow* button);
122
123 private:
124         void add_certificate ();
125         void remove_certificate ();
126         void export_certificate ();
127         void update_certificate_list ();
128         void remake_certificates ();
129         void update_sensitivity ();
130         void update_private_key ();
131         void import_private_key ();
132         void export_private_key ();
133         void export_chain ();
134
135         wxListCtrl* _certificates;
136         wxButton* _add_certificate;
137         wxButton* _export_certificate;
138         wxButton* _remove_certificate;
139         wxButton* _remake_certificates;
140         wxStaticText* _private_key;
141         wxButton* _import_private_key;
142         wxButton* _export_private_key;
143         wxButton* _export_chain;
144         wxStaticText* _private_key_bad;
145         wxSizer* _sizer;
146         wxBoxSizer* _button_sizer;
147         boost::function<void (std::shared_ptr<dcp::CertificateChain>)> _set;
148         boost::function<std::shared_ptr<const dcp::CertificateChain> (void)> _get;
149         boost::function<bool (void)> _nag_alter;
150 };
151
152 class KeysPage : public Page
153 {
154 public:
155         KeysPage (wxSize panel_size, int border)
156                 : Page (panel_size, border)
157         {}
158
159         wxString GetName () const;
160
161 #ifdef DCPOMATIC_OSX
162         wxBitmap GetLargeIcon () const
163         {
164                 return wxBitmap ("keys", wxBITMAP_TYPE_PNG_RESOURCE);
165         }
166 #endif
167
168 private:
169
170         void setup ();
171
172         void export_decryption_certificate ();
173         void config_changed () {}
174         bool nag_alter_decryption_chain ();
175         void decryption_advanced ();
176         void signing_advanced ();
177         void export_decryption_chain_and_key ();
178         void import_decryption_chain_and_key ();
179 };
180
181
182 class SoundPage : public Page
183 {
184 public:
185         SoundPage (wxSize panel_size, int border)
186                 : Page (panel_size, border)
187         {}
188
189         wxString GetName() const;
190
191 #ifdef DCPOMATIC_OSX
192         wxBitmap GetLargeIcon () const
193         {
194                 return wxBitmap ("sound", wxBITMAP_TYPE_PNG_RESOURCE);
195         }
196 #endif
197
198 private:
199
200         void setup ();
201         void config_changed ();
202         boost::optional<std::string> get_sound_output ();
203         void sound_changed ();
204         void sound_output_changed ();
205         void setup_sensitivity ();
206         void map_changed (AudioMapping m);
207         void reset_to_default ();
208
209         wxCheckBox* _sound;
210         wxChoice* _sound_output;
211         wxStaticText* _sound_output_details;
212         AudioMappingView* _map;
213         Button* _reset_to_default;
214 };
215
216 class LocationsPage : public Page
217 {
218 public:
219         LocationsPage (wxSize panel_size, int border);
220
221         wxString GetName () const;
222
223 #ifdef DCPOMATIC_OSX
224         wxBitmap GetLargeIcon () const;
225 #endif
226
227 private:
228         void setup ();
229         void config_changed ();
230         void content_directory_changed ();
231         void playlist_directory_changed ();
232         void kdm_directory_changed ();
233
234         wxDirPickerCtrl* _content_directory;
235         wxDirPickerCtrl* _playlist_directory;
236         wxDirPickerCtrl* _kdm_directory;
237 };
238 #endif