mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-11 03:29:17 +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()
|
QString deviceWidget::setOpenFileName()
|
||||||
{
|
{
|
||||||
QFileDialog::Options options;
|
QFileDialog::Options options;
|
||||||
QString selectedFilter;
|
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,
|
QString fileName = QFileDialog::getOpenFileName(this,
|
||||||
tr("Select firmware file"),
|
tr("Select firmware file"),
|
||||||
"",
|
fwDirectoryStr,
|
||||||
tr("Firmware Files (*.opfw *.bin)"),
|
tr("Firmware Files (*.opfw *.bin)"),
|
||||||
&selectedFilter,
|
&selectedFilter,
|
||||||
options);
|
options);
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Set the save file name
|
||||||
|
*/
|
||||||
QString deviceWidget::setSaveFileName()
|
QString deviceWidget::setSaveFileName()
|
||||||
{
|
{
|
||||||
QFileDialog::Options options;
|
QFileDialog::Options options;
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
#include "uavobjectutilmanager.h"
|
#include "uavobjectutilmanager.h"
|
||||||
#include "devicedescriptorstruct.h"
|
#include "devicedescriptorstruct.h"
|
||||||
|
#include <QDir>
|
||||||
|
#include <QCoreApplication>
|
||||||
using namespace OP_DFU;
|
using namespace OP_DFU;
|
||||||
class deviceWidget : public QWidget
|
class deviceWidget : public QWidget
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user