implemented much of the general tab and behavior tab in the PreferencesDialog
This commit is contained in:
@@ -56,6 +56,26 @@ void Config::SetDefaults()
|
||||
config_map_["AudioScrubbing"] = true;
|
||||
config_map_["AutorecoveryInterval"] = 1;
|
||||
config_map_["Language"] = "en_US";
|
||||
config_map_["ScrollZooms"] = false;
|
||||
config_map_["EnableSeekToImport"] = false;
|
||||
config_map_["EditToolAlsoSeeks"] = false;
|
||||
config_map_["EditToolSelectsLinks"] = false;
|
||||
config_map_["EnableDragFilesToTimeline"] = true;
|
||||
config_map_["InvertTimelineScrollAxes"] = true;
|
||||
config_map_["SelectAlsoSeeks"] = false;
|
||||
config_map_["PasteSeeks"] = true;
|
||||
config_map_["SelectAlsoSeeks"] = false;
|
||||
config_map_["SetNameWithMarker"] = false;
|
||||
config_map_["AutoSeekToBeginning"] = true;
|
||||
config_map_["DropFileOnMediaToReplace"] = false;
|
||||
config_map_["AddDefaultEffectsToClips"] = true;
|
||||
config_map_["AutoscaleByDefault"] = false;
|
||||
|
||||
config_map_["DefaultSequenceWidth"] = 1920;
|
||||
config_map_["DefaultSequenceHeight"] = 1080;
|
||||
config_map_["DefaultSequenceFrameRate"] = QVariant::fromValue(rational(1001, 30000));
|
||||
config_map_["DefaultSequenceAudioFrequency"] = 48000;
|
||||
config_map_["DefaultSequenceAudioLayout"] = AV_CH_LAYOUT_STEREO;
|
||||
}
|
||||
|
||||
void Config::Load()
|
||||
|
||||
@@ -89,6 +89,12 @@ void PreferencesDialog::AddBoolPair(QCheckBox *ui, bool *value, bool restart_req
|
||||
|
||||
void PreferencesDialog::accept()
|
||||
{
|
||||
foreach (PreferencesTab* tab, tabs_) {
|
||||
if (!tab->Validate()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (PreferencesTab* tab, tabs_) {
|
||||
tab->Accept();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <QCheckBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
PreferencesBehaviorTab::PreferencesBehaviorTab()
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
@@ -12,37 +14,116 @@ PreferencesBehaviorTab::PreferencesBehaviorTab()
|
||||
layout->addWidget(behavior_tree_);
|
||||
|
||||
behavior_tree_->setHeaderLabel(tr("Behavior"));
|
||||
behavior_tree_->setRootIsDecorated(false);
|
||||
|
||||
AddItem(tr("Add Default Effects to New Clips"));
|
||||
AddItem(tr("Automatically Seek to the Beginning When Playing at the End of a Sequence"));
|
||||
AddItem(tr("Selecting Also Seeks"));
|
||||
AddItem(tr("Edit Tool Also Seeks"));
|
||||
AddItem(tr("Edit Tool Selects Links"));
|
||||
AddItem(tr("Seek Also Selects"));
|
||||
AddItem(tr("Seek to the End of Pastes"));
|
||||
AddItem(tr("Scroll Wheel Zooms"));
|
||||
AddItem(tr("Invert Timeline Scroll Axes"));
|
||||
AddItem(tr("Enable Drag Files to Timeline"));
|
||||
AddItem(tr("Auto-Scale By Default"));
|
||||
AddItem(tr("Auto-Seek to Imported Clips"));
|
||||
AddItem(tr("Audio Scrubbing"));
|
||||
AddItem(tr("Drop Files on Media to Replace"));
|
||||
AddItem(tr("Enable Hover Focus"));
|
||||
AddItem(tr("Ask For Name When Setting Marker"));
|
||||
QTreeWidgetItem* general_group = AddParent(tr("General"));
|
||||
AddItem(tr("Enable hover focus"),
|
||||
QStringLiteral("HoverFocus"),
|
||||
tr("Panels will be considered focused when the mouse cursor is over them without having to click them."),
|
||||
general_group);
|
||||
AddItem(tr("Scroll wheel zooms by default instead of scrolling"),
|
||||
QStringLiteral("ScrollZooms"),
|
||||
tr("Holding CTRL while using Olive toggles this setting"),
|
||||
general_group);
|
||||
|
||||
//scroll_wheel_zooms->setToolTip(tr("Hold CTRL to toggle this setting"));
|
||||
QTreeWidgetItem* audio_group = AddParent(tr("Audio"));
|
||||
AddItem(tr("Enable audio scrubbing"),
|
||||
QStringLiteral("AudioScrubbing"),
|
||||
audio_group);
|
||||
|
||||
QTreeWidgetItem* timeline_group = AddParent(tr("Timeline"));
|
||||
AddItem(tr("Auto-Seek to Imported Clips"),
|
||||
QStringLiteral("EnableSeekToImport"),
|
||||
timeline_group);
|
||||
AddItem(tr("Edit Tool Also Seeks"),
|
||||
QStringLiteral("EditToolAlsoSeeks"),
|
||||
timeline_group);
|
||||
AddItem(tr("Edit Tool Selects Links"),
|
||||
QStringLiteral("EditToolSelectsLinks"),
|
||||
timeline_group);
|
||||
AddItem(tr("Enable Drag Files to Timeline"),
|
||||
QStringLiteral("EnableDragFilesToTimeline"),
|
||||
timeline_group);
|
||||
AddItem(tr("Invert Timeline Scroll Axes"),
|
||||
QStringLiteral("InvertTimelineScrollAxes"),
|
||||
timeline_group);
|
||||
AddItem(tr("Seek Also Selects"),
|
||||
QStringLiteral("SelectAlsoSeeks"),
|
||||
timeline_group);
|
||||
AddItem(tr("Seek to the End of Pastes"),
|
||||
QStringLiteral("PasteSeeks"),
|
||||
timeline_group);
|
||||
AddItem(tr("Selecting Also Seeks"),
|
||||
QStringLiteral("SelectAlsoSeeks"),
|
||||
timeline_group);
|
||||
|
||||
QTreeWidgetItem* playback_group = AddParent(tr("Playback"));
|
||||
AddItem(tr("Ask For Name When Setting Marker"),
|
||||
QStringLiteral("SetNameWithMarker"),
|
||||
playback_group);
|
||||
AddItem(tr("Automatically rewind at the end of a sequence"),
|
||||
QStringLiteral("AutoSeekToBeginning"),
|
||||
playback_group);
|
||||
|
||||
QTreeWidgetItem* project_group = AddParent(tr("Project"));
|
||||
AddItem(tr("Drop Files on Media to Replace"),
|
||||
QStringLiteral("DropFileOnMediaToReplace"),
|
||||
project_group);
|
||||
|
||||
QTreeWidgetItem* node_group = AddParent(tr("Nodes"));
|
||||
AddItem(tr("Add Default Effects to New Clips"),
|
||||
QStringLiteral("AddDefaultEffectsToClips"),
|
||||
node_group);
|
||||
AddItem(tr("Auto-Scale By Default"),
|
||||
QStringLiteral("AutoscaleByDefault"),
|
||||
node_group);
|
||||
}
|
||||
|
||||
void PreferencesBehaviorTab::Accept()
|
||||
{
|
||||
QMap<QTreeWidgetItem*, QString>::const_iterator iterator;
|
||||
|
||||
for (iterator=config_map_.begin();iterator!=config_map_.end();iterator++) {
|
||||
Config::Current()[iterator.value()] = (iterator.key()->checkState(0) == Qt::Checked);
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesBehaviorTab::AddItem(const QString &text, const QString& tooltip)
|
||||
QTreeWidgetItem* PreferencesBehaviorTab::AddItem(const QString &text, const QString &config_key, const QString& tooltip, QTreeWidgetItem* parent)
|
||||
{
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem({text});
|
||||
item->setToolTip(0, tooltip);
|
||||
item->setCheckState(0, Qt::Unchecked);
|
||||
behavior_tree_->addTopLevelItem(item);
|
||||
item->setCheckState(0, Config::Current()[config_key].toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
|
||||
config_map_.insert(item, config_key);
|
||||
|
||||
if (parent) {
|
||||
parent->addChild(item);
|
||||
} else {
|
||||
behavior_tree_->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *PreferencesBehaviorTab::AddItem(const QString &text, const QString &config_key, QTreeWidgetItem *parent)
|
||||
{
|
||||
return AddItem(text, config_key, QString(), parent);
|
||||
}
|
||||
|
||||
QTreeWidgetItem *PreferencesBehaviorTab::AddParent(const QString &text, const QString &tooltip, QTreeWidgetItem *parent)
|
||||
{
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem({text});
|
||||
item->setToolTip(0, tooltip);
|
||||
|
||||
if (parent) {
|
||||
parent->addChild(item);
|
||||
} else {
|
||||
behavior_tree_->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *PreferencesBehaviorTab::AddParent(const QString &text, QTreeWidgetItem *parent)
|
||||
{
|
||||
return AddParent(text, QString(), parent);
|
||||
}
|
||||
|
||||
@@ -14,9 +14,16 @@ public:
|
||||
virtual void Accept() override;
|
||||
|
||||
private:
|
||||
void AddItem(const QString& text, const QString &tooltip = QString());
|
||||
QTreeWidgetItem *AddParent(const QString& text, const QString &tooltip, QTreeWidgetItem *parent = nullptr);
|
||||
QTreeWidgetItem *AddParent(const QString& text, QTreeWidgetItem *parent = nullptr);
|
||||
|
||||
QTreeWidgetItem *AddItem(const QString& text, const QString& config_key, const QString &tooltip, QTreeWidgetItem *parent );
|
||||
QTreeWidgetItem *AddItem(const QString& text, const QString& config_key, QTreeWidgetItem *parent);
|
||||
|
||||
QMap<QTreeWidgetItem*, QString> config_map_;
|
||||
|
||||
QTreeWidget* behavior_tree_;
|
||||
|
||||
};
|
||||
|
||||
#endif // PREFERENCESBEHAVIORTAB_H
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
#include <QCheckBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "dialog/sequence/sequence.h"
|
||||
#include "project/item/sequence/sequence.h"
|
||||
|
||||
PreferencesGeneralTab::PreferencesGeneralTab()
|
||||
{
|
||||
QVBoxLayout* layout = new QVBoxLayout(this);
|
||||
@@ -19,10 +22,13 @@ PreferencesGeneralTab::PreferencesGeneralTab()
|
||||
// General -> Language
|
||||
general_layout->addWidget(new QLabel(tr("Language:")), row, 0);
|
||||
|
||||
language_combobox = new QComboBox();
|
||||
language_combobox_ = new QComboBox();
|
||||
|
||||
// add default language (en-US)
|
||||
language_combobox->addItem(QLocale::languageToString(QLocale("en-US").language()));
|
||||
// Add default language (en-US)
|
||||
language_combobox_->addItem(QLocale::languageToString(QLocale("en_US").language()));
|
||||
|
||||
// Set sequence to pick up default parameters from the config
|
||||
default_sequence_.set_default_parameters();
|
||||
|
||||
/*
|
||||
// add languages from file
|
||||
@@ -51,56 +57,33 @@ PreferencesGeneralTab::PreferencesGeneralTab()
|
||||
}
|
||||
*/
|
||||
|
||||
general_layout->addWidget(language_combobox, row, 1);
|
||||
general_layout->addWidget(language_combobox_, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
// General -> Thumbnail and Waveform Resolution
|
||||
general_layout->addWidget(new QLabel(tr("Thumbnail Resolution:"), this), row, 0);
|
||||
|
||||
thumbnail_res_spinbox = new QSpinBox(this);
|
||||
thumbnail_res_spinbox->setMinimum(0);
|
||||
thumbnail_res_spinbox->setMaximum(INT_MAX);
|
||||
general_layout->addWidget(thumbnail_res_spinbox, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
general_layout->addWidget(new QLabel(tr("Waveform Resolution:"), this), row, 0);
|
||||
|
||||
waveform_res_spinbox = new QSpinBox(this);
|
||||
waveform_res_spinbox->setMinimum(0);
|
||||
waveform_res_spinbox->setMaximum(INT_MAX);
|
||||
general_layout->addWidget(waveform_res_spinbox, row, 1);
|
||||
|
||||
row++;
|
||||
|
||||
QPushButton* delete_preview_btn = new QPushButton(tr("Delete Previews"));
|
||||
general_layout->addWidget(delete_preview_btn, row, 1);
|
||||
//connect(delete_preview_btn, SIGNAL(clicked(bool)), this, SLOT(delete_all_previews()));
|
||||
|
||||
row++;
|
||||
|
||||
QHBoxLayout* misc_general = new QHBoxLayout();
|
||||
general_layout->addWidget(new QLabel(tr("Default Sequence Settings:")), row, 0);
|
||||
|
||||
// General -> Default Sequence Settings
|
||||
QPushButton* default_sequence_settings = new QPushButton(tr("Default Sequence Settings"));
|
||||
default_sequence_settings->setEnabled(false);
|
||||
QPushButton* default_sequence_settings = new QPushButton(tr("Edit"));
|
||||
connect(default_sequence_settings, SIGNAL(clicked(bool)), this, SLOT(edit_default_sequence_settings()));
|
||||
misc_general->addWidget(default_sequence_settings);
|
||||
|
||||
general_layout->addLayout(misc_general, row, 0);
|
||||
general_layout->addWidget(default_sequence_settings, row, 1);
|
||||
|
||||
layout->addStretch();
|
||||
}
|
||||
|
||||
void PreferencesGeneralTab::Accept()
|
||||
{
|
||||
|
||||
Config::Current()["DefaultSequenceWidth"] = default_sequence_.video_params().width();
|
||||
Config::Current()["DefaultSequenceHeight"] = default_sequence_.video_params().height();;
|
||||
Config::Current()["DefaultSequenceFrameRate"] = QVariant::fromValue(default_sequence_.video_params().time_base());
|
||||
Config::Current()["DefaultSequenceAudioFrequency"] = default_sequence_.audio_params().sample_rate();
|
||||
Config::Current()["DefaultSequenceAudioLayout"] = default_sequence_.audio_params().channel_layout();
|
||||
}
|
||||
|
||||
void PreferencesGeneralTab::edit_default_sequence_settings()
|
||||
{
|
||||
/*NewSequenceDialog nsd(this, nullptr, &default_sequence);
|
||||
nsd.SetNameEditable(false);
|
||||
nsd.exec();*/
|
||||
SequenceDialog sd(&default_sequence_, SequenceDialog::kExisting, this);
|
||||
sd.SetUndoable(false);
|
||||
sd.SetNameIsEditable(false);
|
||||
sd.exec();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QSpinBox>
|
||||
|
||||
#include "preferencestab.h"
|
||||
#include "project/item/sequence/sequence.h"
|
||||
|
||||
class PreferencesGeneralTab : public PreferencesTab
|
||||
{
|
||||
@@ -24,17 +25,13 @@ private:
|
||||
/**
|
||||
* @brief UI widget for selecting the UI language
|
||||
*/
|
||||
QComboBox* language_combobox;
|
||||
QComboBox* language_combobox_;
|
||||
|
||||
/**
|
||||
* @brief UI widget for selecting the resolution of the thumbnails to generate
|
||||
* @brief A sequence we can feed to a SequenceDialog to change the defaults
|
||||
*/
|
||||
QSpinBox* thumbnail_res_spinbox;
|
||||
Sequence default_sequence_;
|
||||
|
||||
/**
|
||||
* @brief UI widget for selecting the resolution of the waveforms to generate
|
||||
*/
|
||||
QSpinBox* waveform_res_spinbox;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -4,3 +4,8 @@ PreferencesTab::PreferencesTab()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool PreferencesTab::Validate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ class PreferencesTab : public QWidget
|
||||
public:
|
||||
PreferencesTab();
|
||||
|
||||
virtual bool Validate();
|
||||
|
||||
virtual void Accept() = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -144,9 +144,14 @@ void SequenceDialog::SetUndoable(bool u)
|
||||
make_undoable_ = u;
|
||||
}
|
||||
|
||||
void SequenceDialog::SetNameIsEditable(bool e)
|
||||
{
|
||||
name_field_->setEnabled(e);
|
||||
}
|
||||
|
||||
void SequenceDialog::accept()
|
||||
{
|
||||
if (name_field_->text().isEmpty()) {
|
||||
if (name_field_->isEnabled() && name_field_->text().isEmpty()) {
|
||||
QMessageBox::critical(this, tr("Error editing Sequence"), tr("Please enter a name for this Sequence."));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,17 @@ public:
|
||||
/**
|
||||
* @brief Set whether the parameter changes should be made into an undo command or not
|
||||
*
|
||||
* @param u
|
||||
* Defaults to true.
|
||||
*/
|
||||
void SetUndoable(bool u);
|
||||
|
||||
/**
|
||||
* @brief Set whether the name of this Sequence can be edited with this dialog
|
||||
*
|
||||
* Defaults to true.
|
||||
*/
|
||||
void SetNameIsEditable(bool e);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* @brief Function called when the user presses OK
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
#include "config/config.h"
|
||||
#include "common/channellayout.h"
|
||||
#include "common/timecodefunctions.h"
|
||||
#include "panel/panelmanager.h"
|
||||
@@ -150,7 +151,9 @@ void Sequence::set_audio_params(const AudioParams ¶ms)
|
||||
|
||||
void Sequence::set_default_parameters()
|
||||
{
|
||||
// FIXME: Make these configurable (hardcoded)
|
||||
set_video_params(VideoParams(1920, 1080, rational(1001, 30000)));
|
||||
set_audio_params(AudioParams(48000, AV_CH_LAYOUT_STEREO));
|
||||
set_video_params(VideoParams(Config::Current()["DefaultSequenceWidth"].toInt(),
|
||||
Config::Current()["DefaultSequenceHeight"].toInt(),
|
||||
Config::Current()["DefaultSequenceFrameRate"].value<rational>()));
|
||||
set_audio_params(AudioParams(Config::Current()["DefaultSequenceAudioFrequency"].toInt(),
|
||||
Config::Current()["DefaultSequenceAudioLayout"].toULongLong()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user