Skip to main content

LensStudio:ProjectSettingsPlugin

Module

Module for registering and managing project settings panels in Lens Studio.

Example

// LensStudio:ProjectSettingsPlugin adds a custom panel to the Lens Studio
// Project Settings dialog. Subclass ProjectSettingsPlugin, return a
// Descriptor describing how the entry appears (id, name, section, title,
// icon), and build the panel UI in createWidget(). The plugin needs Ui.IGui
// in its dependencies so the parent widget hierarchy is available.
import { ProjectSettingsPlugin, Descriptor } from 'LensStudio:ProjectSettingsPlugin';
import * as Ui from 'LensStudio:Ui';

export class ProjectSettingsPluginExampleSettings extends ProjectSettingsPlugin {
connections: any[];
root: Ui.Widget | null;
static descriptor(): Descriptor {
const d = new Descriptor();
d.id = 'com.docs.ProjectSettingsPluginExample';
d.name = 'Example Settings';
d.description = 'Demonstrates a minimal ProjectSettingsPlugin';
d.title = 'Example Settings';
d.section = 'General Settings';
// Bundle an .svg/.png next to the plugin's main module and resolve it
// with import.meta.resolve so the icon ships with the plugin.
d.icon = Editor.Icon.fromFile(new Editor.Path(import.meta.resolve('icon.svg')));
d.dependencies = [Ui.IGui];
return d;
}
constructor(pluginSystem: Editor.PluginSystem, descriptor?: Descriptor) {
super(pluginSystem, descriptor);
this.connections = [];
this.root = null;
}
createWidget(parent: Ui.Widget): Ui.Widget {
this.root = new Ui.Widget(parent);
const layout = new Ui.BoxLayout();
layout.setDirection(Ui.Direction.TopToBottom);

const label = new Ui.Label(this.root);
label.text = 'Hello from a Project Settings plugin';
layout.addWidget(label);
layout.addStretch(1);

this.root.layout = layout;
return this.root;
}
deinit(): void {
this.connections.forEach((c: any) => c?.disconnect());
this.connections = [];
if (this.root) { this.root.deleteLater(); this.root = null; }
}
}

Classes

ClassDescription
DescriptorConfiguration descriptor for a project settings plugin, holding the section and title used to register the panel.
ProjectSettingsPluginConstructs a project settings plugin bound to the given plugin system and optional descriptor.