Index: sources/gui/GuiController.cpp =================================================================== diff -u -rec31f94081864aec8b48a3cfa1e0aea80619714c -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/gui/GuiController.cpp (.../GuiController.cpp) (revision ec31f94081864aec8b48a3cfa1e0aea80619714c) +++ sources/gui/GuiController.cpp (.../GuiController.cpp) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -400,3 +400,12 @@ { emit didTreatmentRangesDone(vPass); } + +/*! + * \brief GuiController::doCancelLogExport + * \details Indicate to the logger to cancel the exporting of logs + */ +void GuiController::doCancelLogExport() +{ + _Logger.cancelExport(); +} Index: sources/gui/GuiController.h =================================================================== diff -u -rec31f94081864aec8b48a3cfa1e0aea80619714c -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/gui/GuiController.h (.../GuiController.h) (revision ec31f94081864aec8b48a3cfa1e0aea80619714c) +++ sources/gui/GuiController.h (.../GuiController.h) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -77,6 +77,7 @@ void doQuitApplication (); void doTreatmentRangesDone(bool vPass); + void doCancelLogExport(); private slots: // Should be private for thread safety and is connected internally. void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG Index: sources/gui/GuiView.cpp =================================================================== diff -u -r689177edf29dee6f10bebfed42f6bbadeb7ce8a8 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/gui/GuiView.cpp (.../GuiView.cpp) (revision 689177edf29dee6f10bebfed42f6bbadeb7ce8a8) +++ sources/gui/GuiView.cpp (.../GuiView.cpp) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -83,6 +83,8 @@ connect(&_GuiController, SIGNAL(didPOSTPass (bool)), this , SLOT( onPOSTPass (bool))); + connect(this , SIGNAL(didCancelLogExport ()), + &_GuiController, SLOT( doCancelLogExport ())); } /*! @@ -407,3 +409,12 @@ void GuiView::doQuitApplication() { emit didQuitApplication(); } + +/*! + * \brief GuiView::doCancelLogExport + * \details emit the didCancelLogExport signal to ask GuiController to cancel the log exporting + */ +void GuiView::doCancelLogExport() +{ + emit didCancelLogExport(); +} Index: sources/gui/GuiView.h =================================================================== diff -u -r689177edf29dee6f10bebfed42f6bbadeb7ce8a8 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/gui/GuiView.h (.../GuiView.h) (revision 689177edf29dee6f10bebfed42f6bbadeb7ce8a8) +++ sources/gui/GuiView.h (.../GuiView.h) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -117,6 +117,7 @@ void doExportLog (); void doExportService (); void doExportTreatment (); + void doCancelLogExport(); void doExportListInsert (quint32 vIndex, const QString &vFilename ); void doExportListDelete (quint32 vIndex ); @@ -141,6 +142,7 @@ void didExportTreatment (const GuiStringIndexMap &vExportList); void didExport (); void didExportStat (quint32 vIndex, const QString &vFileName, quint8 vPercent); + void didCancelLogExport (); void didQuitApplication (); }; Index: sources/gui/qml/components/ExportButton.qml =================================================================== diff -u -rc9f8f8cf3c6c37fc6460d8675c62c9442c4d4263 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/gui/qml/components/ExportButton.qml (.../ExportButton.qml) (revision c9f8f8cf3c6c37fc6460d8675c62c9442c4d4263) +++ sources/gui/qml/components/ExportButton.qml (.../ExportButton.qml) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -22,16 +22,16 @@ TouchRect { id : _root - property bool isSmall: false + property bool isCancelShown : false + property bool isSmall : false + property bool disabled : false - property bool disabled : false - width : isSmall ? 155 : Variables.touchRectWidth height : isSmall ? 50 : Variables.touchRectHeight anchors.margins: 35 text { - text: qsTr("Export") + text: isCancelShown ? qsTr("Cancel Export") : qsTr("Export") font.pixelSize: Fonts.fontPixelButton * (isSmall ? 0.75 : 1) } } Index: sources/gui/qml/pages/settings/SettingsExportLogs.qml =================================================================== diff -u -r80b5e8f1ebb90c03c37d90d90cd2da3bd95d6803 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/gui/qml/pages/settings/SettingsExportLogs.qml (.../SettingsExportLogs.qml) (revision 80b5e8f1ebb90c03c37d90d90cd2da3bd95d6803) +++ sources/gui/qml/pages/settings/SettingsExportLogs.qml (.../SettingsExportLogs.qml) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -298,8 +298,9 @@ height : Variables.touchRectHeight radius : Variables.touchRectRadius border.width : Variables.borderWidth - enabled : _GuiView.usbIsReady && !_GuiView.exportRunning && ! isUpdatePanels - onClicked : doExport() + enabled : true + isCancelShown : _GuiView.usbIsReady && _GuiView.exportRunning && ! isUpdatePanels + onClicked : isCancelShown ? _GuiView.doCancelLogExport() : doExport() } } Column { id : _sdcFolderColumn Index: sources/storage/FileHandler.h =================================================================== diff -u -r1ed15b374613c81883e697cad25e55399e7abc17 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/storage/FileHandler.h (.../FileHandler.h) (revision 1ed15b374613c81883e697cad25e55399e7abc17) +++ sources/storage/FileHandler.h (.../FileHandler.h) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -54,6 +54,7 @@ eSrcReadError , eDstWriteError , eDstFlushError , + eDstRemoveError , }; public: @@ -87,7 +88,7 @@ * \return */ template - static int copyFile(const QString &vSource, const QString &vDestination, const QString &vFileName, const NotifierFunction *notifier = nullptr, quint32 vIndex = 0) + static int copyFile(const QString &vSource, const QString &vDestination, const QString &vFileName, const NotifierFunction *notifier = nullptr, quint32 vIndex = 0, bool *vIsCancelled = nullptr) { FileCopyError_Enums err = eOK; QDir srcDir = QFileInfo (vSource ).absoluteDir(); @@ -123,6 +124,7 @@ qDebug() << "Dst: " << vDestination; while ( copySize ) { + if(vIsCancelled && *vIsCancelled) break; char chunkData[chunkSize] = {}; const qint64 readSize = srcFile.read (chunkData, chunkSize); if ( readSize < 0 ) { err = eSrcOpenError ; goto lErr; } @@ -155,6 +157,12 @@ if ( ! dstFile.flush() ) { err = eDstFlushError ; goto lErr; } dstFile.close(); + if ( vIsCancelled && *vIsCancelled ) + { + // remove the log partially copied when cancel happened + if ( !dstFile.remove() ) { err = eDstRemoveError ; goto lErr; } + } + qDebug() << "\nFinish"; return eOK; Index: sources/storage/Logger.cpp =================================================================== diff -u -r1ed15b374613c81883e697cad25e55399e7abc17 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/storage/Logger.cpp (.../Logger.cpp) (revision 1ed15b374613c81883e697cad25e55399e7abc17) +++ sources/storage/Logger.cpp (.../Logger.cpp) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -691,6 +691,8 @@ // Check USB disk space before proceeding if ( !checkExportUSBSpace(vExportList, mSource) ) return false; + m_cancelExport = false; + if ( vExportList.isEmpty() ) { // Copy Folder result = FileHandler::copyFolder( mSource, mDestination); @@ -702,7 +704,12 @@ // qDebug() << it.key() << it.value() << mSource << mDestination; auto index = it.key (); auto filename = it.value(); - result = FileHandler::copyFile(mSource, mDestination + _logBasePathNames[vLogType], filename, ¬ifier, index); + result = FileHandler::copyFile(mSource, mDestination + _logBasePathNames[vLogType], filename, ¬ifier, index, &m_cancelExport); + if (m_cancelExport) + { + result = FileHandler::eOK; + break; + } } } return result >= 0; // refer to QProcess::execute(hit F1 on execute) doc. @@ -743,6 +750,7 @@ } } - //DEBUG: qDebug()<< "available " << availableSpace << " | total "<< totalSpace << " | size copying " << totalExportSizeExpected << " | expecting after " << (availableSpace + totalExportSizeExpected); - return (availableSpace + totalExportSizeExpected) < totalSpace; + qint64 spaceUsed = totalSpace - availableSpace; + //DEBUG: qDebug()<< ((spaceUsed + totalExportSizeExpected) < totalSpace) << "available " << availableSpace << " | total "<< totalSpace << " | size copying " << totalExportSizeExpected ; + return (spaceUsed + totalExportSizeExpected) < totalSpace; } Index: sources/storage/Logger.h =================================================================== diff -u -r1ed15b374613c81883e697cad25e55399e7abc17 -rfe3f53cba411ccc253f7b86ac0f9f899d2cb0630 --- sources/storage/Logger.h (.../Logger.h) (revision 1ed15b374613c81883e697cad25e55399e7abc17) +++ sources/storage/Logger.h (.../Logger.h) (revision fe3f53cba411ccc253f7b86ac0f9f899d2cb0630) @@ -160,8 +160,9 @@ bool init(); bool init(QThread &vThread); void quit(); - + void cancelExport() { m_cancelExport = true; } private: + bool m_cancelExport = false; void initConnections(); void initThread(QThread &vThread);