/*** 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 . ***/ #include "lutfilefield.h" #include #include #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(layout())->insertWidget(0, library_combo_, 1); refresh_library_entries(); connect(library_combo_, static_cast(&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); } }