1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-1174 uncrustified

This commit is contained in:
Philippe Renon 2014-05-05 00:05:51 +02:00
parent 1e803c292b
commit e3e92efc70
4 changed files with 45 additions and 32 deletions

View File

@ -38,6 +38,7 @@ void AutoUpdatePage::enableButtons(bool enable = false)
void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant value) void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant value)
{ {
QString msg; QString msg;
switch (status) { switch (status) {
case uploader::WAITING_DISCONNECT: case uploader::WAITING_DISCONNECT:
disableButtons(); disableButtons();
@ -53,9 +54,9 @@ void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant valu
// Side effect is that the wizard dialog flickers // Side effect is that the wizard dialog flickers
// the uploader was changed to avoid popups alltogether and that fix is not need anymore // the uploader was changed to avoid popups alltogether and that fix is not need anymore
// same commented fix can be found in FAILURE case and they are kept for future ref. // same commented fix can be found in FAILURE case and they are kept for future ref.
//getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint); // getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint);
//getWizard()->setWindowIcon(qApp->windowIcon()); // getWizard()->setWindowIcon(qApp->windowIcon());
//getWizard()->show(); // getWizard()->show();
// End of Note // End of Note
disableButtons(); disableButtons();
ui->statusLabel->setText(tr("Please connect the board to the USB port (don't use external supply).")); ui->statusLabel->setText(tr("Please connect the board to the USB port (don't use external supply)."));
@ -86,8 +87,8 @@ void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant valu
ui->statusLabel->setText(tr("Board updated, please press 'Next' to continue.")); ui->statusLabel->setText(tr("Board updated, please press 'Next' to continue."));
break; break;
case uploader::FAILURE: case uploader::FAILURE:
//getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint); // getWizard()->setWindowFlags(getWizard()->windowFlags() | Qt::WindowStaysOnTopHint);
//getWizard()->setWindowIcon(qApp->windowIcon()); // getWizard()->setWindowIcon(qApp->windowIcon());
enableButtons(true); enableButtons(true);
QString msg = value.toString(); QString msg = value.toString();
if (msg.isEmpty()) { if (msg.isEmpty()) {

View File

@ -48,8 +48,7 @@
#include <QCheckBox> #include <QCheckBox>
TelemetryPlugin::TelemetryPlugin() : firmwareWarningMessageBox(0) TelemetryPlugin::TelemetryPlugin() : firmwareWarningMessageBox(0)
{ {}
}
TelemetryPlugin::~TelemetryPlugin() TelemetryPlugin::~TelemetryPlugin()
{ {
@ -107,6 +106,7 @@ void TelemetryPlugin::shutdown()
{ {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
TelemetryManager *telMngr = pm->getObject<TelemetryManager>(); TelemetryManager *telMngr = pm->getObject<TelemetryManager>();
disconnect(telMngr, SIGNAL(connected()), this, SLOT(versionMatchCheck())); disconnect(telMngr, SIGNAL(connected()), this, SLOT(versionMatchCheck()));
if (firmwareWarningMessageBox) { if (firmwareWarningMessageBox) {
@ -121,6 +121,7 @@ void TelemetryPlugin::versionMatchCheck()
deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct(); deviceDescriptorStruct boardDescription = utilMngr->getBoardDescriptionStruct();
QString uavoHash = VersionInfo::uavoHashArray(); QString uavoHash = VersionInfo::uavoHashArray();
uavoHash.chop(2); uavoHash.chop(2);
uavoHash.remove(0, 2); uavoHash.remove(0, 2);
uavoHash = uavoHash.trimmed(); uavoHash = uavoHash.trimmed();
@ -132,7 +133,7 @@ void TelemetryPlugin::versionMatchCheck()
} }
QByteArray fwVersion = boardDescription.uavoHash; QByteArray fwVersion = boardDescription.uavoHash;
if (true) {//fwVersion != uavoHashArray) { if (fwVersion != uavoHashArray) {
QString gcsDescription = VersionInfo::revision(); QString gcsDescription = VersionInfo::revision();
QString gcsGitHash = gcsDescription.mid(gcsDescription.indexOf(":") + 1, 8); QString gcsGitHash = gcsDescription.mid(gcsDescription.indexOf(":") + 1, 8);
gcsGitHash.remove(QRegExp("^[0]*")); gcsGitHash.remove(QRegExp("^[0]*"));
@ -147,8 +148,8 @@ void TelemetryPlugin::versionMatchCheck()
gcsUavoHashStr.append(QString::number(i, 16).right(2)); gcsUavoHashStr.append(QString::number(i, 16).right(2));
} }
QString versionFormat = "%1 (%2-%3)"; QString versionFormat = "%1 (%2-%3)";
QString gcsVersion = versionFormat.arg(gcsGitDate, gcsGitHash, gcsUavoHashStr.left(8)); QString gcsVersion = versionFormat.arg(gcsGitDate, gcsGitHash, gcsUavoHashStr.left(8));
QString fwVersion = versionFormat.arg(boardDescription.gitDate, boardDescription.gitHash, fwUavoHashStr.left(8)); QString fwVersion = versionFormat.arg(boardDescription.gitDate, boardDescription.gitHash, fwUavoHashStr.left(8));
if (!firmwareWarningMessageBox) { if (!firmwareWarningMessageBox) {
firmwareWarningMessageBox = new QMessageBox(Core::ICore::instance()->mainWindow()); firmwareWarningMessageBox = new QMessageBox(Core::ICore::instance()->mainWindow());
@ -158,7 +159,7 @@ void TelemetryPlugin::versionMatchCheck()
firmwareWarningMessageBox->setStandardButtons(QMessageBox::Ok); firmwareWarningMessageBox->setStandardButtons(QMessageBox::Ok);
firmwareWarningMessageBox->setText(tr("GCS and firmware versions of the UAV objects set do not match which can cause configuration problems.")); firmwareWarningMessageBox->setText(tr("GCS and firmware versions of the UAV objects set do not match which can cause configuration problems."));
// should we want to re-introduce the checkbox // should we want to re-introduce the checkbox
//firmwareWarningMessageBox->setCheckBox(new QCheckBox(tr("&Don't show this message again."))); // firmwareWarningMessageBox->setCheckBox(new QCheckBox(tr("&Don't show this message again.")));
} }
QString detailTxt = tr("GCS version: %1").arg(gcsVersion) + "\n" + tr("Firmware version: %1").arg(fwVersion); QString detailTxt = tr("GCS version: %1").arg(gcsVersion) + "\n" + tr("Firmware version: %1").arg(fwVersion);
firmwareWarningMessageBox->setDetailedText(detailTxt); firmwareWarningMessageBox->setDetailedText(detailTxt);

View File

@ -27,7 +27,7 @@
#include "uploadergadgetwidget.h" #include "uploadergadgetwidget.h"
#include "flightstatus.h" #include "flightstatus.h"
//#include "delay.h" #include "delay.h"
#include "devicewidget.h" #include "devicewidget.h"
#include "runningdevicewidget.h" #include "runningdevicewidget.h"
@ -48,7 +48,7 @@ const int UploaderGadgetWidget::BOARD_EVENT_TIMEOUT = 20000;
const int UploaderGadgetWidget::AUTOUPDATE_CLOSE_TIMEOUT = 7000; const int UploaderGadgetWidget::AUTOUPDATE_CLOSE_TIMEOUT = 7000;
TimedDialog::TimedDialog(const QString &title, const QString &labelText, int timeout, QWidget *parent, Qt::WindowFlags flags) : TimedDialog::TimedDialog(const QString &title, const QString &labelText, int timeout, QWidget *parent, Qt::WindowFlags flags) :
QProgressDialog(labelText, tr("Cancel"), 0, timeout, parent, flags), bar(new QProgressBar(this)) QProgressDialog(labelText, tr("Cancel"), 0, timeout, parent, flags), bar(new QProgressBar(this))
{ {
setWindowTitle(title); setWindowTitle(title);
setAutoReset(false); setAutoReset(false);
@ -72,10 +72,10 @@ void TimedDialog::perform()
} }
ConnectionWaiter::ConnectionWaiter(int targetDeviceCount, int timeout, QWidget *parent) : QObject(parent), eventLoop(this), timer(this), timeout(timeout), elapsed(0), targetDeviceCount(targetDeviceCount), result(ConnectionWaiter::Ok) ConnectionWaiter::ConnectionWaiter(int targetDeviceCount, int timeout, QWidget *parent) : QObject(parent), eventLoop(this), timer(this), timeout(timeout), elapsed(0), targetDeviceCount(targetDeviceCount), result(ConnectionWaiter::Ok)
{ {}
}
int ConnectionWaiter::exec() { int ConnectionWaiter::exec()
{
connect(USBMonitor::instance(), SIGNAL(deviceDiscovered(USBPortInfo)), this, SLOT(deviceEvent())); connect(USBMonitor::instance(), SIGNAL(deviceDiscovered(USBPortInfo)), this, SLOT(deviceEvent()));
connect(USBMonitor::instance(), SIGNAL(deviceRemoved(USBPortInfo)), this, SLOT(deviceEvent())); connect(USBMonitor::instance(), SIGNAL(deviceRemoved(USBPortInfo)), this, SLOT(deviceEvent()));
@ -88,12 +88,14 @@ int ConnectionWaiter::exec() {
return result; return result;
} }
void ConnectionWaiter::cancel() { void ConnectionWaiter::cancel()
{
quit(); quit();
result = ConnectionWaiter::Canceled; result = ConnectionWaiter::Canceled;
} }
void ConnectionWaiter::quit() { void ConnectionWaiter::quit()
{
disconnect(USBMonitor::instance(), SIGNAL(deviceDiscovered(USBPortInfo)), this, SLOT(deviceEvent())); disconnect(USBMonitor::instance(), SIGNAL(deviceDiscovered(USBPortInfo)), this, SLOT(deviceEvent()));
disconnect(USBMonitor::instance(), SIGNAL(deviceRemoved(USBPortInfo)), this, SLOT(deviceEvent())); disconnect(USBMonitor::instance(), SIGNAL(deviceRemoved(USBPortInfo)), this, SLOT(deviceEvent()));
timer.stop(); timer.stop();
@ -118,9 +120,11 @@ void ConnectionWaiter::deviceEvent()
} }
} }
int ConnectionWaiter::openDialog(const QString &title, const QString &labelText, int targetDeviceCount, int timeout, QWidget *parent, Qt::WindowFlags flags) { int ConnectionWaiter::openDialog(const QString &title, const QString &labelText, int targetDeviceCount, int timeout, QWidget *parent, Qt::WindowFlags flags)
{
TimedDialog dlg(title, labelText, timeout / 1000, parent, flags); TimedDialog dlg(title, labelText, timeout / 1000, parent, flags);
ConnectionWaiter waiter(targetDeviceCount, timeout, parent); ConnectionWaiter waiter(targetDeviceCount, timeout, parent);
connect(&dlg, SIGNAL(canceled()), &waiter, SLOT(cancel())); connect(&dlg, SIGNAL(canceled()), &waiter, SLOT(cancel()));
connect(&waiter, SIGNAL(timeChanged(int)), &dlg, SLOT(perform())); connect(&waiter, SIGNAL(timeChanged(int)), &dlg, SLOT(perform()));
return waiter.exec(); return waiter.exec();
@ -140,24 +144,24 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect())); connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect())); connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(onPhysicalHWConnect()));
connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(systemHalt())); connect(m_config->haltButton, SIGNAL(clicked()), this, SLOT(systemHalt()));
connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset())); connect(m_config->resetButton, SIGNAL(clicked()), this, SLOT(systemReset()));
connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot())); connect(m_config->bootButton, SIGNAL(clicked()), this, SLOT(systemBoot()));
connect(m_config->safeBootButton, SIGNAL(clicked()), this, SLOT(systemSafeBoot())); connect(m_config->safeBootButton, SIGNAL(clicked()), this, SLOT(systemSafeBoot()));
connect(m_config->eraseBootButton, SIGNAL(clicked()), this, SLOT(systemEraseBoot())); connect(m_config->eraseBootButton, SIGNAL(clicked()), this, SLOT(systemEraseBoot()));
connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue())); connect(m_config->rescueButton, SIGNAL(clicked()), this, SLOT(systemRescue()));
Core::ConnectionManager *cm = Core::ICore::instance()->connectionManager();
connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(onPhysicalHWConnect()));
getSerialPorts(); getSerialPorts();
m_config->autoUpdateButton->setEnabled(autoUpdateCapable());
connect(m_config->autoUpdateButton, SIGNAL(clicked()), this, SLOT(startAutoUpdate())); connect(m_config->autoUpdateButton, SIGNAL(clicked()), this, SLOT(startAutoUpdate()));
connect(m_config->autoUpdateOkButton, SIGNAL(clicked()), this, SLOT(closeAutoUpdate())); connect(m_config->autoUpdateOkButton, SIGNAL(clicked()), this, SLOT(closeAutoUpdate()));
m_config->autoUpdateButton->setEnabled(autoUpdateCapable());
m_config->autoUpdateGroupBox->setVisible(false); m_config->autoUpdateGroupBox->setVisible(false);
QIcon rbi; m_config->refreshPorts->setIcon(QIcon(":uploader/images/view-refresh.svg"));
rbi.addFile(QString(":uploader/images/view-refresh.svg"));
m_config->refreshPorts->setIcon(rbi);
bootButtonsSetEnable(false); bootButtonsSetEnable(false);
@ -295,6 +299,7 @@ static void sleep(int ms)
{ {
QEventLoop eventLoop; QEventLoop eventLoop;
QTimer::singleShot(ms, &eventLoop, SLOT(quit())); QTimer::singleShot(ms, &eventLoop, SLOT(quit()));
eventLoop.exec(); eventLoop.exec();
} }
@ -466,6 +471,7 @@ void UploaderGadgetWidget::systemHalt()
// The board can not be halted when in armed state. // The board can not be halted when in armed state.
// If board is armed, or arming. Show message with notice. // If board is armed, or arming. Show message with notice.
FlightStatus *status = getFlightStatus(); FlightStatus *status = getFlightStatus();
if (status->getArmed() == FlightStatus::ARMED_DISARMED) { if (status->getArmed() == FlightStatus::ARMED_DISARMED) {
goToBootloader(); goToBootloader();
} else { } else {
@ -510,7 +516,7 @@ void UploaderGadgetWidget::systemSafeBoot()
void UploaderGadgetWidget::systemEraseBoot() void UploaderGadgetWidget::systemEraseBoot()
{ {
switch(confirmEraseSettingsMessageBox()) { switch (confirmEraseSettingsMessageBox()) {
case QMessageBox::Ok: case QMessageBox::Ok:
commonSystemBoot(true, true); commonSystemBoot(true, true);
break; break;
@ -759,10 +765,11 @@ void UploaderGadgetWidget::systemRescue()
if (USBMonitor::instance()->availableDevices(0x20a0, -1, -1, -1).length() > 0) { if (USBMonitor::instance()->availableDevices(0x20a0, -1, -1, -1).length() > 0) {
QString labelText = QString("<p align=\"left\">%1</p>").arg(tr("Please disconnect your OpenPilot board.")); QString labelText = QString("<p align=\"left\">%1</p>").arg(tr("Please disconnect your OpenPilot board."));
int result = ConnectionWaiter::openDialog(tr("System Rescue"), labelText, 0, BOARD_EVENT_TIMEOUT, this); int result = ConnectionWaiter::openDialog(tr("System Rescue"), labelText, 0, BOARD_EVENT_TIMEOUT, this);
switch(result) { switch (result) {
case ConnectionWaiter::Canceled: case ConnectionWaiter::Canceled:
m_config->rescueButton->setEnabled(true); m_config->rescueButton->setEnabled(true);
return; return;
case ConnectionWaiter::TimedOut: case ConnectionWaiter::TimedOut:
QMessageBox::warning(this, tr("System Rescue"), tr("Timed out while waiting for all boards to be disconnected!")); QMessageBox::warning(this, tr("System Rescue"), tr("Timed out while waiting for all boards to be disconnected!"));
m_config->rescueButton->setEnabled(true); m_config->rescueButton->setEnabled(true);
@ -773,10 +780,11 @@ void UploaderGadgetWidget::systemRescue()
// Now prompt user to connect board // Now prompt user to connect board
QString labelText = QString("<p align=\"left\">%1<br>%2</p>").arg(tr("Please connect your OpenPilot board.")).arg(tr("Board must be connected to the USB port!")); QString labelText = QString("<p align=\"left\">%1<br>%2</p>").arg(tr("Please connect your OpenPilot board.")).arg(tr("Board must be connected to the USB port!"));
int result = ConnectionWaiter::openDialog(tr("System Rescue"), labelText, 1, BOARD_EVENT_TIMEOUT, this); int result = ConnectionWaiter::openDialog(tr("System Rescue"), labelText, 1, BOARD_EVENT_TIMEOUT, this);
switch(result) { switch (result) {
case ConnectionWaiter::Canceled: case ConnectionWaiter::Canceled:
m_config->rescueButton->setEnabled(true); m_config->rescueButton->setEnabled(true);
return; return;
case ConnectionWaiter::TimedOut: case ConnectionWaiter::TimedOut:
QMessageBox::warning(this, tr("System Rescue"), tr("Timed out while waiting for a board to be connected!")); QMessageBox::warning(this, tr("System Rescue"), tr("Timed out while waiting for a board to be connected!"));
m_config->rescueButton->setEnabled(true); m_config->rescueButton->setEnabled(true);
@ -898,6 +906,7 @@ void UploaderGadgetWidget::autoUpdateStatus(uploader::AutoUpdateStep status, QVa
{ {
QString msg; QString msg;
int remaining; int remaining;
switch (status) { switch (status) {
case uploader::WAITING_DISCONNECT: case uploader::WAITING_DISCONNECT:
m_config->autoUpdateLabel->setText(tr("Waiting for all OpenPilot boards to be disconnected from USB.")); m_config->autoUpdateLabel->setText(tr("Waiting for all OpenPilot boards to be disconnected from USB."));
@ -934,7 +943,7 @@ void UploaderGadgetWidget::autoUpdateStatus(uploader::AutoUpdateStep status, QVa
break; break;
case uploader::SUCCESS: case uploader::SUCCESS:
m_config->autoUpdateProgressBar->setValue(m_config->autoUpdateProgressBar->maximum()); m_config->autoUpdateProgressBar->setValue(m_config->autoUpdateProgressBar->maximum());
msg = tr("Board was updated successfully."); msg = tr("Board was updated successfully.");
msg += " " + tr("Press OK to finish."); msg += " " + tr("Press OK to finish.");
m_config->autoUpdateLabel->setText(QString("<font color='green'>%1</font>").arg(msg)); m_config->autoUpdateLabel->setText(QString("<font color='green'>%1</font>").arg(msg));
finishAutoUpdate(); finishAutoUpdate();
@ -986,6 +995,7 @@ void UploaderGadgetWidget::openHelp()
int UploaderGadgetWidget::confirmEraseSettingsMessageBox() int UploaderGadgetWidget::confirmEraseSettingsMessageBox()
{ {
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Confirm Settings Erase?")); msgBox.setWindowTitle(tr("Confirm Settings Erase?"));
msgBox.setIcon(QMessageBox::Question); msgBox.setIcon(QMessageBox::Question);
msgBox.setText(tr("Do you want to erase all settings from the board?")); msgBox.setText(tr("Do you want to erase all settings from the board?"));
@ -997,6 +1007,7 @@ int UploaderGadgetWidget::confirmEraseSettingsMessageBox()
int UploaderGadgetWidget::cannotHaltMessageBox() int UploaderGadgetWidget::cannotHaltMessageBox()
{ {
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Cannot Halt Board!")); msgBox.setWindowTitle(tr("Cannot Halt Board!"));
msgBox.setIcon(QMessageBox::Warning); msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("The controller board is armed and can not be halted.")); msgBox.setText(tr("The controller board is armed and can not be halted."));
@ -1008,6 +1019,7 @@ int UploaderGadgetWidget::cannotHaltMessageBox()
int UploaderGadgetWidget::cannotResetMessageBox() int UploaderGadgetWidget::cannotResetMessageBox()
{ {
QMessageBox msgBox(this); QMessageBox msgBox(this);
msgBox.setWindowTitle(tr("Cannot Reset Board!")); msgBox.setWindowTitle(tr("Cannot Reset Board!"));
msgBox.setIcon(QMessageBox::Warning); msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("The controller board is armed and can not be reset.")); msgBox.setText(tr("The controller board is armed and can not be reset."));

View File

@ -42,7 +42,7 @@ using namespace uploader;
class FlightStatus; class FlightStatus;
class UAVObject; class UAVObject;
class TimedDialog: public QProgressDialog { class TimedDialog : public QProgressDialog {
Q_OBJECT Q_OBJECT
public: public:
@ -58,7 +58,7 @@ private:
// A helper class to wait for board connection and disconnection events // A helper class to wait for board connection and disconnection events
// until a the desired number of connected boards is found // until a the desired number of connected boards is found
// or until a timeout is reached // or until a timeout is reached
class ConnectionWaiter: public QObject { class ConnectionWaiter : public QObject {
Q_OBJECT Q_OBJECT
public: public:
@ -151,7 +151,6 @@ private slots:
void finishAutoUpdate(); void finishAutoUpdate();
void closeAutoUpdate(); void closeAutoUpdate();
void autoUpdateStatus(uploader::AutoUpdateStep status, QVariant value); void autoUpdateStatus(uploader::AutoUpdateStep status, QVariant value);
}; };
#endif // UPLOADERGADGETWIDGET_H #endif // UPLOADERGADGETWIDGET_H