refactor: invert the last engine-to-UI dependencies

- NodeFactory's menu creation moves to UI-side widget/menu/factorymenu
  (the factory only exposes its node library read-only now)
- DiskManager's cache-settings dialog is created through a registered
  std::function handler (registered by Core at startup)
- OlivePluginInstance creates progress UIs through a
  PluginProgressReporter interface (Null fallback headless) and queries
  the active viewer through a provider callback, both registered by Core
- factory.h, diskmanager and pluginSupport no longer reference any
  widget//dialog//panel//window headers or classes
This commit is contained in:
2026-07-20 02:05:01 +08:00
parent bff06e00e5
commit 026ff94b5e
21 changed files with 630 additions and 179 deletions
+2
View File
@@ -3,6 +3,8 @@ target_sources(libolive-editor PRIVATE
olivehost.cpp
oliveplugininstance.h
oliveplugininstance.cpp
pluginprogressreporter.h
pluginprogressreporter.cpp
oliveclip.cpp
oliveclip.h
paraminstance.cpp
+22 -38
View File
@@ -23,11 +23,8 @@
#include "ofxMessage.h"
#include "common/current.h"
#include "coreengine.h"
#include "dialog/progress/progress.h"
#include "pluginprogressreporter.h"
#include "node/output/viewer/viewer.h"
#include "panel/panelmanager.h"
#include "panel/timebased/timebased.h"
#include "panel/timeline/timeline.h"
#include <cstdio>
#include <QApplication>
@@ -125,31 +122,19 @@ private:
bool skip_first_redo_ = true;
};
ActiveViewerProvider active_viewer_provider_;
ViewerOutput *get_active_viewer_output()
{
PanelManager *manager = PanelManager::instance();
if (!manager) {
return nullptr;
}
if (auto *time_panel = manager->most_recently_focused<TimeBasedPanel>()) {
if (time_panel->get_connected_viewer()) {
return time_panel->get_connected_viewer();
}
}
QList<TimelinePanel *> timelines =
manager->get_panels_of_type<TimelinePanel>();
for (TimelinePanel *panel : timelines) {
if (panel && panel->get_connected_viewer()) {
return panel->get_connected_viewer();
}
}
return nullptr;
return active_viewer_provider_ ? active_viewer_provider_() : nullptr;
}
} // namespace
void set_active_viewer_provider(ActiveViewerProvider provider)
{
active_viewer_provider_ = std::move(provider);
}
const std::string &OlivePluginInstance::getDefaultOutputFielding() const
{
return field_order_for_params(params_);
@@ -452,21 +437,20 @@ void OlivePluginInstance::progressStart(const std::string &message,
return;
}
if (progress_dialog_) {
progress_dialog_->close();
progress_dialog_->deleteLater();
if (progress_reporter_) {
progress_reporter_->close();
progress_reporter_->deleteLater();
}
QString dialog_message = message.empty() ? QStringLiteral("Processing...") :
QString::fromStdString(message);
progress_dialog_ = new ::olive::ProgressDialog(
dialog_message, QStringLiteral("OpenFX"), nullptr);
progress_dialog_->setAttribute(Qt::WA_DeleteOnClose);
QObject::connect(progress_dialog_, &::olive::ProgressDialog::cancelled,
progress_dialog_,
progress_reporter_ = create_plugin_progress_reporter(
dialog_message, QStringLiteral("OpenFX"));
QObject::connect(progress_reporter_, &PluginProgressReporter::cancelled,
progress_reporter_,
[this]() { progress_cancelled_ = true; });
progress_dialog_->show();
progress_reporter_->show();
}
void OlivePluginInstance::progressEnd()
@@ -474,9 +458,9 @@ void OlivePluginInstance::progressEnd()
progress_active_ = false;
progress_cancelled_ = false;
if (progress_dialog_) {
progress_dialog_->close();
progress_dialog_->deleteLater();
if (progress_reporter_) {
progress_reporter_->close();
progress_reporter_->deleteLater();
}
}
@@ -486,9 +470,9 @@ bool OlivePluginInstance::progressUpdate(double t)
return true;
}
if (progress_dialog_) {
if (progress_reporter_) {
double clamped = qBound(0.0, t, 1.0);
progress_dialog_->set_progress(clamped);
progress_reporter_->set_progress(clamped);
}
return !progress_cancelled_;
+16 -2
View File
@@ -27,6 +27,7 @@
#include <map>
#include <mutex>
#include <functional>
#include <QCoreApplication>
#include <QPointer>
#include <QThread>
@@ -43,15 +44,28 @@ inline bool is_gui_thread()
}
return true;
}
class ProgressDialog;
class ViewerOutput;
namespace plugin
{
class PluginNode;
class PluginProgressReporter;
enum class ErrorType { error, warning, message };
struct PersistentErrors {
ErrorType type;
QString message;
};
/**
* @brief Provider returning the currently active viewer
*
* Registered by the UI layer, which resolves the viewer through the panel
* manager. Without a provider, the OFX timeline suite falls back to its
* safe defaults (current time 0, empty bounds, seeking does nothing).
*/
using ActiveViewerProvider = std::function<ViewerOutput *()>;
void set_active_viewer_provider(ActiveViewerProvider provider);
class OlivePluginInstance : public OFX::Host::ImageEffect::Instance {
public:
OlivePluginInstance(OFX::Host::ImageEffect::ImageEffectPlugin *plugin,
@@ -214,7 +228,7 @@ private:
QString edit_label_;
QString edit_first_label_;
int edit_param_count_ = 0;
QPointer<olive::ProgressDialog> progress_dialog_;
QPointer<PluginProgressReporter> progress_reporter_;
bool progress_cancelled_ = false;
bool progress_active_ = false;
bool open_gl_enabled_ = false;
@@ -0,0 +1,69 @@
/*
* Oak Video Editor - Non-Linear Video Editor
* Copyright (C) 2025 Olive CE 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 "pluginprogressreporter.h"
namespace olive
{
namespace plugin
{
namespace
{
/**
* @brief No-op reporter used when no UI factory is registered
*
* Never emits cancelled(), so processing always continues.
*/
class NullPluginProgressReporter : public PluginProgressReporter {
public:
void set_progress(double value) override
{
(void)value;
}
void show() override
{
}
void close() override
{
}
};
PluginProgressReporterFactory reporter_factory_;
}
void set_plugin_progress_reporter_factory(
PluginProgressReporterFactory factory)
{
reporter_factory_ = std::move(factory);
}
PluginProgressReporter *
create_plugin_progress_reporter(const QString &message, const QString &title)
{
if (reporter_factory_) {
return reporter_factory_(message, title);
}
return new NullPluginProgressReporter();
}
}
}
@@ -0,0 +1,84 @@
/*
* Oak Video Editor - Non-Linear Video Editor
* Copyright (C) 2025 Olive CE 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 OAK_PLUGIN_PROGRESS_REPORTER_H
#define OAK_PLUGIN_PROGRESS_REPORTER_H
#include <QObject>
#include <QString>
#include <functional>
namespace olive
{
namespace plugin
{
/**
* @brief UI-independent interface for reporting plugin progress
*
* The engine cannot show UI itself, so OFX progress reporting goes through
* this interface. The UI layer registers a factory (see
* set_plugin_progress_reporter_factory()) that creates a reporter wrapping a
* ProgressDialog; without a factory, a no-op reporter is used instead.
*/
class PluginProgressReporter : public QObject {
Q_OBJECT
public:
explicit PluginProgressReporter(QObject *parent = nullptr)
: QObject(parent)
{
}
virtual ~PluginProgressReporter() override = default;
virtual void set_progress(double value) = 0;
virtual void show() = 0;
virtual void close() = 0;
signals:
void cancelled();
};
/**
* @brief Factory creating a PluginProgressReporter for a progress session
*
* Registered by the UI layer at startup. The caller takes ownership of the
* returned reporter.
*/
using PluginProgressReporterFactory =
std::function<PluginProgressReporter *(const QString &message,
const QString &title)>;
void set_plugin_progress_reporter_factory(
PluginProgressReporterFactory factory);
/**
* @brief Create a progress reporter through the registered factory
*
* Without a factory, returns a no-op reporter so engine code can run
* headless. The caller takes ownership of the returned reporter.
*/
PluginProgressReporter *
create_plugin_progress_reporter(const QString &message, const QString &title);
}
}
#endif // OAK_PLUGIN_PROGRESS_REPORTER_H