mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
OP-1230 Automatically load the firmware in build/fw_<boardname> in development environment
This commit is contained in:
parent
09802ef3d0
commit
8bed1e02ce
@ -134,6 +134,11 @@ void DeviceWidget::populate()
|
||||
}
|
||||
|
||||
status("Ready...", STATUSICON_INFO);
|
||||
QString fwFileName = getDevFirmwarePath();
|
||||
QFile fwFile(fwFileName);
|
||||
if(fwFile.exists()){
|
||||
loadFirmware(fwFileName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,11 +258,17 @@ void DeviceWidget::status(QString str, StatusIcon ic)
|
||||
}
|
||||
|
||||
void DeviceWidget::loadFirmware()
|
||||
{
|
||||
QString file = setOpenFileName();
|
||||
loadFirmware(file);
|
||||
}
|
||||
|
||||
void DeviceWidget::loadFirmware(QString fwfilename)
|
||||
{
|
||||
myDevice->verticalGroupBox_loaded->setVisible(false);
|
||||
myDevice->groupCustom->setVisible(false);
|
||||
|
||||
filename = setOpenFileName();
|
||||
filename = fwfilename;
|
||||
|
||||
myDevice->confirmCheckBox->setVisible(false);
|
||||
myDevice->confirmCheckBox->setChecked(false);
|
||||
@ -312,6 +323,7 @@ void DeviceWidget::loadFirmware()
|
||||
myDevice->verticalGroupBox_loaded->setVisible(false);
|
||||
myDevice->groupCustom->setVisible(true);
|
||||
}
|
||||
myDevice->filenameLabel->setText(tr("Firmware loaded: ") + filename);
|
||||
myDevice->statusIcon->setPixmap(px);
|
||||
}
|
||||
|
||||
@ -508,17 +520,10 @@ void DeviceWidget::setProgress(int percent)
|
||||
myDevice->progressBar->setValue(percent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an open file dialog.
|
||||
*/
|
||||
QString DeviceWidget::setOpenFileName()
|
||||
QString DeviceWidget::getDevFirmwarePath()
|
||||
{
|
||||
QFileDialog::Options options;
|
||||
QString selectedFilter;
|
||||
QString fwDirectoryStr;
|
||||
QDir fwDirectory;
|
||||
|
||||
// Format filename for file chooser
|
||||
QString fwDirectoryStr;
|
||||
#ifdef Q_OS_WIN
|
||||
fwDirectoryStr = QCoreApplication::applicationDirPath();
|
||||
fwDirectory = QDir(fwDirectoryStr);
|
||||
@ -528,7 +533,7 @@ QString DeviceWidget::setOpenFileName()
|
||||
#elif defined Q_OS_LINUX
|
||||
fwDirectoryStr = QCoreApplication::applicationDirPath();
|
||||
fwDirectory = QDir(fwDirectoryStr);
|
||||
fwDirectory.cd("../../..");
|
||||
fwDirectory.cd("../..");
|
||||
fwDirectoryStr = fwDirectory.absolutePath();
|
||||
fwDirectoryStr = fwDirectoryStr + "/fw_" + myDevice->lblBrdName->text().toLower() + "/fw_" + myDevice->lblBrdName->text().toLower() + ".opfw";
|
||||
#elif defined Q_OS_MAC
|
||||
@ -538,12 +543,21 @@ QString DeviceWidget::setOpenFileName()
|
||||
fwDirectoryStr = fwDirectory.absolutePath();
|
||||
fwDirectoryStr = fwDirectoryStr + "/fw_" + myDevice->lblBrdName->text().toLower() + "/fw_" + myDevice->lblBrdName->text().toLower() + ".opfw";
|
||||
#endif
|
||||
return fwDirectoryStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens an open file dialog.
|
||||
*/
|
||||
QString DeviceWidget::setOpenFileName()
|
||||
{
|
||||
QString fwDirectoryStr = getDevFirmwarePath();
|
||||
|
||||
// Format filename for file chooser
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Select firmware file"),
|
||||
fwDirectoryStr,
|
||||
tr("Firmware Files (*.opfw *.bin)"),
|
||||
&selectedFilter,
|
||||
options);
|
||||
tr("Firmware Files (*.opfw *.bin)"));
|
||||
return fileName;
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ private:
|
||||
bool populateBoardStructuredDescription(QByteArray arr);
|
||||
bool populateLoadedStructuredDescription(QByteArray arr);
|
||||
void updateButtons(bool enabled);
|
||||
QString getDevFirmwarePath();
|
||||
|
||||
signals:
|
||||
void uploadStarted();
|
||||
@ -82,6 +83,7 @@ signals:
|
||||
public slots:
|
||||
void uploadFirmware();
|
||||
void loadFirmware();
|
||||
void loadFirmware(QString fwfilename);
|
||||
void downloadFirmware();
|
||||
void setProgress(int);
|
||||
void downloadFinished();
|
||||
|
@ -190,6 +190,28 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="filenameLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>filename</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user