mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-06 20:12:29 +00:00
Cards & Settings refactoring
- All cards now live in Modules/Cards - CalendarPanel is now called ClockPanel - Added a way to ease settings migration in separate QML files
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import QtQuick
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
// Migrate from version < 26 to version 26
|
||||
// Replaces old calendar-card and banner-card with calendar-header-card and calendar-month-card
|
||||
function migrate(adapter, logger) {
|
||||
logger.i("Settings", "Migrating settings to v26");
|
||||
|
||||
// Replace old calendar-card and banner-card with calendar-header-card and calendar-month-card
|
||||
if (adapter.calendar !== undefined && adapter.calendar.cards !== undefined) {
|
||||
const oldCards = adapter.calendar.cards;
|
||||
const newCards = [];
|
||||
let anyCalendarEnabled = false;
|
||||
|
||||
// Check if any calendar-related card was enabled
|
||||
for (var i = 0; i < oldCards.length; i++) {
|
||||
const card = oldCards[i];
|
||||
if ((card.id === "banner-card" || card.id === "calendar-card") && card.enabled) {
|
||||
anyCalendarEnabled = true;
|
||||
} else if (card.id !== "banner-card" && card.id !== "calendar-card") {
|
||||
// Keep other cards as-is (timer, weather)
|
||||
newCards.push(card);
|
||||
}
|
||||
}
|
||||
|
||||
// Add new split cards at the beginning (enabled if any old calendar card was enabled)
|
||||
newCards.unshift({
|
||||
"id": "calendar-month-card",
|
||||
"enabled": anyCalendarEnabled
|
||||
});
|
||||
newCards.unshift({
|
||||
"id": "calendar-header-card",
|
||||
"enabled": anyCalendarEnabled
|
||||
});
|
||||
|
||||
adapter.calendar.cards = newCards;
|
||||
logger.i("Settings", "Replaced old calendar cards with calendar-header-card + calendar-month-card");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user