code: use config macro
Macro is much easier to use and more readable
This commit is contained in:
@@ -233,7 +233,7 @@ ColorValuesTab::ColorValuesTab(bool with_legacy_option, QWidget *parent) :
|
||||
|
||||
if (with_legacy_option) {
|
||||
legacy_box_ = new QCheckBox(tr("Use legacy (8-bit) values"));
|
||||
legacy_box_->setChecked(Config::Current()[QStringLiteral("UseLegacyColorInInputTab")].toBool());
|
||||
legacy_box_->setChecked(OLIVE_CONFIG("UseLegacyColorInInputTab").toBool());
|
||||
connect(legacy_box_, &QCheckBox::clicked, this, &ColorValuesTab::LegacyChanged);
|
||||
layout->addWidget(legacy_box_, row, 0, 1, 2);
|
||||
row++;
|
||||
@@ -356,7 +356,7 @@ void ColorValuesTab::SliderChanged()
|
||||
|
||||
void ColorValuesTab::LegacyChanged(bool legacy)
|
||||
{
|
||||
Config::Current()[QStringLiteral("UseLegacyColorInInputTab")] = legacy;
|
||||
OLIVE_CONFIG("UseLegacyColorInInputTab") = legacy;
|
||||
|
||||
double legacy_multiplier = legacy ? kLegacyMultiplier : 1.0/kLegacyMultiplier;
|
||||
int decimal_places = legacy ? 0 : 5;
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace olive {
|
||||
HandMovableView::HandMovableView(QWidget* parent) :
|
||||
super(parent),
|
||||
dragging_hand_(false),
|
||||
scroll_zooms_by_default_(Config::Current()[QStringLiteral("ScrollZooms")].toBool())
|
||||
scroll_zooms_by_default_(OLIVE_CONFIG("ScrollZooms").toBool())
|
||||
{
|
||||
connect(Core::instance(), &Core::ToolChanged, this, &HandMovableView::ApplicationToolChanged);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void ScopeBase::DrawScope(TexturePtr managed_tex, QVariant pipeline)
|
||||
job.InsertValue(QStringLiteral("ove_maintex"), NodeValue(NodeValue::kTexture, QVariant::fromValue(managed_tex)));
|
||||
|
||||
renderer()->Blit(pipeline, job, VideoParams(width(), height(),
|
||||
static_cast<VideoParams::Format>(Config::Current()["OfflinePixelFormat"].toInt()),
|
||||
static_cast<VideoParams::Format>(OLIVE_CONFIG("OfflinePixelFormat").toInt()),
|
||||
VideoParams::kInternalChannelCount));
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ void WaveformScope::DrawScope(TexturePtr managed_tex, QVariant pipeline)
|
||||
NodeValue(NodeValue::kTexture, QVariant::fromValue(managed_tex)));
|
||||
|
||||
renderer()->Blit(pipeline, job, VideoParams(width(), height(),
|
||||
static_cast<VideoParams::Format>(Config::Current()["OfflinePixelFormat"].toInt()),
|
||||
static_cast<VideoParams::Format>(OLIVE_CONFIG("OfflinePixelFormat").toInt()),
|
||||
VideoParams::kInternalChannelCount));
|
||||
|
||||
float waveform_dim_x = ceil((width() - 1.0) * waveform_scale);
|
||||
|
||||
@@ -139,7 +139,7 @@ bool NumericSliderBase::IsDragging() const
|
||||
|
||||
bool NumericSliderBase::UsingLadders() const
|
||||
{
|
||||
return ladder_element_count_ > 0 && Config::Current()[QStringLiteral("UseSliderLadders")].toBool();
|
||||
return ladder_element_count_ > 0 && OLIVE_CONFIG("UseSliderLadders").toBool();
|
||||
}
|
||||
|
||||
QVariant NumericSliderBase::AdjustValue(const QVariant &value) const
|
||||
|
||||
@@ -48,7 +48,7 @@ SliderLadder::SliderLadder(double drag_multiplier, int nb_outer_values, QString
|
||||
setFrameShape(QFrame::Box);
|
||||
setLineWidth(1);
|
||||
|
||||
if (!Config::Current()[QStringLiteral("UseSliderLadders")].toBool()) {
|
||||
if (!OLIVE_CONFIG("UseSliderLadders").toBool()) {
|
||||
nb_outer_values = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -292,7 +292,7 @@ void TimeBasedWidget::SetTime(const rational &time)
|
||||
QMetaObject::invokeMethod(this, "CatchUpScrollToPlayhead", Qt::QueuedConnection);
|
||||
} else {
|
||||
// Otherwise, assume we jumped to this out of nowhere and must now autoscroll
|
||||
switch (static_cast<AutoScroll::Method>(Config::Current()["Autoscroll"].toInt())) {
|
||||
switch (static_cast<AutoScroll::Method>(OLIVE_CONFIG("Autoscroll").toInt())) {
|
||||
case AutoScroll::kNone:
|
||||
// Do nothing
|
||||
break;
|
||||
@@ -606,12 +606,12 @@ void TimeBasedWidget::SetMarker()
|
||||
color = closest->color();
|
||||
} else {
|
||||
// Fallback to default color in preferences
|
||||
color = Config::Current()[QStringLiteral("MarkerColor")].toInt();
|
||||
color = OLIVE_CONFIG("MarkerColor").toInt();
|
||||
}
|
||||
|
||||
TimelineMarker *marker = new TimelineMarker(color, TimeRange(GetTime(), GetTime()));
|
||||
|
||||
if (Config::Current()[QStringLiteral("SetNameWithMarker")].toBool()) {
|
||||
if (OLIVE_CONFIG("SetNameWithMarker").toBool()) {
|
||||
MarkerPropertiesDialog mpd({marker}, timebase(), this);
|
||||
if (mpd.exec() != QDialog::Accepted) {
|
||||
delete marker;
|
||||
|
||||
@@ -222,7 +222,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const DraggedFootageData
|
||||
|
||||
if (footage_duration.isNull()) {
|
||||
// Fallback to still length if legngth was 0
|
||||
footage_duration = Config::Current()[QStringLiteral("DefaultStillLength")].value<rational>();
|
||||
footage_duration = OLIVE_CONFIG("DefaultStillLength").value<rational>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ void ImportTool::DropGhosts(bool insert)
|
||||
} else {
|
||||
// There's no active timeline here, ask the user what to do
|
||||
|
||||
DropWithoutSequenceBehavior behavior = static_cast<DropWithoutSequenceBehavior>(Config::Current()["DropWithoutSequenceBehavior"].toInt());
|
||||
DropWithoutSequenceBehavior behavior = static_cast<DropWithoutSequenceBehavior>(OLIVE_CONFIG("DropWithoutSequenceBehavior").toInt());
|
||||
|
||||
if (behavior == kDWSAsk) {
|
||||
QCheckBox* dont_ask_again_box = new QCheckBox(QCoreApplication::translate("ImportTool", "Don't ask me again"));
|
||||
@@ -312,7 +312,7 @@ void ImportTool::DropGhosts(bool insert)
|
||||
}
|
||||
|
||||
if (behavior != kDWSDisable && dont_ask_again_box->isChecked()) {
|
||||
Config::Current()["DropWithoutSequenceBehavior"] = behavior;
|
||||
OLIVE_CONFIG("DropWithoutSequenceBehavior") = behavior;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ private:
|
||||
class TimelineAddTrackCommand : public UndoCommand {
|
||||
public:
|
||||
TimelineAddTrackCommand(TrackList *timeline) :
|
||||
TimelineAddTrackCommand(timeline, Config::Current()[QStringLiteral("AutoMergeTracks")].toBool())
|
||||
TimelineAddTrackCommand(timeline, OLIVE_CONFIG("AutoMergeTracks").toBool())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ void TimelineView::wheelEvent(QWheelEvent *event)
|
||||
|
||||
QPoint angle_delta = event->angleDelta();
|
||||
|
||||
if (Config::Current()[QStringLiteral("InvertTimelineScrollAxes")].toBool() // Check if config is set to invert timeline axes
|
||||
if (OLIVE_CONFIG("InvertTimelineScrollAxes").toBool() // Check if config is set to invert timeline axes
|
||||
&& event->source() != Qt::MouseEventSynthesizedBySystem) { // Never flip axes on Apple trackpads though
|
||||
angle_delta = QPoint(angle_delta.y(), angle_delta.x());
|
||||
}
|
||||
@@ -184,7 +184,7 @@ void TimelineView::wheelEvent(QWheelEvent *event)
|
||||
|
||||
Qt::Orientation orientation = event->orientation();
|
||||
|
||||
if (Config::Current()["InvertTimelineScrollAxes"].toBool()) {
|
||||
if (OLIVE_CONFIG("InvertTimelineScrollAxes").toBool()) {
|
||||
orientation = (orientation == Qt::Horizontal) ? Qt::Vertical : Qt::Horizontal;
|
||||
}
|
||||
|
||||
@@ -307,7 +307,7 @@ void TimelineView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||
|
||||
Block *attached = Node::ValueToPtr<Block>(ghost->GetData(TimelineViewGhostItem::kAttachedBlock));
|
||||
|
||||
if (attached && Config::Current()[QStringLiteral("ShowClipWhileDragging")].toBool()) {
|
||||
if (attached && OLIVE_CONFIG("ShowClipWhileDragging").toBool()) {
|
||||
int adj_track = ghost->GetAdjustedTrack().index();
|
||||
qreal track_top = GetTrackY(adj_track);
|
||||
qreal track_height = GetTrackHeight(adj_track);
|
||||
|
||||
@@ -741,7 +741,7 @@ void ViewerWidget::PauseInternal()
|
||||
|
||||
void ViewerWidget::PushScrubbedAudio()
|
||||
{
|
||||
if (!IsPlaying() && GetConnectedNode() && Config::Current()[QStringLiteral("AudioScrubbing")].toBool()) {
|
||||
if (!IsPlaying() && GetConnectedNode() && OLIVE_CONFIG("AudioScrubbing").toBool()) {
|
||||
// Get audio src device from renderer
|
||||
const AudioParams& params = GetConnectedNode()->audio_playback_cache()->GetParameters();
|
||||
|
||||
@@ -1129,9 +1129,9 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
QAction *stop_playback_on_last_frame = menu.addAction(tr("Stop Playback On Last Frame"));
|
||||
stop_playback_on_last_frame->setCheckable(true);
|
||||
stop_playback_on_last_frame->setChecked(Config::Current()[QStringLiteral("StopPlaybackOnLastFrame")].toBool());
|
||||
stop_playback_on_last_frame->setChecked(OLIVE_CONFIG("StopPlaybackOnLastFrame").toBool());
|
||||
connect(stop_playback_on_last_frame, &QAction::triggered, this, [](bool e){
|
||||
Config::Current()[QStringLiteral("StopPlaybackOnLastFrame")] = e;
|
||||
OLIVE_CONFIG("StopPlaybackOnLastFrame") = e;
|
||||
});
|
||||
|
||||
menu.addSeparator();
|
||||
@@ -1180,7 +1180,7 @@ void ViewerWidget::Play(bool in_to_out_only)
|
||||
|
||||
recording_filename_ = audio_path.filePath(QStringLiteral("%1.%2").arg(
|
||||
QDateTime::currentDateTime().toString("yyyy-MM-dd hh-mm-ss"),
|
||||
ExportFormat::GetExtension(static_cast<ExportFormat::Format>(Config::Current()[QStringLiteral("AudioRecordingFormat")].toInt())))
|
||||
ExportFormat::GetExtension(static_cast<ExportFormat::Format>(OLIVE_CONFIG("AudioRecordingFormat").toInt())))
|
||||
);
|
||||
|
||||
AudioParams ap(OLIVE_CONFIG("AudioRecordingSampleRate").toInt(), OLIVE_CONFIG("AudioRecordingChannelLayout").toULongLong(), static_cast<AudioParams::Format>(OLIVE_CONFIG("AudioRecordingSampleFormat").toInt()));
|
||||
@@ -1304,7 +1304,7 @@ void ViewerWidget::PlaybackTimerUpdate()
|
||||
|
||||
// If we're stopping playback on the last frame rather than after it, subtract our max time
|
||||
// by one timebase unit
|
||||
if (Config::Current()[QStringLiteral("StopPlaybackOnLastFrame")].toBool()) {
|
||||
if (OLIVE_CONFIG("StopPlaybackOnLastFrame").toBool()) {
|
||||
max_time = qMax(min_time, max_time - timebase());
|
||||
}
|
||||
|
||||
@@ -1329,7 +1329,7 @@ void ViewerWidget::PlaybackTimerUpdate()
|
||||
// or restart playback
|
||||
end_of_line = true;
|
||||
|
||||
if (Config::Current()[QStringLiteral("Loop")].toBool() && !recording_) {
|
||||
if (OLIVE_CONFIG("Loop").toBool() && !recording_) {
|
||||
|
||||
// If we're looping, jump to the other side of the workarea and continue
|
||||
time_to_set = (tripped_time == min_time) ? max_time : min_time;
|
||||
|
||||
@@ -428,7 +428,7 @@ void ViewerDisplayWidget::OnPaint()
|
||||
// Draw texture through color transform
|
||||
int device_width = width() * devicePixelRatioF();
|
||||
int device_height = height() * devicePixelRatioF();
|
||||
VideoParams::Format device_format = static_cast<VideoParams::Format>(Config::Current()["OfflinePixelFormat"].toInt());
|
||||
VideoParams::Format device_format = static_cast<VideoParams::Format>(OLIVE_CONFIG("OfflinePixelFormat").toInt());
|
||||
VideoParams device_params(device_width, device_height, device_format, VideoParams::kInternalChannelCount);
|
||||
|
||||
if (push_mode_ == kPushBlank) {
|
||||
@@ -486,7 +486,7 @@ void ViewerDisplayWidget::OnPaint()
|
||||
}
|
||||
|
||||
renderer()->BlitColorManaged(color_service(), texture_to_draw,
|
||||
Config::Current()[QStringLiteral("ReassocLinToNonLin")].toBool() ? Renderer::kAlphaAssociated : Renderer::kAlphaNone,
|
||||
OLIVE_CONFIG("ReassocLinToNonLin").toBool() ? Renderer::kAlphaAssociated : Renderer::kAlphaNone,
|
||||
device_params, false,
|
||||
combined_matrix_flipped_, crop_matrix_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user