Commit 5cbe6b53 authored by Ahmad Samir's avatar Ahmad Samir
Browse files

Migrate old custom view font config entries

parent 802ecc92
......@@ -86,8 +86,10 @@
namespace {
// Used for GeneralSettings::version() to determine whether
// an updated version of Dolphin is running.
const int CurrentDolphinVersion = 201;
// an updated version of Dolphin is running, so as to migrate
// removed/renamed ...etc config entries; increment it in such
// cases
const int CurrentDolphinVersion = 202;
// The maximum number of entries in the back/forward popup menu
const int MaxNumberOfNavigationentries = 12;
// The maximum number of "Activate Tab" shortcuts
......
......@@ -32,7 +32,7 @@
<default>true</default>
</entry>
<entry name="Version" type="Int">
<label>Internal version of Dolphin, containing 3 digits for major, minor, bugfix</label>
<label>Internal config version of Dolphin, mainly Used to determine whether an updated version of Dolphin is running, so as to migrate config entries that were removed/renamed ...etc</label>
<default>0</default>
</entry>
<entry name="ModifiedStartupSettings" type="Bool">
......
......@@ -11,7 +11,43 @@
#include "dolphin_detailsmodesettings.h"
#include "dolphin_iconsmodesettings.h"
#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);
font.setWeight(group.readEntry<int>("FontWeight", QFont::Normal));
font.setItalic(group.readEntry("ItalicFont", false));
removeEntries(group);
// Write the new config entry
group.writeEntry("ViewFont", font);
}
config->sync();
}
}
ViewModeSettings::ViewModeSettings(DolphinView::Mode mode)
: ViewModeSettings()
{
switch (mode) {
case DolphinView::IconsView: m_viewModeSettingsVariant = IconsModeSettings::self(); return;
......@@ -23,6 +59,7 @@ ViewModeSettings::ViewModeSettings(DolphinView::Mode mode)
}
ViewModeSettings::ViewModeSettings(ViewSettingsTab::Mode mode)
: ViewModeSettings()
{
switch (mode) {
case ViewSettingsTab::IconsMode: m_viewModeSettingsVariant = IconsModeSettings::self(); return;
......@@ -34,6 +71,7 @@ ViewModeSettings::ViewModeSettings(ViewSettingsTab::Mode mode)
}
ViewModeSettings::ViewModeSettings(KStandardItemListView::ItemLayout itemLayout)
: ViewModeSettings()
{
switch (itemLayout) {
case KStandardItemListView::IconsLayout: m_viewModeSettingsVariant = IconsModeSettings::self(); return;
......
......@@ -48,6 +48,8 @@ public:
void save();
private:
explicit ViewModeSettings();
std::variant<IconsModeSettings *, CompactModeSettings *, DetailsModeSettings *> m_viewModeSettingsVariant;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment