File indexing completed on 2024-12-29 05:05:33
0001 /* 0002 SPDX-FileCopyrightText: 2022 Jin Liu <ad.liu.jin@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 /* 0008 Plasma 5.26 introduced a new config entry autoFontAndSize which defaults to true. 0009 This means if the user customized font before (fontFamily, boldText, italicText), 0010 in 5.26 these settings are ignored. 0011 0012 So we need to set autoFontAndSize=false if: 0013 1. Any of these 3 old entries above is set. 0014 2. No new entries introduced in 5.26 (autoFontAndSize, fontSize, fontWeight, fontStyleName) 0015 are set, so this is a config from 5.25. 0016 0017 And fontWeight should be set to 75 (Font.Bold) if boldText==true. 0018 0019 See https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/1809 0020 */ 0021 0022 const containments = desktops().concat(panels()); 0023 for (var i in containments) { 0024 var cont = containments[i]; 0025 const widgets = cont.widgets(); 0026 for (var j in widgets) { 0027 var widget = widgets[j]; 0028 0029 if (widget.type == "org.kde.plasma.digitalclock") { 0030 widget.currentConfigGroup = new Array('Appearance') 0031 if ((widget.readConfig("fontFamily", "").length > 0 0032 || widget.readConfig("boldText", false) 0033 || widget.readConfig("italicText", false)) 0034 && 0035 (widget.readConfig("autoFontAndSize", true) 0036 && widget.readConfig("fontSize", 10) === 10 0037 && widget.readConfig("fontWeight", 50) === 50 0038 && widget.readConfig("fontStyleName", "").length === 0)) { 0039 widget.writeConfig("autoFontAndSize", false) 0040 if (widget.readConfig("boldText", false)) { 0041 widget.writeConfig("fontWeight", 75) 0042 } 0043 // Set the font size to the largest value (72) in the font dialog, 0044 // so the font autofits the panel when the panel height is less 0045 // than 72pt. This should keep 5.25's autosize behavior for custom 0046 // font. 0047 // For panels taller than 72pt, with custom font set in 5.25, the 0048 // digital clock's look may still change, though. 0049 widget.writeConfig("fontSize", 72) 0050 } 0051 } 0052 } 0053 }