Files
Mike-Solar 0aa5879f35 app: migrate all engine access to the C ABI facade (nm U _ZN5olive = 0)
Every app module now reaches liboakengine exclusively through
oakengine_* C calls, EngineEventBridge subscriptions and app-side
handle headers (cliphandle/keyframehandle/nodevaluehandle/oakvaluehelper).
Direct C++ command construction, engine signal connect()s, and engine
type usage in MOC-visible signatures are gone: 557 -> 0 undefined
olive:: symbols in oak-editor.
2026-07-26 22:43:21 +08:00

110 lines
2.9 KiB
C++

/***
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 "oakengine/lut.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);
refresh_library_entries();
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()) {
set_filename(path);
emit filename_changed(path);
}
});
// Keep the combo in sync when the path is edited directly
connect(this, &FileField::filename_changed, this, [this](const QString &) {
refresh_library_entries();
});
}
void LutFileField::set_filename(const QString &s)
{
FileField::set_filename(s);
refresh_library_entries();
}
void LutFileField::refresh_library_entries()
{
const QString current = get_filename();
const QSignalBlocker blocker(library_combo_);
library_combo_->clear();
library_combo_->addItem(tr("Other (Custom File)..."), QString());
QStringList library_dirs;
{
int dir_count = oakengine_lut_directory_count();
for (int i = 0; i < dir_count; i++) {
char buf[4096];
int len = oakengine_lut_directory_at(i, buf, sizeof(buf));
if (len > 0) {
library_dirs.append(QString::fromUtf8(buf, len));
}
}
}
QStringList luts;
{
int file_count = oakengine_lut_file_count();
for (int i = 0; i < file_count; i++) {
char buf[4096];
int len = oakengine_lut_file_at(i, buf, sizeof(buf));
if (len > 0) {
luts.append(QString::fromUtf8(buf, len));
}
}
}
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);
}
}