Personal noctalia plugins collection
at 1a731775408725b0212555294f1d387e1fdf1125 185 lines 6.1 kB view raw
1import QtQuick 2import QtQuick.Layouts 3import qs.Commons 4import qs.Widgets 5 6ColumnLayout { 7 id: root 8 9 property var pluginApi: null 10 11 property string weekStart: "1" 12 property string timeFormat: "24h" 13 property string lineColorType: "mOutline" 14 property string panelMode: "attached" 15 property real hourLineOpacity: 0.5 16 property real dayLineOpacity: 1.0 17 18 spacing: Style.marginL 19 20 Component.onCompleted: { 21 Logger.i("WeeklyCalendar", "Settings UI loaded") 22 23 if (pluginApi?.pluginSettings) { 24 panelMode = pluginApi.pluginSettings.panelMode || "attached" 25 weekStart = pluginApi.pluginSettings.weekStart || "1" 26 timeFormat = pluginApi.pluginSettings.timeFormat || "24h" 27 lineColorType = pluginApi.pluginSettings.lineColorType || "mOutline" 28 hourLineOpacity = pluginApi.pluginSettings.hourLineOpacity || 0.5 29 dayLineOpacity = pluginApi.pluginSettings.dayLineOpacity || 0.9 30 } 31 } 32 33 // Time Format toggle 34 NToggle { 35 label: pluginApi.tr("settings.timeFormat") 36 description: pluginApi.tr("settings.timeFormat_description") 37 checked: root.timeFormat === pluginApi.tr("settings.12h") 38 onToggled: checked => root.timeFormat = checked ? pluginApi.tr("settings.12h") : pluginApi.tr("settings.24h") 39 } 40 41 // Week Start selector 42 NComboBox { 43 Layout.fillWidth: true 44 label: pluginApi.tr("settings.weekStart") 45 description: pluginApi.tr("settings.weekStart_description") 46 model: [ 47 {"key": "1", "name": pluginApi.tr("settings.monday")}, 48 {"key": "0", "name": pluginApi.tr("settings.sunday")}, 49 {"key": "6", "name": pluginApi.tr("settings.saturday")} 50 ] 51 currentKey: root.weekStart 52 onSelected: key => root.weekStart = key 53 } 54 55 NDivider { 56 Layout.fillWidth: true 57 Layout.topMargin: Style.marginM 58 Layout.bottomMargin: Style.marginM 59 } 60 61 // Line color type selector 62 NComboBox { 63 Layout.fillWidth: true 64 label: pluginApi.tr("settings.gridColor") 65 description: pluginApi.tr("settings.gridColor_description") 66 model: [ 67 {"key": "mOutline", "name": pluginApi.tr("settings.colorOutline")}, 68 {"key": "mOnSurfaceVariant", "name": pluginApi.tr("settings.colorOnSurfaceVariant")} 69 ] 70 currentKey: root.lineColorType 71 onSelected: key => root.lineColorType = key 72 } 73 74 // Hour line opacity slider 75 ColumnLayout { 76 Layout.fillWidth: true 77 spacing: Style.marginS 78 NLabel { 79 label: pluginApi.tr("settings.hourLineOpacity") 80 } 81 RowLayout { 82 Layout.fillWidth: true 83 NText { 84 text: pluginApi.tr("settings.hourLineOpacity_description") 85 font.pointSize: Style.fontSizeS 86 color: Color.mOnSurfaceVariant 87 wrapMode: Text.WordWrap 88 Layout.fillWidth: true 89 } 90 Item { Layout.fillWidth: true } 91 NText { 92 text: Math.round(root.hourLineOpacity * 100) + "%" 93 font.pointSize: Style.fontSizeS 94 color: Color.mOnSurfaceVariant 95 } 96 } 97 98 NSlider { 99 Layout.fillWidth: true 100 from: 0.1 101 to: 1 102 stepSize: 0.1 103 value: root.hourLineOpacity 104 onValueChanged: root.hourLineOpacity = value 105 } 106 } 107 108 // Day line opacity slider 109 ColumnLayout { 110 Layout.fillWidth: true 111 spacing: Style.marginS 112 NLabel { 113 label: pluginApi.tr("settings.dayLineOpacity") 114 } 115 RowLayout { 116 Layout.fillWidth: true 117 NText { 118 text: pluginApi.tr("settings.dayLineOpacity_description") 119 font.pointSize: Style.fontSizeS 120 color: Color.mOnSurfaceVariant 121 wrapMode: Text.WordWrap 122 Layout.fillWidth: true 123 } 124 Item { Layout.fillWidth: true } 125 NText { 126 text: Math.round(root.dayLineOpacity * 100) + "%" 127 font.pointSize: Style.fontSizeS 128 color: Color.mOnSurfaceVariant 129 } 130 } 131 132 NSlider { 133 Layout.fillWidth: true 134 from: 0.1 135 to: 1 136 stepSize: 0.1 137 value: root.dayLineOpacity 138 onValueChanged: root.dayLineOpacity = value 139 } 140 141 } 142 143 NDivider { 144 Layout.fillWidth: true 145 Layout.topMargin: Style.marginM 146 Layout.bottomMargin: Style.marginM 147 } 148 149 NComboBox { 150 Layout.fillWidth: true 151 label: pluginApi.tr("settings.panelMode") 152 description: pluginApi.tr("settings.panelMode_description") 153 model: [ 154 {"key": "attached", "name": pluginApi.tr("settings.panelAttach")}, 155 {"key": "centered", "name": pluginApi.tr("settings.panelCenter")}, 156 ] 157 currentKey: root.panelMode 158 onSelected: key => root.panelMode = key 159 } 160 161 function saveSettings() { 162 if (!pluginApi) { 163 Logger.e("WeeklyCalendar", "Cannot save settings: pluginApi is null") 164 return 165 } 166 167 if (!pluginApi.pluginSettings) { 168 pluginApi.pluginSettings = {} 169 } 170 pluginApi.pluginSettings.panelMode = panelMode 171 pluginApi.pluginSettings.weekStart = weekStart 172 pluginApi.pluginSettings.timeFormat = timeFormat 173 pluginApi.pluginSettings.lineColorType = lineColorType 174 pluginApi.pluginSettings.hourLineOpacity = hourLineOpacity 175 pluginApi.pluginSettings.dayLineOpacity = dayLineOpacity 176 pluginApi.saveSettings() 177 178 Logger.i("WeeklyCalendar", "Settings saved: weekStart=" + weekStart + 179 ", timeFormat=" + timeFormat + 180 ", panelMode=" + panelMode + 181 ", lineColorType=" + lineColorType + 182 ", hourLineOpacity=" + hourLineOpacity + 183 ", dayLineOpacity=" + dayLineOpacity) 184 } 185}