Bind audio API choice to do something.
[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 class Choice;
54 class FilmViewer;
55
56
57 class Page : public wxPreferencesPage
58 {
59 public:
60         Page (wxSize panel_size, int border);
61         virtual ~Page () {}
62
63         wxWindow* CreateWindow (wxWindow* parent) override;
64
65 protected:
66         wxWindow* create_window (wxWindow* parent);
67
68         int _border;
69         wxPanel* _panel;
70
71 private:
72         virtual void config_changed () = 0;
73         virtual void setup () = 0;
74
75         void config_changed_wrapper ();
76         void window_destroyed ();
77
78         wxSize _panel_size;
79         boost::signals2::scoped_connection _config_connection;
80         bool _window_exists;
81 };
82
83
84 class GeneralPage : public Page
85 {
86 public:
87         GeneralPage (wxSize panel_size, int border);
88
89         wxString GetName () const override;
90
91 #ifdef DCPOMATIC_OSX
92         wxBitmap GetLargeIcon () const override
93         {
94                 return wxBitmap(icon_path("general"), wxBITMAP_TYPE_PNG);
95         }
96 #endif
97
98 protected:
99         void add_language_controls (wxGridBagSizer* table, int& r);
100         void add_update_controls (wxGridBagSizer* table, int& r);
101         void config_changed () override;
102
103 private:
104         void setup_sensitivity ();
105         void set_language_changed ();
106         void language_changed ();
107         void check_for_updates_changed ();
108         void check_for_test_updates_changed ();
109
110         CheckBox* _set_language;
111         wxChoice* _language;
112         CheckBox* _check_for_updates;
113         CheckBox* _check_for_test_updates;
114 };
115
116
117 class CertificateChainEditor : public wxDialog
118 {
119 public:
120         CertificateChainEditor (
121                 wxWindow* parent,
122                 wxString title,
123                 int border,
124                 std::function<void (std::shared_ptr<dcp::CertificateChain>)> set,
125                 std::function<std::shared_ptr<const dcp::CertificateChain> (void)> get,
126                 std::function<bool (void)> nag_alter
127                 );
128
129         void add_button (wxWindow* button);
130
131 private:
132         void add_certificate ();
133         void remove_certificate ();
134         void export_certificate ();
135         void update_certificate_list ();
136         void remake_certificates ();
137         void update_sensitivity ();
138         void update_private_key ();
139         void import_private_key ();
140         void export_private_key ();
141         void export_chain ();
142
143         wxListCtrl* _certificates;
144         wxButton* _add_certificate;
145         wxButton* _export_certificate;
146         wxButton* _remove_certificate;
147         wxButton* _remake_certificates;
148         wxStaticText* _private_key;
149         wxButton* _import_private_key;
150         wxButton* _export_private_key;
151         wxButton* _export_chain;
152         wxStaticText* _private_key_bad;
153         wxSizer* _sizer;
154         wxBoxSizer* _button_sizer;
155         std::function<void (std::shared_ptr<dcp::CertificateChain>)> _set;
156         std::function<std::shared_ptr<const dcp::CertificateChain> (void)> _get;
157         std::function<bool (void)> _nag_alter;
158 };
159
160 class KeysPage : public Page
161 {
162 public:
163         KeysPage (wxSize panel_size, int border)
164                 : Page (panel_size, border)
165         {}
166
167         wxString GetName () const override;
168
169 #ifdef DCPOMATIC_OSX
170         wxBitmap GetLargeIcon () const override
171         {
172                 return wxBitmap(icon_path("keys"), wxBITMAP_TYPE_PNG);
173         }
174 #endif
175
176 private:
177
178         void setup () override;
179
180         void export_decryption_certificate ();
181         void config_changed () override {}
182         bool nag_alter_decryption_chain ();
183         void decryption_advanced ();
184         void signing_advanced ();
185         void export_decryption_chain_and_key ();
186         void import_decryption_chain_and_key ();
187         void remake_signing ();
188 };
189
190
191 class SoundPage : public Page
192 {
193 public:
194         SoundPage(wxSize panel_size, int border, FilmViewer* viewer)
195                 : Page (panel_size, border)
196                 , _viewer(viewer)
197         {}
198
199         wxString GetName() const override;
200
201 #ifdef DCPOMATIC_OSX
202         wxBitmap GetLargeIcon () const override
203         {
204                 return wxBitmap(icon_path("sound"), wxBITMAP_TYPE_PNG);
205         }
206 #endif
207
208 private:
209
210         void setup () override;
211         void config_changed () override;
212         boost::optional<std::string> get_sound_api() const;
213         boost::optional<std::string> get_sound_output() const;
214         void sound_changed ();
215         void sound_api_changed();
216         void sound_output_changed ();
217         void setup_sensitivity ();
218         void map_changed (AudioMapping m);
219         void reset_to_default ();
220         void update_sound_outputs();
221
222         CheckBox* _sound;
223         Choice* _sound_api;
224         wxChoice* _sound_output;
225         wxStaticText* _sound_output_details;
226         AudioMappingView* _map;
227         Button* _reset_to_default;
228         FilmViewer* _viewer;
229 };
230
231
232 class LocationsPage : public Page
233 {
234 public:
235         LocationsPage (wxSize panel_size, int border);
236
237         wxString GetName () const override;
238
239 #ifdef DCPOMATIC_OSX
240         wxBitmap GetLargeIcon () const override;
241 #endif
242
243 private:
244         void setup () override;
245         void config_changed () override;
246         void content_directory_changed ();
247         void playlist_directory_changed ();
248         void kdm_directory_changed ();
249
250         wxDirPickerCtrl* _content_directory;
251         wxDirPickerCtrl* _playlist_directory;
252         wxDirPickerCtrl* _kdm_directory;
253 };
254
255 #endif