Changeset View
Changeset View
Standalone View
Standalone View
src/mainwindow.cpp
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Line(s) | 159 | QMessageBox::warning(this, i18n("Error"), | |||
---|---|---|---|---|---|
160 | i18n("There's no GCode File open. \n Please select a file and try again."), | 160 | i18n("There's no GCode File open. \n Please select a file and try again."), | ||
161 | QMessageBox::Ok); | 161 | QMessageBox::Ok); | ||
162 | break; | 162 | break; | ||
163 | case 1: | 163 | case 1: | ||
164 | file = m_openFiles.at(0); | 164 | file = m_openFiles.at(0); | ||
165 | break; | 165 | break; | ||
166 | default: | 166 | default: | ||
167 | ChooseFileDialog dialog(this, m_openFiles); | 167 | ChooseFileDialog dialog(this, m_openFiles); | ||
168 | if (dialog.exec() == QDialog::Accepted) { | 168 | if (dialog.exec() != QDialog::Accepted) { | ||
169 | file = dialog.choosenFile(); | 169 | return; | ||
patrickelectric: != accept makes more senses if new or a undefined behaviour happens,. | |||||
170 | } | 170 | } | ||
171 | file = dialog.choosenFile(); | ||||
patrickelectric: Why is this necessary ? | |||||
There is a check in print that will make an error dialog if print is called with an empty file . So by checking here we prevent this if the user hits cancel. rizzitello: There is a check in print that will make an error dialog if print is called with an empty file . | |||||
int result = dialog.exec(); if (result == QDialog::Rejected) { return; } if (result == QDialog::Accepted) { file = dialog.choosenFile(); } Why not like this ? int result = dialog.exec(); if (result != QDialog::Accepted) { return; } file = dialog.choosenFile(); patrickelectric: ```
int result = dialog.exec();
if (result == QDialog::Rejected) {… | |||||
171 | break; | 172 | break; | ||
172 | } | 173 | } | ||
173 | if (m_gcodeEditor->modifiedFiles().contains(file)) | 174 | if (m_gcodeEditor->modifiedFiles().contains(file)) | ||
174 | { | 175 | { | ||
175 | int result = QMessageBox::question( | 176 | int result = QMessageBox::question( | ||
176 | this | 177 | this | ||
177 | , i18n("Document Modified") | 178 | , i18n("Document Modified") | ||
178 | , i18n("%1 \n Contains Unsaved Changes That will not be in the print.\n Would you like to Save before printing?", file.toLocalFile()) | 179 | , i18n("%1 \n Contains Unsaved Changes That will not be in the print.\n Would you like to Save before printing?", file.toLocalFile()) | ||
▲ Show 20 Lines • Show All 322 Lines • Show Last 20 Lines |
!= accept makes more senses if new or a undefined behaviour happens,.