This commit is contained in:
itsmattkc
2019-02-15 16:10:09 -08:00
parent 65a136b0e9
commit c29f0a12c1
6 changed files with 81 additions and 46 deletions
+59 -32
View File
@@ -20,6 +20,7 @@
#include "preferencesdialog.h" #include "preferencesdialog.h"
#include "oliveglobal.h"
#include "io/config.h" #include "io/config.h"
#include "io/path.h" #include "io/path.h"
#include "playback/audio.h" #include "playback/audio.h"
@@ -168,6 +169,10 @@ void PreferencesDialog::setup_kbd_shortcuts(QMenuBar* menubar) {
} }
void PreferencesDialog::save() { void PreferencesDialog::save() {
bool restart_after_saving = false;
bool reinit_audio = false;
// Validate whether the specified CSS file exists
if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) { if (!custom_css_fn->text().isEmpty() && !QFileInfo::exists(custom_css_fn->text())) {
QMessageBox::critical( QMessageBox::critical(
this, this,
@@ -177,10 +182,48 @@ void PreferencesDialog::save() {
return; return;
} }
// save settings from UI to backend // Check if any settings will require a restart of Olive
if (config.effect_textbox_lines != effect_textbox_lines_field->value()
|| config.use_software_fallback != use_software_fallbacks_checkbox->isChecked()
|| config.language_file != language_combobox->currentData().toString()
|| config.thumbnail_resolution != thumbnail_res_spinbox->value()
|| config.waveform_resolution != waveform_res_spinbox->value()) {
// any changes to these settings will require a restart - ask the user if we should do one now or later
int ret = QMessageBox::question(this,
"Restart Required",
"Some of the changed settings will require a restart of Olive. Would you like to"
"restart now?",
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel);
if (ret == QMessageBox::Cancel) {
// Return to Preferences dialog without saving any settings
return;
} else if (ret == QMessageBox::Yes) {
// Check if we can close the current project. If not, we'll treat it as if the user clicked "Cancel".
if (Olive::Global->can_close_project()) {
restart_after_saving = true;
} else {
return;
}
}
// Selecting "No" will save the settings and not restart. They will become active next time Olive opens.
}
// Audio settings may require the audio device to be re-initiated.
if (config.preferred_audio_output != audio_output_devices->currentData().toString()
|| config.preferred_audio_input != audio_input_devices->currentData().toString()
|| config.audio_rate != audio_sample_rate->currentData().toInt()) {
reinit_audio = true;
}
// save settings from UI to backend
config.css_path = custom_css_fn->text(); config.css_path = custom_css_fn->text();
Olive::MainWindow->load_css_from_file(config.css_path); Olive::MainWindow->load_css_from_file(config.css_path);
config.recording_mode = recordingComboBox->currentIndex() + 1; config.recording_mode = recordingComboBox->currentIndex() + 1;
config.img_seq_formats = imgSeqFormatEdit->text(); config.img_seq_formats = imgSeqFormatEdit->text();
config.fast_seeking = fastSeekButton->isChecked(); config.fast_seeking = fastSeekButton->isChecked();
@@ -188,38 +231,19 @@ void PreferencesDialog::save() {
config.upcoming_queue_type = upcoming_queue_type->currentIndex(); config.upcoming_queue_type = upcoming_queue_type->currentIndex();
config.previous_queue_size = previous_queue_spinbox->value(); config.previous_queue_size = previous_queue_spinbox->value();
config.previous_queue_type = previous_queue_type->currentIndex(); config.previous_queue_type = previous_queue_type->currentIndex();
config.add_default_effects_to_clips = add_default_effects_to_clips->isChecked();
// audio preferences
bool reset_audio_required = (config.preferred_audio_output != audio_output_devices->currentData().toString()
|| config.preferred_audio_input != audio_input_devices->currentData().toString());
config.preferred_audio_output = audio_output_devices->currentData().toString(); config.preferred_audio_output = audio_output_devices->currentData().toString();
config.preferred_audio_input = audio_input_devices->currentData().toString(); config.preferred_audio_input = audio_input_devices->currentData().toString();
config.audio_rate = audio_sample_rate->currentData().toInt(); config.audio_rate = audio_sample_rate->currentData().toInt();
// the following settings may require a restart of Olive to take effect: config.effect_textbox_lines = effect_textbox_lines_field->value();
config.use_software_fallback = use_software_fallbacks_checkbox->isChecked();
bool needs_restart = false; config.language_file = language_combobox->currentData().toString();
if (config.effect_textbox_lines != effect_textbox_lines_field->value()) {
needs_restart = true;
config.effect_textbox_lines = effect_textbox_lines_field->value();
}
if (config.use_software_fallback != use_software_fallbacks_checkbox->isChecked()) {
needs_restart = true;
config.use_software_fallback = use_software_fallbacks_checkbox->isChecked();
}
if (config.language_file != language_combobox->currentData().toString()) {
needs_restart = true;
config.language_file = language_combobox->currentData().toString();
}
if (config.thumbnail_resolution != thumbnail_res_spinbox->value() if (config.thumbnail_resolution != thumbnail_res_spinbox->value()
|| config.waveform_resolution != waveform_res_spinbox->value()) { || config.waveform_resolution != waveform_res_spinbox->value()) {
// we're changing the size of thumbnails and waveforms, so let's delete them and regenerate them next start // we're changing the size of thumbnails and waveforms, so let's delete them and regenerate them next start
needs_restart = true;
// delete nothing // delete nothing
char delete_match = 0; char delete_match = 0;
@@ -249,18 +273,15 @@ void PreferencesDialog::save() {
delete_previews(delete_match); delete_previews(delete_match);
} }
// save keyboard shortcuts // Save keyboard shortcuts
for (int i=0;i<key_shortcut_fields.size();i++) { for (int i=0;i<key_shortcut_fields.size();i++) {
key_shortcut_fields.at(i)->set_action_shortcut(); key_shortcut_fields.at(i)->set_action_shortcut();
} }
if (reset_audio_required) { // Audio settings may require the audio device to be re-initiated.
if (reinit_audio) {
init_audio(); init_audio();
} }
if (needs_restart) {
QMessageBox::information(this, tr("Warning"), tr("Some changed settings will require restarting Olive to take effect"));
}
accept(); accept();
} }
@@ -525,6 +546,12 @@ void PreferencesDialog::setup_ui() {
QWidget* behavior_tab = new QWidget(this); QWidget* behavior_tab = new QWidget(this);
tabWidget->addTab(behavior_tab, tr("Behavior")); tabWidget->addTab(behavior_tab, tr("Behavior"));
QVBoxLayout* behavior_tab_layout = new QVBoxLayout(behavior_tab);
add_default_effects_to_clips = new QCheckBox("Add Default Effects to New Clips");
add_default_effects_to_clips->setChecked(config.add_default_effects_to_clips);
behavior_tab_layout->addWidget(add_default_effects_to_clips);
// Playback // Playback
QWidget* playback_tab = new QWidget(this); QWidget* playback_tab = new QWidget(this);
QVBoxLayout* playback_tab_layout = new QVBoxLayout(playback_tab); QVBoxLayout* playback_tab_layout = new QVBoxLayout(playback_tab);
+1
View File
@@ -92,6 +92,7 @@ private:
QComboBox* language_combobox; QComboBox* language_combobox;
QSpinBox* thumbnail_res_spinbox; QSpinBox* thumbnail_res_spinbox;
QSpinBox* waveform_res_spinbox; QSpinBox* waveform_res_spinbox;
QCheckBox* add_default_effects_to_clips;
QVector<QAction*> key_shortcut_actions; QVector<QAction*> key_shortcut_actions;
QVector<QTreeWidgetItem*> key_shortcut_items; QVector<QTreeWidgetItem*> key_shortcut_items;
+8 -3
View File
@@ -70,7 +70,8 @@ Config::Config()
use_software_fallback(false), use_software_fallback(false),
center_timeline_timecodes(true), center_timeline_timecodes(true),
waveform_resolution(64), waveform_resolution(64),
thumbnail_resolution(120) thumbnail_resolution(120),
add_default_effects_to_clips(true)
{} {}
void Config::load(QString path) { void Config::load(QString path) {
@@ -207,7 +208,10 @@ void Config::load(QString path) {
} else if (stream.name() == "WaveformResolution") { } else if (stream.name() == "WaveformResolution") {
stream.readNext(); stream.readNext();
waveform_resolution = stream.text().toInt(); waveform_resolution = stream.text().toInt();
} } else if (stream.name() == "AddDefaultEffectsToClips") {
stream.readNext();
add_default_effects_to_clips = (stream.text() == "1");
}
} }
} }
if (stream.hasError()) { if (stream.hasError()) {
@@ -272,7 +276,8 @@ void Config::save(QString path) {
stream.writeTextElement("PreferredAudioInput", preferred_audio_input); stream.writeTextElement("PreferredAudioInput", preferred_audio_input);
stream.writeTextElement("LanguageFile", language_file); stream.writeTextElement("LanguageFile", language_file);
stream.writeTextElement("ThumbnailResolution", QString::number(thumbnail_resolution)); stream.writeTextElement("ThumbnailResolution", QString::number(thumbnail_resolution));
stream.writeTextElement("WaveformResolution", QString::number(waveform_resolution)); stream.writeTextElement("WaveformResolution", QString::number(waveform_resolution));
stream.writeTextElement("AddDefaultEffectsToClips", QString::number(add_default_effects_to_clips));
stream.writeEndElement(); // configuration stream.writeEndElement(); // configuration
stream.writeEndDocument(); // doc stream.writeEndDocument(); // doc
+1
View File
@@ -89,6 +89,7 @@ struct Config {
QString language_file; QString language_file;
int waveform_resolution; int waveform_resolution;
int thumbnail_resolution; int thumbnail_resolution;
bool add_default_effects_to_clips;
void load(QString path); void load(QString path);
void save(QString path); void save(QString path);
+10 -8
View File
@@ -335,14 +335,16 @@ void Timeline::add_clips_from_ghosts(ComboAction* ca, Sequence* s) {
} }
} }
if (c->track < 0) { if (config.add_default_effects_to_clips) {
// add default video effects if (c->track < 0) {
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_TRANSFORM, EFFECT_TYPE_EFFECT))); // add default video effects
} else { c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_TRANSFORM, EFFECT_TYPE_EFFECT)));
// add default audio effects } else {
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_VOLUME, EFFECT_TYPE_EFFECT))); // add default audio effects
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_PAN, EFFECT_TYPE_EFFECT))); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_VOLUME, EFFECT_TYPE_EFFECT)));
} c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_PAN, EFFECT_TYPE_EFFECT)));
}
}
} }
if (config.enable_seek_to_import) { if (config.enable_seek_to_import) {
panel_sequence_viewer->seek(earliest_point); panel_sequence_viewer->seek(earliest_point);
+2 -3
View File
@@ -840,10 +840,9 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
add.append(c); add.append(c);
ca->append(new AddClipCommand(Olive::ActiveSequence, add)); ca->append(new AddClipCommand(Olive::ActiveSequence, add));
if (c->track < 0) { if (c->track < 0 && config.add_default_effects_to_clips) {
// default video effects (before custom effects) // default video effects (before custom effects)
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_TRANSFORM, EFFECT_TYPE_EFFECT))); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_TRANSFORM, EFFECT_TYPE_EFFECT)));
//c->media_type = MEDIA_TYPE_SOLID;
} }
switch (panel_timeline->creating_object) { switch (panel_timeline->creating_object) {
@@ -873,7 +872,7 @@ void TimelineWidget::mouseReleaseEvent(QMouseEvent *event) {
break; break;
} }
if (c->track >= 0) { if (c->track >= 0 && config.add_default_effects_to_clips) {
// default audio effects (after custom effects) // default audio effects (after custom effects)
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_VOLUME, EFFECT_TYPE_EFFECT))); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_VOLUME, EFFECT_TYPE_EFFECT)));
c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_PAN, EFFECT_TYPE_EFFECT))); c->effects.append(create_effect(c, get_internal_meta(EFFECT_INTERNAL_PAN, EFFECT_TYPE_EFFECT)));