Initial commit of the Quickshell desktop suite: bar, dock, launcher, settings, Control Center, dashboard, OSD, lock screen, desktop widgets, plugin host with the vendored Noctalia/Omarchy compatibility layer, helpers, packaging, tests and phase documentation. Includes the optimization work so far: usage widgets and dashboard gauges no longer animate continuously, desktop widgets pause while covered, system controls stop flickering on background polls, dock app matching uses an indexed catalog, and workspace ghosts are created only for occupied slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
121 lines
4.7 KiB
QML
121 lines
4.7 KiB
QML
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
|
|
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)
|
|
}
|