lut: pick from the global LUT library in node params; i18n; doc

- File inputs marked with the 'lut_library' property (currently the
  OCIO LUT node) now show a combo box populated from the global LUT
  library above the path field: pick a library LUT directly, or use
  'Other (Custom File)...' with the regular path field; selections go
  through the standard undoable input-change path
- Refresh zh_CN translations with lupdate and translate all strings
  introduced by the proxy dialog, LUT library, LUT picker, waveform
  sync and footage start time work
- Document the new per-footage custom <proxy> attributes and the
  'manual' source-start-time origin in the project file reference
- Add LutFileField UI tests
This commit is contained in:
2026-07-16 23:49:59 +08:00
parent caafac4203
commit 4a4dcae580
9 changed files with 2530 additions and 3162 deletions
+2233 -3157
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -18,5 +18,7 @@ set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/filefield/filefield.cpp
widget/filefield/filefield.h
widget/filefield/lutfilefield.cpp
widget/filefield/lutfilefield.h
PARENT_SCOPE
)
+1 -1
View File
@@ -38,7 +38,7 @@ public:
return line_edit_->text();
}
void SetFilename(const QString &s)
virtual void SetFilename(const QString &s)
{
line_edit_->setText(s);
}
+89
View File
@@ -0,0 +1,89 @@
/***
Oak - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "lutfilefield.h"
#include <QDir>
#include <QHBoxLayout>
#include "render/lutlibrary.h"
namespace olive
{
LutFileField::LutFileField(QWidget *parent) : FileField(parent)
{
library_combo_ = new QComboBox();
library_combo_->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLengthWithIcon);
library_combo_->setMinimumContentsLength(12);
static_cast<QHBoxLayout *>(layout())->insertWidget(0, library_combo_, 1);
RefreshLibraryEntries();
connect(library_combo_,
static_cast<void (QComboBox::*)(int)>(&QComboBox::activated), this,
[this](int index) {
const QString path =
library_combo_->itemData(index).toString();
if (!path.isEmpty()) {
SetFilename(path);
emit FilenameChanged(path);
}
});
// Keep the combo in sync when the path is edited directly
connect(this, &FileField::FilenameChanged, this, [this](const QString &) {
RefreshLibraryEntries();
});
}
void LutFileField::SetFilename(const QString &s)
{
FileField::SetFilename(s);
RefreshLibraryEntries();
}
void LutFileField::RefreshLibraryEntries()
{
const QString current = GetFilename();
const QSignalBlocker blocker(library_combo_);
library_combo_->clear();
library_combo_->addItem(tr("Other (Custom File)..."), QString());
const QStringList library_dirs = LUTLibrary::GetDirectories();
const QStringList luts = LUTLibrary::GetLutFiles();
for (const QString &lut : luts) {
// Show the path relative to the library directory that contains it
QString display = lut;
for (const QString &dir : library_dirs) {
if (lut.startsWith(dir)) {
display = QDir(dir).relativeFilePath(lut);
break;
}
}
library_combo_->addItem(display, lut);
}
const int index = library_combo_->findData(current);
library_combo_->setCurrentIndex(index >= 0 ? index : 0);
}
}
+71
View File
@@ -0,0 +1,71 @@
/***
Oak - Non-Linear Video Editor
Copyright (C) 2026 Oak Team
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef LUTFILEFIELD_H
#define LUTFILEFIELD_H
#include <QComboBox>
#include "filefield.h"
namespace olive
{
/**
* @brief A FileField with a combo box for picking LUTs from the global LUT
* library
*
* The combo lists every LUT found by LUTLibrary::GetLutFiles() plus an
* "Other" entry for custom file paths. Picking a library entry fills in the
* file path (through the regular FilenameChanged signal, so undo keeps
* working); picking "Other" or entering a path that is not in the library
* leaves the path untouched and shows the combo's "Other" entry.
*/
class LutFileField : public FileField {
Q_OBJECT
public:
LutFileField(QWidget *parent = nullptr);
virtual void SetFilename(const QString &s) override;
/**
* @brief The combo box listing the LUT library entries
*
* Exposed for inspection and UI tests; prefer SetFilename()/GetFilename()
* for interacting with the field itself.
*/
QComboBox *library_combo() const
{
return library_combo_;
}
private:
/**
* @brief Repopulates the combo from the LUT library and syncs the
* selection with the current filename
*/
void RefreshLibraryEntries();
QComboBox *library_combo_;
};
}
#endif // LUTFILEFIELD_H
@@ -42,6 +42,7 @@
#include "widget/bezier/bezierwidget.h"
#include "widget/colorbutton/colorbutton.h"
#include "widget/filefield/filefield.h"
#include "widget/filefield/lutfilefield.h"
#include "widget/slider/floatslider.h"
#include "widget/slider/integerslider.h"
#include "widget/slider/rationalslider.h"
@@ -141,7 +142,15 @@ void NodeParamViewWidgetBridge::CreateWidgets()
break;
}
case NodeValue::kFile: {
FileField *file_field = new FileField(parent);
FileField *file_field;
if (GetInnerInput().GetProperty(QStringLiteral("lut_library"))
.toBool()) {
// File inputs that accept LUTs get a combo box for picking
// from the global LUT library
file_field = new LutFileField(parent);
} else {
file_field = new FileField(parent);
}
widgets_.append(file_field);
connect(file_field, &FileField::FilenameChanged, this,
&NodeParamViewWidgetBridge::WidgetCallback);
+15 -2
View File
@@ -352,6 +352,7 @@ Default `Node::SaveCustom()` writes nothing. Specific node subclasses may overri
<custom>
<timestamp>1740000000</timestamp>
<proxy enabled="1" state="ready" stream="0" preset="1">/path/to/proxy.mp4</proxy>
<proxy enabled="1" state="ready" stream="0" preset="1" custom="1" pwidth="960" pheight="540" pcrf="20" ppreset="fast" pext="mov" paudio="0">/path/to/proxy.mov</proxy>
<sourcestarttime source="timecode">1/25</sourcestarttime>
<viewer>...</viewer>
</custom>
@@ -370,12 +371,24 @@ Default `Node::SaveCustom()` writes nothing. Specific node subclasses may overri
- `stream`:代理使用的视频流索引。
- `preset`: proxy preset version.
- `preset`:代理预设版本。
- `custom` (optional): `1` when the footage uses per-footage custom proxy parameters instead of the global settings.
- `custom`(可选):为 `1` 表示该素材使用独立的自定义代理参数,而不是全局设置。
- `pwidth`, `pheight` (optional, requires `custom="1"`): custom proxy dimensions.
- `pwidth``pheight`(可选,需 `custom="1"`):自定义代理分辨率。
- `pcrf` (optional): custom x264 CRF value.
- `pcrf`(可选):自定义 x264 CRF 值。
- `ppreset` (optional): custom x264 preset name.
- `ppreset`(可选):自定义 x264 预设名称。
- `pext` (optional): custom proxy container extension (e.g. `mp4`, `mov`).
- `pext`(可选):自定义代理容器扩展名(如 `mp4``mov`)。
- `paudio` (optional): `1` if the proxy includes audio streams, `0` for video-only. Proxies generated with audio store the video stream at index 0 followed by the source audio streams in source order.
- `paudio`(可选):`1` 表示代理包含音频流,`0` 表示仅视频。包含音频的代理将视频流放在索引 0,其后按源顺序跟随音频流。
- Text content: proxy file path (may be empty if `enabled` is true but proxy is not yet generated).
- 文本内容:代理文件路径(如果 `enabled` 为 true 但代理尚未生成,则可能为空)。
- `<sourcestarttime>`: source start time offset.
- `<sourcestarttime>`:源起始时间偏移。
- `source` attribute: source identifier (e.g. `timecode`).
- `source` 属性:源标识符(如 `timecode`)。
- `source` attribute: source identifier (e.g. `timecode`, `bwf_time_reference`, or `manual` when entered by the user).
- `source` 属性:源标识符(如 `timecode``bwf_time_reference`,或用户手动输入时的 `manual`)。
- Text: rational `numerator/denominator`.
- 文本:有理数 `numerator/denominator`
- `<viewer>`: see `ViewerOutput` below.
+1
View File
@@ -46,6 +46,7 @@ add_executable(olive-gtest
project_serializer_test.cpp
proxy_manager_test.cpp
proxy_dialog_test.cpp
lut_file_field_test.cpp
timeline_marker_test.cpp
undo_stack_test.cpp
plugin_support_test.cpp
+107
View File
@@ -0,0 +1,107 @@
#include <gtest/gtest.h>
#include <QDir>
#include <QFile>
#include <QSignalSpy>
#include <QTemporaryDir>
#include "config/config.h"
#include "render/lutlibrary.h"
#include "widget/filefield/lutfilefield.h"
namespace
{
class LutLibraryConfigGuard {
public:
LutLibraryConfigGuard()
: previous_(olive::Config::Current()[QStringLiteral("LUTLibraryPaths")]
.toString())
{
}
~LutLibraryConfigGuard()
{
olive::Config::Current()[QStringLiteral("LUTLibraryPaths")] = previous_;
}
private:
QString previous_;
};
QString WriteFile(const QString &path)
{
QFile file(path);
if (!file.open(QIODevice::WriteOnly)) {
return QString();
}
file.close();
return path;
}
} // namespace
TEST(LutFileField, PopulatesComboFromLibrary)
{
LutLibraryConfigGuard guard;
QTemporaryDir dir;
ASSERT_TRUE(dir.isValid());
const QString cube =
WriteFile(QDir(dir.path()).filePath(QStringLiteral("a.cube")));
const QString three_dl =
WriteFile(QDir(dir.path()).filePath(QStringLiteral("b.3dl")));
const QString other =
WriteFile(QDir(dir.path()).filePath(QStringLiteral("c.txt")));
ASSERT_FALSE(cube.isEmpty());
ASSERT_FALSE(three_dl.isEmpty());
ASSERT_FALSE(other.isEmpty());
olive::LUTLibrary::SetDirectories({ dir.path() });
olive::LutFileField field;
// One "Other" entry plus one entry per supported LUT
ASSERT_EQ(field.library_combo()->count(), 3);
EXPECT_TRUE(field.library_combo()->itemData(0).toString().isEmpty());
EXPECT_GE(field.library_combo()->findData(cube), 1);
EXPECT_GE(field.library_combo()->findData(three_dl), 1);
EXPECT_EQ(field.library_combo()->findData(other), -1);
}
TEST(LutFileField, SelectionFollowsFilenameAndEmitsOnPick)
{
LutLibraryConfigGuard guard;
QTemporaryDir dir;
ASSERT_TRUE(dir.isValid());
const QString cube =
WriteFile(QDir(dir.path()).filePath(QStringLiteral("a.cube")));
ASSERT_FALSE(cube.isEmpty());
olive::LUTLibrary::SetDirectories({ dir.path() });
olive::LutFileField field;
// A path that is not in the library shows the "Other" entry
field.SetFilename(QStringLiteral("/custom/elsewhere.cube"));
EXPECT_EQ(field.library_combo()->currentIndex(), 0);
// A library path selects its entry
field.SetFilename(cube);
EXPECT_GT(field.library_combo()->currentIndex(), 0);
// Picking a library entry updates the filename and emits the change
// signal so the parameter bridge applies it like any other edit
field.SetFilename(QString());
QSignalSpy spy(&field, &olive::FileField::FilenameChanged);
const int index = field.library_combo()->findData(cube);
ASSERT_GE(index, 1);
emit field.library_combo()->activated(index);
EXPECT_EQ(field.GetFilename(), cube);
ASSERT_EQ(spy.count(), 1);
EXPECT_EQ(spy.first().first().toString(), cube);
}