* @brief Applies one of the recovery actions; the user is expected to restart afterwards. */
| 155 | * @brief Applies one of the recovery actions; the user is expected to restart afterwards. |
| 156 | */ |
| 157 | void Misc::CrashTracker::applyRecovery(int action) |
| 158 | { |
| 159 | switch (action) { |
| 160 | case ResetGraphicsBackend: |
| 161 | m_settings.setValue(QStringLiteral("App/GraphicsBackend"), 0); |
| 162 | m_settings.remove(QStringLiteral("App/GraphicsBackendPending")); |
| 163 | break; |
| 164 | case SkipLastProject: |
| 165 | m_settings.remove(QStringLiteral("project_file_path")); |
| 166 | break; |
| 167 | case ResetAllPreferences: { |
| 168 | QVariantMap preserved; |
| 169 | const QStringList groups{QStringLiteral("licensing"), QStringLiteral("trial")}; |
| 170 | for (const QString& group : groups) { |
| 171 | m_settings.beginGroup(group); |
| 172 | const QStringList keys = m_settings.allKeys(); |
| 173 | for (const QString& key : keys) |
| 174 | preserved.insert(group + QLatin1Char('/') + key, m_settings.value(key)); |
| 175 | |
| 176 | m_settings.endGroup(); |
| 177 | } |
| 178 | |
| 179 | m_settings.clear(); |
| 180 | for (auto it = preserved.constBegin(); it != preserved.constEnd(); ++it) |
| 181 | m_settings.setValue(it.key(), it.value()); |
| 182 | |
| 183 | break; |
| 184 | } |
| 185 | default: |
| 186 | break; |
| 187 | } |
| 188 | |
| 189 | acknowledge(); |
| 190 | } |