mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
Merge branch 'amorale/OP-1230_autoload_dev_firmware' into next
This commit is contained in:
commit
597a6b4670
@ -132,8 +132,13 @@ void DeviceWidget::populate()
|
|||||||
myDevice->lblGitTag->setText(tr("Unknown"));
|
myDevice->lblGitTag->setText(tr("Unknown"));
|
||||||
myDevice->lblBrdName->setText(tr("Unknown"));
|
myDevice->lblBrdName->setText(tr("Unknown"));
|
||||||
}
|
}
|
||||||
|
myDevice->filenameLabel->setText(tr("No file loaded"));
|
||||||
status("Ready...", STATUSICON_INFO);
|
status("Ready...", STATUSICON_INFO);
|
||||||
|
QString fwFileName = getDevFirmwarePath();
|
||||||
|
QFile fwFile(fwFileName);
|
||||||
|
if(fwFile.exists()){
|
||||||
|
loadFirmware(fwFileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,11 +259,17 @@ void DeviceWidget::status(QString str, StatusIcon ic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceWidget::loadFirmware()
|
void DeviceWidget::loadFirmware()
|
||||||
|
{
|
||||||
|
QString file = setOpenFileName();
|
||||||
|
loadFirmware(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceWidget::loadFirmware(QString fwfilename)
|
||||||
{
|
{
|
||||||
myDevice->verticalGroupBox_loaded->setVisible(false);
|
myDevice->verticalGroupBox_loaded->setVisible(false);
|
||||||
myDevice->groupCustom->setVisible(false);
|
myDevice->groupCustom->setVisible(false);
|
||||||
|
|
||||||
filename = setOpenFileName();
|
filename = fwfilename;
|
||||||
|
|
||||||
myDevice->confirmCheckBox->setVisible(false);
|
myDevice->confirmCheckBox->setVisible(false);
|
||||||
myDevice->confirmCheckBox->setChecked(false);
|
myDevice->confirmCheckBox->setChecked(false);
|
||||||
@ -313,6 +324,7 @@ void DeviceWidget::loadFirmware()
|
|||||||
myDevice->verticalGroupBox_loaded->setVisible(false);
|
myDevice->verticalGroupBox_loaded->setVisible(false);
|
||||||
myDevice->groupCustom->setVisible(true);
|
myDevice->groupCustom->setVisible(true);
|
||||||
}
|
}
|
||||||
|
myDevice->filenameLabel->setText(tr("Firmware loaded: ") + filename);
|
||||||
myDevice->statusIcon->setPixmap(px);
|
myDevice->statusIcon->setPixmap(px);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -509,42 +521,38 @@ void DeviceWidget::setProgress(int percent)
|
|||||||
myDevice->progressBar->setValue(percent);
|
myDevice->progressBar->setValue(percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DeviceWidget::getDevFirmwarePath()
|
||||||
|
{
|
||||||
|
QDir fwDirectory;
|
||||||
|
QString fwDirectoryStr;
|
||||||
|
fwDirectoryStr = QCoreApplication::applicationDirPath();
|
||||||
|
fwDirectory = QDir(fwDirectoryStr);
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
fwDirectory.cd("../..");
|
||||||
|
fwDirectoryStr = fwDirectory.absolutePath();
|
||||||
|
#elif defined Q_OS_LINUX
|
||||||
|
fwDirectory.cd("../..");
|
||||||
|
fwDirectoryStr = fwDirectory.absolutePath();
|
||||||
|
#elif defined Q_OS_MAC
|
||||||
|
fwDirectory.cd("../../../../../..");
|
||||||
|
fwDirectoryStr = fwDirectory.absolutePath();
|
||||||
|
#endif
|
||||||
|
fwDirectoryStr = fwDirectoryStr + "/fw_" + myDevice->lblBrdName->text().toLower() + "/fw_" + myDevice->lblBrdName->text().toLower() + ".opfw";
|
||||||
|
return fwDirectoryStr;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens an open file dialog.
|
* Opens an open file dialog.
|
||||||
*/
|
*/
|
||||||
QString DeviceWidget::setOpenFileName()
|
QString DeviceWidget::setOpenFileName()
|
||||||
{
|
{
|
||||||
QFileDialog::Options options;
|
QString fwDirectoryStr = getDevFirmwarePath();
|
||||||
QString selectedFilter;
|
|
||||||
QString fwDirectoryStr;
|
|
||||||
QDir fwDirectory;
|
|
||||||
|
|
||||||
// Format filename for file chooser
|
// 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,
|
fwDirectoryStr,
|
||||||
tr("Firmware Files (*.opfw *.bin)"),
|
tr("Firmware Files (*.opfw *.bin)"));
|
||||||
&selectedFilter,
|
|
||||||
options);
|
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ private:
|
|||||||
bool populateBoardStructuredDescription(QByteArray arr);
|
bool populateBoardStructuredDescription(QByteArray arr);
|
||||||
bool populateLoadedStructuredDescription(QByteArray arr);
|
bool populateLoadedStructuredDescription(QByteArray arr);
|
||||||
void updateButtons(bool enabled);
|
void updateButtons(bool enabled);
|
||||||
|
QString getDevFirmwarePath();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void uploadStarted();
|
void uploadStarted();
|
||||||
@ -82,6 +83,7 @@ signals:
|
|||||||
public slots:
|
public slots:
|
||||||
void uploadFirmware();
|
void uploadFirmware();
|
||||||
void loadFirmware();
|
void loadFirmware();
|
||||||
|
void loadFirmware(QString fwfilename);
|
||||||
void downloadFirmware();
|
void downloadFirmware();
|
||||||
void setProgress(int);
|
void setProgress(int);
|
||||||
void downloadFinished();
|
void downloadFinished();
|
||||||
|
@ -190,6 +190,28 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user