Olive
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
preferencesdialog.h
Go to the documentation of this file.
1 /***
2 
3  Olive - Non-Linear Video Editor
4  Copyright (C) 2019 Olive Team
5 
6  This program 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 3 of the License, or
9  (at your option) any later version.
10 
11  This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 ***/
20 
21 #ifndef PREFERENCESDIALOG_H
22 #define PREFERENCESDIALOG_H
23 
24 #include <QDialog>
25 #include <QKeySequenceEdit>
26 #include <QMenuBar>
27 #include <QLineEdit>
28 #include <QComboBox>
29 #include <QRadioButton>
30 #include <QTreeWidget>
31 #include <QTreeWidgetItem>
32 #include <QMenu>
33 #include <QCheckBox>
34 #include <QDoubleSpinBox>
35 #include <QSpinBox>
36 
37 #include "timeline/sequence.h"
38 
39 class KeySequenceEditor;
40 
47 class PreferencesDialog : public QDialog
48 {
49  Q_OBJECT
50 
51 public:
59  explicit PreferencesDialog(QWidget *parent = nullptr);
60 
61 private slots:
65  virtual void accept() override;
66 
71 
77  void reset_all_shortcuts();
78 
99  bool refine_shortcut_list(const QString &s, QTreeWidgetItem* parent = nullptr);
100 
104  void load_shortcut_file();
105 
109  void save_shortcut_file();
110 
114  void browse_css_file();
115 
119  void delete_all_previews();
120 
125 
126 private:
127 
131  void setup_ui();
132 
140  void setup_kbd_shortcuts(QMenuBar* menu);
141 
158  void setup_kbd_shortcut_worker(QMenu* menu, QTreeWidgetItem* parent);
159 
160  // used to delete previews
161  // type can be: 't' for thumbnails, 'w' for waveforms, or 1 for all
169  void delete_previews(char type);
170 
174  QLineEdit* custom_css_fn;
175 
179  QLineEdit* imgSeqFormatEdit;
180 
184  QComboBox* recordingComboBox;
185 
189  QTreeWidget* keyboard_tree;
190 
194  QDoubleSpinBox* upcoming_queue_spinbox;
195 
200 
204  QDoubleSpinBox* previous_queue_spinbox;
205 
210 
215 
220 
225 
229  QComboBox* audio_sample_rate;
230 
234  QComboBox* language_combobox;
235 
240 
245 
249  QComboBox* ui_style;
250 
258 
263  QVector<QAction*> key_shortcut_actions;
264 
269  QVector<QTreeWidgetItem*> key_shortcut_items;
270 
275  QVector<KeySequenceEditor*> key_shortcut_fields;
276 
299  void AddBoolPair(QCheckBox* ui, bool* value, bool restart_required = false);
300 
304  QVector<QCheckBox*> bool_ui;
305 
309  QVector<bool*> bool_value;
310 
314  QVector<bool> bool_restart_required;
315 };
316 
323 class KeySequenceEditor : public QKeySequenceEdit {
324  Q_OBJECT
325 public:
337  KeySequenceEditor(QWidget *parent, QAction* a);
338 
346  void set_action_shortcut();
347 
358  void reset_to_default();
359 
371  QString action_name();
372 
383  QString export_shortcut();
384 private:
388  QAction* action;
389 };
390 
391 #endif // PREFERENCESDIALOG_H
void AddBoolPair(QCheckBox *ui, bool *value, bool restart_required=false)
Add an automated QCheckBox+boolean value pair.
Definition: preferencesdialog.cpp:154
Sequence default_sequence
Stored default Sequence object.
Definition: preferencesdialog.h:257
QLineEdit * custom_css_fn
UI widget for editing the CSS filename.
Definition: preferencesdialog.h:174
QSpinBox * effect_textbox_lines_field
UI widget for editing the size of textboxes in the EffectControls panel.
Definition: preferencesdialog.h:214
The PreferencesDialog class.
Definition: preferencesdialog.h:47
QVector< QAction * > key_shortcut_actions
List of keyboard shortcut actions that can be triggered (links with key_shortcut_items and key_shortc...
Definition: preferencesdialog.h:263
QComboBox * ui_style
UI widget for selecting the current UI style.
Definition: preferencesdialog.h:249
void setup_ui()
Create and arrange all UI widgets.
Definition: preferencesdialog.cpp:494
QComboBox * language_combobox
UI widget for selecting the UI language.
Definition: preferencesdialog.h:234
QComboBox * audio_sample_rate
UI widget for selecting the audio sampling rates.
Definition: preferencesdialog.h:229
KeySequenceEditor(QWidget *parent, QAction *a)
KeySequenceEditor Constructor.
Definition: preferencesdialog.cpp:56
QVector< QCheckBox * > bool_ui
Internal array managed by AddBoolPair(). Do not access this directly.
Definition: preferencesdialog.h:304
virtual void accept() override
Override of accept to save preferences to Config.
Definition: preferencesdialog.cpp:186
void browse_css_file()
Show a file dialog to browse for an external CSS file to load for styling the application.
Definition: preferencesdialog.cpp:467
QVector< bool > bool_restart_required
Internal array managed by AddBoolPair(). Do not access this directly.
Definition: preferencesdialog.h:314
QSpinBox * waveform_res_spinbox
UI widget for selecting the resolution of the waveforms to generate.
Definition: preferencesdialog.h:244
QAction * action
Internal reference to the linked QAction.
Definition: preferencesdialog.h:388
QComboBox * previous_queue_type
UI widget for editing the previous queue type.
Definition: preferencesdialog.h:209
void setup_kbd_shortcuts(QMenuBar *menu)
Populate keyboard shortcut panel with keyboard shortcuts from the menu bar.
Definition: preferencesdialog.cpp:163
void edit_default_sequence_settings()
Shows a NewSequenceDialog attached to default_sequence.
Definition: preferencesdialog.cpp:487
void reset_to_default()
Set this shortcut back to the QAction&#39;s default shortcut.
Definition: preferencesdialog.cpp:65
void reset_default_shortcut()
Reset all selected shortcuts in keyboard_tree to their defaults.
Definition: preferencesdialog.cpp:352
QString action_name()
Return attached QAction&#39;s unique ID.
Definition: preferencesdialog.cpp:69
QVector< bool * > bool_value
Internal array managed by AddBoolPair(). Do not access this directly.
Definition: preferencesdialog.h:309
QComboBox * audio_output_devices
UI widget for selecting the output audio device.
Definition: preferencesdialog.h:219
QDoubleSpinBox * upcoming_queue_spinbox
UI widget for editing the upcoming queue size.
Definition: preferencesdialog.h:194
QTreeWidget * keyboard_tree
UI widget for editing keyboard shortcuts.
Definition: preferencesdialog.h:189
void setup_kbd_shortcut_worker(QMenu *menu, QTreeWidgetItem *parent)
Internal function called by setup_kbd_shortcuts() to traverse down the menu bar&#39;s hierarchy and popul...
Definition: preferencesdialog.cpp:99
QLineEdit * imgSeqFormatEdit
UI widget for editing the list of extensions to detect image sequences from.
Definition: preferencesdialog.h:179
void reset_all_shortcuts()
Reset all shortcuts indiscriminately to their defaults.
Definition: preferencesdialog.cpp:360
QVector< KeySequenceEditor * > key_shortcut_fields
List of keyboard shortcut editing fields in keyboard_tree corresponding to existing actions (links wi...
Definition: preferencesdialog.h:275
void delete_previews(char type)
Delete disk cached preview files (thumbnails, waveforms, etc.)
Definition: preferencesdialog.cpp:121
QString export_shortcut()
Serialize this shortcut entry into a string that can be saved to a file.
Definition: preferencesdialog.cpp:73
The KeySequenceEditor class.
Definition: preferencesdialog.h:323
PreferencesDialog(QWidget *parent=nullptr)
PreferencesDialog Constructor.
Definition: preferencesdialog.cpp:81
QComboBox * recordingComboBox
UI widget for editing the recording channels.
Definition: preferencesdialog.h:184
QSpinBox * thumbnail_res_spinbox
UI widget for selecting the resolution of the thumbnails to generate.
Definition: preferencesdialog.h:239
Definition: sequence.h:31
QVector< QTreeWidgetItem * > key_shortcut_items
List of keyboard shortcut items in keyboard_tree corresponding to existing actions (links with key_sh...
Definition: preferencesdialog.h:269
void set_action_shortcut()
Sets the attached QAction&#39;s shortcut to the shortcut entered in this field.
Definition: preferencesdialog.cpp:61
void save_shortcut_file()
Show a file dialog to save an external shortcut preset from file.
Definition: preferencesdialog.cpp:445
QComboBox * upcoming_queue_type
UI widget for editing the upcoming queue type.
Definition: preferencesdialog.h:199
bool refine_shortcut_list(const QString &s, QTreeWidgetItem *parent=nullptr)
Shows/hides shortcut entries according to a shortcut query.
Definition: preferencesdialog.cpp:372
void load_shortcut_file()
Show a file dialog to load an external shortcut preset from file.
Definition: preferencesdialog.cpp:413
QDoubleSpinBox * previous_queue_spinbox
UI widget for editing the previous queue size.
Definition: preferencesdialog.h:204
QComboBox * audio_input_devices
UI widget for selecting the input audio device.
Definition: preferencesdialog.h:224
void delete_all_previews()
Delete all previews (waveform and thumbnail cache)
Definition: preferencesdialog.cpp:474