Commit 42288925 authored by Gus Grubba's avatar Gus Grubba

Remove QtWidget dialogs from GeoTag

Cleanup GeoTag UI
parent 29f66547
...@@ -17,22 +17,25 @@ import QGroundControl.ScreenTools 1.0 ...@@ -17,22 +17,25 @@ import QGroundControl.ScreenTools 1.0
/// Base view control for all Analyze pages /// Base view control for all Analyze pages
Item { Item {
anchors.fill: parent anchors.fill: parent
anchors.margins: ScreenTools.defaultFontPixelWidth
property alias pageComponent: pageLoader.sourceComponent property alias pageComponent: pageLoader.sourceComponent
property alias pageName: pageNameLabel.text property alias pageName: pageNameLabel.text
property alias pageDescription: pageDescriptionLabel.text property alias pageDescription: pageDescriptionLabel.text
property real availableWidth: width - pageLoader.x property real availableWidth: width - pageLoader.x
property real availableHeight: height - pageLoader.y property real availableHeight: height - pageLoader.y
property real _margins: ScreenTools.defaultFontPixelHeight * 0.5 property real _margins: ScreenTools.defaultFontPixelHeight * 0.5
QGCFlickable { QGCFlickable {
anchors.fill: parent anchors.fill: parent
contentWidth: pageLoader.x + pageLoader.item.width contentWidth: pageLoader.x + pageLoader.item.width
contentHeight: pageLoader.y + pageLoader.item.height contentHeight: pageLoader.y + pageLoader.item.height
clip: true clip: true
Column { Column {
id: headingColumn id: headingColumn
width: parent.width width: parent.width
spacing: _margins spacing: _margins
QGCLabel { QGCLabel {
id: pageNameLabel id: pageNameLabel
font.pointSize: ScreenTools.largeFontPointSize font.pointSize: ScreenTools.largeFontPointSize
......
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include "ULogParser.h" #include "ULogParser.h"
#include "PX4LogParser.h" #include "PX4LogParser.h"
static const char* kTagged = "/TAGGED";
GeoTagController::GeoTagController() GeoTagController::GeoTagController()
: _progress(0) : _progress(0)
, _inProgress(false) , _inProgress(false)
...@@ -52,7 +54,16 @@ void GeoTagController::setImageDirectory(QString dir) ...@@ -52,7 +54,16 @@ void GeoTagController::setImageDirectory(QString dir)
if (!dir.isEmpty()) { if (!dir.isEmpty()) {
_worker.setImageDirectory(dir); _worker.setImageDirectory(dir);
emit imageDirectoryChanged(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) void GeoTagController::setSaveDirectory(QString dir)
...@@ -61,37 +72,36 @@ void GeoTagController::setSaveDirectory(QString dir) ...@@ -61,37 +72,36 @@ void GeoTagController::setSaveDirectory(QString dir)
if (!dir.isEmpty()) { if (!dir.isEmpty()) {
_worker.setSaveDirectory(dir); _worker.setSaveDirectory(dir);
emit saveDirectoryChanged(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() void GeoTagController::startTagging()
{ {
_errorMessage.clear(); _errorMessage.clear();
emit errorMessageChanged(_errorMessage); emit errorMessageChanged(_errorMessage);
QDir imageDirectory = QDir(_worker.imageDirectory()); QDir imageDirectory = QDir(_worker.imageDirectory());
if(!imageDirectory.exists()) { if(!imageDirectory.exists()) {
_setErrorMessage(tr("Cannot find the image directory")); _setErrorMessage(tr("Cannot find the image directory."));
return; return;
} }
if(_worker.saveDirectory() == "") { if(_worker.saveDirectory() == "") {
if(!imageDirectory.mkdir(_worker.imageDirectory() + "/TAGGED")) { QDir oldTaggedFolder = QDir(_worker.imageDirectory() + kTagged);
//--TODO: if(oldTaggedFolder.exists()) {
/*
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");
oldTaggedFolder.removeRecursively(); oldTaggedFolder.removeRecursively();
if(!imageDirectory.mkdir(_worker.imageDirectory() + "/TAGGED")) { if(!imageDirectory.mkdir(_worker.imageDirectory() + kTagged)) {
_setErrorMessage(tr("Couldn't replace the previously tagged images")); _setErrorMessage(tr("Couldn't replace the previously tagged images"));
return; return;
} }
...@@ -99,36 +109,9 @@ void GeoTagController::startTagging() ...@@ -99,36 +109,9 @@ void GeoTagController::startTagging()
} else { } else {
QDir saveDirectory = QDir(_worker.saveDirectory()); QDir saveDirectory = QDir(_worker.saveDirectory());
if(!saveDirectory.exists()) { if(!saveDirectory.exists()) {
_setErrorMessage(tr("Cannot find the save directory")); _setErrorMessage(tr("Cannot find the save directory."));
return; 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(); _worker.start();
} }
...@@ -321,17 +304,14 @@ bool GeoTagWorker::triggerFiltering() ...@@ -321,17 +304,14 @@ bool GeoTagWorker::triggerFiltering()
{ {
_imageIndices.clear(); _imageIndices.clear();
_triggerIndices.clear(); _triggerIndices.clear();
if(_imageList.count() > _triggerList.count()) { // Logging dropouts if(_imageList.count() > _triggerList.count()) { // Logging dropouts
qCDebug(GeotaggingLog) << "Detected missing feedback packets."; qCDebug(GeotaggingLog) << "Detected missing feedback packets.";
} else if (_imageList.count() < _triggerList.count()) { // Camera skipped frames } else if (_imageList.count() < _triggerList.count()) { // Camera skipped frames
qCDebug(GeotaggingLog) << "Detected missing image frames."; qCDebug(GeotaggingLog) << "Detected missing image frames.";
} }
for(int i = 0; i < _imageList.count() && i < _triggerList.count(); i++) { for(int i = 0; i < _imageList.count() && i < _triggerList.count(); i++) {
_imageIndices.append(_triggerList[i].imageSequence); _imageIndices.append(static_cast<int>(_triggerList[i].imageSequence));
_triggerIndices.append(i); _triggerIndices.append(i);
} }
return true; return true;
} }
...@@ -33,40 +33,34 @@ AnalyzePage { ...@@ -33,40 +33,34 @@ AnalyzePage {
Component { Component {
id: pageComponent id: pageComponent
GridLayout { GridLayout {
columns: 3 columns: 2
columnSpacing: _margin columnSpacing: _margin
rowSpacing: ScreenTools.defaultFontPixelWidth * 2 rowSpacing: ScreenTools.defaultFontPixelWidth * 2
width: availableWidth 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 { ProgressBar {
id: progressBar id: progressBar
to: 100 to: 100
value: geoController.progress value: geoController.progress
opacity: geoController.progress > 0 ? 1 : 0.25
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter 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 { QGCLabel {
text: geoController.errorMessage text: geoController.errorMessage
font.bold: true
font.pointSize: ScreenTools.largeFontPointSize
color: "red" color: "red"
Layout.columnSpan: 3 font.family: ScreenTools.demiboldFontFamily
} font.pointSize: ScreenTools.mediumFontPointSize
//----------------------------------------------------------------- horizontalAlignment:Text.AlignHCenter
//-- Horizontal spacer line Layout.alignment: Qt.AlignHCenter
Rectangle { Layout.columnSpan: 2
height: 1
color: qgcPal.windowShadeDark
Layout.fillWidth: true
Layout.columnSpan: 3
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Log File //-- Log File
...@@ -95,7 +89,6 @@ AnalyzePage { ...@@ -95,7 +89,6 @@ AnalyzePage {
elide: Text.ElideLeft elide: Text.ElideLeft
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.columnSpan: 2
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Image Directory //-- Image Directory
...@@ -113,7 +106,7 @@ AnalyzePage { ...@@ -113,7 +106,7 @@ AnalyzePage {
selectFolder: true selectFolder: true
selectExisting: true selectExisting: true
onAccepted: { onAccepted: {
geoController.selectImageDir = openLogFile.folder geoController.imageDirectory = selectImageDir.folder
close() close()
} }
} }
...@@ -123,7 +116,6 @@ AnalyzePage { ...@@ -123,7 +116,6 @@ AnalyzePage {
elide: Text.ElideLeft elide: Text.ElideLeft
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.columnSpan: 2
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Save Directory //-- Save Directory
...@@ -147,27 +139,19 @@ AnalyzePage { ...@@ -147,27 +139,19 @@ AnalyzePage {
} }
} }
QGCLabel { 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 elide: Text.ElideLeft
Layout.fillWidth: true Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
Layout.columnSpan: 2
}
//-----------------------------------------------------------------
//-- Horizontal spacer line
Rectangle {
height: 1
color: qgcPal.windowShadeDark
Layout.fillWidth: true
Layout.columnSpan: 3
} }
//----------------------------------------------------------------- //-----------------------------------------------------------------
//-- Execute //-- Execute
QGCButton { QGCButton {
text: geoController.inProgress ? qsTr("Cancel Tagging") : qsTr("Start Tagging") text: geoController.inProgress ? qsTr("Cancel Tagging") : qsTr("Start Tagging")
width: ScreenTools.defaultFontPixelWidth * 30 width: ScreenTools.defaultFontPixelWidth * 30
enabled: (geoController.imageDirectory !== "" && geoController.logFile !== "") || geoController.inProgress
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.columnSpan: 3 Layout.columnSpan: 2
onClicked: { onClicked: {
if (geoController.inProgress) { if (geoController.inProgress) {
geoController.cancelTagging() geoController.cancelTagging()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment