-#define VIEWMODESETTINGS_SET_VALUE(mode, setValue, value) \
- switch (mode) { \
- case ViewModeSettings::IconsMode: IconsModeSettings::setValue(value); break; \
- case ViewModeSettings::CompactMode: CompactModeSettings::setValue(value); break; \
- case ViewModeSettings::DetailsMode: DetailsModeSettings::setValue(value); break; \
- default: Q_ASSERT(false); break; \
+#include "dolphin_generalsettings.h"
+
+ViewModeSettings::ViewModeSettings()
+{
+ auto removeEntries = [](KConfigGroup &group) {
+ group.deleteEntry("FontFamily");
+ group.deleteEntry("FontWeight");
+ group.deleteEntry("ItalicFont");
+ };
+
+ KSharedConfig::Ptr config = KSharedConfig::openConfig();
+ // Migrate old config entries
+ if (GeneralSettings::version() < 202) {
+ for (const char *groupName : {"CompactMode", "DetailsMode", "IconsMode"}) {
+ KConfigGroup group = config->group(groupName);
+ const QString family = group.readEntry("FontFamily", QString{});
+ if (family.isEmpty()) {
+ removeEntries(group);
+ continue;
+ }
+
+ QFont font;
+ font.setFamily(family);
+ const int weight = group.readEntry<int>("FontWeight", QFont::Normal);
+ font.setWeight(static_cast<QFont::Weight>(weight));
+ font.setItalic(group.readEntry("ItalicFont", false));
+ removeEntries(group);
+
+ // Write the new config entry
+ group.writeEntry("ViewFont", font);
+ }
+
+ config->sync();