Commit db7b86fb authored by Don Gagne's avatar Don Gagne

Use new QGCMessageBox apis

Subclass of QMessageBox which re-implements the static public
functions. There are two reasons for this:
1) The QMessageBox implementation on OSX does now show the title
string. This leads to message boxes which don't make much sense. So on
OSX we set title to text and text to informative text.
2) If parent is NULL, we set parent to MainWindow::instance. This
prevents message boxes which can go behind MainWindow
parent e833fe46
......@@ -487,7 +487,8 @@ HEADERS += \
src/uas/QGCUASWorker.h \
src/CmdLineOptParser.h \
src/uas/QGXPX4UAS.h \
src/QGCFileDialog.h
src/QGCFileDialog.h \
src/QGCMessageBox.h
SOURCES += \
src/main.cc \
......
......@@ -47,6 +47,7 @@
#include "MainWindow.h"
#include "GAudioOutput.h"
#include "CmdLineOptParser.h"
#include "QGCMessageBox.h"
#ifdef QGC_RTLAB_ENABLED
#include "OpalLink.h"
......@@ -245,19 +246,12 @@ bool QGCApplication::init(void)
// Check if link could be connected
if (udpLink && !LinkManager::instance()->connectLink(udpLink))
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not connect UDP port. Is an instance of " + qAppName() + "already running?");
msgBox.setInformativeText("It is recommended to close the application and stop all instances. Click Yes to close.");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
// Close the message box shortly after the click to prevent accidental clicks
QTimer::singleShot(15000, &msgBox, SLOT(reject()));
QMessageBox::StandardButton button = QGCMessageBox::critical(tr("Could not connect UDP port. Is an instance of %1 already running?").arg(qAppName()),
tr("It is recommended to close the application and stop all instances. Click Yes to close."),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
// Exit application
if (ret == QMessageBox::Yes)
if (button == QMessageBox::Yes)
{
//mainWindow->close();
QTimer::singleShot(200, _mainWindow, SLOT(close()));
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef QGCMESSAGEBOX_H
#define QGCMESSAGEBOX_H
#include <QMessageBox>
#include "MainWindow.h"
/// @file
/// @brief Subclass of QMessageBox which re-implements the static public functions. There are two reasons for this:
/// 1) The QMessageBox implementation on OSX does now show the title string. This leads to message
/// boxes which don't make much sense. So on OSX we set title to text and text to informative text.
/// 2) If parent is NULL, we set parent to MainWindow::instance
/// @author Don Gagne <don@thegagnes.com>
class QGCMessageBox : public QMessageBox {
public:
static StandardButton critical(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Critical, title, text, buttons, defaultButton, parent); }
static StandardButton information(const QString & title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Information, title, text, buttons, defaultButton, parent); }
static StandardButton question(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Question, title, text, buttons, defaultButton, parent); }
static StandardButton warning(const QString& title, const QString& text, StandardButtons buttons = Ok, StandardButton defaultButton = NoButton, QWidget* parent = NULL)
{ return _messageBox(QMessageBox::Warning, title, text, buttons, defaultButton, parent); }
private:
#ifdef Q_OS_MAC
static StandardButton _messageBox(Icon icon, const QString& title, const QString& text, StandardButtons buttons, StandardButton defaultButton, QWidget* parent)
{
if (parent == NULL) {
parent = MainWindow::instance();
}
QString emptyTitle;
QMessageBox box(icon, emptyTitle, title, buttons, parent);
box.setDefaultButton(defaultButton);
box.setInformativeText(text);
return static_cast<QMessageBox::StandardButton>(box.exec());
}
#else
static StandardButton _messageBox(Icon icon, const QString& title, const QString& text, StandardButtons buttons, StandardButton defaultButton, QWidget* parent)
{
if (parent == NULL) {
parent = MainWindow::instance();
}
QMessageBox box(icon, title, text, buttons, parent);
box.setDefaultButton(defaultButton);
return static_cast<QMessageBox::StandardButton>(box.exec());
}
#endif
};
#endif
......@@ -31,11 +31,11 @@ This file is part of the QGROUNDCONTROL project
#include <QList>
#include <QApplication>
#include <QMessageBox>
#include <QDebug>
#include "LinkManager.h"
#include "MainWindow.h"
#include "QGCMessageBox.h"
LinkManager* LinkManager::instance()
{
......@@ -284,9 +284,8 @@ const QList<SerialLink*> LinkManager::getSerialLinks()
bool LinkManager::_connectionsSuspendedMsg(void)
{
if (_connectionsSuspended) {
QMessageBox::information(MainWindow::instance(),
tr("Connect not allowed"),
tr("Connect not allowed: %1").arg(_connectionsSuspendedReason));
QGCMessageBox::information(tr("Connect not allowed"),
tr("Connect not allowed: %1").arg(_connectionsSuspendedReason));
return true;
} else {
return false;
......
......@@ -13,7 +13,6 @@
#include <QDebug>
#include <QTime>
#include <QApplication>
#include <QMessageBox>
#include <QSettings>
#include <QStandardPaths>
#include <QtEndian>
......
#include "OpalRT.h"
#include "QGCMessageBox.h"
namespace OpalRT
{
......@@ -7,10 +8,7 @@ void OpalErrorMsg::displayLastErrorMsg()
{
static QString lastErrorMsg;
setLastErrorMsg();
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(lastErrorMsg);
msgBox.exec();
QGCMessageBox::critical(QString(), lastErrorMsg);
}
void OpalErrorMsg::setLastErrorMsg()
......
......@@ -31,7 +31,6 @@ This file is part of the QGROUNDCONTROL project
#define OPALRT_H
#include <QString>
#include <QMessageBox>
#include "OpalApi.h"
......
......@@ -35,6 +35,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug>
#include <QMutexLocker>
#include <QHostInfo>
#include <QMessageBox>
#include <iostream>
......
......@@ -9,9 +9,9 @@
#include "Mouse6dofInput.h"
#include "UAS.h"
#include "UASManager.h"
#include "QMessageBox"
#include "QGCMessageBox.h"
#ifdef QGC_MOUSE_ENABLED_LINUX
#ifdef QGC_MOUSE_ENABLED_LINUX
#include <QX11Info>
#include <X11/Xlib.h>
#ifdef Success
......@@ -21,9 +21,9 @@ extern "C"
{
#include "xdrvlib.h"
}
#endif // QGC_MOUSE_ENABLED_LINUX
#endif // QGC_MOUSE_ENABLED_LINUX
#ifdef QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_WIN
Mouse6dofInput::Mouse6dofInput(Mouse3DInput* mouseInput) :
mouse3DMax(0.075), // TODO: check maximum value fot plugged device
uas(NULL),
......@@ -45,9 +45,9 @@ Mouse6dofInput::Mouse6dofInput(Mouse3DInput* mouseInput) :
//connect(mouseInput, SIGNAL(On3dmouseKeyUp(int)), this, SLOT(FUNCTION(int)));
}
#endif //QGC_MOUSE_ENABLED_WIN
#endif //QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_LINUX
#ifdef QGC_MOUSE_ENABLED_LINUX
Mouse6dofInput::Mouse6dofInput(QWidget* parent) :
mouse3DMax(350.0), // TODO: check maximum value fot plugged device
uas(NULL),
......@@ -86,14 +86,8 @@ Mouse6dofInput::Mouse6dofInput(QWidget* parent) :
}
if ( !MagellanInit( display, parent->winId() ) )
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("No 3DxWare driver is running."));
msgBox.setInformativeText(tr("Enter in Terminal 'sudo /etc/3DxWare/daemon/3dxsrv -d usb' and then restart QGroundControl."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
QGCMessageBox::critical(tr("No 3DxWare driver is running."),
tr("Enter in Terminal 'sudo /etc/3DxWare/daemon/3dxsrv -d usb' and then restart QGroundControl."));
qDebug() << "No 3DxWare driver is running!";
return;
}
......@@ -109,7 +103,7 @@ Mouse6dofInput::Mouse6dofInput(QWidget* parent) :
}
}
#endif //QGC_MOUSE_ENABLED_LINUX
#endif //QGC_MOUSE_ENABLED_LINUX
Mouse6dofInput::~Mouse6dofInput()
......@@ -191,7 +185,7 @@ void Mouse6dofInput::run()
}
}
#ifdef QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_WIN
void Mouse6dofInput::motion3DMouse(std::vector<float> &motionData)
{
if (motionData.size() < 6) return;
......@@ -220,9 +214,9 @@ void Mouse6dofInput::motion3DMouse(std::vector<float> &motionData)
//qDebug() << "NEW 3D MOUSE VALUES -- X" << xValue << " -- Y" << yValue << " -- Z" << zValue << " -- A" << aValue << " -- B" << bValue << " -- C" << cValue;
}
#endif //QGC_MOUSE_ENABLED_WIN
#endif //QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_WIN
void Mouse6dofInput::button3DMouseDown(int button)
{
switch(button)
......@@ -245,9 +239,9 @@ void Mouse6dofInput::button3DMouseDown(int button)
break;
}
}
#endif //QGC_MOUSE_ENABLED_WIN
#endif //QGC_MOUSE_ENABLED_WIN
#ifdef QGC_MOUSE_ENABLED_LINUX
#ifdef QGC_MOUSE_ENABLED_LINUX
void Mouse6dofInput::handleX11Event(XEvent *event)
{
//qDebug("XEvent occured...");
......@@ -327,4 +321,4 @@ void Mouse6dofInput::handleX11Event(XEvent *event)
}
}
}
#endif //QGC_MOUSE_ENABLED_LINUX
#endif //QGC_MOUSE_ENABLED_LINUX
......@@ -2,9 +2,9 @@
#include <QApplication>
#include <QDir>
#include <QMessageBox>
#include "UASInterface.h"
#include "QGCMessageBox.h"
QGCUASParamManager::QGCUASParamManager(QObject *parent) :
QGCUASParamManagerInterface(parent),
......@@ -193,9 +193,8 @@ void QGCUASParamManager::copyVolatileParamsToPersistent()
int changedParamCount = paramDataModel.countPendingParams();
if (changedParamCount > 0) {
QMessageBox msgBox;
msgBox.setText(tr("There are locally changed parameters. Please transmit them first (<TRANSMIT>) or update them with the onboard values (<REFRESH>) before storing onboard from RAM to ROM."));
msgBox.exec();
QGCMessageBox::warning(tr("Warning"),
tr("There are locally changed parameters. Please transmit them first (<TRANSMIT>) or update them with the onboard values (<REFRESH>) before storing onboard from RAM to ROM."));
}
else {
paramCommsMgr.writeParamsToPersistentStorage();
......
......@@ -10,13 +10,14 @@
*/
#include <QList>
#include <QMessageBox>
#include <QTimer>
#include <QSettings>
#include <iostream>
#include <QDebug>
#include <cmath>
#include <qmath.h>
#include "UAS.h"
#include "LinkInterface.h"
#include "UASManager.h"
......@@ -29,6 +30,7 @@
#include "UASParameterCommsMgr.h"
#include <Eigen/Geometry>
#include "AutoPilotPlugin.h"
#include "QGCMessageBox.h"
/**
* Gets the settings from the previous UAS (name, airframe, autopilot, battery specs)
......@@ -1404,19 +1406,11 @@ void UAS::setHomePosition(double lat, double lon, double alt)
tr("UAS") + QString::number(getUASID())
: getUASName();
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Set a new home position for vehicle %1").arg(uasName));
msgBox.setInformativeText("Do you want to set a new origin? Waypoints defined in the local frame will be shifted in their physical location");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
// Close the message box shortly after the click to prevent accidental clicks
QTimer::singleShot(5000, &msgBox, SLOT(reject()));
if (ret == QMessageBox::Yes)
QMessageBox::StandardButton button = QGCMessageBox::question(tr("Set a new home position for vehicle %1").arg(uasName),
tr("Do you want to set a new origin? Waypoints defined in the local frame will be shifted in their physical location"),
QMessageBox::Yes | QMessageBox::Cancel,
QMessageBox::Cancel);
if (button == QMessageBox::Yes)
{
mavlink_message_t msg;
mavlink_msg_command_long_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), 0, MAV_CMD_DO_SET_HOME, 1, 0, 0, 0, 0, lat, lon, alt);
......@@ -1442,19 +1436,11 @@ void UAS::setHomePosition(double lat, double lon, double alt)
**/
void UAS::setLocalOriginAtCurrentGPSPosition()
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText("Set the home position at the current GPS position?");
msgBox.setInformativeText("Do you want to set a new origin? Waypoints defined in the local frame will be shifted in their physical location");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
// Close the message box shortly after the click to prevent accidental clicks
QTimer::singleShot(5000, &msgBox, SLOT(reject()));
if (ret == QMessageBox::Yes)
QMessageBox::StandardButton button = QGCMessageBox::question(tr("Set the home position at the current GPS position?"),
tr("Do you want to set a new origin? Waypoints defined in the local frame will be shifted in their physical location"),
QMessageBox::Yes | QMessageBox::Cancel,
QMessageBox::Cancel);
if (button == QMessageBox::Yes)
{
mavlink_message_t msg;
mavlink_msg_command_long_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, this->getUASID(), 0, MAV_CMD_DO_SET_HOME, 1, 1, 0, 0, 0, 0, 0, 0);
......@@ -3204,19 +3190,11 @@ void UAS::stopHil()
void UAS::shutdown()
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Shutting down the UAS");
msgBox.setInformativeText("Do you want to shut down the onboard computer?");
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Cancel);
int ret = msgBox.exec();
// Close the message box shortly after the click to prevent accidental clicks
QTimer::singleShot(5000, &msgBox, SLOT(reject()));
if (ret == QMessageBox::Yes)
QMessageBox::StandardButton button = QGCMessageBox::question(tr("Shutting down the UAS"),
tr("Do you want to shut down the onboard computer?"),
QMessageBox::Yes | QMessageBox::Cancel,
QMessageBox::Cancel);
if (button == QMessageBox::Yes)
{
// If the active UAS is set, execute command
mavlink_message_t msg;
......
......@@ -10,13 +10,14 @@
#include <QList>
#include <QApplication>
#include <QMessageBox>
#include <QTimer>
#include <QSettings>
#include "UAS.h"
#include "UASInterface.h"
#include "UASManager.h"
#include "QGC.h"
#include "QGCMessageBox.h"
#define PI 3.1415926535897932384626433832795
#define MEAN_EARTH_DIAMETER 12756274.0
......@@ -308,7 +309,7 @@ void UASManager::addUAS(UASInterface* uas)
setActiveUAS(uas);
if (offlineUASWaypointManager->getWaypointEditableList().size() > 0)
{
if (QMessageBox::question(0,"Question","Do you want to append the offline waypoints to the ones currently on the UAV?",QMessageBox::Yes,QMessageBox::No) == QMessageBox::Yes)
if (QGCMessageBox::question(tr("Question"), tr("Do you want to append the offline waypoints to the ones currently on the UAV?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{
//Need to transfer all waypoints from the offline mode WPManager to the online mode.
for (int i=0;i<offlineUASWaypointManager->getWaypointEditableList().size();i++)
......
......@@ -28,7 +28,6 @@ This file is part of the QGROUNDCONTROL project
*/
#include <QFileInfo>
#include <QMessageBox>
#include <QStandardPaths>
#include "MAVLinkSettingsWidget.h"
......
......@@ -30,7 +30,6 @@ This file is part of the QGROUNDCONTROL project
#include <QSettings>
#include <QDockWidget>
#include <QNetworkInterface>
#include <QMessageBox>
#include <QDebug>
#include <QTimer>
#include <QHostInfo>
......@@ -73,6 +72,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCUASFileViewMulti.h"
#include "QGCCore.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
#ifdef QGC_OSG_ENABLED
#include "Q3DWidgetFactory.h"
......@@ -1131,14 +1131,14 @@ void MainWindow::showCriticalMessage(const QString& title, const QString& messag
{
_hideSplashScreen();
qDebug() << "Critical" << title << message;
QMessageBox::critical(this, title, message);
QGCMessageBox::critical(title, message);
}
void MainWindow::showInfoMessage(const QString& title, const QString& message)
{
_hideSplashScreen();
qDebug() << "Information" << title << message;
QMessageBox::information(this, title, message);
QGCMessageBox::information(title, message);
}
/**
......@@ -1676,15 +1676,11 @@ void MainWindow::handleMisconfiguration(UASInterface* uas)
_hideSplashScreen();
// Ask user if he wants to handle this now
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Information);
msgBox.setText(tr("Missing or Invalid Onboard Configuration"));
msgBox.setInformativeText(tr("The onboard system configuration is missing or incomplete. Do you want to resolve this now?"));
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
int val = msgBox.exec();
if (val == QMessageBox::Ok) {
QMessageBox::StandardButton button = QGCMessageBox::question(tr("Missing or Invalid Onboard Configuration"),
tr("The onboard system configuration is missing or incomplete. Do you want to resolve this now?"),
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok);
if (button == QMessageBox::Ok) {
// He wants to handle it, make sure this system is selected
UASManager::instance()->setActiveUAS(uas);
......
......@@ -29,7 +29,6 @@ This file is part of the QGROUNDCONTROL project
*/
#include <QTemporaryFile>
#include <QMessageBox>
#include <QPrintDialog>
#include <QProgressDialog>
#include <QHBoxLayout>
......@@ -45,6 +44,7 @@ This file is part of the QGROUNDCONTROL project
#include "MG.h"
#include "MainWindow.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
QGCDataPlot2D::QGCDataPlot2D(QWidget *parent) :
QWidget(parent),
......@@ -130,14 +130,14 @@ void QGCDataPlot2D::savePlot()
}
while(!(fileName.endsWith(".svg") || fileName.endsWith(".pdf"))) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Unsuitable file extension for PDF or SVG");
msgBox.setInformativeText("Please choose .pdf or .svg as file extension. Click OK to change the file extension, cancel to not save the file.");
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
QMessageBox::StandardButton button = QGCMessageBox::critical(tr("Unsuitable file extension for PDF or SVG"),
tr("Please choose .pdf or .svg as file extension. Click OK to change the file extension, cancel to not save the file."),
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok);
// Abort if cancelled
if(msgBox.exec() == QMessageBox::Cancel) return;
if (button == QMessageBox::Cancel) {
return;
}
fileName = QGCFileDialog::getSaveFileName(
this, "Export File Name", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation),
"PDF Documents (*.pdf);;SVG Images (*.svg)");
......@@ -279,13 +279,8 @@ void QGCDataPlot2D::selectFile()
QFileInfo fileInfo(fileName);
if (!fileInfo.isReadable())
{
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Could not open file");
msgBox.setInformativeText(tr("The file is owned by user %1. Is the file currently used by another program?").arg(fileInfo.owner()));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
QGCMessageBox::critical(tr("Could not open file"),
tr("The file is owned by user %1. Is the file currently used by another program?").arg(fileInfo.owner()));
ui->filenameLabel->setText(tr("Could not open %1").arg(fileInfo.baseName()+"."+fileInfo.completeSuffix()));
}
else
......@@ -705,26 +700,6 @@ void QGCDataPlot2D::saveCsvLog()
fileName.append(".csv");
}
// QFileInfo fileInfo(fileName);
//
// // Check if we could create a new file in this directory
// QDir dir(fileInfo.absoluteDir());
// QFileInfo dirInfo(dir);
//
// while(!(dirInfo.isWritable()))
// {
// QMessageBox msgBox;
// msgBox.setIcon(QMessageBox::Critical);
// msgBox.setText("File cannot be written, Operating System denies permission");
// msgBox.setInformativeText("Please choose a different file name or directory. Click OK to change the file, cancel to not save the file.");
// msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
// msgBox.setDefaultButton(QMessageBox::Ok);
// if(msgBox.exec() == QMessageBox::Cancel) break;
// fileName = QGCFileDialog::getSaveFileName(
// this, "Export CSV File Name", QStandardPaths::writableLocation(QStandardPaths::DesktopLocation),
// "CSV file (*.csv);;Text file (*.txt)");
// }
bool success = logFile->copy(fileName);
qDebug() << "Saved CSV log. Success: " << success;
......
......@@ -10,7 +10,6 @@
#include <QTimer>
#include <QDir>
#include <QXmlStreamReader>
#include <QMessageBox>
#include <QLabel>
#include "QGCPX4VehicleConfig.h"
......@@ -152,37 +151,6 @@ void QGCPX4VehicleConfig::firmwareMenuButtonClicked()
ui->tabTitleLabel->setText(tr("Firmware Upgrade"));
}
#if 0
void QGCPX4VehicleConfig::toggleSpektrumPairing(bool enabled)
{
Q_UNUSED(enabled);
if (!ui->dsm2RadioButton->isChecked() && !ui->dsmxRadioButton->isChecked()
&& !ui->dsmx8RadioButton->isChecked()) {
// Reject
QMessageBox warnMsgBox;
warnMsgBox.setText(tr("Please select a Spektrum Protocol Version"));
warnMsgBox.setInformativeText(tr("Please select either DSM2 or DSM-X\ndirectly below the pair button,\nbased on the receiver type."));
warnMsgBox.setStandardButtons(QMessageBox::Ok);
warnMsgBox.setDefaultButton(QMessageBox::Ok);
(void)warnMsgBox.exec();
return;
}
UASInterface* mav = UASManager::instance()->getActiveUAS();
if (mav) {
int rxSubType;
if (ui->dsm2RadioButton->isChecked())
rxSubType = 0;
else if (ui->dsmxRadioButton->isChecked())
rxSubType = 1;
else // if (ui->dsmx8RadioButton->isChecked())
rxSubType = 2;
mav->pairRX(0, rxSubType);
}
}
#endif
void QGCPX4VehicleConfig::menuButtonClicked()
{
QPushButton *button = qobject_cast<QPushButton*>(sender());
......
......@@ -7,7 +7,6 @@
#include <QGroupBox>
#include <QPushButton>
#include <QStringList>
#include <QMessageBox>
#include <QGraphicsScene>
#include "QGCToolWidget.h"
......@@ -78,7 +77,6 @@ protected:
QPixmap planeSide;
QGCPX4SensorCalibration* px4SensorCalibration;
PX4RCCalibration* px4RCCalibration;
QMessageBox msgBox;
QGraphicsScene scene;
QPushButton* skipActionButton;
......
......@@ -33,7 +33,6 @@ This file is part of the QGROUNDCONTROL project
#include <QGridLayout>
#include <QList>
#include <QMessageBox>
#include <QPushButton>
#include <QSettings>
#include <QTime>
......
......@@ -35,6 +35,7 @@
#include "GAudioOutput.h"
#include "QGCCore.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
SettingsDialog::SettingsDialog(JoystickInput *joystick, QWidget *parent, Qt::WindowFlags flags) :
QDialog(parent, flags),
......@@ -122,11 +123,10 @@ void SettingsDialog::selectCustomMode(int mode)
void SettingsDialog::_deleteSettingsToggled(bool checked)
{
if (checked){
QMessageBox::StandardButton answer = QMessageBox::question(this,
tr("Delete Settings"),
tr("All saved settings will be deleted the next time you start QGroundControl. Is this really what you want?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
QGCMessageBox::StandardButton answer = QGCMessageBox::question(tr("Delete Settings"),
tr("All saved settings will be deleted the next time you start QGroundControl. Is this really what you want?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
if (answer == QMessageBox::Yes) {
qgcApp()->deleteAllSettingsNextBoot();
} else {
......@@ -146,9 +146,8 @@ void SettingsDialog::_validateBeforeClose(void)
QString saveLocation = _ui->savedFilesLocation->text();
if (!app->validatePossibleSavedFilesLocation(saveLocation)) {
QMessageBox::warning(_mainWindow,
tr("Bad save location"),
tr("The location to save files to is invalid, or cannot be written to. Please provide a valid directory."));
QGCMessageBox::warning(tr("Bad save location"),
tr("The location to save files to is invalid, or cannot be written to. Please provide a valid directory."));
return;
}
......
......@@ -27,7 +27,6 @@
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
QGCUASFileView::QGCUASFileView(QWidget *parent, QGCUASFileManager *manager) :
QWidget(parent),
......
......@@ -39,7 +39,6 @@ This file is part of the PIXHAWK project
#include <UAS.h>
#include <UASManager.h>
#include <QDebug>
#include <QMessageBox>
#include <QMouseEvent>
#include <QTextEdit>
......
......@@ -38,11 +38,11 @@ This file is part of the APM_PLANNER project
#include "ui_terminalconsole.h"
#include "console.h"
#include "QGCConfig.h"
#include "QGCMessageBox.h"
#include <QDebug>
#include <QSettings>
#include <QStatusBar>
#include <QMessageBox>
#include <QVBoxLayout>
#include <QComboBox>
#include <QSerialPort>
......@@ -159,12 +159,12 @@ void TerminalConsole::openSerialPort(const SerialSettings &settings)
} else {
m_serial->close();
QMessageBox::critical(this, tr("Error"), m_serial->errorString());
QGCMessageBox::critical(tr("Error"), m_serial->errorString());
m_statusBar->showMessage(tr("Open error"));
}
} else {
QMessageBox::critical(this, tr("Error"), m_serial->errorString());
QGCMessageBox::critical(tr("Error"), m_serial->errorString());
m_statusBar->showMessage(tr("Configure error"));
}
......@@ -222,7 +222,7 @@ void TerminalConsole::readData()
void TerminalConsole::handleError(QSerialPort::SerialPortError error)
{
if (error == QSerialPort::ResourceError) {
QMessageBox::critical(this, tr("Critical Error"), m_serial->errorString());
QGCMessageBox::critical(tr("Critical Error"), m_serial->errorString());
closeSerialPort();
}
}
......
......@@ -43,7 +43,6 @@ This file is part of the PIXHAWK project
#include <QColor>
#include <QPalette>
#include <QStandardPaths>
#include <QMessageBox>
#include <QShortcut>
#include "LinechartWidget.h"
......@@ -53,6 +52,7 @@ This file is part of the PIXHAWK project
#include "QGC.h"
#include "MG.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
LinechartWidget::LinechartWidget(int systemid, QWidget *parent) : QWidget(parent),
sysid(systemid),
......@@ -442,13 +442,7 @@ void LinechartWidget::startLogging()
// Check if any curve is enabled
if (!activePlot->anyCurveVisible()) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("No curves selected for logging.");
msgBox.setInformativeText("Please check all curves you want to log. Currently no data would be logged, aborting the logging.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
QGCMessageBox::critical(tr("No curves selected for logging."), tr("Please check all curves you want to log. Currently no data would be logged, aborting the logging."));
return;
}
......@@ -458,14 +452,11 @@ void LinechartWidget::startLogging()
QString fileName = QGCFileDialog::getSaveFileName(this, tr("Specify log file name"), QStandardPaths::writableLocation(QStandardPaths::DesktopLocation), tr("Logfile (*.log);;"));
while (!(fileName.endsWith(".log")) && !abort && fileName != "") {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText("Unsuitable file extension for logfile");
msgBox.setInformativeText("Please choose .log as file extension. Click OK to change the file extension, cancel to not start logging.");
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
msgBox.setDefaultButton(QMessageBox::Ok);
if(msgBox.exec() != QMessageBox::Ok)
{
QMessageBox::StandardButton button = QGCMessageBox::critical(tr("Unsuitable file extension for logfile"),
tr("Please choose .log as file extension. Click OK to change the file extension, cancel to not start logging."),
QMessageBox::Ok | QMessageBox::Cancel,
QMessageBox::Ok);
if (button != QMessageBox::Ok) {
abort = true;
break;
}
......@@ -501,15 +492,12 @@ void LinechartWidget::stopLogging()
connect(compressor, SIGNAL(finishedFile(QString)), this, SIGNAL(logfileWritten(QString)));
connect(compressor, SIGNAL(logProcessingStatusChanged(QString)), MainWindow::instance(), SLOT(showStatusMessage(QString)));
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Question);
msgBox.setText(tr("Starting Log Compression"));
msgBox.setInformativeText(tr("Should empty fields (e.g. due to packet drops) be filled with the previous value of the same variable (zero order hold)?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
int ret = msgBox.exec();
QMessageBox::StandardButton button = QGCMessageBox::question(tr("Starting Log Compression"),
tr("Should empty fields (e.g. due to packet drops) be filled with the previous value of the same variable (zero order hold)?"),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No);
bool fill;
if (ret == QMessageBox::Yes)
if (button == QMessageBox::Yes)
{
fill = true;
}
......
......@@ -6,6 +6,7 @@
#include "MAV2DIcon.h"
#include "Waypoint2DIcon.h"
#include "UASWaypointManager.h"
#include "QGCMessageBox.h"
QGCMapWidget::QGCMapWidget(QWidget *parent) :
mapcontrol::OPMapWidget(parent),
......@@ -65,7 +66,7 @@ void QGCMapWidget::guidedActionTriggered()
{
if (!uas)
{
QMessageBox::information(0,"Error","Please connect first");
QGCMessageBox::information(tr("Error"), tr("Please connect first"));
return;
}
if (currWPManager)
......@@ -91,7 +92,7 @@ bool QGCMapWidget::guidedAltActionTriggered()
{
if (!uas)
{
QMessageBox::information(0,"Error","Please connect first");
QGCMessageBox::information(tr("Error"), tr("Please connect first"));
return false;
}
bool ok = false;
......@@ -113,7 +114,7 @@ bool QGCMapWidget::setHomeActionTriggered()
{
if (!uas)
{
QMessageBox::information(0,"Error","Please connect first");
QGCMessageBox::information(tr("Error"), tr("Please connect first"));
return false;
}
UASManagerInterface *uasManager = UASManager::instance();
......@@ -597,13 +598,8 @@ void QGCMapWidget::cacheVisibleRegion()
if (rect.IsEmpty())
{
QMessageBox msgBox(this);
msgBox.setIcon(QMessageBox::Information);
msgBox.setText("Cannot cache tiles for offline use");
msgBox.setInformativeText("Please select an area first by holding down SHIFT or ALT and selecting the area with the left mouse button.");
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
QGCMessageBox::information(tr("Cannot cache tiles for offline use"),
tr("Please select an area first by holding down SHIFT or ALT and selecting the area with the left mouse button."));
}
else
{
......
......@@ -45,6 +45,7 @@
#include "TerrainParamDialog.h"
#include "UASManager.h"
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
#include "QGC.h"
#include "gpl.h"
......@@ -618,10 +619,8 @@ Pixhawk3DWidget::loadTerrainModel(void)
}
else
{
QMessageBox msgBox(QMessageBox::Warning,
"Error loading model",
QString("Error: Unable to load terrain model (%1).").arg(filename));
msgBox.exec();
QGCMessageBox::warning(tr("Error loading model"),
tr("Error: Unable to load terrain model (%1).").arg(filename));
}
}
......
......@@ -34,9 +34,9 @@
#include <QJsonObject>
#include <QDir>
#include <QDebug>
#include <QMessageBox>
#include "QGCFileDialog.h"
#include "QGCMessageBox.h"
/// @Brief Constructs a new PX4FirmwareUpgrade Widget. This widget is used within the PX4VehicleConfig set of screens.
PX4FirmwareUpgrade::PX4FirmwareUpgrade(QWidget *parent) :
......@@ -294,7 +294,7 @@ void PX4FirmwareUpgrade::_foundBoard(bool firstTry, const QString portName, QStr
{
if (firstTry) {
// Board is still plugged
QMessageBox::critical(this, tr("Firmware Upgrade"), tr("You must unplug you board before beginning the Firmware Upgrade process."));
QGCMessageBox::critical(tr("Firmware Upgrade"), tr("You must unplug you board before beginning the Firmware Upgrade process."));
_cancel();
} else {
_portName = portName;
......
......@@ -25,11 +25,11 @@
/// @brief PX4 RC Calibration Widget
/// @author Don Gagne <don@thegagnes.com
#include <QMessageBox>
#include <QSettings>
#include "PX4RCCalibration.h"
#include "UASManager.h"
#include "QGCMessageBox.h"
const int PX4RCCalibration::_updateInterval = 150; ///< Interval for timer which updates radio channel widgets
const int PX4RCCalibration::_rcCalPWMCenterPoint = ((PX4RCCalibration::_rcCalPWMValidMaxValue - PX4RCCalibration::_rcCalPWMValidMinValue) / 2.0f) + PX4RCCalibration::_rcCalPWMValidMinValue;
......@@ -297,7 +297,7 @@ void PX4RCCalibration::_nextButton(void)
if (_unitTestMode) {
emit nextButtonMessageBoxDisplayed();
} else {
QMessageBox::warning(this, tr("Receiver"), tr("Detected %1 radio channels. To operate PX4, you need at least %2 channels.").arg(_chanCount).arg(_chanMinimum));
QGCMessageBox::warning(tr("Receiver"), tr("Detected %1 radio channels. To operate PX4, you need at least %2 channels.").arg(_chanCount).arg(_chanMinimum));
}
return;
}
......@@ -322,7 +322,7 @@ void PX4RCCalibration::_skipButton(void)
void PX4RCCalibration::_trimNYI(void)
{
QMessageBox::warning(this, tr("Set Trim"), tr("Setting individual trims is not yet implemented. You will need to go through full calibration to set trims."));
QGCMessageBox::warning(tr("Set Trim"), tr("Setting individual trims is not yet implemented. You will need to go through full calibration to set trims."));
}
void PX4RCCalibration::_saveAllTrims(void)
......@@ -559,7 +559,7 @@ void PX4RCCalibration::_saveFlapsDown(void)
if (_unitTestMode) {
emit nextButtonMessageBoxDisplayed();
} else {
QMessageBox::warning(this, tr("Flaps switch"), tr("Flaps switch has not yet been detected."));
QGCMessageBox::warning(tr("Flaps switch"), tr("Flaps switch has not yet been detected."));
}
return;
}
......
#include <QMessageBox>
#include <QProgressDialog>
#include <QDebug>
#include <QTimer>
......@@ -10,6 +9,7 @@
#include "LinkManager.h"
#include "UAS.h"
#include "QGC.h"
#include "QGCMessageBox.h"
QGCPX4AirframeConfig::QGCPX4AirframeConfig(QWidget *parent) :
QWidget(parent),
......@@ -251,13 +251,8 @@ void QGCPX4AirframeConfig::applyAndReboot()
// Guard against the case of an edit where we didn't receive all params yet
if (selectedId <= 0)
{
QMessageBox msgBox;
msgBox.setText(tr("No airframe selected"));
msgBox.setInformativeText(tr("Please select an airframe first."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
(void)msgBox.exec();
QGCMessageBox::warning(tr("No airframe selected"),
tr("Please select an airframe first."));
return;
}
......@@ -276,25 +271,15 @@ void QGCPX4AirframeConfig::applyAndReboot()
// Guard against the case of an edit where we didn't receive all params yet
if (paramMgr->countPendingParams() > 0 || components.count() == 0)
{
QMessageBox msgBox;
msgBox.setText(tr("Parameter sync with UAS not yet complete"));
msgBox.setInformativeText(tr("Please wait a few moments and retry"));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
(void)msgBox.exec();
QGCMessageBox::information(tr("Parameter sync with UAS not yet complete"),
tr("Please wait a few moments and retry"));
return;
}
// Guard against multiple components responding - this will never show in practice
if (components.count() != 1) {
QMessageBox msgBox;
msgBox.setText(tr("Invalid system setup detected"));
msgBox.setInformativeText(tr("None or more than one component advertised to provide the main system configuration option. This is an invalid system setup - please check your autopilot."));
msgBox.setStandardButtons(QMessageBox::Ok);
msgBox.setDefaultButton(QMessageBox::Ok);
(void)msgBox.exec();
QGCMessageBox::warning(tr("Invalid system setup detected"),
tr("None or more than one component advertised to provide the main system configuration option. This is an invalid system setup - please check your autopilot."));
return;
}
......
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