mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +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->lblBrdName->setText(tr("Unknown"));
|
||||
}
|
||||
|
||||
myDevice->filenameLabel->setText(tr("No file loaded"));
|
||||
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()
|
||||
{
|
||||
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);
|
||||
@ -313,6 +324,7 @@ void DeviceWidget::loadFirmware()
|
||||
myDevice->verticalGroupBox_loaded->setVisible(false);
|
||||
myDevice->groupCustom->setVisible(true);
|
||||
}
|
||||
myDevice->filenameLabel->setText(tr("Firmware loaded: ") + filename);
|
||||
myDevice->statusIcon->setPixmap(px);
|
||||
}
|
||||
|
||||
@ -509,42 +521,38 @@ void DeviceWidget::setProgress(int 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.
|
||||
*/
|
||||
QString DeviceWidget::setOpenFileName()
|
||||
{
|
||||
QFileDialog::Options options;
|
||||
QString selectedFilter;
|
||||
QString fwDirectoryStr;
|
||||
QDir fwDirectory;
|
||||
QString fwDirectoryStr = getDevFirmwarePath();
|
||||
|
||||
// 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);
|
||||
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…
Reference in New Issue
Block a user