Control Center Widget
Control center widgets are button components that appear in the Control Center panel. They provide quick access to plugin functionality directly from the shortcuts area.
Basic Structure
Section titled “Basic Structure”A control center widget is typically a simple button that can toggle a panel or perform an action:
import QtQuickimport Quickshellimport qs.Widgets
NIconButtonHot { property ShellScreen screen property var pluginApi: null
icon: "my-icon" tooltipText: "My Plugin"
onClicked: { if (pluginApi) { pluginApi.togglePanel(screen, this) } }}Manifest Entry Point
Section titled “Manifest Entry Point”Add the controlCenterWidget entry point to your manifest.json:
{ "id": "my-plugin", "name": "My Plugin", "version": "1.0.0", "author": "Your Name", "description": "A plugin with a control center widget", "entryPoints": { "controlCenterWidget": "ControlCenterWidget.qml", "panel": "Panel.qml" }}Required Properties
Section titled “Required Properties”Your control center widget component must accept these properties:
| Property | Type | Description |
|---|---|---|
screen | ShellScreen | The screen the widget is displayed on |
pluginApi | var | The plugin API object (injected by PluginService) |
Widget Types
Section titled “Widget Types”NIconButtonHot (Recommended)
Section titled “NIconButtonHot (Recommended)”The most common widget type. Displays an icon that can be clicked and shows a tooltip on hover:
import QtQuickimport Quickshellimport qs.Widgets
NIconButtonHot { property ShellScreen screen property var pluginApi: null
icon: "settings" tooltipText: pluginApi?.tr("widget.tooltip") || "Open Settings"
onClicked: pluginApi?.togglePanel(screen, this)}NIconButton
Section titled “NIconButton”A simpler icon button without the hot state styling:
import QtQuickimport Quickshellimport qs.Widgets
NIconButton { property ShellScreen screen property var pluginApi: null
icon: "refresh" tooltip: "Refresh Data"
onClicked: { // Perform an action pluginApi?.mainInstance?.refresh() }}Custom Widget
Section titled “Custom Widget”You can create a fully custom widget if needed:
import QtQuickimport QtQuick.Layoutsimport Quickshellimport qs.Commonsimport qs.Widgets
Rectangle { id: root
property ShellScreen screen property var pluginApi: null
implicitWidth: 32 implicitHeight: 32 radius: Style.radiusS color: mouseArea.containsMouse ? Color.mSurfaceVariant : "transparent"
NIcon { anchors.centerIn: parent icon: "star" color: Color.mOnSurface }
MouseArea { id: mouseArea anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: pluginApi?.togglePanel(root.screen, root) }}Accessing Plugin Settings
Section titled “Accessing Plugin Settings”Read settings from your plugin API:
NIconButtonHot { property ShellScreen screen property var pluginApi: null
// Read icon from settings with fallback icon: pluginApi?.pluginSettings?.icon || "star" tooltipText: pluginApi?.pluginSettings?.tooltipText || "My Widget"
onClicked: pluginApi?.togglePanel(screen, this)}Using Translations
Section titled “Using Translations”Support multiple languages in your widget:
NIconButtonHot { property ShellScreen screen property var pluginApi: null
icon: "globe" tooltipText: pluginApi?.tr("controlCenter.tooltip") || "Open Panel"
onClicked: pluginApi?.togglePanel(screen, this)}Translation file (i18n/en.json):
{ "controlCenter": { "tooltip": "Open My Plugin" }}Complete Example
Section titled “Complete Example”Here’s the control center widget from the hello-world plugin:
import QtQuickimport Quickshellimport qs.Widgets
NIconButtonHot { property ShellScreen screen property var pluginApi: null
icon: "noctalia" tooltipText: "Hello World"
onClicked: { if (pluginApi) { pluginApi.togglePanel(screen, this) } }}Best Practices
Section titled “Best Practices”- Keep it simple - Control center widgets should be simple buttons, not complex UIs
- Use tooltips - Always provide a tooltip so users know what the button does
- Toggle panels - The most common pattern is to toggle a panel on click
- Use standard icons - Use Tabler icons that match the Noctalia design language
- Handle null pluginApi - Always check if
pluginApiexists before using it
See Also
Section titled “See Also”- Bar Widget - Widgets for the top/bottom bar
- Panel - Create full overlay panels
- Plugin API - Full API reference
- Manifest Reference - Plugin configuration