diff --git a/src/AnalyzeView/AnalyzePage.qml b/src/AnalyzeView/AnalyzePage.qml index b3d3bdb66e3470e658aff22ea8c8327928fd99d5..e4597e8601756d7fe9ead9349d218938b189150e 100644 --- a/src/AnalyzeView/AnalyzePage.qml +++ b/src/AnalyzeView/AnalyzePage.qml @@ -17,22 +17,25 @@ import QGroundControl.ScreenTools 1.0 /// Base view control for all Analyze pages Item { - anchors.fill: parent + anchors.fill: parent + anchors.margins: ScreenTools.defaultFontPixelWidth + property alias pageComponent: pageLoader.sourceComponent property alias pageName: pageNameLabel.text property alias pageDescription: pageDescriptionLabel.text property real availableWidth: width - pageLoader.x property real availableHeight: height - pageLoader.y property real _margins: ScreenTools.defaultFontPixelHeight * 0.5 + QGCFlickable { - anchors.fill: parent - contentWidth: pageLoader.x + pageLoader.item.width - contentHeight: pageLoader.y + pageLoader.item.height - clip: true + anchors.fill: parent + contentWidth: pageLoader.x + pageLoader.item.width + contentHeight: pageLoader.y + pageLoader.item.height + clip: true Column { - id: headingColumn - width: parent.width - spacing: _margins + id: headingColumn + width: parent.width + spacing: _margins QGCLabel { id: pageNameLabel font.pointSize: ScreenTools.largeFontPointSize diff --git a/src/AnalyzeView/GeoTagController.cc b/src/AnalyzeView/GeoTagController.cc index a9f853878cbcb703e2fe23148b6d01c9b7da047f..dce5469f8e772fa31e4732576095856c09fed3cc 100644 --- a/src/AnalyzeView/GeoTagController.cc +++ b/src/AnalyzeView/GeoTagController.cc @@ -22,6 +22,8 @@ #include "ULogParser.h" #include "PX4LogParser.h" +static const char* kTagged = "/TAGGED"; + GeoTagController::GeoTagController() : _progress(0) , _inProgress(false) @@ -52,7 +54,16 @@ void GeoTagController::setImageDirectory(QString dir) if (!dir.isEmpty()) { _worker.setImageDirectory(dir); emit imageDirectoryChanged(dir); + if(_worker.saveDirectory() == "") { + QDir saveDirectory = QDir(_worker.imageDirectory() + kTagged); + if(saveDirectory.exists()) { + _setErrorMessage(tr("Images have alreay been tagged. Existing images will be removed.")); + return; + } + } } + _errorMessage.clear(); + emit errorMessageChanged(_errorMessage); } void GeoTagController::setSaveDirectory(QString dir) @@ -61,37 +72,36 @@ void GeoTagController::setSaveDirectory(QString dir) if (!dir.isEmpty()) { _worker.setSaveDirectory(dir); emit saveDirectoryChanged(dir); + //-- Check and see if there are images already there + QDir saveDirectory = QDir(_worker.saveDirectory()); + saveDirectory.setFilter(QDir::Files | QDir::Readable | QDir::NoSymLinks | QDir::Writable); + QStringList nameFilters; + nameFilters << "*.jpg" << "*.JPG"; + saveDirectory.setNameFilters(nameFilters); + QStringList imageList = saveDirectory.entryList(); + if(!imageList.isEmpty()) { + _setErrorMessage(tr("The save folder already contains images.")); + return; + } } + _errorMessage.clear(); + emit errorMessageChanged(_errorMessage); } void GeoTagController::startTagging() { _errorMessage.clear(); emit errorMessageChanged(_errorMessage); - QDir imageDirectory = QDir(_worker.imageDirectory()); if(!imageDirectory.exists()) { - _setErrorMessage(tr("Cannot find the image directory")); + _setErrorMessage(tr("Cannot find the image directory.")); return; } if(_worker.saveDirectory() == "") { - if(!imageDirectory.mkdir(_worker.imageDirectory() + "/TAGGED")) { - //--TODO: - /* - QMessageBox msgBox(QMessageBox::Question, - tr("Images have alreay been tagged."), - tr("The images have already been tagged. Do you want to replace the previously tagged images?"), - QMessageBox::Cancel); - msgBox.setWindowModality(Qt::ApplicationModal); - msgBox.addButton(tr("Replace"), QMessageBox::ActionRole); - if (msgBox.exec() == QMessageBox::Cancel) { - _setErrorMessage(tr("Images have already been tagged")); - return; - } - */ - QDir oldTaggedFolder = QDir(_worker.imageDirectory() + "/TAGGED"); + QDir oldTaggedFolder = QDir(_worker.imageDirectory() + kTagged); + if(oldTaggedFolder.exists()) { oldTaggedFolder.removeRecursively(); - if(!imageDirectory.mkdir(_worker.imageDirectory() + "/TAGGED")) { + if(!imageDirectory.mkdir(_worker.imageDirectory() + kTagged)) { _setErrorMessage(tr("Couldn't replace the previously tagged images")); return; } @@ -99,36 +109,9 @@ void GeoTagController::startTagging() } else { QDir saveDirectory = QDir(_worker.saveDirectory()); if(!saveDirectory.exists()) { - _setErrorMessage(tr("Cannot find the save directory")); + _setErrorMessage(tr("Cannot find the save directory.")); return; } - saveDirectory.setFilter(QDir::Files | QDir::Readable | QDir::NoSymLinks | QDir::Writable); - QStringList nameFilters; - nameFilters << "*.jpg" << "*.JPG"; - saveDirectory.setNameFilters(nameFilters); - QStringList imageList = saveDirectory.entryList(); - if(!imageList.isEmpty()) { - //--TODO: - /* - QMessageBox msgBox(QMessageBox::Question, - tr("Save folder not empty."), - tr("The save folder already contains images. Do you want to replace them?"), - QMessageBox::Cancel); - msgBox.setWindowModality(Qt::ApplicationModal); - msgBox.addButton(tr("Replace"), QMessageBox::ActionRole); - if (msgBox.exec() == QMessageBox::Cancel) { - _setErrorMessage(tr("Save folder not empty")); - return; - } - */ - for(QString dirFile: imageList) - { - if(!saveDirectory.remove(dirFile)) { - _setErrorMessage(tr("Couldn't replace the existing images")); - return; - } - } - } } _worker.start(); } @@ -321,17 +304,14 @@ bool GeoTagWorker::triggerFiltering() { _imageIndices.clear(); _triggerIndices.clear(); - if(_imageList.count() > _triggerList.count()) { // Logging dropouts qCDebug(GeotaggingLog) << "Detected missing feedback packets."; } else if (_imageList.count() < _triggerList.count()) { // Camera skipped frames qCDebug(GeotaggingLog) << "Detected missing image frames."; } - for(int i = 0; i < _imageList.count() && i < _triggerList.count(); i++) { - _imageIndices.append(_triggerList[i].imageSequence); + _imageIndices.append(static_cast(_triggerList[i].imageSequence)); _triggerIndices.append(i); } - return true; } diff --git a/src/AnalyzeView/GeoTagPage.qml b/src/AnalyzeView/GeoTagPage.qml index 7cf3270b31f99d9461b74bc81bf7c08eb630ca3e..f4aeb003a6f70098b8127ecca1561759c645957d 100644 --- a/src/AnalyzeView/GeoTagPage.qml +++ b/src/AnalyzeView/GeoTagPage.qml @@ -33,40 +33,34 @@ AnalyzePage { Component { id: pageComponent GridLayout { - columns: 3 + columns: 2 columnSpacing: _margin rowSpacing: ScreenTools.defaultFontPixelWidth * 2 width: availableWidth + BusyIndicator { + running: geoController.progress > 0 && geoController.progress < 100 && geoController.errorMessage === "" + width: progressBar.height + height: progressBar.height + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter + } //----------------------------------------------------------------- ProgressBar { id: progressBar to: 100 value: geoController.progress + opacity: geoController.progress > 0 ? 1 : 0.25 Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter - Layout.columnSpan: 2 - } - BusyIndicator { - running: geoController.progress > 0 && geoController.progress < 100 && geoController.errorMessage === "" - width: progressBar.height - height: progressBar.height - Layout.alignment: Qt.AlignVCenter } //----------------------------------------------------------------- QGCLabel { text: geoController.errorMessage - font.bold: true - font.pointSize: ScreenTools.largeFontPointSize color: "red" - Layout.columnSpan: 3 - } - //----------------------------------------------------------------- - //-- Horizontal spacer line - Rectangle { - height: 1 - color: qgcPal.windowShadeDark - Layout.fillWidth: true - Layout.columnSpan: 3 + font.family: ScreenTools.demiboldFontFamily + font.pointSize: ScreenTools.mediumFontPointSize + horizontalAlignment:Text.AlignHCenter + Layout.alignment: Qt.AlignHCenter + Layout.columnSpan: 2 } //----------------------------------------------------------------- //-- Log File @@ -95,7 +89,6 @@ AnalyzePage { elide: Text.ElideLeft Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter - Layout.columnSpan: 2 } //----------------------------------------------------------------- //-- Image Directory @@ -113,7 +106,7 @@ AnalyzePage { selectFolder: true selectExisting: true onAccepted: { - geoController.selectImageDir = openLogFile.folder + geoController.imageDirectory = selectImageDir.folder close() } } @@ -123,7 +116,6 @@ AnalyzePage { elide: Text.ElideLeft Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter - Layout.columnSpan: 2 } //----------------------------------------------------------------- //-- Save Directory @@ -147,27 +139,19 @@ AnalyzePage { } } QGCLabel { - text: geoController.saveDirectory !== "" ? geoController.saveDirectory : "/TAGGED folder in your image folder" + text: geoController.saveDirectory === "" ? (geoController.imageDirectory === "" ? "/TAGGED folder in your image folder" : geoController.imageDirectory + "/TAGGED") : geoController.saveDirectory elide: Text.ElideLeft Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter - Layout.columnSpan: 2 - } - //----------------------------------------------------------------- - //-- Horizontal spacer line - Rectangle { - height: 1 - color: qgcPal.windowShadeDark - Layout.fillWidth: true - Layout.columnSpan: 3 } //----------------------------------------------------------------- //-- Execute QGCButton { text: geoController.inProgress ? qsTr("Cancel Tagging") : qsTr("Start Tagging") width: ScreenTools.defaultFontPixelWidth * 30 + enabled: (geoController.imageDirectory !== "" && geoController.logFile !== "") || geoController.inProgress Layout.alignment: Qt.AlignHCenter - Layout.columnSpan: 3 + Layout.columnSpan: 2 onClicked: { if (geoController.inProgress) { geoController.cancelTagging()