add noctalia and fuzzel
This commit is contained in:
+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