src/Configuration.cc

changeset 642
751a8df42842
parent 639
851634b85893
child 644
93dcd1a0e4bd
equal deleted inserted replaced
641:425b169a82aa 642:751a8df42842
51 QString path = qApp->applicationDirPath() + "/" UNIXNAME EXTENSION; 51 QString path = qApp->applicationDirPath() + "/" UNIXNAME EXTENSION;
52 return new QSettings (path, QSettings::IniFormat); 52 return new QSettings (path, QSettings::IniFormat);
53 } 53 }
54 54
55 Config::Config (QString name) : 55 Config::Config (QString name) :
56 m_Name (name) {} 56 m_name (name) {}
57 57
58 // ============================================================================= 58 // =============================================================================
59 // Load the configuration from file 59 // Load the configuration from file
60 // ============================================================================= 60 // =============================================================================
61 bool Config::load() 61 bool Config::load()
66 for (Config* cfg : g_configPointers) 66 for (Config* cfg : g_configPointers)
67 { 67 {
68 if (!cfg) 68 if (!cfg)
69 break; 69 break;
70 70
71 QVariant val = settings->value (cfg->getName(), cfg->getDefaultAsVariant()); 71 QVariant val = settings->value (cfg->name(), cfg->getDefaultAsVariant());
72 cfg->loadFromVariant (val); 72 cfg->loadFromVariant (val);
73 g_configsByName[cfg->getName()] = cfg; 73 g_configsByName[cfg->name()] = cfg;
74 g_configs << cfg; 74 g_configs << cfg;
75 } 75 }
76 76
77 settings->deleteLater(); 77 settings->deleteLater();
78 return true; 78 return true;
87 log ("Saving configuration to %1...\n", settings->fileName()); 87 log ("Saving configuration to %1...\n", settings->fileName());
88 88
89 for (Config* cfg : g_configs) 89 for (Config* cfg : g_configs)
90 { 90 {
91 if (!cfg->isDefault()) 91 if (!cfg->isDefault())
92 settings->setValue (cfg->getName(), cfg->toVariant()); 92 settings->setValue (cfg->name(), cfg->toVariant());
93 else 93 else
94 settings->remove (cfg->getName()); 94 settings->remove (cfg->name());
95 } 95 }
96 96
97 settings->sync(); 97 settings->sync();
98 settings->deleteLater(); 98 settings->deleteLater();
99 return true; 99 return true;

mercurial