Complete API reference for ActionPad QML and C++ interfaces.
PlasmoidItem {
id: root
}Inherits: PlasmoidItem (Plasma 6)
property var buttons: []Type: Array<ButtonObject>
Description: Array of button data objects
Default: [] (empty, loads from configuration)
Read/Write: Read-write
Example:
root.buttons.push({
id: "btn_001",
label: "Test",
actionType: "script",
actionTarget: "/path/to/script.sh"
})readonly property bool isInPanelType: bool
Description: True if widget is in a panel
Read-only: Yes
Calculation:
[PlasmaCore.Types.TopEdge, PlasmaCore.Types.BottomEdge,
PlasmaCore.Types.LeftEdge, PlasmaCore.Types.RightEdge]
.indexOf(plasmoid.location) !== -1readonly property bool isVertical
readonly property bool isHorizontalType: bool
Description: Panel orientation
Read-only: Yes
readonly property color backgroundColor
readonly property color textColor
readonly property color highlightColor
readonly property color buttonBackgroundColorType: color
Description: Theme-aware colors from PlasmaCore.Theme
Read-only: Yes
Updates: Automatically on theme change
function addButton(buttonData: ButtonObject): stringParameters:
buttonData- Button configuration object
Returns: string - Newly created button ID
Description: Adds a new button to the widget
Example:
let id = root.addButton({
label: "Firefox",
tooltip: "Open browser",
actionType: "application",
actionTarget: "firefox",
icon: "firefox",
color: "#ff9500"
})function updateButton(buttonId: string, buttonData: ButtonObject): boolParameters:
buttonId- ID of button to updatebuttonData- New button data (partial update supported)
Returns: bool - True if successful, false if button not found
Description: Updates an existing button's properties
Example:
root.updateButton("btn_001", {
label: "New Label",
color: "#ff0000"
})function deleteButton(buttonId: string): boolParameters:
buttonId- ID of button to delete
Returns: bool - True if successful
Description: Removes a button from the widget
Example:
root.deleteButton("btn_001")function moveButton(fromIndex: int, toIndex: int): voidParameters:
fromIndex- Current button indextoIndex- Target button index
Description: Reorders buttons by moving from one position to another
Example:
// Move button from position 2 to position 0 (first)
root.moveButton(2, 0)function executeAction(buttonData: ButtonObject): voidParameters:
buttonData- Button object containing action details
Description: Main dispatch function for executing button actions. Routes to specific execution function based on actionType.
Example:
root.executeAction({
actionType: "script",
actionTarget: "/path/to/script.sh",
arguments: "--flag value",
runInTerminal: true
})function executeScript(buttonData: ButtonObject): voidParameters:
buttonData- Button data with script details
Description: Executes a shell script or command
Required Fields:
actionTarget- Script path or commandrunInTerminal(optional) - Show terminal outputarguments(optional) - Command argumentsworkingDirectory(optional) - Execution directory
Example:
root.executeScript({
actionTarget: "/home/user/backup.sh",
arguments: "--full --verbose",
runInTerminal: true,
workingDirectory: "/home/user"
})function executeApplication(buttonData: ButtonObject): voidParameters:
buttonData- Button data with application details
Description: Launches an application
Required Fields:
actionTarget- Application name or path
Example:
root.executeApplication({
actionTarget: "firefox",
arguments: "--new-window https://github.com"
})function executeUrl(buttonData: ButtonObject): voidParameters:
buttonData- Button data with URL
Description: Opens URL in default browser using Qt.openUrlExternally()
Required Fields:
actionTarget- URL to open
Auto-adds https:// if no protocol specified
Example:
root.executeUrl({
actionTarget: "github.com" // Opens as https://github.com
})function getContrastColor(backgroundColor: string): stringParameters:
backgroundColor- Hex color string (e.g., "#ff5733")
Returns: string - "#000000" or "#FFFFFF"
Description: Calculates optimal text color (black/white) for given background using relative luminance formula
Algorithm:
luminance = 0.299 * R + 0.587 * G + 0.114 * B
return luminance > 0.5 ? "#000000" : "#FFFFFF"Example:
let textColor = root.getContrastColor("#e74c3c") // Returns "#FFFFFF"function generateUniqueId(): stringReturns: string - Unique button ID
Format: "btn_<timestamp>_<random>"
Example:
let id = root.generateUniqueId() // "btn_1700000000_456"KCM.SimpleKCM {
id: configPage
}Inherits: KCM.SimpleKCM (KDE Configuration Module)
property alias cfg_layoutType: layoutTypeCombo.currentValue
property alias cfg_buttonSize: buttonSizeCombo.currentValue
property alias cfg_spacing: spacingSpinBox.value
property alias cfg_gridColumns: gridColumnsSpinBox.value
property string cfg_buttonsData: plasmoid.configuration.buttonsDataDescription: Two-way data binding with widget configuration
function addNewButton(): voidDescription: Creates new button with default values and opens edit dialog
Default Button:
{
id: "btn_<timestamp>_<random>",
label: "New Button",
tooltip: "New Button",
actionType: "script",
actionTarget: "",
icon: "application-default-icon",
iconOnly: false,
color: "",
arguments: "",
runInTerminal: false,
workingDirectory: ""
}function deleteButton(buttonId: string): voidParameters:
buttonId- ID of button to remove
Description: Removes button from configuration and saves
function moveButtonUp(index: int): void
function moveButtonDown(index: int): voidParameters:
index- Current button index in list
Description: Reorders buttons in configuration list
Header: plugin/commandexecutor.h
Namespace: Global (registered to QML as com.github.shortcutwidget)
Inherits: QObject
explicit CommandExecutor(QObject *parent = nullptr)Parameters:
parent- Parent QObject (optional)
Description: Creates CommandExecutor instance with QProcess
Q_INVOKABLE void executeCommand(
const QString &command,
const QString &workingDirectory = QString()
)Parameters:
command- Shell command to executeworkingDirectory- Working directory (optional, defaults to home)
Description: Executes command in background using QProcess
Signals Emitted:
commandStarted(command)commandFinished(exitCode, output)orcommandError(error)
QML Usage:
commandExecutor.executeCommand(
"echo 'Hello World'",
"/home/user"
)Q_INVOKABLE void executeInTerminal(
const QString &command,
const QString &workingDirectory = QString()
)Parameters:
command- Command to execute in terminalworkingDirectory- Working directory (optional)
Description: Launches Konsole terminal with command
Terminal Command:
konsole --hold -e bash -c "cd <workdir> && <command>"QML Usage:
commandExecutor.executeInTerminal(
"./build.sh",
"/home/user/project"
)Q_INVOKABLE void launchApplication(
const QString &application,
const QString &arguments = QString()
)Parameters:
application- Application name or patharguments- Command-line arguments (optional)
Description: Launches application using QProcess::startDetached()
QML Usage:
commandExecutor.launchApplication(
"firefox",
"--new-window https://github.com"
)void commandStarted(const QString &command)Parameters:
command- Command that started
Description: Emitted when command execution begins
void commandFinished(int exitCode, const QString &output)Parameters:
exitCode- Process exit code (0 = success)output- Combined stdout/stderr
Description: Emitted when command completes successfully
void commandError(const QString &error)Parameters:
error- Error description
Description: Emitted when command fails to start or crashes
Complete button configuration object.
interface ButtonObject {
id: string // Unique identifier
label: string // Button text
tooltip?: string // Hover tooltip
actionType: ActionType // "script" | "application" | "url"
actionTarget: string // Path/command/URL
icon?: string // Icon name or path
iconOnly?: boolean // Hide label, show only icon
color?: string // Custom background color (hex/rgb)
arguments?: string // Command arguments
runInTerminal?: boolean // Run script in terminal
workingDirectory?: string // Execution directory
}Field Details:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id |
string |
Yes | Auto-generated | Unique button ID |
label |
string |
Yes | - | Button text |
tooltip |
string |
No | Same as label | Hover text |
actionType |
ActionType |
Yes | - | Action type |
actionTarget |
string |
Yes | - | Target path/command/URL |
icon |
string |
No | "application-default-icon" |
Icon identifier |
iconOnly |
boolean |
No | false |
Icon-only mode |
color |
string |
No | "" (theme) |
Background color |
arguments |
string |
No | "" |
Command arguments |
runInTerminal |
boolean |
No | false |
Terminal execution |
workingDirectory |
string |
No | "" (home) |
Working directory |
type ActionType = "script" | "application" | "url"- script: Execute shell script or command
- application: Launch application
- url: Open URL in browser
plasmoid.configuration.buttonsData // string (JSON)
plasmoid.configuration.layoutType // string: "grid"|"row"|"column"
plasmoid.configuration.buttonSize // string: "small"|"medium"|"large"
plasmoid.configuration.spacing // int: 0-50
plasmoid.configuration.gridColumns // int: 1-10Connections {
target: plasmoid.configuration
function onButtonsDataChanged() {
// Reload buttons
}
}Connections {
target: PlasmaCore.Theme
function onThemeChanged() {
// Update colors
}
}import QtQuick
import org.kde.plasma.plasmoid
import com.github.shortcutwidget 1.0
PlasmoidItem {
id: root
// C++ Command Executor
CommandExecutor {
id: executor
onCommandStarted: function(cmd) {
console.log("Started:", cmd)
}
onCommandFinished: function(code, output) {
console.log("Finished:", code, output)
}
onCommandError: function(err) {
console.error("Error:", err)
}
}
// Button with all features
function createButton() {
return addButton({
label: "Deploy",
tooltip: "Deploy to production",
actionType: "script",
actionTarget: "/home/user/deploy.sh",
icon: "application-x-executable-script",
iconOnly: false,
color: "#e74c3c",
arguments: "--env=prod --backup",
runInTerminal: true,
workingDirectory: "/home/user/project"
})
}
// Execute button
function runButton(buttonId) {
let button = buttons.find(b => b.id === buttonId)
if (button) {
executeAction(button)
}
}
}- 1.0.0 - Initial API release
Questions? See DEVELOPMENT.md or open an issue on GitHub!