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