Changeset View
Standalone View
src/widgets/atcoreinstancewidget.cpp
Show First 20 Lines • Show All 305 Lines • ▼ Show 20 Line(s) | 299 | connect(m_sdWidget, &SdWidget::deleteSdFile, this, [this](const QString & fileName) { | |||
---|---|---|---|---|---|
306 | } else { | 306 | } else { | ||
307 | m_core.sdDelete(fileName); | 307 | m_core.sdDelete(fileName); | ||
308 | } | 308 | } | ||
309 | }); | 309 | }); | ||
310 | } | 310 | } | ||
311 | 311 | | |||
312 | void AtCoreInstanceWidget::printFile(const QUrl &fileName) | 312 | void AtCoreInstanceWidget::printFile(const QUrl &fileName) | ||
313 | { | 313 | { | ||
314 | if (!fileName.isEmpty() && (m_core.state() == AtCore::IDLE)) { | 314 | if (fileName.isEmpty() || !QFileInfo::exists(fileName.toString())) { | ||
rizzitello: Its a shame QFileInfo does not accept a QUrl :( | |||||
315 | QMessageBox::critical( | ||||
This is good but the wording of the dialog is not very descriptive of what the error was or why it happened. I would use something more inline with Then for the body "The chosen file can not be printed because it no longer exists" Something like that that is more descriptive of what the error is . And im sure we can come up with even better wording then that too. rizzitello: This is good but the wording of the dialog is not very descriptive of what the error was or why… | |||||
316 | this | ||||
317 | , i18n("Invalid File") | ||||
318 | , i18n("The file you have chosen is invalid. Please check and try again.") | ||||
319 | ); | ||||
320 | } | ||||
321 | if (m_core.state() == AtCore::IDLE) { | ||||
patrickelectric: also !QFileInfo(fileName)::isReadable() | |||||
isReadable() cannot receive a file as param. The alternative is to create a QFileInfo obj and do the tests from it. https://doc.qt.io/qt-5/qfileinfo.html#isReadable QFileInfo file(fileName.toString()); if (fileName.isEmpty() || !file.exists() || file.isReadable()) { laysrodrigues: isReadable() cannot receive a file as param. The alternative is to create a QFileInfo obj and… | |||||
Good point @patrickelectric , If the file does not exist is is also not readable ? if so we should only have to check if QFileInfo::isReadable() to know if its both exsiting and readable. rizzitello: Good point @patrickelectric , If the file does not exist is is also not readable ? if so we… | |||||
Im all for doing something like this where we show a different message for either error. QFileInfo.isReadable() works well as a single check to see if it exists also. if ( fileName.isEmpty() ) { QMessageBox::critical( this , i18n("Filename Empty") , i18n("No fileName sent from calling method."); return; } else if ( !QFileInfo(fileName).isReadable() ) { QMessageBox::critical( this , i18n("File not found") , i18n("%1 \nIs not readable", fileName.toString()); return; } rizzitello: Im all for doing something like this where we show a different message for either error. | |||||
315 | m_logWidget->appendLog(i18n("Printing:%1", fileName.toLocalFile())); | 322 | m_logWidget->appendLog(i18n("Printing:%1", fileName.toLocalFile())); | ||
316 | m_core.print(fileName.toLocalFile()); | 323 | m_core.print(fileName.toLocalFile()); | ||
317 | } | 324 | } | ||
318 | } | 325 | } | ||
319 | 326 | | |||
320 | void AtCoreInstanceWidget::print() | 327 | void AtCoreInstanceWidget::print() | ||
321 | { | 328 | { | ||
322 | emit(requestFileChooser()); | 329 | emit(requestFileChooser()); | ||
▲ Show 20 Lines • Show All 285 Lines • Show Last 20 Lines |
Its a shame QFileInfo does not accept a QUrl :(