mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08:54:15 +01:00
Fixed firmware file chooser to be a little more intelligent. Especially important for windows users.
However, for Mac and Linux, this currently points to a directory relative to the build directory, which is helpful for devs, but not for users.
This commit is contained in:
parent
6feb198437
commit
d9510a94eb
@ -513,22 +513,47 @@ void deviceWidget::setProgress(int percent)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Opens an open file dialog.
|
||||
|
||||
*/
|
||||
*Opens an open file dialog.
|
||||
*/
|
||||
QString deviceWidget::setOpenFileName()
|
||||
{
|
||||
QFileDialog::Options options;
|
||||
QString selectedFilter;
|
||||
QString fwDirectoryStr;
|
||||
QDir fwDirectory;
|
||||
|
||||
//Format filename for file chooser
|
||||
#ifdef Q_OS_WIN
|
||||
fwDirectoryStr=QCoreApplication::applicationDirPath();
|
||||
fwDirectory=QDir(fwDirectoryStr);
|
||||
fwDirectory.cdUp();
|
||||
fwDirectory.cd("firmware");
|
||||
fwDirectoryStr=fwDirectory.absolutePath();
|
||||
#elif defined Q_OS_LINUX
|
||||
fwDirectoryStr=QCoreApplication::applicationDirPath();
|
||||
fwDirectory=QDir(fwDirectoryStr);
|
||||
fwDirectory.cd("../../..");
|
||||
fwDirectoryStr=fwDirectory.absolutePath();
|
||||
fwDirectoryStr=fwDirectoryStr+"/fw_"+myDevice->lblBrdName->text().toLower()+"/fw_"+myDevice->lblBrdName->text().toLower()+".opfw";
|
||||
#elif defined Q_OS_MAC
|
||||
fwDirectoryStr=QCoreApplication::applicationDirPath();
|
||||
fwDirectory=QDir(fwDirectoryStr);
|
||||
fwDirectory.cd("../../../../../..");
|
||||
fwDirectoryStr=fwDirectory.absolutePath();
|
||||
fwDirectoryStr=fwDirectoryStr+"/fw_"+myDevice->lblBrdName->text().toLower()+"/fw_"+myDevice->lblBrdName->text().toLower()+".opfw";
|
||||
#endif
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Select firmware file"),
|
||||
"",
|
||||
fwDirectoryStr,
|
||||
tr("Firmware Files (*.opfw *.bin)"),
|
||||
&selectedFilter,
|
||||
options);
|
||||
return fileName;
|
||||
}
|
||||
|
||||
/**
|
||||
*Set the save file name
|
||||
*/
|
||||
QString deviceWidget::setSaveFileName()
|
||||
{
|
||||
QFileDialog::Options options;
|
||||
|
@ -40,6 +40,8 @@
|
||||
#include <QCryptographicHash>
|
||||
#include "uavobjectutilmanager.h"
|
||||
#include "devicedescriptorstruct.h"
|
||||
#include <QDir>
|
||||
#include <QCoreApplication>
|
||||
using namespace OP_DFU;
|
||||
class deviceWidget : public QWidget
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user