import QtQuick import Quickshell import "../../components" import "../../core" import "../../services" import "../../theme" import "../../compat/omarchy/Ui" as OmarchyUi // Hosts an installed plugin's bar widget inside glassMxrph's own pill, so it // sits in the bar like any built-in module (size, glass, spacing, per-screen // layouts, cog options). The widget gets a PluginBarApi whose colors, font and // size come from the glassMxrph theme; tooltips use the shared hover popout. GlassPill { id: root property var barScreen property var entry: ({}) readonly property string pluginId: entry.id ? String(entry.id).slice("plugin:".length) : "" readonly property bool noctalia: PluginService.ecosystem(pluginId) === "noctalia" readonly property string source: PluginService.entryUrl(pluginId, "bar-widget") readonly property var settings: PluginService.widgetSettings(pluginId, entry.options) readonly property Item widget: loader.item as Item // Not widget.visible: that reads false while this pill is still hidden. // Omarchy widgets report emptiness through hasVisualContent instead. readonly property var widgetObject: loader.item readonly property bool shown: !!widget && (noctalia || widgetObject.hasVisualContent !== false) && widget.implicitWidth > 0 // A plugin can offer a "background" setting; "transparent" drops the // pill so its widget sits straight on the bar, like the tray's option. readonly property bool bare: settings.background === "transparent" color: bare ? "transparent" : Qt.alpha(Theme.surface, surfaceOpacity) border.width: bare ? 0 : 1 plain: bare implicitHeight: ModuleRegistry.pillHeight implicitWidth: shown ? Math.ceil(widget.implicitWidth) + 8 : 0 visible: implicitWidth > 0 Behavior on implicitWidth { NumberAnimation { duration: Theme.duration easing.type: Easing.OutCubic } } OmarchyUi.PluginBarApi { id: api pluginId: root.pluginId moduleName: root.pluginId shell: root.pluginId ? PluginService.shellFor(root.pluginId) : null foreground: Theme.text barForeground: Theme.text background: Qt.alpha(Theme.surface, Theme.glassOpacity) urgent: Theme.urgent fontFamily: fontProbe.font.family position: "top" vertical: false barSize: ModuleRegistry.pillHeight transparent: true foregroundAnimationEnabled: Theme.duration > 0 activePopout: PluginService.activePopout layoutConfig: root.settings // Like Omarchy's bar: only a hovered widget shows its tooltip (plugins // also call this whenever their data refreshes). _showTooltip: (target, text) => { if (text && target && target.tooltipHovered !== false) PopoutState.hover(target, "tooltip", text); } _hideTooltip: target => PopoutState.unhover(target) _requestPopout: owner => PluginService.requestPopout(owner) _releasePopout: owner => PluginService.releasePopout(owner) _switchPanelFrom: (owner, direction) => false _targetBelongsToWindow: (target, window) => !!target && !!target.QsWindow && target.QsWindow.window === window _moduleWidgets: id => PluginService.widgets[id] || [] _run: command => Quickshell.execDetached(Array.isArray(command) ? command : ["sh", "-c", String(command)]) } // The default UI font, which glassMxrph's own text uses. Text { id: fontProbe visible: false } // Noctalia widgets get their pluginApi at creation, as in Noctalia, so their // first bindings already see it. onSourceChanged: load() Component.onCompleted: load() function load() { if (!source) { loader.source = ""; return; } if (!noctalia) { loader.source = source; return; } loader.setSource(source, { pluginApi: PluginService.noctaliaApi(pluginId), screen: barScreen, widgetId: pluginId, section: entry.position || "right", sectionWidgetIndex: 0, sectionWidgetsCount: 1 }); } Loader { id: loader anchors.centerIn: parent height: parent.height onLoaded: { if (root.noctalia) { // Noctalia v4 bar widget contract. const napi = PluginService.noctaliaApi(root.pluginId); if ("screen" in item) item.screen = Qt.binding(() => root.barScreen); if (napi) napi.barWidget = item; } else { if ("bar" in item) item.bar = api; if ("moduleName" in item) item.moduleName = root.pluginId; if ("settings" in item) item.settings = Qt.binding(() => root.settings); } PluginService.registerWidget(root.pluginId, item); } } Component.onDestruction: if (loader.item) PluginService.unregisterWidget(pluginId, loader.item) }