aerothemeplasma/plasma/shells/io.gitgud.wackyideas.desktop/contents/updates/migrate_font_weights.js
wackyideas 6f831d540f Move to new shell plugin & panel, add SDDM sessions
This is a big update which requires existing users to migrate their
desktop setup (Plasmoids, their configurations, layout changes, etc.) to
a new desktop session.

This commit replaces the modified desktop shell (org.kde.plasma.desktop)
with ATP's shell (io.gitgud.wackyideas.desktop) which requires new
session options. This is similar to how plasma-bigscreen and
plasma-mobile are used - logging into a separate session via the login
manager (SDDM). ATP will provide sessions for both X11 and Wayland.

This, along with now providing a forked panel as well, is a step forward
regarding separating ATP's codebase and KDE's upstream code. Further
goals are to be able to further isolate the ATP session from the regular
KDE session in terms of shared configurations, etc.

For existing users - Rerun install_plasmoids.sh and
install_plasma_components.sh, you can delete the old shell
(shells/org.kde.plasma.desktop) and panel plasmoid
(plasmoids/org.kde.panel). As mentioned previously, panel and desktop
layouts, plasmoids and their configurations will not be migrated to the
newly available sessions, so they need to be set up manually.
2025-10-21 13:23:06 +02:00

44 lines
1.6 KiB
JavaScript

/*
SPDX-FileCopyrightText: 2023 Akseli Lahtinen <akselmo@akselmo.dev>
SPDX-License-Identifier: GPL-2.0-or-later
*/
// Find all depicted widgets and migrate their font weights from qt5 to qt6 style
var containments = desktops().concat(panels());
for (var c in containments) {
const cont = containments[c];
const widgets = cont.widgets();
for (var w in widgets) {
var widget = widgets[w];
switch(widget.type) {
case "org.kde.plasma.digitalclock":
widget.currentConfigGroup = ['Appearance'];
// Use "normal" weight as default if weight is not set
const oldFontWeight = widget.readConfig("fontWeight", 400);
const newFontWeight = migrateFontWeight(Number(oldFontWeight));
widget.writeConfig("fontWeight", newFontWeight);
break;
}
}
}
function migrateFontWeight(oldWeight) {
// Takes old weight (Qt5 weight) and returns the Qt6 equivalent
// Qt5 font weights: https://doc.qt.io/qt-5/qfont.html#Weight-enum
// Qt6 font weights: https://doc.qt.io/qt-6/qfont.html#Weight-enum
var newWeight = 400;
if (oldWeight === 0) { newWeight = 100; }
else if (oldWeight === 12) { newWeight = 200; }
else if (oldWeight === 25) { newWeight = 300; }
else if (oldWeight === 50) { newWeight = 400; }
else if (oldWeight === 57) { newWeight = 500; }
else if (oldWeight === 63) { newWeight = 600; }
else if (oldWeight === 75) { newWeight = 700; }
else if (oldWeight === 81) { newWeight = 800; }
else if (oldWeight === 87) { newWeight = 900; }
return newWeight;
}