mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-06 05:25:41 -05:00
moar
This commit is contained in:
@@ -8,7 +8,8 @@ Column {
|
|||||||
required property string settingKey
|
required property string settingKey
|
||||||
required property string label
|
required property string label
|
||||||
property string description: ""
|
property string description: ""
|
||||||
property var items: []
|
property var defaultValue: []
|
||||||
|
property var items: defaultValue
|
||||||
property Component delegate: null
|
property Component delegate: null
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
@@ -17,7 +18,7 @@ Column {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
const settings = findSettings()
|
const settings = findSettings()
|
||||||
if (settings) {
|
if (settings) {
|
||||||
items = settings.loadValue(settingKey, [])
|
items = settings.loadValue(settingKey, defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ Column {
|
|||||||
required property string label
|
required property string label
|
||||||
property string description: ""
|
property string description: ""
|
||||||
property var fields: []
|
property var fields: []
|
||||||
property var items: []
|
property var defaultValue: []
|
||||||
|
property var items: defaultValue
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
@@ -17,7 +18,7 @@ Column {
|
|||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
const settings = findSettings()
|
const settings = findSettings()
|
||||||
if (settings) {
|
if (settings) {
|
||||||
items = settings.loadValue(settingKey, [])
|
items = settings.loadValue(settingKey, defaultValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
@@ -9,11 +10,20 @@ Item {
|
|||||||
property var pluginService: null
|
property var pluginService: null
|
||||||
default property alias content: settingsColumn.children
|
default property alias content: settingsColumn.children
|
||||||
|
|
||||||
implicitHeight: settingsColumn.implicitHeight
|
implicitHeight: hasPermission ? settingsColumn.implicitHeight : errorText.implicitHeight
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
|
|
||||||
|
readonly property bool hasPermission: pluginService && pluginService.hasPermission ? pluginService.hasPermission(pluginId, "settings_write") : true
|
||||||
|
|
||||||
function saveValue(key, value) {
|
function saveValue(key, value) {
|
||||||
if (pluginService && pluginService.savePluginData) {
|
if (!pluginService) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!hasPermission) {
|
||||||
|
console.warn("PluginSettings: Plugin", pluginId, "does not have settings_write permission")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (pluginService.savePluginData) {
|
||||||
pluginService.savePluginData(pluginId, key, value)
|
pluginService.savePluginData(pluginId, key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,8 +35,21 @@ Item {
|
|||||||
return defaultValue
|
return defaultValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: errorText
|
||||||
|
visible: pluginService && !root.hasPermission
|
||||||
|
anchors.fill: parent
|
||||||
|
text: "This plugin does not have 'settings_write' permission.\n\nAdd \"permissions\": [\"settings_read\", \"settings_write\"] to plugin.json"
|
||||||
|
color: Theme.error
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
horizontalAlignment: Text.AlignHCenter
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: settingsColumn
|
id: settingsColumn
|
||||||
|
visible: root.hasPermission
|
||||||
width: parent.width
|
width: parent.width
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
}
|
}
|
||||||
|
|||||||
76
Modules/Plugins/SliderSetting.qml
Normal file
76
Modules/Plugins/SliderSetting.qml
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.Common
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
required property string settingKey
|
||||||
|
required property string label
|
||||||
|
property string description: ""
|
||||||
|
property int defaultValue: 0
|
||||||
|
property int value: defaultValue
|
||||||
|
property int minimum: 0
|
||||||
|
property int maximum: 100
|
||||||
|
property string leftIcon: ""
|
||||||
|
property string rightIcon: ""
|
||||||
|
property string unit: ""
|
||||||
|
|
||||||
|
width: parent.width
|
||||||
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
const settings = findSettings()
|
||||||
|
if (settings) {
|
||||||
|
value = settings.loadValue(settingKey, defaultValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onValueChanged: {
|
||||||
|
const settings = findSettings()
|
||||||
|
if (settings) {
|
||||||
|
settings.saveValue(settingKey, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function findSettings() {
|
||||||
|
let item = parent
|
||||||
|
while (item) {
|
||||||
|
if (item.saveValue !== undefined && item.loadValue !== undefined) {
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
item = item.parent
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: root.label
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: root.description
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceVariantText
|
||||||
|
width: parent.width
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
visible: root.description !== ""
|
||||||
|
}
|
||||||
|
|
||||||
|
DankSlider {
|
||||||
|
width: parent.width
|
||||||
|
value: root.value
|
||||||
|
minimum: root.minimum
|
||||||
|
maximum: root.maximum
|
||||||
|
leftIcon: root.leftIcon
|
||||||
|
rightIcon: root.rightIcon
|
||||||
|
unit: root.unit
|
||||||
|
wheelEnabled: false
|
||||||
|
onSliderValueChanged: newValue => {
|
||||||
|
root.value = newValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -271,22 +271,25 @@ Item {
|
|||||||
id: pluginToggle
|
id: pluginToggle
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
checked: PluginService.isPluginLoaded(pluginDelegate.pluginId)
|
checked: PluginService.isPluginLoaded(pluginDelegate.pluginId)
|
||||||
onToggled: (isChecked) => {
|
onToggled: isChecked => {
|
||||||
|
const currentPluginId = pluginDelegate.pluginId
|
||||||
|
const currentPluginName = pluginDelegate.pluginName
|
||||||
|
|
||||||
if (isChecked) {
|
if (isChecked) {
|
||||||
if (PluginService.enablePlugin(pluginDelegate.pluginId)) {
|
if (PluginService.enablePlugin(currentPluginId)) {
|
||||||
ToastService.showInfo("Plugin enabled: " + pluginDelegate.pluginName)
|
ToastService.showInfo("Plugin enabled: " + currentPluginName)
|
||||||
} else {
|
} else {
|
||||||
ToastService.showError("Failed to enable plugin: " + pluginDelegate.pluginName)
|
ToastService.showError("Failed to enable plugin: " + currentPluginName)
|
||||||
checked = false
|
checked = false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (PluginService.disablePlugin(pluginDelegate.pluginId)) {
|
if (PluginService.disablePlugin(currentPluginId)) {
|
||||||
ToastService.showInfo("Plugin disabled: " + pluginDelegate.pluginName)
|
ToastService.showInfo("Plugin disabled: " + currentPluginName)
|
||||||
if (pluginsTab.expandedPluginId === pluginDelegate.pluginId) {
|
if (pluginDelegate.isExpanded) {
|
||||||
pluginsTab.expandedPluginId = ""
|
expandedPluginId = ""
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastService.showError("Failed to disable plugin: " + pluginDelegate.pluginName)
|
ToastService.showError("Failed to disable plugin: " + currentPluginName)
|
||||||
checked = true
|
checked = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
97
PLUGINS/ExampleEmojiPlugin/EmojiSettings.qml
Normal file
97
PLUGINS/ExampleEmojiPlugin/EmojiSettings.qml
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
import QtQuick
|
||||||
|
import qs.Common
|
||||||
|
import qs.Widgets
|
||||||
|
import qs.Modules.Plugins
|
||||||
|
|
||||||
|
PluginSettings {
|
||||||
|
id: root
|
||||||
|
pluginId: "exampleEmojiPlugin"
|
||||||
|
|
||||||
|
// Header section to explain what this plugin does
|
||||||
|
StyledText {
|
||||||
|
width: parent.width
|
||||||
|
text: "Emoji Cycler Settings"
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
font.weight: Font.Bold
|
||||||
|
color: Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
width: parent.width
|
||||||
|
text: "Configure which emojis appear in your bar, how quickly they cycle, and how many show at once."
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceVariantText
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dropdown to select which emoji set to use
|
||||||
|
SelectionSetting {
|
||||||
|
settingKey: "emojiSet"
|
||||||
|
label: "Emoji Set"
|
||||||
|
description: "Choose which collection of emojis to cycle through"
|
||||||
|
options: [
|
||||||
|
{label: "Happy & Sad", value: "happySad"},
|
||||||
|
{label: "Hearts", value: "hearts"},
|
||||||
|
{label: "Hand Gestures", value: "hands"},
|
||||||
|
{label: "All Mixed", value: "mixed"}
|
||||||
|
]
|
||||||
|
defaultValue: "happySad"
|
||||||
|
|
||||||
|
// Update the actual emoji array when selection changes
|
||||||
|
onValueChanged: {
|
||||||
|
const sets = {
|
||||||
|
"happySad": ["😊", "😢", "😂", "😭", "😍", "😡"],
|
||||||
|
"hearts": ["❤️", "🧡", "💛", "💚", "💙", "💜", "🖤", "🤍"],
|
||||||
|
"hands": ["👍", "👎", "👊", "✌️", "🤘", "👌", "✋", "🤚"],
|
||||||
|
"mixed": ["😊", "❤️", "👍", "🎉", "🔥", "✨", "🌟", "💯"]
|
||||||
|
}
|
||||||
|
const newEmojis = sets[value] || sets["happySad"]
|
||||||
|
root.saveValue("emojis", newEmojis)
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// Initialize the emojis array on first load
|
||||||
|
const currentSet = value || defaultValue
|
||||||
|
const sets = {
|
||||||
|
"happySad": ["😊", "😢", "😂", "😭", "😍", "😡"],
|
||||||
|
"hearts": ["❤️", "🧡", "💛", "💚", "💙", "💜", "🖤", "🤍"],
|
||||||
|
"hands": ["👍", "👎", "👊", "✌️", "🤘", "👌", "✋", "🤚"],
|
||||||
|
"mixed": ["😊", "❤️", "👍", "🎉", "🔥", "✨", "🌟", "💯"]
|
||||||
|
}
|
||||||
|
const emojis = sets[currentSet] || sets["happySad"]
|
||||||
|
root.saveValue("emojis", emojis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slider to control how fast emojis cycle (in milliseconds)
|
||||||
|
SliderSetting {
|
||||||
|
settingKey: "cycleInterval"
|
||||||
|
label: "Cycle Speed"
|
||||||
|
description: "How quickly emojis rotate (in seconds)"
|
||||||
|
defaultValue: 3000
|
||||||
|
minimum: 500
|
||||||
|
maximum: 10000
|
||||||
|
unit: "ms"
|
||||||
|
leftIcon: "schedule"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slider to control max emojis shown in the bar
|
||||||
|
SliderSetting {
|
||||||
|
settingKey: "maxBarEmojis"
|
||||||
|
label: "Max Bar Emojis"
|
||||||
|
description: "Maximum number of emojis to display in the bar at once"
|
||||||
|
defaultValue: 3
|
||||||
|
minimum: 1
|
||||||
|
maximum: 8
|
||||||
|
unit: ""
|
||||||
|
rightIcon: "emoji_emotions"
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
width: parent.width
|
||||||
|
text: "💡 Tip: Click the emoji widget in your bar to open the emoji picker and copy any emoji to your clipboard!"
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.surfaceVariantText
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
}
|
||||||
|
}
|
||||||
185
PLUGINS/ExampleEmojiPlugin/EmojiWidget.qml
Normal file
185
PLUGINS/ExampleEmojiPlugin/EmojiWidget.qml
Normal file
@@ -0,0 +1,185 @@
|
|||||||
|
import QtQuick
|
||||||
|
import Quickshell
|
||||||
|
import qs.Common
|
||||||
|
import qs.Services
|
||||||
|
import qs.Widgets
|
||||||
|
import qs.Modules.Plugins
|
||||||
|
|
||||||
|
PluginComponent {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property var pluginService: null
|
||||||
|
|
||||||
|
// Load settings from PluginService
|
||||||
|
property var enabledEmojis: pluginService ? pluginService.loadPluginData("exampleEmojiPlugin", "emojis", ["😊", "😢", "❤️"]) : ["😊", "😢", "❤️"]
|
||||||
|
property int cycleInterval: pluginService ? pluginService.loadPluginData("exampleEmojiPlugin", "cycleInterval", 3000) : 3000
|
||||||
|
property int maxBarEmojis: pluginService ? pluginService.loadPluginData("exampleEmojiPlugin", "maxBarEmojis", 3) : 3
|
||||||
|
|
||||||
|
// Current state for cycling through emojis
|
||||||
|
property int currentIndex: 0
|
||||||
|
property var displayedEmojis: []
|
||||||
|
|
||||||
|
// Timer to cycle through emojis at the configured interval
|
||||||
|
Timer {
|
||||||
|
interval: root.cycleInterval
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
if (root.enabledEmojis.length > 0) {
|
||||||
|
root.currentIndex = (root.currentIndex + 1) % root.enabledEmojis.length
|
||||||
|
root.updateDisplayedEmojis()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the emojis shown in the bar when settings or index changes
|
||||||
|
function updateDisplayedEmojis() {
|
||||||
|
const maxToShow = Math.min(root.maxBarEmojis, root.enabledEmojis.length)
|
||||||
|
let emojis = []
|
||||||
|
for (let i = 0; i < maxToShow; i++) {
|
||||||
|
const idx = (root.currentIndex + i) % root.enabledEmojis.length
|
||||||
|
emojis.push(root.enabledEmojis[idx])
|
||||||
|
}
|
||||||
|
root.displayedEmojis = emojis
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
updateDisplayedEmojis()
|
||||||
|
}
|
||||||
|
|
||||||
|
onEnabledEmojisChanged: updateDisplayedEmojis()
|
||||||
|
onMaxBarEmojisChanged: updateDisplayedEmojis()
|
||||||
|
|
||||||
|
horizontalBarPill: Component {
|
||||||
|
StyledRect {
|
||||||
|
width: emojiRow.implicitWidth + Theme.spacingM * 2
|
||||||
|
height: parent.widgetThickness
|
||||||
|
radius: Theme.cornerRadius
|
||||||
|
color: Theme.surfaceContainerHigh
|
||||||
|
|
||||||
|
Row {
|
||||||
|
id: emojiRow
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: root.displayedEmojis
|
||||||
|
StyledText {
|
||||||
|
text: modelData
|
||||||
|
font.pixelSize: Theme.fontSizeLarge
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
verticalBarPill: Component {
|
||||||
|
StyledRect {
|
||||||
|
width: parent.widgetThickness
|
||||||
|
height: emojiColumn.implicitHeight + Theme.spacingM * 2
|
||||||
|
radius: Theme.cornerRadius
|
||||||
|
color: Theme.surfaceContainerHigh
|
||||||
|
|
||||||
|
Column {
|
||||||
|
id: emojiColumn
|
||||||
|
anchors.centerIn: parent
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: root.displayedEmojis
|
||||||
|
StyledText {
|
||||||
|
text: modelData
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
popoutContent: Component {
|
||||||
|
Item {
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height
|
||||||
|
|
||||||
|
// A grid of 120+ emojis for the user to pick from
|
||||||
|
property var allEmojis: [
|
||||||
|
"😀", "😃", "😄", "😁", "😆", "😅", "🤣", "😂", "🙂", "🙃",
|
||||||
|
"😉", "😊", "😇", "🥰", "😍", "🤩", "😘", "😗", "😚", "😙",
|
||||||
|
"😋", "😛", "😜", "🤪", "😝", "🤑", "🤗", "🤭", "🤫", "🤔",
|
||||||
|
"🤐", "🤨", "😐", "😑", "😶", "😏", "😒", "🙄", "😬", "🤥",
|
||||||
|
"😌", "😔", "😪", "🤤", "😴", "😷", "🤒", "🤕", "🤢", "🤮",
|
||||||
|
"🤧", "🥵", "🥶", "😶🌫️", "😵", "😵💫", "🤯", "🤠", "🥳", "😎",
|
||||||
|
"🤓", "🧐", "😕", "😟", "🙁", "☹️", "😮", "😯", "😲", "😳",
|
||||||
|
"🥺", "😦", "😧", "😨", "😰", "😥", "😢", "😭", "😱", "😖",
|
||||||
|
"😣", "😞", "😓", "😩", "😫", "🥱", "😤", "😡", "😠", "🤬",
|
||||||
|
"❤️", "🧡", "💛", "💚", "💙", "💜", "🖤", "🤍", "🤎", "💔",
|
||||||
|
"❤️🔥", "❤️🩹", "💕", "💞", "💓", "💗", "💖", "💘", "💝", "💟",
|
||||||
|
"👍", "👎", "👊", "✊", "🤛", "🤜", "🤞", "✌️", "🤟", "🤘",
|
||||||
|
"👌", "🤌", "🤏", "👈", "👉", "👆", "👇", "☝️", "✋", "🤚"
|
||||||
|
]
|
||||||
|
|
||||||
|
Column {
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: Theme.spacingM
|
||||||
|
spacing: Theme.spacingM
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
text: "Click an emoji to copy it!"
|
||||||
|
font.pixelSize: Theme.fontSizeMedium
|
||||||
|
font.weight: Font.Medium
|
||||||
|
color: Theme.surfaceText
|
||||||
|
}
|
||||||
|
|
||||||
|
DankFlickable {
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height - parent.spacing - 30
|
||||||
|
contentWidth: emojiGrid.width
|
||||||
|
contentHeight: emojiGrid.height
|
||||||
|
clip: true
|
||||||
|
|
||||||
|
Grid {
|
||||||
|
id: emojiGrid
|
||||||
|
width: parent.width - Theme.spacingM
|
||||||
|
columns: 8
|
||||||
|
spacing: Theme.spacingS
|
||||||
|
|
||||||
|
Repeater {
|
||||||
|
model: allEmojis
|
||||||
|
|
||||||
|
StyledRect {
|
||||||
|
width: 45
|
||||||
|
height: 45
|
||||||
|
radius: Theme.cornerRadius
|
||||||
|
color: emojiMouseArea.containsMouse ? Theme.surfaceContainerHighest : Theme.surfaceContainerHigh
|
||||||
|
border.width: 0
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: modelData
|
||||||
|
font.pixelSize: Theme.fontSizeXLarge
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
id: emojiMouseArea
|
||||||
|
anchors.fill: parent
|
||||||
|
hoverEnabled: true
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
Quickshell.execDetached(["sh", "-c", "echo -n '" + modelData + "' | wl-copy"])
|
||||||
|
ToastService.show("Copied " + modelData + " to clipboard", 2000)
|
||||||
|
root.closePopout()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
popoutWidth: 400
|
||||||
|
popoutHeight: 500
|
||||||
|
}
|
||||||
56
PLUGINS/ExampleEmojiPlugin/README.md
Normal file
56
PLUGINS/ExampleEmojiPlugin/README.md
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
# Emoji Cycler Plugin
|
||||||
|
|
||||||
|
An example DankMaterialShell plugin that displays cycling emojis in your bar with an emoji picker popout.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Cycling Emojis**: Automatically rotates through your selected emoji set in the bar
|
||||||
|
- **Emoji Picker**: Click the widget to open a grid of 120+ emojis
|
||||||
|
- **Copy to Clipboard**: Click any emoji in the picker to copy it to clipboard (uses `wl-copy`)
|
||||||
|
- **Customizable**: Choose emoji sets, cycle speed, and max emojis shown
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. Copy this directory to `~/.config/DankMaterialShell/plugins/ExampleEmojiPlugin`
|
||||||
|
2. Open DMS Settings → Plugins
|
||||||
|
3. Click "Scan for Plugins"
|
||||||
|
4. Enable "Emoji Cycler"
|
||||||
|
5. Add `exampleEmojiPlugin` to your DankBar widget list
|
||||||
|
|
||||||
|
## Settings
|
||||||
|
|
||||||
|
### Emoji Set
|
||||||
|
Choose from different emoji collections:
|
||||||
|
- **Happy & Sad**: Mix of emotional faces
|
||||||
|
- **Hearts**: Various colored hearts
|
||||||
|
- **Hand Gestures**: Thumbs up, peace signs, etc.
|
||||||
|
- **All Mixed**: A bit of everything
|
||||||
|
|
||||||
|
### Cycle Speed
|
||||||
|
Control how fast emojis rotate (500ms - 10000ms)
|
||||||
|
|
||||||
|
### Max Bar Emojis
|
||||||
|
How many emojis to display at once (1-8)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
**In the bar**: Watch emojis cycle through automatically
|
||||||
|
**Click the widget**: Opens emoji picker with 120+ emojis
|
||||||
|
**Click any emoji**: Copies it to clipboard and shows toast
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- `wl-copy` (for clipboard support on Wayland)
|
||||||
|
|
||||||
|
## Example Code Highlights
|
||||||
|
|
||||||
|
This plugin demonstrates:
|
||||||
|
- Using `PluginComponent` for bar integration
|
||||||
|
- `SelectionSetting`, `SliderSetting` for configuration
|
||||||
|
- Timer-based animation
|
||||||
|
- Popout content with grid layout
|
||||||
|
- External command execution (`Quickshell.execDetached`)
|
||||||
|
- Toast notifications (`ToastService.show`)
|
||||||
|
- Dynamic settings loading/saving
|
||||||
|
|
||||||
|
Perfect template for creating your own DMS plugins!
|
||||||
14
PLUGINS/ExampleEmojiPlugin/plugin.json
Normal file
14
PLUGINS/ExampleEmojiPlugin/plugin.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"id": "exampleEmojiPlugin",
|
||||||
|
"name": "Emoji Cycler",
|
||||||
|
"description": "Display cycling emojis in your bar with a handy emoji picker popout",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": "DMS Plugin System",
|
||||||
|
"icon": "mood",
|
||||||
|
"component": "./EmojiWidget.qml",
|
||||||
|
"settings": "./EmojiSettings.qml",
|
||||||
|
"permissions": [
|
||||||
|
"settings_read",
|
||||||
|
"settings_write"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -57,18 +57,6 @@ The manifest file defines plugin metadata and configuration:
|
|||||||
"icon": "material_icon_name",
|
"icon": "material_icon_name",
|
||||||
"component": "./YourWidget.qml",
|
"component": "./YourWidget.qml",
|
||||||
"settings": "./YourSettings.qml",
|
"settings": "./YourSettings.qml",
|
||||||
"dependencies": {
|
|
||||||
"libraryName": {
|
|
||||||
"url": "https://cdn.example.com/library.js",
|
|
||||||
"optional": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"settings_schema": {
|
|
||||||
"settingKey": {
|
|
||||||
"type": "string|number|boolean|array|object",
|
|
||||||
"default": "defaultValue"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"settings_read",
|
"settings_read",
|
||||||
"settings_write"
|
"settings_write"
|
||||||
@@ -82,14 +70,20 @@ The manifest file defines plugin metadata and configuration:
|
|||||||
- `component`: Relative path to widget QML file
|
- `component`: Relative path to widget QML file
|
||||||
|
|
||||||
**Optional Fields:**
|
**Optional Fields:**
|
||||||
- `description`: Short description of plugin functionality
|
- `description`: Short description of plugin functionality (displayed in UI)
|
||||||
- `version`: Semantic version string
|
- `version`: Semantic version string (displayed in UI)
|
||||||
- `author`: Plugin creator name
|
- `author`: Plugin creator name (displayed in UI)
|
||||||
- `icon`: Material Design icon name
|
- `icon`: Material Design icon name (displayed in UI)
|
||||||
- `settings`: Path to settings component
|
- `settings`: Path to settings component (enables settings UI)
|
||||||
- `dependencies`: External JS libraries
|
- `permissions`: Required capabilities (enforced by PluginSettings component)
|
||||||
- `settings_schema`: Configuration schema
|
|
||||||
- `permissions`: Required capabilities
|
**Permissions:**
|
||||||
|
|
||||||
|
The plugin system enforces permissions when settings are accessed:
|
||||||
|
- `settings_read`: Required to read plugin settings (currently not enforced)
|
||||||
|
- `settings_write`: **Required** to use PluginSettings component and save settings
|
||||||
|
|
||||||
|
If your plugin includes a settings component but doesn't declare `settings_write` permission, users will see an error message instead of the settings UI.
|
||||||
|
|
||||||
### Widget Component
|
### Widget Component
|
||||||
|
|
||||||
@@ -261,6 +255,27 @@ PluginSettings {
|
|||||||
|
|
||||||
All settings automatically save on change and load on component creation. No manual `pluginService.savePluginData()` calls needed!
|
All settings automatically save on change and load on component creation. No manual `pluginService.savePluginData()` calls needed!
|
||||||
|
|
||||||
|
**How Default Values Work:**
|
||||||
|
|
||||||
|
Each setting component has a `defaultValue` property that is used when no saved value exists. Define sensible defaults in your settings UI:
|
||||||
|
|
||||||
|
```qml
|
||||||
|
StringSetting {
|
||||||
|
settingKey: "apiKey"
|
||||||
|
defaultValue: "" // Empty string if no key saved
|
||||||
|
}
|
||||||
|
|
||||||
|
ToggleSetting {
|
||||||
|
settingKey: "enabled"
|
||||||
|
defaultValue: true // Enabled by default
|
||||||
|
}
|
||||||
|
|
||||||
|
ListSettingWithInput {
|
||||||
|
settingKey: "locations"
|
||||||
|
defaultValue: [] // Empty array if no locations saved
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
1. **PluginSettings** - Root wrapper for all plugin settings
|
1. **PluginSettings** - Root wrapper for all plugin settings
|
||||||
- `pluginId`: Your plugin ID (required)
|
- `pluginId`: Your plugin ID (required)
|
||||||
- Auto-handles storage and provides saveValue/loadValue to children
|
- Auto-handles storage and provides saveValue/loadValue to children
|
||||||
@@ -271,14 +286,14 @@ All settings automatically save on change and load on component creation. No man
|
|||||||
- `label`: Display label (required)
|
- `label`: Display label (required)
|
||||||
- `description`: Help text (optional)
|
- `description`: Help text (optional)
|
||||||
- `placeholder`: Input placeholder (optional)
|
- `placeholder`: Input placeholder (optional)
|
||||||
- `defaultValue`: Default value (optional)
|
- `defaultValue`: Default value (optional, default: `""`)
|
||||||
- Layout: Vertical stack (label, description, input field)
|
- Layout: Vertical stack (label, description, input field)
|
||||||
|
|
||||||
3. **ToggleSetting** - Boolean toggle switch
|
3. **ToggleSetting** - Boolean toggle switch
|
||||||
- `settingKey`: Storage key (required)
|
- `settingKey`: Storage key (required)
|
||||||
- `label`: Display label (required)
|
- `label`: Display label (required)
|
||||||
- `description`: Help text (optional)
|
- `description`: Help text (optional)
|
||||||
- `defaultValue`: Default boolean (optional)
|
- `defaultValue`: Default boolean (optional, default: `false`)
|
||||||
- Layout: Horizontal (label/description left, toggle right)
|
- Layout: Horizontal (label/description left, toggle right)
|
||||||
|
|
||||||
4. **SelectionSetting** - Dropdown menu
|
4. **SelectionSetting** - Dropdown menu
|
||||||
@@ -286,7 +301,7 @@ All settings automatically save on change and load on component creation. No man
|
|||||||
- `label`: Display label (required)
|
- `label`: Display label (required)
|
||||||
- `description`: Help text (optional)
|
- `description`: Help text (optional)
|
||||||
- `options`: Array of `{label, value}` objects or simple strings (required)
|
- `options`: Array of `{label, value}` objects or simple strings (required)
|
||||||
- `defaultValue`: Default value (optional)
|
- `defaultValue`: Default value (optional, default: `""`)
|
||||||
- Layout: Horizontal (label/description left, dropdown right)
|
- Layout: Horizontal (label/description left, dropdown right)
|
||||||
- Stores the `value` field, displays the `label` field
|
- Stores the `value` field, displays the `label` field
|
||||||
|
|
||||||
@@ -294,6 +309,7 @@ All settings automatically save on change and load on component creation. No man
|
|||||||
- `settingKey`: Storage key (required)
|
- `settingKey`: Storage key (required)
|
||||||
- `label`: Display label (required)
|
- `label`: Display label (required)
|
||||||
- `description`: Help text (optional)
|
- `description`: Help text (optional)
|
||||||
|
- `defaultValue`: Default array (optional, default: `[]`)
|
||||||
- `delegate`: Custom item delegate Component (optional)
|
- `delegate`: Custom item delegate Component (optional)
|
||||||
- `addItem(item)`: Add item to list
|
- `addItem(item)`: Add item to list
|
||||||
- `removeItem(index)`: Remove item from list
|
- `removeItem(index)`: Remove item from list
|
||||||
@@ -303,6 +319,7 @@ All settings automatically save on change and load on component creation. No man
|
|||||||
- `settingKey`: Storage key (required)
|
- `settingKey`: Storage key (required)
|
||||||
- `label`: Display label (required)
|
- `label`: Display label (required)
|
||||||
- `description`: Help text (optional)
|
- `description`: Help text (optional)
|
||||||
|
- `defaultValue`: Default array (optional, default: `[]`)
|
||||||
- `fields`: Array of field definitions (required)
|
- `fields`: Array of field definitions (required)
|
||||||
- `id`: Field ID in saved object (required)
|
- `id`: Field ID in saved object (required)
|
||||||
- `label`: Column header text (required)
|
- `label`: Column header text (required)
|
||||||
@@ -329,7 +346,6 @@ import qs.Modules.Plugins
|
|||||||
PluginSettings {
|
PluginSettings {
|
||||||
pluginId: "myPlugin"
|
pluginId: "myPlugin"
|
||||||
|
|
||||||
// Section header (optional)
|
|
||||||
StyledText {
|
StyledText {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
text: "General Settings"
|
text: "General Settings"
|
||||||
@@ -338,7 +354,6 @@ PluginSettings {
|
|||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text input
|
|
||||||
StringSetting {
|
StringSetting {
|
||||||
settingKey: "apiKey"
|
settingKey: "apiKey"
|
||||||
label: "API Key"
|
label: "API Key"
|
||||||
@@ -347,7 +362,6 @@ PluginSettings {
|
|||||||
defaultValue: ""
|
defaultValue: ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toggle switches
|
|
||||||
ToggleSetting {
|
ToggleSetting {
|
||||||
settingKey: "enabled"
|
settingKey: "enabled"
|
||||||
label: "Enable Feature"
|
label: "Enable Feature"
|
||||||
@@ -355,7 +369,6 @@ PluginSettings {
|
|||||||
defaultValue: true
|
defaultValue: true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dropdown selection
|
|
||||||
SelectionSetting {
|
SelectionSetting {
|
||||||
settingKey: "theme"
|
settingKey: "theme"
|
||||||
label: "Theme"
|
label: "Theme"
|
||||||
@@ -368,11 +381,11 @@ PluginSettings {
|
|||||||
defaultValue: "dark"
|
defaultValue: "dark"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Structured list with multi-field input
|
|
||||||
ListSettingWithInput {
|
ListSettingWithInput {
|
||||||
settingKey: "locations"
|
settingKey: "locations"
|
||||||
label: "Locations"
|
label: "Locations"
|
||||||
description: "Track multiple locations"
|
description: "Track multiple locations"
|
||||||
|
defaultValue: []
|
||||||
fields: [
|
fields: [
|
||||||
{id: "name", label: "Name", placeholder: "Home", width: 150, required: true},
|
{id: "name", label: "Name", placeholder: "Home", width: 150, required: true},
|
||||||
{id: "timezone", label: "Timezone", placeholder: "America/New_York", width: 200, required: true}
|
{id: "timezone", label: "Timezone", placeholder: "America/New_York", width: 200, required: true}
|
||||||
@@ -636,12 +649,12 @@ Look for lines prefixed with:
|
|||||||
Plugins run with full QML runtime access. Only install plugins from trusted sources.
|
Plugins run with full QML runtime access. Only install plugins from trusted sources.
|
||||||
|
|
||||||
**Permissions System:**
|
**Permissions System:**
|
||||||
- `settings_read`: Read plugin configuration
|
- `settings_read`: Read plugin configuration (not currently enforced)
|
||||||
- `settings_write`: Write plugin configuration
|
- `settings_write`: **Required** to use PluginSettings - write plugin configuration (enforced)
|
||||||
- `process`: Execute system commands
|
- `process`: Execute system commands (not currently enforced)
|
||||||
- `network`: Network access
|
- `network`: Network access (not currently enforced)
|
||||||
|
|
||||||
Future versions may enforce permission restrictions.
|
Currently, only `settings_write` is enforced by the PluginSettings component.
|
||||||
|
|
||||||
## API Stability
|
## API Stability
|
||||||
|
|
||||||
@@ -171,6 +171,15 @@ Singleton {
|
|||||||
console.log("PluginService: Component path:", pluginInfo.componentPath)
|
console.log("PluginService: Component path:", pluginInfo.componentPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasPermission(pluginId, permission) {
|
||||||
|
var plugin = availablePlugins[pluginId]
|
||||||
|
if (!plugin) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
var permissions = plugin.permissions || []
|
||||||
|
return permissions.indexOf(permission) !== -1
|
||||||
|
}
|
||||||
|
|
||||||
function loadPlugin(pluginId) {
|
function loadPlugin(pluginId) {
|
||||||
console.log("PluginService: loadPlugin called for", pluginId)
|
console.log("PluginService: loadPlugin called for", pluginId)
|
||||||
var plugin = availablePlugins[pluginId]
|
var plugin = availablePlugins[pluginId]
|
||||||
@@ -185,15 +194,34 @@ Singleton {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pluginWidgetComponents[pluginId]) {
|
||||||
|
var oldComponent = pluginWidgetComponents[pluginId]
|
||||||
|
if (oldComponent) {
|
||||||
|
oldComponent.destroy()
|
||||||
|
}
|
||||||
|
delete pluginWidgetComponents[pluginId]
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create the widget component
|
|
||||||
var componentUrl = "file://" + plugin.componentPath
|
var componentUrl = "file://" + plugin.componentPath
|
||||||
console.log("PluginService: Loading component from:", componentUrl)
|
console.log("PluginService: Loading component from:", componentUrl)
|
||||||
|
|
||||||
var component = Qt.createComponent(componentUrl)
|
var component = Qt.createComponent(componentUrl, Component.PreferSynchronous)
|
||||||
|
|
||||||
|
if (component.status === Component.Loading) {
|
||||||
|
component.statusChanged.connect(function() {
|
||||||
|
if (component.status === Component.Error) {
|
||||||
|
console.error("PluginService: Failed to create component for plugin:", pluginId, "Error:", component.errorString())
|
||||||
|
pluginLoadFailed(pluginId, component.errorString())
|
||||||
|
component.destroy()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (component.status === Component.Error) {
|
if (component.status === Component.Error) {
|
||||||
console.error("PluginService: Failed to create component for plugin:", pluginId, "Error:", component.errorString())
|
console.error("PluginService: Failed to create component for plugin:", pluginId, "Error:", component.errorString())
|
||||||
pluginLoadFailed(pluginId, component.errorString())
|
pluginLoadFailed(pluginId, component.errorString())
|
||||||
|
component.destroy()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,10 +248,14 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Remove from component map
|
if (pluginWidgetComponents[pluginId]) {
|
||||||
|
var component = pluginWidgetComponents[pluginId]
|
||||||
|
if (component) {
|
||||||
|
component.destroy()
|
||||||
|
}
|
||||||
|
}
|
||||||
delete pluginWidgetComponents[pluginId]
|
delete pluginWidgetComponents[pluginId]
|
||||||
|
|
||||||
// Mark as unloaded
|
|
||||||
plugin.loaded = false
|
plugin.loaded = false
|
||||||
delete loadedPlugins[pluginId]
|
delete loadedPlugins[pluginId]
|
||||||
|
|
||||||
@@ -281,17 +313,12 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function savePluginData(pluginId, key, value) {
|
function savePluginData(pluginId, key, value) {
|
||||||
console.log("PluginService: Saving plugin data:", pluginId, key, JSON.stringify(value))
|
|
||||||
SettingsData.setPluginSetting(pluginId, key, value)
|
SettingsData.setPluginSetting(pluginId, key, value)
|
||||||
console.log("PluginService: Data saved successfully")
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadPluginData(pluginId, key, defaultValue) {
|
function loadPluginData(pluginId, key, defaultValue) {
|
||||||
console.log("PluginService: Loading plugin data:", pluginId, key)
|
return SettingsData.getPluginSetting(pluginId, key, defaultValue)
|
||||||
var value = SettingsData.getPluginSetting(pluginId, key, defaultValue)
|
|
||||||
console.log("PluginService: Loaded key:", key, "value:", JSON.stringify(value))
|
|
||||||
return value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPluginDirectory() {
|
function createPluginDirectory() {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ Item {
|
|||||||
DankIcon {
|
DankIcon {
|
||||||
name: slider.leftIcon
|
name: slider.leftIcon
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: slider.enabled ? Theme.onSurface : Theme.onSurface_38
|
color: slider.enabled ? Theme.surfaceText : Theme.onSurface_38
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
visible: slider.leftIcon.length > 0
|
visible: slider.leftIcon.length > 0
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ Item {
|
|||||||
DankIcon {
|
DankIcon {
|
||||||
name: slider.rightIcon
|
name: slider.rightIcon
|
||||||
size: Theme.iconSize
|
size: Theme.iconSize
|
||||||
color: slider.enabled ? Theme.onSurface : Theme.onSurface_38
|
color: slider.enabled ? Theme.surfaceText : Theme.onSurface_38
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
visible: slider.rightIcon.length > 0
|
visible: slider.rightIcon.length > 0
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user