fedora
This commit is contained in:
+276
@@ -0,0 +1,276 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Effects
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import qs.Commons
|
||||
import qs.Services.Noctalia
|
||||
import qs.Services.UI
|
||||
import qs.Widgets
|
||||
|
||||
Popup {
|
||||
id: root
|
||||
|
||||
property int widgetIndex: -1
|
||||
property var widgetData: null
|
||||
property string widgetId: ""
|
||||
property string sectionId: "" // Not used for desktop widgets, but required by NSectionEditor
|
||||
property var screen: null
|
||||
property var settingsCache: ({})
|
||||
|
||||
readonly property real maxHeight: (screen ? screen.height : (parent ? parent.height : 800)) * 0.8
|
||||
|
||||
signal updateWidgetSettings(string section, int index, var settings)
|
||||
|
||||
width: Math.max(content.implicitWidth + padding * 2, 500)
|
||||
height: Math.min(content.implicitHeight + padding * 2, maxHeight)
|
||||
padding: Style.marginXL
|
||||
modal: true
|
||||
closePolicy: Popup.NoAutoClose
|
||||
dim: false
|
||||
|
||||
// Center in parent
|
||||
x: Math.round((parent.width - width) / 2)
|
||||
y: Math.round((parent.height - height) / 2)
|
||||
|
||||
onOpened: {
|
||||
if (widgetData && widgetId) {
|
||||
loadWidgetSettings();
|
||||
}
|
||||
forceActiveFocus();
|
||||
}
|
||||
|
||||
background: Rectangle {
|
||||
id: bgRect
|
||||
color: Color.mSurface
|
||||
radius: Style.radiusL
|
||||
border.color: Color.mPrimary
|
||||
border.width: Style.borderM
|
||||
}
|
||||
|
||||
contentItem: FocusScope {
|
||||
id: focusScope
|
||||
focus: true
|
||||
|
||||
ColumnLayout {
|
||||
id: content
|
||||
anchors.fill: parent
|
||||
spacing: Style.marginM
|
||||
|
||||
RowLayout {
|
||||
id: titleRow
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: implicitHeight
|
||||
|
||||
NText {
|
||||
text: I18n.tr("system.widget-settings-title", {
|
||||
"widget": DesktopWidgetRegistry.getWidgetDisplayName(root.widgetId)
|
||||
})
|
||||
pointSize: Style.fontSizeL
|
||||
font.weight: Style.fontWeightBold
|
||||
color: Color.mPrimary
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NIconButton {
|
||||
icon: "close"
|
||||
tooltipText: I18n.tr("common.close")
|
||||
onClicked: saveAndClose()
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: separator
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 1
|
||||
color: Color.mOutline
|
||||
}
|
||||
|
||||
// Scrollable settings area
|
||||
NScrollView {
|
||||
id: scrollView
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.minimumHeight: 100
|
||||
gradientColor: Color.mSurface
|
||||
|
||||
ColumnLayout {
|
||||
width: scrollView.availableWidth
|
||||
spacing: Style.marginM
|
||||
|
||||
Loader {
|
||||
id: settingsLoader
|
||||
Layout.fillWidth: true
|
||||
onLoaded: {
|
||||
if (item) {
|
||||
Qt.callLater(() => {
|
||||
var firstInput = findFirstFocusable(item);
|
||||
if (firstInput) {
|
||||
firstInput.forceActiveFocus();
|
||||
} else {
|
||||
focusScope.forceActiveFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function findFirstFocusable(item) {
|
||||
if (!item)
|
||||
return null;
|
||||
if (item.focus !== undefined && item.focus === true)
|
||||
return item;
|
||||
if (item.children) {
|
||||
for (var i = 0; i < item.children.length; i++) {
|
||||
var child = item.children[i];
|
||||
if (child && child.focus !== undefined && child.focus === true)
|
||||
return child;
|
||||
var found = findFirstFocusable(child);
|
||||
if (found)
|
||||
return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse area for a draggable popup
|
||||
MouseArea {
|
||||
x: titleRow.x
|
||||
y: titleRow.y
|
||||
width: titleRow.width
|
||||
height: titleRow.height
|
||||
z: -1
|
||||
|
||||
cursorShape: Qt.OpenHandCursor
|
||||
|
||||
property real pressX: 0
|
||||
property real pressY: 0
|
||||
|
||||
onPressed: mouse => {
|
||||
pressX = mouse.x;
|
||||
pressY = mouse.y;
|
||||
cursorShape = Qt.ClosedHandCursor;
|
||||
}
|
||||
|
||||
onReleased: {
|
||||
cursorShape = Qt.OpenHandCursor;
|
||||
}
|
||||
|
||||
onPositionChanged: mouse => {
|
||||
if (pressed) {
|
||||
var deltaX = mouse.x - pressX;
|
||||
var deltaY = mouse.y - pressY;
|
||||
|
||||
root.x += deltaX;
|
||||
root.y += deltaY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: saveTimer
|
||||
running: false
|
||||
interval: 150
|
||||
onTriggered: {
|
||||
root.updateWidgetSettings(root.sectionId, root.widgetIndex, root.settingsCache);
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: settingsLoader.item
|
||||
ignoreUnknownSignals: true
|
||||
function onSettingsChanged(newSettings) {
|
||||
if (newSettings) {
|
||||
root.settingsCache = newSettings;
|
||||
saveTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
function onSettingsSaved(newSettings) {
|
||||
if (newSettings) {
|
||||
root.updateWidgetSettings(root.sectionId, root.widgetIndex, newSettings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveAndClose() {
|
||||
if (settingsLoader.item && typeof settingsLoader.item.saveSettings === 'function') {
|
||||
var newSettings = settingsLoader.item.saveSettings();
|
||||
if (newSettings) {
|
||||
root.updateWidgetSettings(root.sectionId, root.widgetIndex, newSettings);
|
||||
}
|
||||
}
|
||||
root.close();
|
||||
}
|
||||
|
||||
function loadWidgetSettings() {
|
||||
// Handle plugin widgets
|
||||
if (DesktopWidgetRegistry.isPluginWidget(widgetId)) {
|
||||
var pluginId = widgetId.replace("plugin:", "");
|
||||
var manifest = PluginRegistry.getPluginManifest(pluginId);
|
||||
|
||||
var pluginDir = PluginRegistry.getPluginDir(pluginId);
|
||||
var loadVersion = PluginRegistry.pluginLoadVersions[pluginId] || 0;
|
||||
var api = PluginService.getPluginAPI(pluginId);
|
||||
|
||||
var settingsPath;
|
||||
if (manifest && manifest.entryPoints && manifest.entryPoints.desktopWidgetSettings) {
|
||||
settingsPath = "file://" + pluginDir + "/" + manifest.entryPoints.desktopWidgetSettings;
|
||||
|
||||
var widgetSettings = {};
|
||||
widgetSettings.data = widgetData || {};
|
||||
widgetSettings.metadata = DesktopWidgetRegistry.widgetMetadata[widgetId] || {};
|
||||
widgetSettings.save = function () {
|
||||
var newSettings = Object.assign({}, widgetSettings.data);
|
||||
root.settingsCache = newSettings;
|
||||
saveTimer.start();
|
||||
};
|
||||
|
||||
settingsLoader.setSource(settingsPath + "?v=" + loadVersion, {
|
||||
"pluginApi": api,
|
||||
"widgetSettings": widgetSettings
|
||||
});
|
||||
} else {
|
||||
Logger.w("DesktopWidgetSettingsDialog", "Plugin does not have desktop widget settings:", pluginId);
|
||||
|
||||
// Fallback to the plugin settings
|
||||
if (manifest && manifest.entryPoints && manifest.entryPoints.settings) {
|
||||
settingsPath = "file://" + pluginDir + "/" + manifest.entryPoints.settings;
|
||||
|
||||
settingsLoader.setSource(settingsPath + "?v=" + loadVersion, {
|
||||
"pluginApi": api
|
||||
});
|
||||
} else {
|
||||
Logger.w("DesktopWidgetSettingsDialog", "Plugin does not have settings:", pluginId);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle core widgets
|
||||
const source = DesktopWidgetRegistry.widgetSettingsMap[widgetId];
|
||||
if (source) {
|
||||
var currentWidgetData = widgetData;
|
||||
var monitorWidgets = Settings.data.desktopWidgets.monitorWidgets || [];
|
||||
for (var i = 0; i < monitorWidgets.length; i++) {
|
||||
if (monitorWidgets[i].name === sectionId) {
|
||||
var widgets = monitorWidgets[i].widgets || [];
|
||||
if (widgetIndex >= 0 && widgetIndex < widgets.length) {
|
||||
currentWidgetData = widgets[widgetIndex];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
var fullPath = Qt.resolvedUrl(Quickshell.shellDir + "/Modules/Panels/Settings/DesktopWidgets/" + source);
|
||||
settingsLoader.setSource(fullPath, {
|
||||
"widgetData": currentWidgetData,
|
||||
"widgetMetadata": DesktopWidgetRegistry.widgetMetadata[widgetId]
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Commons
|
||||
import qs.Widgets
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: Style.marginM
|
||||
|
||||
property var widgetData: null
|
||||
property var widgetMetadata: null
|
||||
|
||||
signal settingsChanged(var settings)
|
||||
|
||||
property int valueWidth: widgetData.width !== undefined ? widgetData.width : widgetMetadata.width
|
||||
property int valueHeight: widgetData.height !== undefined ? widgetData.height : widgetMetadata.height
|
||||
property string valueVisualizerType: widgetData.visualizerType !== undefined ? widgetData.visualizerType : widgetMetadata.visualizerType
|
||||
property string valueColorName: widgetData.colorName !== undefined ? widgetData.colorName : widgetMetadata.colorName
|
||||
property bool valueHideWhenIdle: widgetData.hideWhenIdle !== undefined ? widgetData.hideWhenIdle : widgetMetadata.hideWhenIdle
|
||||
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
|
||||
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
|
||||
|
||||
function saveSettings() {
|
||||
var settings = Object.assign({}, widgetData || {});
|
||||
settings.width = valueWidth;
|
||||
settings.height = valueHeight;
|
||||
settings.visualizerType = valueVisualizerType;
|
||||
settings.colorName = valueColorName;
|
||||
settings.hideWhenIdle = valueHideWhenIdle;
|
||||
settings.showBackground = valueShowBackground;
|
||||
settings.roundedCorners = valueRoundedCorners;
|
||||
settingsChanged(settings);
|
||||
}
|
||||
|
||||
NTextInput {
|
||||
id: widthInput
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("common.width")
|
||||
description: I18n.tr("bar.audio-visualizer.width-description")
|
||||
text: String(valueWidth)
|
||||
placeholderText: I18n.tr("placeholders.enter-width-pixels")
|
||||
inputMethodHints: Qt.ImhDigitsOnly
|
||||
onEditingFinished: {
|
||||
const parsed = parseInt(text);
|
||||
if (!isNaN(parsed) && parsed > 0) {
|
||||
valueWidth = parsed;
|
||||
saveSettings();
|
||||
} else {
|
||||
text = String(valueWidth);
|
||||
}
|
||||
}
|
||||
defaultValue: String(widgetMetadata.width)
|
||||
}
|
||||
|
||||
NTextInput {
|
||||
id: heightInput
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("common.height")
|
||||
description: I18n.tr("bar.audio-visualizer.height-description")
|
||||
text: String(valueHeight)
|
||||
placeholderText: I18n.tr("placeholders.enter-width-pixels")
|
||||
inputMethodHints: Qt.ImhDigitsOnly
|
||||
onEditingFinished: {
|
||||
const parsed = parseInt(text);
|
||||
if (!isNaN(parsed) && parsed > 0) {
|
||||
valueHeight = parsed;
|
||||
saveSettings();
|
||||
} else {
|
||||
text = String(valueHeight);
|
||||
}
|
||||
}
|
||||
defaultValue: String(widgetMetadata.height)
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.audio.visualizer-type-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-visualizer-type-description")
|
||||
model: [
|
||||
{
|
||||
"key": "linear",
|
||||
"name": I18n.tr("options.visualizer-types.linear")
|
||||
},
|
||||
{
|
||||
"key": "mirrored",
|
||||
"name": I18n.tr("options.visualizer-types.mirrored")
|
||||
},
|
||||
{
|
||||
"key": "wave",
|
||||
"name": I18n.tr("options.visualizer-types.wave")
|
||||
}
|
||||
]
|
||||
currentKey: valueVisualizerType
|
||||
onSelected: key => {
|
||||
valueVisualizerType = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.visualizerType
|
||||
}
|
||||
|
||||
NColorChoice {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("bar.audio-visualizer.color-name-label")
|
||||
description: I18n.tr("bar.audio-visualizer.color-name-description")
|
||||
currentKey: valueColorName
|
||||
onSelected: key => {
|
||||
valueColorName = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.colorName
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("bar.audio-visualizer.hide-when-idle-label")
|
||||
description: I18n.tr("bar.audio-visualizer.hide-when-idle-description")
|
||||
checked: valueHideWhenIdle
|
||||
onToggled: checked => {
|
||||
valueHideWhenIdle = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.hideWhenIdle
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.clock-show-background-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-show-background-description")
|
||||
checked: valueShowBackground
|
||||
onToggled: checked => {
|
||||
valueShowBackground = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showBackground
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
visible: valueShowBackground
|
||||
label: I18n.tr("panels.desktop-widgets.clock-rounded-corners-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-rounded-corners-description")
|
||||
checked: valueRoundedCorners
|
||||
onToggled: checked => {
|
||||
valueRoundedCorners = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.roundedCorners
|
||||
}
|
||||
}
|
||||
+293
@@ -0,0 +1,293 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Commons
|
||||
import qs.Services.System
|
||||
import qs.Widgets
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: Style.marginM
|
||||
width: 700
|
||||
|
||||
property var widgetData: null
|
||||
property var widgetMetadata: null
|
||||
|
||||
signal settingsChanged(var settings)
|
||||
|
||||
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
|
||||
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
|
||||
property string valueClockStyle: widgetData.clockStyle !== undefined ? widgetData.clockStyle : widgetMetadata.clockStyle
|
||||
property string valueClockColor: widgetData.clockColor !== undefined ? widgetData.clockColor : widgetMetadata.clockColor
|
||||
property bool valueUseCustomFont: widgetData.useCustomFont !== undefined ? widgetData.useCustomFont : widgetMetadata.useCustomFont
|
||||
property string valueCustomFont: widgetData.customFont !== undefined ? widgetData.customFont : widgetMetadata.custonFont
|
||||
property string valueFormat: widgetData.format !== undefined ? widgetData.format : widgetMetadata.format
|
||||
|
||||
// Track the currently focused input field
|
||||
property var focusedInput: null
|
||||
|
||||
readonly property bool isMinimalMode: valueClockStyle === "minimal"
|
||||
readonly property var now: Time.now
|
||||
|
||||
function saveSettings() {
|
||||
var settings = Object.assign({}, widgetData || {});
|
||||
settings.showBackground = valueShowBackground;
|
||||
settings.roundedCorners = valueRoundedCorners;
|
||||
settings.clockStyle = valueClockStyle;
|
||||
settings.clockColor = valueClockColor;
|
||||
settings.useCustomFont = valueUseCustomFont;
|
||||
settings.customFont = valueCustomFont;
|
||||
settings.format = valueFormat.trim();
|
||||
settingsChanged(settings);
|
||||
}
|
||||
|
||||
// Function to insert token at cursor position in the focused input
|
||||
function insertToken(token) {
|
||||
if (!focusedInput || !focusedInput.inputItem) {
|
||||
// If no input is focused, default to format input
|
||||
if (formatInput.inputItem) {
|
||||
formatInput.inputItem.focus = true;
|
||||
focusedInput = formatInput;
|
||||
}
|
||||
}
|
||||
|
||||
if (focusedInput && focusedInput.inputItem) {
|
||||
var input = focusedInput.inputItem;
|
||||
var cursorPos = input.cursorPosition;
|
||||
var currentText = input.text;
|
||||
|
||||
// Insert token at cursor position
|
||||
var newText = currentText.substring(0, cursorPos) + token + currentText.substring(cursorPos);
|
||||
input.text = newText + " ";
|
||||
|
||||
// Move cursor after the inserted token
|
||||
input.cursorPosition = cursorPos + token.length + 1;
|
||||
|
||||
// Ensure the input keeps focus
|
||||
input.focus = true;
|
||||
saveSettings();
|
||||
}
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.clock-style-label")
|
||||
description: I18n.tr("panels.desktop-widgets.clock-style-description")
|
||||
currentKey: valueClockStyle
|
||||
minimumWidth: 260 * Style.uiScaleRatio
|
||||
model: [
|
||||
{
|
||||
"key": "minimal",
|
||||
"name": I18n.tr("panels.desktop-widgets.clock-style-minimal")
|
||||
},
|
||||
{
|
||||
"key": "digital",
|
||||
"name": I18n.tr("panels.desktop-widgets.clock-style-digital")
|
||||
},
|
||||
{
|
||||
"key": "analog",
|
||||
"name": I18n.tr("panels.desktop-widgets.clock-style-analog")
|
||||
},
|
||||
{
|
||||
"key": "binary",
|
||||
"name": I18n.tr("panels.desktop-widgets.clock-style-binary")
|
||||
}
|
||||
]
|
||||
onSelected: key => {
|
||||
valueClockStyle = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.clockStyle
|
||||
}
|
||||
|
||||
NColorChoice {
|
||||
label: I18n.tr("common.select-color")
|
||||
description: I18n.tr("common.select-color-description")
|
||||
currentKey: valueClockColor
|
||||
onSelected: key => {
|
||||
valueClockColor = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.clockColor
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("bar.clock.use-custom-font-label")
|
||||
description: I18n.tr("bar.clock.use-custom-font-description")
|
||||
checked: valueUseCustomFont
|
||||
onToggled: checked => {
|
||||
valueUseCustomFont = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.useCustomFont
|
||||
}
|
||||
|
||||
NSearchableComboBox {
|
||||
Layout.fillWidth: true
|
||||
visible: valueUseCustomFont
|
||||
label: I18n.tr("bar.clock.custom-font-label")
|
||||
description: I18n.tr("bar.clock.custom-font-description")
|
||||
model: FontService.availableFonts
|
||||
currentKey: valueCustomFont
|
||||
placeholder: I18n.tr("bar.clock.custom-font-placeholder")
|
||||
searchPlaceholder: I18n.tr("bar.clock.custom-font-search-placeholder")
|
||||
popupHeight: 420
|
||||
minimumWidth: 300
|
||||
onSelected: function (key) {
|
||||
valueCustomFont = key;
|
||||
saveSettings();
|
||||
}
|
||||
enabled: valueClockStyle === "minimal"
|
||||
defaultValue: Settings.data.ui.fontDefault
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
visible: isMinimalMode
|
||||
}
|
||||
|
||||
NHeader {
|
||||
visible: isMinimalMode
|
||||
label: I18n.tr("bar.clock.clock-display-label")
|
||||
description: I18n.tr("bar.clock.clock-display-description")
|
||||
}
|
||||
|
||||
// Format editor - only visible in minimal mode
|
||||
RowLayout {
|
||||
id: main
|
||||
visible: isMinimalMode
|
||||
spacing: Style.marginL
|
||||
Layout.fillWidth: true
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Style.marginM
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredWidth: 1
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
|
||||
NTextInput {
|
||||
id: formatInput
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.clock-format-label")
|
||||
description: I18n.tr("bar.clock.horizontal-bar-description")
|
||||
placeholderText: "HH:mm\\nd MMMM yyyy"
|
||||
text: valueFormat
|
||||
onTextChanged: {
|
||||
valueFormat = text;
|
||||
settingsChanged(saveSettings());
|
||||
}
|
||||
Component.onCompleted: {
|
||||
if (inputItem) {
|
||||
inputItem.onActiveFocusChanged.connect(function () {
|
||||
if (inputItem.activeFocus) {
|
||||
root.focusedInput = formatInput;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
defaultValue: widgetMetadata.format
|
||||
}
|
||||
}
|
||||
|
||||
// Preview
|
||||
ColumnLayout {
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
Layout.fillWidth: false
|
||||
|
||||
NLabel {
|
||||
label: I18n.tr("bar.clock.preview")
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.preferredWidth: 320
|
||||
Layout.preferredHeight: 160
|
||||
color: Color.mSurfaceVariant
|
||||
radius: Style.radiusM
|
||||
border.color: Color.mSecondary
|
||||
border.width: Style.borderS
|
||||
|
||||
Behavior on border.color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
spacing: Style.marginM
|
||||
anchors.centerIn: parent
|
||||
|
||||
ColumnLayout {
|
||||
spacing: -2
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
|
||||
Repeater {
|
||||
Layout.topMargin: Style.marginM
|
||||
model: I18n.locale.toString(now, valueFormat.trim()).split("\\n")
|
||||
delegate: NText {
|
||||
visible: text !== ""
|
||||
text: modelData
|
||||
family: valueUseCustomFont && valueCustomFont ? valueCustomFont : Settings.data.ui.fontDefault
|
||||
pointSize: Style.fontSizeM
|
||||
font.weight: Style.fontWeightBold
|
||||
color: Color.resolveColorKey(valueClockColor)
|
||||
wrapMode: Text.WordWrap
|
||||
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
|
||||
|
||||
Behavior on color {
|
||||
ColorAnimation {
|
||||
duration: Style.animationFast
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.topMargin: Style.marginM
|
||||
Layout.bottomMargin: Style.marginM
|
||||
visible: isMinimalMode
|
||||
}
|
||||
|
||||
NDateTimeTokens {
|
||||
Layout.fillWidth: true
|
||||
height: 200
|
||||
visible: isMinimalMode
|
||||
onTokenClicked: token => root.insertToken(token)
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.clock-show-background-label")
|
||||
description: I18n.tr("panels.desktop-widgets.clock-show-background-description")
|
||||
checked: valueShowBackground
|
||||
onToggled: checked => {
|
||||
valueShowBackground = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showBackground
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
visible: valueShowBackground
|
||||
label: I18n.tr("panels.desktop-widgets.clock-rounded-corners-label")
|
||||
description: I18n.tr("panels.desktop-widgets.clock-rounded-corners-description")
|
||||
checked: valueRoundedCorners
|
||||
onToggled: checked => {
|
||||
valueRoundedCorners = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.roundedCorners
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Commons
|
||||
import qs.Widgets
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: Style.marginM
|
||||
|
||||
property var widgetData: null
|
||||
property var widgetMetadata: null
|
||||
|
||||
signal settingsChanged(var settings)
|
||||
|
||||
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
|
||||
property string valueVisualizerType: widgetData.visualizerType ? widgetData.visualizerType : widgetMetadata.visualizerType
|
||||
property string valueHideMode: widgetData.hideMode !== undefined ? widgetData.hideMode : widgetMetadata.hideMode
|
||||
property bool valueShowButtons: widgetData.showButtons !== undefined ? widgetData.showButtons : widgetMetadata.showButtons
|
||||
property bool valueShowAlbumArt: widgetData.showAlbumArt !== undefined ? widgetData.showAlbumArt : widgetMetadata.showAlbumArt
|
||||
property bool valueShowVisualizer: widgetData.showVisualizer !== undefined ? widgetData.showVisualizer : widgetMetadata.showVisualizer
|
||||
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
|
||||
|
||||
function saveSettings() {
|
||||
var settings = Object.assign({}, widgetData || {});
|
||||
settings.showBackground = valueShowBackground;
|
||||
settings.visualizerType = valueVisualizerType;
|
||||
settings.hideMode = valueHideMode;
|
||||
settings.showButtons = valueShowButtons;
|
||||
settings.showAlbumArt = valueShowAlbumArt;
|
||||
settings.showVisualizer = valueShowVisualizer;
|
||||
settings.roundedCorners = valueRoundedCorners;
|
||||
settingsChanged(settings);
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.clock-show-background-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-show-background-description")
|
||||
checked: valueShowBackground
|
||||
onToggled: checked => {
|
||||
valueShowBackground = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showBackground
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.clock-rounded-corners-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-rounded-corners-description")
|
||||
checked: valueRoundedCorners
|
||||
onToggled: checked => {
|
||||
valueRoundedCorners = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.roundedCorners
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.media-player-show-album-art-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-show-album-art-description")
|
||||
checked: valueShowAlbumArt
|
||||
onToggled: checked => {
|
||||
valueShowAlbumArt = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showAlbumArt
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("bar.media-mini.show-visualizer-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-show-visualizer-description")
|
||||
checked: valueShowVisualizer
|
||||
onToggled: checked => {
|
||||
valueShowVisualizer = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showVisualizer
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.media-player-show-buttons-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-show-buttons-description")
|
||||
checked: valueShowButtons
|
||||
onToggled: checked => {
|
||||
valueShowButtons = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showButtons
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.audio.visualizer-type-label")
|
||||
description: I18n.tr("panels.desktop-widgets.media-player-visualizer-type-description")
|
||||
enabled: valueShowVisualizer
|
||||
model: [
|
||||
{
|
||||
"key": "linear",
|
||||
"name": I18n.tr("options.visualizer-types.linear")
|
||||
},
|
||||
{
|
||||
"key": "mirrored",
|
||||
"name": I18n.tr("options.visualizer-types.mirrored")
|
||||
},
|
||||
{
|
||||
"key": "wave",
|
||||
"name": I18n.tr("options.visualizer-types.wave")
|
||||
}
|
||||
]
|
||||
currentKey: valueVisualizerType
|
||||
onSelected: key => {
|
||||
valueVisualizerType = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.visualizerType
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("bar.taskbar.hide-mode-label")
|
||||
description: I18n.tr("bar.media-mini.hide-mode-description")
|
||||
model: [
|
||||
{
|
||||
"key": "hidden",
|
||||
"name": I18n.tr("hide-modes.hidden")
|
||||
},
|
||||
{
|
||||
"key": "idle",
|
||||
"name": I18n.tr("hide-modes.idle")
|
||||
},
|
||||
{
|
||||
"key": "visible",
|
||||
"name": I18n.tr("hide-modes.visible")
|
||||
}
|
||||
]
|
||||
currentKey: valueHideMode
|
||||
onSelected: key => {
|
||||
valueHideMode = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.hideMode
|
||||
}
|
||||
}
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Commons
|
||||
import qs.Services.System
|
||||
import qs.Widgets
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: Style.marginM
|
||||
width: 700
|
||||
|
||||
property var widgetData: null
|
||||
property var widgetMetadata: null
|
||||
|
||||
signal settingsChanged(var settings)
|
||||
|
||||
property string valueStatType: widgetData.statType !== undefined ? widgetData.statType : widgetMetadata.statType
|
||||
property string valueDiskPath: widgetData.diskPath !== undefined ? widgetData.diskPath : widgetMetadata.diskPath
|
||||
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
|
||||
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
|
||||
property string valueLayout: widgetData.layout !== undefined ? widgetData.layout : widgetMetadata.layout
|
||||
|
||||
function saveSettings() {
|
||||
var settings = Object.assign({}, widgetData || {});
|
||||
settings.statType = valueStatType;
|
||||
settings.diskPath = valueDiskPath;
|
||||
settings.showBackground = valueShowBackground;
|
||||
settings.roundedCorners = valueRoundedCorners;
|
||||
settings.layout = valueLayout;
|
||||
settingsChanged(settings);
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.system-stat-stat-type-label")
|
||||
description: I18n.tr("panels.desktop-widgets.system-stat-stat-type-description")
|
||||
currentKey: valueStatType
|
||||
minimumWidth: 260 * Style.uiScaleRatio
|
||||
model: {
|
||||
let items = [
|
||||
{
|
||||
"key": "CPU",
|
||||
"name": I18n.tr("system-monitor.cpu-usage")
|
||||
},
|
||||
{
|
||||
"key": "Memory",
|
||||
"name": I18n.tr("common.memory")
|
||||
},
|
||||
{
|
||||
"key": "Network",
|
||||
"name": I18n.tr("bar.system-monitor.network-traffic-label")
|
||||
},
|
||||
{
|
||||
"key": "Disk",
|
||||
"name": I18n.tr("system-monitor.disk")
|
||||
}
|
||||
];
|
||||
if (Settings.data.systemMonitor.enableDgpuMonitoring)
|
||||
items.push({
|
||||
"key": "GPU",
|
||||
"name": I18n.tr("panels.system-monitor.gpu-section-label")
|
||||
});
|
||||
return items;
|
||||
}
|
||||
onSelected: key => {
|
||||
valueStatType = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.statType
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
visible: valueStatType === "Disk"
|
||||
label: I18n.tr("bar.system-monitor.disk-path-label")
|
||||
description: I18n.tr("bar.system-monitor.disk-path-description")
|
||||
model: {
|
||||
const paths = Object.keys(SystemStatService.diskPercents).sort();
|
||||
return paths.map(path => ({
|
||||
key: path,
|
||||
name: path
|
||||
}));
|
||||
}
|
||||
currentKey: valueDiskPath
|
||||
onSelected: key => {
|
||||
valueDiskPath = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.diskPath
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.system-stat-show-background-label")
|
||||
description: I18n.tr("panels.desktop-widgets.system-stat-show-background-description")
|
||||
checked: valueShowBackground
|
||||
onToggled: checked => {
|
||||
valueShowBackground = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showBackground
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
visible: valueShowBackground
|
||||
label: I18n.tr("panels.desktop-widgets.system-stat-rounded-corners-label")
|
||||
description: I18n.tr("panels.desktop-widgets.system-stat-rounded-corners-description")
|
||||
checked: valueRoundedCorners
|
||||
onToggled: checked => {
|
||||
valueRoundedCorners = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.roundedCorners
|
||||
}
|
||||
|
||||
NDivider {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
NComboBox {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.system-stat-layout-label")
|
||||
description: I18n.tr("panels.desktop-widgets.system-stat-layout-description")
|
||||
currentKey: valueLayout
|
||||
minimumWidth: 260 * Style.uiScaleRatio
|
||||
model: [
|
||||
{
|
||||
"key": "side",
|
||||
"name": I18n.tr("panels.desktop-widgets.system-stat-layout-side")
|
||||
},
|
||||
{
|
||||
"key": "bottom",
|
||||
"name": I18n.tr("panels.desktop-widgets.system-stat-layout-bottom")
|
||||
}
|
||||
]
|
||||
onSelected: key => {
|
||||
valueLayout = key;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.layout
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Commons
|
||||
import qs.Widgets
|
||||
|
||||
ColumnLayout {
|
||||
id: root
|
||||
spacing: Style.marginM
|
||||
|
||||
property var widgetData: null
|
||||
property var widgetMetadata: null
|
||||
|
||||
signal settingsChanged(var settings)
|
||||
|
||||
property bool valueShowBackground: widgetData.showBackground !== undefined ? widgetData.showBackground : widgetMetadata.showBackground
|
||||
property bool valueRoundedCorners: widgetData.roundedCorners !== undefined ? widgetData.roundedCorners : widgetMetadata.roundedCorners
|
||||
|
||||
function saveSettings() {
|
||||
var settings = Object.assign({}, widgetData || {});
|
||||
settings.showBackground = valueShowBackground;
|
||||
settings.roundedCorners = valueRoundedCorners;
|
||||
settingsChanged(settings);
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
label: I18n.tr("panels.desktop-widgets.clock-show-background-label")
|
||||
description: I18n.tr("panels.desktop-widgets.weather-show-background-description")
|
||||
checked: valueShowBackground
|
||||
onToggled: checked => {
|
||||
valueShowBackground = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.showBackground
|
||||
}
|
||||
|
||||
NToggle {
|
||||
Layout.fillWidth: true
|
||||
visible: valueShowBackground
|
||||
label: I18n.tr("panels.desktop-widgets.clock-rounded-corners-label")
|
||||
description: I18n.tr("panels.desktop-widgets.clock-rounded-corners-description")
|
||||
checked: valueRoundedCorners
|
||||
onToggled: checked => {
|
||||
valueRoundedCorners = checked;
|
||||
saveSettings();
|
||||
}
|
||||
defaultValue: widgetMetadata.roundedCorners
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user