mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
OP-1119 Added cancel functionality on download. Added soem more gui update logic.
This commit is contained in:
parent
a3c555f8bb
commit
74ad0fd40a
@ -146,7 +146,7 @@ Rectangle {
|
||||
height: 40
|
||||
Button {
|
||||
id: exportButton
|
||||
enabled: !logManager.disableControls
|
||||
enabled: !logManager.disableControls && !logManager.disableExport
|
||||
text: qsTr("Export...")
|
||||
activeFocusOnPress: true
|
||||
onClicked: logManager.exportLogs()
|
||||
@ -161,10 +161,18 @@ Rectangle {
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
Button {
|
||||
id: cancelButton
|
||||
enabled: logManager.disableControls
|
||||
text: qsTr("Cancel")
|
||||
activeFocusOnPress: true
|
||||
onClicked: logManager.cancelExportLogs()
|
||||
}
|
||||
Button {
|
||||
id: okButton
|
||||
enabled: !logManager.disableControls
|
||||
text: qsTr("OK")
|
||||
isDefault: true
|
||||
activeFocusOnPress: true
|
||||
onClicked: dialog.close()
|
||||
}
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include "utils/logfile.h"
|
||||
|
||||
FlightLogManager::FlightLogManager(QObject *parent) :
|
||||
QObject(parent), m_disableControls(false)
|
||||
QObject(parent), m_disableControls(false), m_cancelDownload(false)
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
|
||||
@ -121,6 +121,7 @@ void FlightLogManager::clearLogList()
|
||||
m_logEntries.clear();
|
||||
|
||||
emit logEntriesChanged();
|
||||
setDisableExport(true);
|
||||
|
||||
while (!tmpList.isEmpty()) {
|
||||
delete tmpList.takeFirst();
|
||||
@ -131,7 +132,7 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
||||
{
|
||||
setDisableControls(true);
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
m_cancelDownload = false;
|
||||
UAVObjectUpdaterHelper updateHelper;
|
||||
UAVObjectRequestHelper requestHelper;
|
||||
|
||||
@ -169,16 +170,30 @@ void FlightLogManager::retrieveLogs(int flightToRetrieve)
|
||||
// We failed for some reason
|
||||
break;
|
||||
}
|
||||
if (m_cancelDownload) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m_cancelDownload) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_cancelDownload) {
|
||||
clearLogList();
|
||||
m_cancelDownload = false;
|
||||
}
|
||||
|
||||
emit logEntriesChanged();
|
||||
setDisableExport(m_logEntries.count() == 0);
|
||||
|
||||
QApplication::restoreOverrideCursor();
|
||||
setDisableControls(false);
|
||||
}
|
||||
|
||||
void FlightLogManager::exportLogs()
|
||||
{
|
||||
if(m_flightEntries.isEmpty()) {
|
||||
if(m_logEntries.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -231,6 +246,11 @@ void FlightLogManager::exportLogs()
|
||||
setDisableControls(false);
|
||||
}
|
||||
|
||||
void FlightLogManager::cancelExportLogs()
|
||||
{
|
||||
m_cancelDownload = true;
|
||||
}
|
||||
|
||||
void FlightLogManager::updateFlightEntries(quint16 currentFlight)
|
||||
{
|
||||
Q_UNUSED(currentFlight);
|
||||
|
@ -71,6 +71,7 @@ class FlightLogManager : public QObject {
|
||||
Q_PROPERTY(QQmlListProperty<ExtendedDebugLogEntry> logEntries READ logEntries NOTIFY logEntriesChanged)
|
||||
Q_PROPERTY(QStringList flightEntries READ flightEntries NOTIFY flightEntriesChanged)
|
||||
Q_PROPERTY(bool disableControls READ disableControls WRITE setDisableControls NOTIFY disableControlsChanged)
|
||||
Q_PROPERTY(bool disableExport READ disableExport WRITE setDisableExport NOTIFY disableExportChanged)
|
||||
|
||||
public:
|
||||
explicit FlightLogManager(QObject *parent = 0);
|
||||
@ -89,18 +90,24 @@ public:
|
||||
return m_disableControls;
|
||||
}
|
||||
|
||||
bool disableExport() const
|
||||
{
|
||||
return m_disableExport;
|
||||
}
|
||||
|
||||
void clearLogList();
|
||||
|
||||
signals:
|
||||
void logEntriesChanged();
|
||||
void flightEntriesChanged();
|
||||
void disableControlsChanged(bool arg);
|
||||
|
||||
void disableExportChanged(bool arg);
|
||||
|
||||
public slots:
|
||||
void clearAllLogs();
|
||||
void retrieveLogs(int flightToRetrieve = -1);
|
||||
void exportLogs();
|
||||
void cancelExportLogs();
|
||||
|
||||
void setDisableControls(bool arg)
|
||||
{
|
||||
@ -110,6 +117,14 @@ public slots:
|
||||
}
|
||||
}
|
||||
|
||||
void setDisableExport(bool arg)
|
||||
{
|
||||
if (m_disableExport != arg) {
|
||||
m_disableExport = arg;
|
||||
emit disableExportChanged(arg);
|
||||
}
|
||||
}
|
||||
|
||||
private slots:
|
||||
void updateFlightEntries(quint16 currentFlight);
|
||||
|
||||
@ -123,6 +138,8 @@ private:
|
||||
|
||||
static const int UAVTALK_TIMEOUT = 4000;
|
||||
bool m_disableControls;
|
||||
bool m_disableExport;
|
||||
bool m_cancelDownload;
|
||||
};
|
||||
|
||||
#endif // FLIGHTLOGMANAGER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user