add noctalia and fuzzel

This commit is contained in:
2026-05-23 21:20:58 +02:00
parent 364801f1a3
commit 9a3eceb3ab
599 changed files with 204318 additions and 0 deletions
@@ -0,0 +1,160 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qs.Commons
import qs.Services.UI
import qs.Widgets
// Widget Settings Dialog Component
Popup {
id: root
property int widgetIndex: -1
property var widgetData: null
property string widgetId: ""
property string sectionId: ""
property var screen: null
property var settingsCache: ({})
signal updateWidgetSettings(string section, int index, var settings)
readonly property real maxHeight: (screen ? screen.height : (parent ? parent.height : 800)) * 0.8
readonly property real defaultContentWidth: Math.round(600 * Style.uiScaleRatio)
readonly property real settingsContentWidth: {
if (settingsLoader.item && settingsLoader.item.implicitWidth > 0) {
return settingsLoader.item.implicitWidth;
}
return defaultContentWidth;
}
readonly property real dialogPadding: Style.marginXL
width: Math.max(settingsContentWidth + dialogPadding * 2, 500)
height: Math.min(content.implicitHeight + dialogPadding * 2, maxHeight)
padding: 0
modal: true
closePolicy: Popup.NoAutoClose
anchors.centerIn: parent
onOpened: {
if (widgetData && widgetId) {
loadWidgetSettings();
}
}
background: Rectangle {
color: Color.mSurface
radius: Style.radiusL
border.color: Color.mPrimary
border.width: Style.borderM
}
contentItem: ColumnLayout {
id: content
anchors.fill: parent
anchors.margins: dialogPadding
spacing: Style.marginM
// Title
RowLayout {
id: titleRow
Layout.fillWidth: true
Layout.preferredHeight: implicitHeight
NText {
text: I18n.tr("system.widget-settings-title", {
"widget": 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()
}
}
// Separator
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
reserveScrollbarSpace: false
ColumnLayout {
width: scrollView.availableWidth
spacing: Style.marginM
Loader {
id: settingsLoader
Layout.fillWidth: true
onItemChanged: {
if (item) {
// Force width recalculation when content loads
Qt.callLater(() => {
root.width = Math.max(root.settingsContentWidth + root.dialogPadding * 2, 500);
});
}
}
}
}
}
}
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 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() {
const widgetSettingsMap = {
"CustomButton": "WidgetSettings/CustomButtonSettings.qml"
};
const source = widgetSettingsMap[widgetId];
if (source) {
settingsLoader.setSource(source, {
"widgetData": widgetData,
"widgetMetadata": ControlCenterWidgetRegistry.widgetMetadata[widgetId]
});
}
}
}
@@ -0,0 +1,303 @@
import QtQml.Models
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import qs.Commons
import qs.Widgets
ColumnLayout {
id: root
spacing: Style.marginM
Layout.preferredWidth: Math.round(600 * Style.uiScaleRatio)
implicitWidth: Layout.preferredWidth
property var widgetData: null
property var widgetMetadata: null
property var rootSettings: null
signal settingsChanged(var settings)
QtObject {
id: _settings
property string icon: widgetData.icon !== undefined ? widgetData.icon : widgetMetadata.icon
property string onClicked: widgetData.onClicked !== undefined ? widgetData.onClicked : widgetMetadata.onClicked
property string onRightClicked: widgetData.onRightClicked !== undefined ? widgetData.onRightClicked : widgetMetadata.onRightClicked
property string onMiddleClicked: widgetData.onMiddleClicked !== undefined ? widgetData.onMiddleClicked : widgetMetadata.onMiddleClicked
property ListModel _stateChecksListModel: ListModel {}
property string stateChecksJson: "[]"
property string generalTooltipText: widgetData.generalTooltipText !== undefined ? widgetData.generalTooltipText : widgetMetadata.generalTooltipText
property bool enableOnStateLogic: widgetData.enableOnStateLogic !== undefined ? widgetData.enableOnStateLogic : widgetMetadata.enableOnStateLogic
property bool showExecTooltip: widgetData.showExecTooltip !== undefined ? widgetData.showExecTooltip : widgetMetadata.showExecTooltip
function populateStateChecks() {
try {
var initialChecks = JSON.parse(stateChecksJson);
if (initialChecks && Array.isArray(initialChecks)) {
for (var i = 0; i < initialChecks.length; i++) {
var item = initialChecks[i];
if (item && typeof item === "object") {
_settings._stateChecksListModel.append({
"command": item.command || "",
"icon": item.icon || ""
});
} else {
Logger.w("CustomButtonSettings", "Invalid stateChecks entry at index " + i + ":", item);
}
}
}
} catch (e) {
Logger.e("CustomButtonSettings", "Failed to parse stateChecksJson:", e.message);
}
}
Component.onCompleted: {
root.rootSettings = _settings;
stateChecksJson = (widgetData && widgetData.stateChecksJson !== undefined) ? widgetData.stateChecksJson : (widgetMetadata && widgetMetadata.stateChecksJson ? widgetMetadata.stateChecksJson : "[]");
Qt.callLater(populateStateChecks);
}
function saveSettings() {
var savedStateChecksArray = [];
for (var i = 0; i < _settings._stateChecksListModel.count; i++) {
savedStateChecksArray.push(_settings._stateChecksListModel.get(i));
}
_settings.stateChecksJson = JSON.stringify(savedStateChecksArray);
return {
"id": widgetData.id,
"icon": _settings.icon,
"onClicked": _settings.onClicked,
"onRightClicked": _settings.onRightClicked,
"onMiddleClicked": _settings.onMiddleClicked,
"stateChecksJson": _settings.stateChecksJson,
"generalTooltipText": _settings.generalTooltipText,
"enableOnStateLogic": _settings.enableOnStateLogic,
"showExecTooltip": _settings.showExecTooltip
};
}
}
function saveSettings() {
return _settings.saveSettings();
}
function updateStateCheck(index, command, icon) {
_settings._stateChecksListModel.set(index, {
"command": command,
"icon": icon
});
_settings.saveSettings();
}
function removeStateCheck(index) {
_settings._stateChecksListModel.remove(index);
_settings.saveSettings();
}
function addStateCheck() {
_settings._stateChecksListModel.append({
"command": "",
"icon": ""
});
_settings.saveSettings();
}
RowLayout {
spacing: Style?.marginM ?? 8
NLabel {
label: I18n.tr("common.icon")
description: I18n.tr("panels.control-center.shortcuts-custom-button-icon-description")
}
NIcon {
Layout.alignment: Qt.AlignVCenter
icon: _settings.icon || (widgetMetadata && widgetMetadata.icon ? widgetMetadata.icon : "")
pointSize: Style?.fontSizeXL ?? 24
visible: (_settings.icon || (widgetMetadata && widgetMetadata.icon ? widgetMetadata.icon : "")) !== ""
}
NButton {
text: I18n.tr("common.browse")
onClicked: iconPicker.open()
}
}
NIconPicker {
id: iconPicker
initialIcon: _settings.icon
onIconSelected: function (iconName) {
_settings.icon = iconName;
saveSettings();
}
}
NTextInput {
Layout.fillWidth: true
label: I18n.tr("bar.custom-button.general-tooltip-text-label")
description: I18n.tr("bar.custom-button.general-tooltip-text-description")
placeholderText: I18n.tr("placeholders.enter-tooltip")
text: _settings.generalTooltipText
onTextChanged: {
_settings.generalTooltipText = text;
saveSettings();
}
defaultValue: widgetMetadata.generalTooltipText
}
NToggle {
Layout.fillWidth: true
label: I18n.tr("bar.custom-button.show-exec-tooltip-label")
description: I18n.tr("bar.custom-button.show-exec-tooltip-description")
checked: _settings.showExecTooltip
onToggled: checked => {
_settings.showExecTooltip = checked;
saveSettings();
}
defaultValue: widgetMetadata.showExecTooltip
}
NTextInput {
Layout.fillWidth: true
label: I18n.tr("bar.custom-button.left-click-label")
description: I18n.tr("bar.custom-button.left-click-description")
placeholderText: I18n.tr("placeholders.enter-command")
text: _settings.onClicked
onTextChanged: {
_settings.onClicked = text;
saveSettings();
}
defaultValue: widgetMetadata.onClicked
}
NTextInput {
Layout.fillWidth: true
label: I18n.tr("bar.custom-button.right-click-label")
description: I18n.tr("bar.custom-button.right-click-description")
placeholderText: I18n.tr("placeholders.enter-command")
text: _settings.onRightClicked
onTextChanged: {
_settings.onRightClicked = text;
saveSettings();
}
defaultValue: widgetMetadata.onRightClicked
}
NTextInput {
Layout.fillWidth: true
label: I18n.tr("bar.custom-button.middle-click-label")
description: I18n.tr("bar.custom-button.middle-click-description")
placeholderText: I18n.tr("placeholders.enter-command")
text: _settings.onMiddleClicked
onTextChanged: {
_settings.onMiddleClicked = text;
saveSettings();
}
defaultValue: widgetMetadata.onMiddleClicked
}
NDivider {}
NToggle {
id: enableOnStateLogicToggle
Layout.fillWidth: true
label: I18n.tr("panels.control-center.shortcuts-custom-button-enable-on-state-logic-label")
description: I18n.tr("panels.control-center.shortcuts-custom-button-enable-on-state-logic-description")
checked: _settings.enableOnStateLogic
onToggled: checked => {
_settings.enableOnStateLogic = checked;
saveSettings();
}
defaultValue: widgetMetadata.enableOnStateLogic
}
ColumnLayout {
Layout.fillWidth: true
visible: root.rootSettings && root.rootSettings.enableOnStateLogic
spacing: Style?.marginM ?? 8
NLabel {
label: I18n.tr("panels.control-center.shortcuts-custom-button-state-checks-label")
}
Repeater {
model: root.rootSettings ? root.rootSettings._stateChecksListModel : null
delegate: Item {
property int currentIndex: index
implicitHeight: contentRow.implicitHeight
Layout.fillWidth: true
RowLayout {
id: contentRow
anchors.fill: parent
spacing: Style?.marginM ?? 8
NTextInput {
Layout.fillWidth: true
placeholderText: I18n.tr("panels.control-center.shortcuts-custom-button-state-checks-command")
text: model.command
onTextChanged: {
updateStateCheck(currentIndex, text, model.icon);
}
}
RowLayout {
Layout.alignment: Qt.AlignVCenter
spacing: Style?.marginS ?? 4
NIcon {
icon: model.icon
pointSize: Style?.fontSizeL ?? 20
visible: model.icon !== undefined && model.icon !== ""
}
NIconButton {
icon: "folder"
tooltipText: I18n.tr("common.browse")
baseSize: Style?.buttonSizeS ?? 24
onClicked: iconPickerDelegate.open()
}
NIconButton {
icon: "close"
tooltipText: I18n.tr("panels.control-center.shortcuts-custom-button-state-checks-remove")
baseSize: Style?.buttonSizeS ?? 24
colorBorder: Qt.alpha(Color.mOutline, Style.opacityLight)
colorBg: Color.mError
colorFg: Color.mOnError
colorBgHover: Qt.alpha(Color.mError, Style.opacityMedium)
colorFgHover: Color.mOnError
onClicked: {
removeStateCheck(currentIndex);
}
}
}
}
NIconPicker {
id: iconPickerDelegate
initialIcon: model.icon
onIconSelected: function (iconName) {
updateStateCheck(currentIndex, model.command, iconName);
}
}
}
}
Item {
Layout.fillWidth: true
}
RowLayout {
Layout.fillWidth: true
spacing: Style?.marginM ?? 8
NButton {
text: I18n.tr("panels.control-center.shortcuts-custom-button-state-checks-add")
onClicked: addStateCheck()
}
}
}
}