From cf32fcfee14044957d1bb9350b34de7ec2155cba Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Sun, 12 Jul 2026 16:26:05 +0800 Subject: [PATCH] Add configurable proxy settings and a menu entry - Extend ProxyManager::ProxyParams with crf and preset, and update ProxyTask/ProxyParamsEqual to use them. - Add global config keys ProxyWidth, ProxyHeight, ProxyCRF, ProxyPreset. - Add a Proxy Settings group to Preferences -> Disk with width/height/CRF/preset controls. - Read proxy settings from config when generating proxies from the timeline. - Add Tools -> Proxy Settings... menu entry that opens Preferences on the Disk tab. - Add ConfigDialogBase::SetCurrentTab() so PreferencesDialog can start on a specific tab. --- app/codec/proxymanager.cpp | 3 +- app/codec/proxymanager.h | 2 + app/config/config.cpp | 6 ++ app/core.cpp | 4 +- app/core.h | 2 +- app/dialog/configbase/configdialogbase.cpp | 7 +++ app/dialog/configbase/configdialogbase.h | 2 + app/dialog/preferences/preferences.cpp | 4 +- app/dialog/preferences/preferences.h | 2 +- .../preferences/tabs/preferencesdisktab.cpp | 60 +++++++++++++++++++ .../preferences/tabs/preferencesdisktab.h | 7 +++ app/task/proxy/proxy.cpp | 4 +- app/widget/timelinewidget/timelinewidget.cpp | 4 ++ app/window/mainwindow/mainmenu.cpp | 7 +++ app/window/mainwindow/mainmenu.h | 1 + 15 files changed, 107 insertions(+), 8 deletions(-) diff --git a/app/codec/proxymanager.cpp b/app/codec/proxymanager.cpp index 722cf609c..fd523b9cc 100644 --- a/app/codec/proxymanager.cpp +++ b/app/codec/proxymanager.cpp @@ -35,7 +35,8 @@ bool ProxyParamsEqual(const ProxyManager::ProxyParams &a, const ProxyManager::ProxyParams &b) { return a.width == b.width && a.height == b.height && - a.version == b.version && a.extension == b.extension; + a.version == b.version && a.extension == b.extension && + a.crf == b.crf && a.preset == b.preset; } QString ProxyManager::GetProxyDirectory(const QString &cache_path) diff --git a/app/codec/proxymanager.h b/app/codec/proxymanager.h index ee3c740d6..ff6cb1a48 100644 --- a/app/codec/proxymanager.h +++ b/app/codec/proxymanager.h @@ -64,6 +64,8 @@ public: int height = 720; int version = 1; QString extension = QStringLiteral("mp4"); + int crf = 23; + QString preset = QStringLiteral("veryfast"); }; struct Proxy { diff --git a/app/config/config.cpp b/app/config/config.cpp index 32169dd59..6019fb159 100644 --- a/app/config/config.cpp +++ b/app/config/config.cpp @@ -228,6 +228,12 @@ void Config::SetDefaults() SetEntryInternal(QStringLiteral("DiskCacheAhead"), NodeValue::kRational, QVariant::fromValue(rational(60))); + SetEntryInternal(QStringLiteral("ProxyWidth"), NodeValue::kInt, 1280); + SetEntryInternal(QStringLiteral("ProxyHeight"), NodeValue::kInt, 720); + SetEntryInternal(QStringLiteral("ProxyCRF"), NodeValue::kInt, 23); + SetEntryInternal(QStringLiteral("ProxyPreset"), NodeValue::kText, + QStringLiteral("veryfast")); + SetEntryInternal(QStringLiteral("DefaultSequenceWidth"), NodeValue::kInt, 1920); SetEntryInternal(QStringLiteral("DefaultSequenceHeight"), NodeValue::kInt, diff --git a/app/core.cpp b/app/core.cpp index b7638f0ca..45fda3ce9 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -484,9 +484,9 @@ void Core::DialogImportShow() } } -void Core::DialogPreferencesShow() +void Core::DialogPreferencesShow(int start_tab) { - PreferencesDialog pd(main_window_); + PreferencesDialog pd(main_window_, start_tab); pd.exec(); } diff --git a/app/core.h b/app/core.h index 846973786..c0021e1a6 100644 --- a/app/core.h +++ b/app/core.h @@ -350,7 +350,7 @@ public slots: /** * @brief Show Preferences dialog */ - void DialogPreferencesShow(); + void DialogPreferencesShow(int start_tab = 0); /** * @brief Show Project Properties dialog diff --git a/app/dialog/configbase/configdialogbase.cpp b/app/dialog/configbase/configdialogbase.cpp index ca64752b9..7bed9b1a4 100644 --- a/app/dialog/configbase/configdialogbase.cpp +++ b/app/dialog/configbase/configdialogbase.cpp @@ -91,4 +91,11 @@ void ConfigDialogBase::AddTab(ConfigDialogBaseTab *tab, const QString &title) tabs_.append(tab); } +void ConfigDialogBase::SetCurrentTab(int index) +{ + if (index >= 0 && index < list_widget_->count()) { + list_widget_->setCurrentRow(index); + } +} + } diff --git a/app/dialog/configbase/configdialogbase.h b/app/dialog/configbase/configdialogbase.h index 9a27a84c4..c4d2ed0a1 100644 --- a/app/dialog/configbase/configdialogbase.h +++ b/app/dialog/configbase/configdialogbase.h @@ -36,6 +36,8 @@ class ConfigDialogBase : public QDialog { public: ConfigDialogBase(QWidget *parent = nullptr); + void SetCurrentTab(int index); + private slots: /** * @brief Override of accept to save preferences to Config. diff --git a/app/dialog/preferences/preferences.cpp b/app/dialog/preferences/preferences.cpp index 922d5dfcf..2444ef3fb 100644 --- a/app/dialog/preferences/preferences.cpp +++ b/app/dialog/preferences/preferences.cpp @@ -38,7 +38,7 @@ namespace olive { -PreferencesDialog::PreferencesDialog(MainWindow *main_window) +PreferencesDialog::PreferencesDialog(MainWindow *main_window, int start_tab) : ConfigDialogBase(main_window) { setWindowTitle(tr("Preferences")); @@ -49,6 +49,8 @@ PreferencesDialog::PreferencesDialog(MainWindow *main_window) AddTab(new PreferencesDiskTab(), tr("Disk")); AddTab(new PreferencesAudioTab(), tr("Audio")); AddTab(new PreferencesKeyboardTab(main_window), tr("Keyboard")); + + SetCurrentTab(start_tab); } void PreferencesDialog::AcceptEvent() diff --git a/app/dialog/preferences/preferences.h b/app/dialog/preferences/preferences.h index 9718c3b2b..8299f3ff8 100644 --- a/app/dialog/preferences/preferences.h +++ b/app/dialog/preferences/preferences.h @@ -45,7 +45,7 @@ class PreferencesDialog : public ConfigDialogBase { Q_OBJECT public: - PreferencesDialog(MainWindow *main_window); + PreferencesDialog(MainWindow *main_window, int start_tab = 0); protected: virtual void AcceptEvent() override; diff --git a/app/dialog/preferences/tabs/preferencesdisktab.cpp b/app/dialog/preferences/tabs/preferencesdisktab.cpp index 1f800343b..81c08a8f4 100644 --- a/app/dialog/preferences/tabs/preferencesdisktab.cpp +++ b/app/dialog/preferences/tabs/preferencesdisktab.cpp @@ -29,6 +29,7 @@ #include #include "common/filefunctions.h" +#include "config/config.h" namespace olive { @@ -92,6 +93,60 @@ PreferencesDiskTab::PreferencesDiskTab() OLIVE_CONFIG("DiskCacheBehind").value().toDouble()); cache_behavior_layout->addWidget(cache_behind_slider_, row, 3); + row++; + + QGroupBox *proxy_group = new QGroupBox(tr("Proxy Settings")); + outer_layout->addWidget(proxy_group); + QGridLayout *proxy_layout = new QGridLayout(proxy_group); + + int proxy_row = 0; + + proxy_layout->addWidget(new QLabel(tr("Proxy Width:")), proxy_row, 0); + proxy_width_slider_ = new IntegerSlider(); + proxy_width_slider_->SetMinimum(160); + proxy_width_slider_->SetMaximum(4096); + proxy_width_slider_->SetValue( + OLIVE_CONFIG("ProxyWidth").value()); + proxy_layout->addWidget(proxy_width_slider_, proxy_row, 1); + + proxy_layout->addWidget(new QLabel(tr("Proxy Height:")), proxy_row, 2); + proxy_height_slider_ = new IntegerSlider(); + proxy_height_slider_->SetMinimum(120); + proxy_height_slider_->SetMaximum(2160); + proxy_height_slider_->SetValue( + OLIVE_CONFIG("ProxyHeight").value()); + proxy_layout->addWidget(proxy_height_slider_, proxy_row, 3); + + proxy_row++; + + proxy_layout->addWidget(new QLabel(tr("Proxy CRF:")), proxy_row, 0); + proxy_crf_slider_ = new IntegerSlider(); + proxy_crf_slider_->SetMinimum(0); + proxy_crf_slider_->SetMaximum(51); + proxy_crf_slider_->SetValue( + OLIVE_CONFIG("ProxyCRF").value()); + proxy_layout->addWidget(proxy_crf_slider_, proxy_row, 1); + + proxy_layout->addWidget(new QLabel(tr("Proxy Preset:")), proxy_row, 2); + proxy_preset_combo_ = new QComboBox(); + const QStringList presets = { + QStringLiteral("ultrafast"), + QStringLiteral("superfast"), + QStringLiteral("veryfast"), + QStringLiteral("faster"), + QStringLiteral("fast"), + QStringLiteral("medium"), + QStringLiteral("slow"), + QStringLiteral("slower"), + QStringLiteral("veryslow"), + }; + for (const QString &preset : presets) { + proxy_preset_combo_->addItem(preset); + } + proxy_preset_combo_->setCurrentText( + OLIVE_CONFIG("ProxyPreset").toString()); + proxy_layout->addWidget(proxy_preset_combo_, proxy_row, 3); + outer_layout->addStretch(); } @@ -129,6 +184,11 @@ void PreferencesDiskTab::Accept(MultiUndoCommand *command) rational::fromDouble(cache_behind_slider_->GetValue())); OLIVE_CONFIG("DiskCacheAhead") = QVariant::fromValue( rational::fromDouble(cache_ahead_slider_->GetValue())); + + OLIVE_CONFIG("ProxyWidth") = static_cast(proxy_width_slider_->GetValue()); + OLIVE_CONFIG("ProxyHeight") = static_cast(proxy_height_slider_->GetValue()); + OLIVE_CONFIG("ProxyCRF") = static_cast(proxy_crf_slider_->GetValue()); + OLIVE_CONFIG("ProxyPreset") = proxy_preset_combo_->currentText(); } } diff --git a/app/dialog/preferences/tabs/preferencesdisktab.h b/app/dialog/preferences/tabs/preferencesdisktab.h index 59366d1b0..ee2a4767a 100644 --- a/app/dialog/preferences/tabs/preferencesdisktab.h +++ b/app/dialog/preferences/tabs/preferencesdisktab.h @@ -23,12 +23,14 @@ #define PREFERENCESDISKTAB_H #include +#include #include #include #include "dialog/configbase/configdialogbase.h" #include "render/diskmanager.h" #include "widget/slider/floatslider.h" +#include "widget/slider/integerslider.h" #include "widget/path/pathwidget.h" namespace olive @@ -51,6 +53,11 @@ private: FloatSlider *cache_behind_slider_; DiskCacheFolder *default_disk_cache_folder_; + + IntegerSlider *proxy_width_slider_; + IntegerSlider *proxy_height_slider_; + IntegerSlider *proxy_crf_slider_; + QComboBox *proxy_preset_combo_; }; } diff --git a/app/task/proxy/proxy.cpp b/app/task/proxy/proxy.cpp index e17fc2e59..2bd2f0221 100644 --- a/app/task/proxy/proxy.cpp +++ b/app/task/proxy/proxy.cpp @@ -79,8 +79,8 @@ bool ProxyTask::Run() << QStringLiteral("-an") << QStringLiteral("-vf") << scale_filter << QStringLiteral("-c:v") << QStringLiteral("libx264") - << QStringLiteral("-preset") << QStringLiteral("veryfast") - << QStringLiteral("-crf") << QStringLiteral("23") + << QStringLiteral("-preset") << params_.preset + << QStringLiteral("-crf") << QString::number(params_.crf) << QStringLiteral("-pix_fmt") << QStringLiteral("yuv420p") << QStringLiteral("-movflags") << QStringLiteral("+faststart") << QStringLiteral("-f") << container_format diff --git a/app/widget/timelinewidget/timelinewidget.cpp b/app/widget/timelinewidget/timelinewidget.cpp index b228686d5..0313510a9 100644 --- a/app/widget/timelinewidget/timelinewidget.cpp +++ b/app/widget/timelinewidget/timelinewidget.cpp @@ -1196,6 +1196,10 @@ void TimelineWidget::GenerateProxiesForSelectedClips() } ProxyManager::ProxyParams params; + params.width = OLIVE_CONFIG("ProxyWidth").value(); + params.height = OLIVE_CONFIG("ProxyHeight").value(); + params.crf = OLIVE_CONFIG("ProxyCRF").value(); + params.preset = OLIVE_CONFIG("ProxyPreset").toString(); const ProxyManager::Proxy proxy = ProxyManager::instance()->GetOrStartProxy( item->project()->cache_path(), item->filename(), diff --git a/app/window/mainwindow/mainmenu.cpp b/app/window/mainwindow/mainmenu.cpp index 253b368a7..81a26401d 100644 --- a/app/window/mainwindow/mainmenu.cpp +++ b/app/window/mainwindow/mainmenu.cpp @@ -360,6 +360,12 @@ MainMenu::MainMenu(MainWindow *parent) tools_menu_->addSeparator(); + tools_proxy_settings_item_ = new QAction(this); + Menu::ConformItem(tools_proxy_settings_item_, "proxysettings"); + connect(tools_proxy_settings_item_, &QAction::triggered, this, + []() { Core::instance()->DialogPreferencesShow(3); }); + tools_menu_->addAction(tools_proxy_settings_item_); + tools_preferences_item_ = tools_menu_->AddItem( "prefs", Core::instance(), &Core::DialogPreferencesShow, tr("Ctrl+,")); @@ -879,6 +885,7 @@ void MainMenu::Retranslate() tools_add_item_->setText(tr("Add Tool")); tools_record_item_->setText(tr("Record Tool")); tools_snapping_item_->setText(tr("Enable Snapping")); + tools_proxy_settings_item_->setText(tr("Proxy Settings...")); tools_preferences_item_->setText(tr("Preferences")); tools_add_item_menu_->setTitle(tr("Add Tool Item")); #ifndef NDEBUG diff --git a/app/window/mainwindow/mainmenu.h b/app/window/mainwindow/mainmenu.h index ccd957a59..cade486ab 100644 --- a/app/window/mainwindow/mainmenu.h +++ b/app/window/mainwindow/mainmenu.h @@ -281,6 +281,7 @@ private: QAction *tools_add_item_; QAction *tools_record_item_; QAction *tools_snapping_item_; + QAction *tools_proxy_settings_item_; QAction *tools_preferences_item_; Menu *tools_add_item_menu_;