| 180 | } |
| 181 | |
| 182 | QByteArray PreferencesDialog::allowFileRestore(const QString& path) |
| 183 | { |
| 184 | QFileInfo fi(path); |
| 185 | auto filePath = fi.canonicalFilePath(); |
| 186 | if (_restore.contains(filePath)) { |
| 187 | // Already processed |
| 188 | return _restore[filePath]; |
| 189 | } |
| 190 | if (_remove.contains(filePath)) { |
| 191 | // Already processed |
| 192 | return QByteArray(); |
| 193 | } |
| 194 | QFile f(path); |
| 195 | if (f.exists()) { |
| 196 | // Restore to old contents on cancel |
| 197 | if (f.open(QIODevice::ReadOnly)) { |
| 198 | auto contents = f.readAll(); |
| 199 | _restore[filePath] = contents; |
| 200 | f.close(); |
| 201 | return contents; |
| 202 | } |
| 203 | } else { |
| 204 | // Remove on cancel |
| 205 | _remove << filePath; |
| 206 | } |
| 207 | return QByteArray(); |
| 208 | } |
| 209 | |
| 210 | void PreferencesDialog::loadDriver(bool showError) |
| 211 | { |