59 // Load the configuration from file |
59 // Load the configuration from file |
60 // ============================================================================= |
60 // ============================================================================= |
61 bool Config::load() |
61 bool Config::load() |
62 { |
62 { |
63 QSettings* settings = getSettingsObject(); |
63 QSettings* settings = getSettingsObject(); |
64 log ("config::load: Loading configuration file from %1\n", settings->fileName()); |
64 print ("config::load: Loading configuration file from %1\n", settings->fileName()); |
65 |
65 |
66 for (Config* cfg : g_configPointers) |
66 for (Config* cfg : g_configPointers) |
67 { |
67 { |
68 if (!cfg) |
68 if (!cfg) |
69 break; |
69 break; |
77 settings->deleteLater(); |
77 settings->deleteLater(); |
78 return true; |
78 return true; |
79 } |
79 } |
80 |
80 |
81 // ============================================================================= |
81 // ============================================================================= |
|
82 // |
82 // Save the configuration to disk |
83 // Save the configuration to disk |
83 // ============================================================================= |
84 // |
84 bool Config::save() |
85 bool Config::save() |
85 { |
86 { |
86 QSettings* settings = getSettingsObject(); |
87 QSettings* settings = getSettingsObject(); |
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->name(), cfg->toVariant()); |
92 settings->setValue (cfg->name(), cfg->toVariant()); |
93 else |
93 else |
94 settings->remove (cfg->name()); |
94 settings->remove (cfg->name()); |
95 } |
95 } |
96 |
96 |
97 settings->sync(); |
97 settings->sync(); |
|
98 print ("Configuration saved to %1.\n", settings->fileName()); |
98 settings->deleteLater(); |
99 settings->deleteLater(); |
99 return true; |
100 return true; |
100 } |
101 } |
101 |
102 |
102 // ============================================================================= |
103 // ============================================================================= |