mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-10-26 13:07:49 -04:00
deprecation notice to plugin compatibility shims - When qml-common became a thing, we left qs.Widgets shims in place for plugin compatibility - It's annoying to need to maintain them when qml-common has any change, add a warning so we can safely deprecate them in the future - One shot rename the common stuff to D to make it shorter and nicer to write
73 lines
1.8 KiB
QML
73 lines
1.8 KiB
QML
import QtQuick
|
|
import qs.Common
|
|
import qs.DCommon.Widgets
|
|
import "../../Common/QmlUtils.js" as QmlUtils
|
|
|
|
Row {
|
|
id: root
|
|
|
|
required property string settingKey
|
|
required property string label
|
|
property string description: ""
|
|
property bool defaultValue: false
|
|
property bool value: defaultValue
|
|
|
|
width: parent.width
|
|
spacing: Theme.spacingM
|
|
|
|
property bool isInitialized: false
|
|
|
|
function loadValue() {
|
|
const settings = QmlUtils.findSettings(root.parent);
|
|
if (settings && settings.pluginService) {
|
|
const loadedValue = settings.loadValue(settingKey, defaultValue);
|
|
value = loadedValue;
|
|
isInitialized = true;
|
|
}
|
|
}
|
|
|
|
Component.onCompleted: {
|
|
Qt.callLater(loadValue);
|
|
}
|
|
|
|
onValueChanged: {
|
|
if (!isInitialized)
|
|
return;
|
|
const settings = QmlUtils.findSettings(root.parent);
|
|
if (settings) {
|
|
settings.saveValue(settingKey, value);
|
|
}
|
|
}
|
|
|
|
Column {
|
|
width: parent.width - toggle.width - Theme.spacingM
|
|
spacing: Theme.spacingXS
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
StyledText {
|
|
text: root.label
|
|
font.pixelSize: Theme.fontSizeLarge
|
|
font.weight: Theme.fontWeightMedium
|
|
color: Theme.surfaceText
|
|
}
|
|
|
|
StyledText {
|
|
text: root.description
|
|
font.pixelSize: Theme.fontSizeSmall
|
|
color: Theme.surfaceVariantText
|
|
width: parent.width
|
|
wrapMode: Text.WordWrap
|
|
visible: root.description !== ""
|
|
}
|
|
}
|
|
|
|
DToggle {
|
|
id: toggle
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
checked: root.value
|
|
onToggled: isChecked => {
|
|
root.value = isChecked;
|
|
}
|
|
}
|
|
}
|