| 116 | } |
| 117 | |
| 118 | void MainWindow::handleRecentProject(int ndx) |
| 119 | { |
| 120 | if(ndx >= _recentProjects.size()) { |
| 121 | return; |
| 122 | } |
| 123 | |
| 124 | QString projectName = _recentProjects[ndx].first; |
| 125 | QString projectFile = _recentProjects[ndx].second; |
| 126 | |
| 127 | QFile file(projectFile); |
| 128 | |
| 129 | if (!file.open(QIODevice::ReadOnly)) { |
| 130 | cds_error("Could not open file: {}", projectFile.toStdString()); |
| 131 | |
| 132 | auto userReply = QMessageBox::warning( |
| 133 | this, "Project not found", "File " + projectFile + " not found. Do you want to remove it from the recent list?", |
| 134 | QMessageBox::Yes | QMessageBox::No); |
| 135 | |
| 136 | if (userReply == QMessageBox::Yes) { |
| 137 | _recentProjects.remove(ndx); |
| 138 | refreshRecentProjects(); |
| 139 | } |
| 140 | |
| 141 | return; |
| 142 | } |
| 143 | |
| 144 | QByteArray wholeFile = file.readAll(); |
| 145 | |
| 146 | |
| 147 | if (createProjectConfig(projectName)) { |
| 148 | if (_projectConfig) { |
| 149 | _projectConfig->load(wholeFile); // FIXME |
| 150 | _projectFile = projectFile; |
| 151 | |
| 152 | addRecentProject(projectName, projectFile); |
| 153 | } else { |
| 154 | cds_error("Project config does not exist"); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | file.close(); |
| 159 | |
| 160 | refreshRecentProjects(); |
| 161 | } |
| 162 | |
| 163 | void MainWindow::loadSettings() |
| 164 | { |