diff --git a/companion/src/appdata.h b/companion/src/appdata.h
index 210b8ae8f..7377bb4f0 100644
--- a/companion/src/appdata.h
+++ b/companion/src/appdata.h
@@ -124,7 +124,7 @@ class Profile: protected CompStoreObj
QString splashFile() const;
bool burnFirmware() const;
bool renameFwFiles() const;
- bool patchImage() const;
+ bool patchImage() const; //TODO This variable is unused and should be removed
int channelOrder() const;
int defaultMode() const;
diff --git a/companion/src/burndialog.cpp b/companion/src/burndialog.cpp
index 764f84ab8..05d7ef8ce 100644
--- a/companion/src/burndialog.cpp
+++ b/companion/src/burndialog.cpp
@@ -17,7 +17,18 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
hexType(Type)
{
ui->setupUi(this);
- ui->libraryButton->setIcon(CompanionIcon("library.png"));
+
+ if(!g.profile[g.id()].splashFile().isEmpty()){
+ imageSource=PROFILE;
+ imageFile=g.profile[g.id()].splashFile();
+ }
+ else{
+ ui->useProfileImageCB->setDisabled(true);
+ imageSource=FIRMWARE;
+ imageFile="";
+ }
+ updateUI();
+
ui->SplashFrame->hide();
ui->FramFWInfo->hide();
ui->EEbackupCB->hide();
@@ -27,7 +38,6 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->profile_label->hide();
ui->patchcalib_CB->hide();
ui->patchhw_CB->hide();
- ui->InvertColorButton->setDisabled(true);
setWindowTitle(tr("Write firmware to TX"));
if (IS_TARANIS(GetEepromInterface()->getBoard())) {
ui->EEbackupCB->hide();
@@ -39,12 +49,7 @@ burnDialog::burnDialog(QWidget *parent, int Type, QString * fileName, bool * bac
ui->patchcalib_CB->hide();
ui->patchhw_CB->hide();
ui->EEpromCB->hide();
- ui->ImageLoadButton->setDisabled(true);
- ui->libraryButton->setDisabled(true);
- ui->InvertColorButton->setDisabled(true);
ui->BurnFlashButton->setDisabled(true);
- ui->ImageFileName->clear();
- ui->FwImage->clear();
ui->FWFileName->clear();
ui->DateField->clear();
ui->SVNField->clear();
@@ -124,12 +129,7 @@ void burnDialog::on_FlashLoadButton_clicked()
{
QString fileName;
- ui->ImageLoadButton->setDisabled(true);
- ui->libraryButton->setDisabled(true);
- ui->InvertColorButton->setDisabled(true);
ui->BurnFlashButton->setDisabled(true);
- ui->ImageFileName->clear();
- ui->FwImage->clear();
ui->FWFileName->clear();
ui->DateField->clear();
ui->SVNField->clear();
@@ -169,6 +169,7 @@ void burnDialog::on_FlashLoadButton_clicked()
QTimer::singleShot(0, this, SLOT(shrink()));
}
}
+ updateUI();
}
void burnDialog::checkFw(QString fileName)
@@ -194,48 +195,28 @@ void burnDialog::checkFw(QString fileName)
ui->BurnFlashButton->setText(tr("Write to TX"));
if (flash.hasSplash()) {
ui->SplashFrame->show();
- ui->ImageLoadButton->setEnabled(true);
- ui->libraryButton->setEnabled(true);
- ui->FwImage->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight());
ui->imageLabel->setFixedSize(flash.getSplashWidth(), flash.getSplashHeight());
- ui->FwImage->show();
- ui->FwImage->setPixmap(QPixmap::fromImage(flash.getSplash()));
QString ImageStr = g.profile[g.id()].splashFile();
- bool PatchFwCB = g.profile[g.id()].patchImage();
if (!ImageStr.isEmpty()) {
QImage Image;
Image.load(ImageStr);
ui->imageLabel->setPixmap(QPixmap::fromImage(Image.convertToFormat(flash.getSplashFormat())));
- ui->InvertColorButton->setEnabled(true);
- ui->PreferredImageCB->setChecked(true);
- ui->PatchFWCB->setChecked(PatchFwCB);
}
else {
- QString fileName=ui->ImageFileName->text();
+ QString fileName=imageFile;
if (!fileName.isEmpty()) {
QImage image(fileName);
if (!image.isNull()) {
- ui->InvertColorButton->setEnabled(true);
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(flash.getSplashFormat())));
- ui->PatchFWCB->setEnabled(true);
- ui->PatchFWCB->setChecked(PatchFwCB);
}
else {
- ui->PatchFWCB->setDisabled(true);
- ui->PatchFWCB->setChecked(false);
- ui->PreferredImageCB->setDisabled(true);
}
}
else {
- ui->PatchFWCB->setDisabled(true);
- ui->PatchFWCB->setChecked(false);
- ui->PreferredImageCB->setDisabled(true);
}
}
}
else {
- ui->FwImage->hide();
- ui->ImageFileName->setText("");
ui->SplashFrame->hide();
}
}
@@ -338,87 +319,122 @@ bool burnDialog::checkeEprom(QString fileName)
return true;
}
-void burnDialog::on_ImageLoadButton_clicked()
+void burnDialog::displaySplash()
+{
+ QImage image;
+ if (imageSource == FIRMWARE){
+ FlashInterface flash(ui->FWFileName->text());
+ image = flash.getSplash();
+ }
+ else{
+ image.load(imageFile);
+ }
+ if (image.isNull()) {
+ return;
+ }
+ if (ui->imageLabel->width()!=128) {
+ image=image.convertToFormat(QImage::Format_RGB32);
+ QRgb col;
+ int gray;
+ int width = image.width();
+ int height = image.height();
+ for (int i = 0; i < width; ++i)
+ {
+ for (int j = 0; j < height; ++j)
+ {
+ col = image.pixel(i, j);
+ gray = qGray(col);
+ image.setPixel(i, j, qRgb(gray, gray, gray));
+ }
+ }
+ ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
+ }
+ else {
+ ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(QImage::Format_Mono)));
+ }
+}
+
+void burnDialog::updateUI()
+{
+ ui->useProfileImageCB->setChecked( imageSource == PROFILE );
+ ui->useFwImageCB->setChecked( imageSource == FIRMWARE );
+ ui->useLibraryImageCB->setChecked( imageSource == LIBRARY );
+ ui->useAnotherImageCB->setChecked( imageSource == ANOTHER );
+
+ displaySplash();
+}
+
+void burnDialog::on_useFwImageCB_clicked()
+{
+ QString fileName = ui->FWFileName->text();
+ FlashInterface flash(fileName);
+ if (!flash.isValid()) {
+ QMessageBox::critical(this, tr("Error"), tr( "The firmware file is not valid." ));
+ return;
+ }
+ if (!flash.hasSplash()) {
+ QMessageBox::critical(this, tr("Error"), tr( "There is no start screen image in the firmware file." ));
+ return;
+ }
+ imageSource = FIRMWARE;
+ imageFile = fileName;
+ updateUI();
+}
+
+void burnDialog::on_useProfileImageCB_clicked()
+{
+ QString fileName = g.profile[g.id()].splashFile();
+ if (fileName.isEmpty()){
+ QMessageBox::critical(this, tr("Error"), tr( "The radio profile has no defined start screen." ));
+ return;
+ }
+ QImage image(fileName);
+ if (image.isNull()) {
+ QMessageBox::critical(this, tr("Error"), tr("The profile image %1 does not seem to contain an image.").arg(fileName));
+ return;
+ }
+ imageSource = PROFILE;
+ imageFile = fileName;
+ updateUI();
+}
+
+void burnDialog::on_useAnotherImageCB_clicked()
{
QString supportedImageFormats;
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
}
-
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Open Image to load"), g.imagesDir(), tr("Images (%1)").arg(supportedImageFormats));
-
- if (!fileName.isEmpty()) {
- g.imagesDir( QFileInfo(fileName).dir().absolutePath() );
- QImage image(fileName);
- if (image.isNull()) {
- QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
- ui->PatchFWCB->setDisabled(true);
- ui->PatchFWCB->setChecked(false);
- ui->InvertColorButton->setDisabled(true);
- return;
- }
- ui->ImageFileName->setText(fileName);
- ui->InvertColorButton->setEnabled(true);
- if (ui->imageLabel->width()!=128) {
- image=image.convertToFormat(QImage::Format_RGB32);
- QRgb col;
- int gray;
- int width = image.width();
- int height = image.height();
- for (int i = 0; i < width; ++i) {
- for (int j = 0; j < height; ++j) {
- col = image.pixel(i, j);
- gray = qGray(col);
- image.setPixel(i, j, qRgb(gray, gray, gray));
- }
- }
- ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
- }
- else {
- ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(QImage::Format_Mono)));
- }
- ui->PatchFWCB->setEnabled(true);
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Open image file to use as Tx start screen"), g.imagesDir(), tr("Images (%1)").arg(supportedImageFormats));
+ if (fileName.isEmpty()){
+ return;
}
+ g.imagesDir( QFileInfo(fileName).dir().absolutePath() );
+ QImage image(fileName);
+ if (image.isNull()) {
+ QMessageBox::critical(this, tr("Error"), tr("Image could not be loaded from %1").arg(fileName));
+ return;
+ }
+ imageSource = ANOTHER;
+ imageFile = fileName;
+ updateUI();
}
-void burnDialog::on_libraryButton_clicked()
+void burnDialog::on_useLibraryImageCB_clicked()
{
QString fileName;
splashLibrary *ld = new splashLibrary(this,&fileName);
ld->exec();
- if (!fileName.isEmpty()) {
- QImage image(fileName);
- if (image.isNull()) {
- QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
- ui->PatchFWCB->setDisabled(true);
- ui->PatchFWCB->setChecked(false);
- ui->InvertColorButton->setDisabled(true);
- return;
- }
- ui->ImageFileName->setText(fileName);
- ui->InvertColorButton->setEnabled(true);
- if (ui->imageLabel->width()!=128) {
- image=image.convertToFormat(QImage::Format_RGB32);
- QRgb col;
- int gray;
- int width = image.width();
- int height = image.height();
- for (int i = 0; i < width; ++i)
- {
- for (int j = 0; j < height; ++j)
- {
- col = image.pixel(i, j);
- gray = qGray(col);
- image.setPixel(i, j, qRgb(gray, gray, gray));
- }
- }
- ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
- } else {
- ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height()).convertToFormat(QImage::Format_Mono)));
- }
- ui->PatchFWCB->setEnabled(true);
+ if (fileName.isEmpty()) {
+ return;
}
+ QImage image(fileName);
+ if (image.isNull()) {
+ QMessageBox::critical(this, tr("Error"), tr("The library image could not be loaded"));
+ return;
+ }
+ imageSource = LIBRARY;
+ imageFile = fileName;
+ updateUI();
}
void burnDialog::on_BurnFlashButton_clicked()
@@ -428,11 +444,10 @@ void burnDialog::on_BurnFlashButton_clicked()
if (!fileName.isEmpty()) {
g.flashDir( QFileInfo(fileName).dir().absolutePath() );
g.lastFw( fileName );
- if (ui->PatchFWCB->isChecked()) {
- g.profile[g.id()].patchImage( true );
+ if (!ui->useFwImageCB->isChecked()) {
QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width(), ui->imageLabel->height());
if (!image.isNull()) {
- QString tempDir = QDir::tempPath();
+ QString tempDir = QDir::tempPath();
QString tempFile;
if (getFileType(fileName) == FILE_TYPE_HEX)
tempFile = tempDir + "/flash.hex";
@@ -452,7 +467,6 @@ void burnDialog::on_BurnFlashButton_clicked()
QMessageBox::critical(this, tr("Warning"), tr("Custom image not found"));
}
} else {
- g.profile[g.id()].patchImage( false );
hexfileName->clear();
hexfileName->append(fileName);
}
@@ -610,15 +624,6 @@ void burnDialog::on_cancelButton_clicked()
this->close();
}
-void burnDialog::on_InvertColorButton_clicked()
-{
- if (ui->imageLabel->pixmap()) {
- QImage image = ui->imageLabel->pixmap()->toImage();
- image.invertPixels();
- ui->imageLabel->setPixmap(QPixmap::fromImage(image));
- }
-}
-
void burnDialog::on_EEpromCB_toggled(bool checked)
{
if (ui->EEpromCB->isChecked()) {
@@ -628,83 +633,6 @@ void burnDialog::on_EEpromCB_toggled(bool checked)
}
}
-void burnDialog::on_PreferredImageCB_toggled(bool checked)
-{
- QString tmpFileName;
- if (checked) {
- QString ImageStr = g.profile[g.id()].splashFile();
- if (!ImageStr.isEmpty()) {
- QImage Image;
- Image.load( ImageStr );
- if (ui->imageLabel->width()!=128) {
- Image=Image.convertToFormat(QImage::Format_RGB32);
- QRgb col;
- int gray;
- int width = Image.width();
- int height = Image.height();
- for (int i = 0; i < width; ++i)
- {
- for (int j = 0; j < height; ++j)
- {
- col = Image.pixel(i, j);
- gray = qGray(col);
- Image.setPixel(i, j, qRgb(gray, gray, gray));
- }
- }
- } else {
- Image=Image.convertToFormat(QImage::Format_Mono);
- }
- ui->imageLabel->setPixmap(QPixmap::fromImage(Image));
- ui->InvertColorButton->setEnabled(true);
- ui->PreferredImageCB->setChecked(true);
- ui->ImageFileName->setDisabled(true);
- ui->ImageLoadButton->setDisabled(true);
- ui->libraryButton->setDisabled(true);
- ui->PatchFWCB->setEnabled(true);
- }
- } else {
- ui->imageLabel->clear();
- ui->ImageLoadButton->setEnabled(true);
- ui->libraryButton->setEnabled(true);
- tmpFileName = ui->ImageFileName->text();
- if (!tmpFileName.isEmpty()) {
- QImage image(tmpFileName);
- if (!image.isNull()) {
- if (ui->imageLabel->width()!=128) {
- image=image.convertToFormat(QImage::Format_RGB32);
- QRgb col;
- int gray;
- int width = image.width();
- int height = image.height();
- for (int i = 0; i < width; ++i)
- {
- for (int j = 0; j < height; ++j)
- {
- col = image.pixel(i, j);
- gray = qGray(col);
- image.setPixel(i, j, qRgb(gray, gray, gray));
- }
- }
- } else {
- image=image.convertToFormat(QImage::Format_Mono);
- }
- ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width(), ui->imageLabel->height())));
- ui->InvertColorButton->setEnabled(true);
- ui->ImageFileName->setEnabled(true);
- ui->PatchFWCB->setDisabled(false);
- } else {
- ui->InvertColorButton->setDisabled(true);
- ui->PatchFWCB->setDisabled(true);
- ui->PatchFWCB->setChecked(false);
- }
- } else {
- ui->InvertColorButton->setDisabled(true);
- ui->PatchFWCB->setDisabled(true);
- ui->PatchFWCB->setChecked(false);
- }
- }
-}
-
void burnDialog::shrink()
{
resize(0,0);
diff --git a/companion/src/burndialog.h b/companion/src/burndialog.h
index 40068f3ac..f56342133 100644
--- a/companion/src/burndialog.h
+++ b/companion/src/burndialog.h
@@ -36,18 +36,22 @@ public:
private slots:
void on_FlashLoadButton_clicked();
- void on_ImageLoadButton_clicked();
- void on_libraryButton_clicked();
void on_BurnFlashButton_clicked();
void on_cancelButton_clicked();
- void on_InvertColorButton_clicked();
void on_EEbackupCB_clicked();
- void on_PreferredImageCB_toggled(bool checked);
- void on_EEpromCB_toggled(bool checked);
- void checkFw(QString fileName);
+ void on_EEpromCB_toggled(bool checked);
bool checkeEprom(QString fileName);
+ void on_useProfileImageCB_clicked();
+ void on_useFwImageCB_clicked();
+ void on_useLibraryImageCB_clicked();
+ void on_useAnotherImageCB_clicked();
+
+ void checkFw(QString fileName);
+ void displaySplash();
+ void updateUI();
void shrink();
+
private:
Ui::burnDialog *ui;
QString * hexfileName;
@@ -55,6 +59,9 @@ private:
int hexType;
RadioData radioData;
bool burnraw;
+ enum ImageSource {FIRMWARE, PROFILE, LIBRARY, ANOTHER};
+ ImageSource imageSource;
+ QString imageFile;
};
#endif // BURNDIALOG_H
diff --git a/companion/src/burndialog.ui b/companion/src/burndialog.ui
index e86634e9a..89107b672 100644
--- a/companion/src/burndialog.ui
+++ b/companion/src/burndialog.ui
@@ -7,7 +7,7 @@
0
0
440
- 418
+ 423
@@ -30,21 +30,8 @@
:/icon.png:/icon.png
- -
+
-
-
-
-
-
- Qt::Vertical
-
-
-
- 20
- 0
-
-
-
-
-
@@ -71,19 +58,6 @@
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
-
@@ -100,19 +74,6 @@
- -
-
-
- Qt::Horizontal
-
-
-
- 48
- 20
-
-
-
-
-
@@ -152,56 +113,22 @@
QFrame::Raised
-
-
-
-
-
- 0
- 0
-
-
-
-
- 128
- 64
-
-
-
-
- 212
- 64
-
-
-
- QFrame::Panel
-
-
- QFrame::Raised
-
-
-
-
-
- true
-
-
-
- -
-
+
-
+
true
- -
-
+
-
+
- Date & Time
+ Variant
- -
-
+
-
+
true
@@ -214,17 +141,17 @@
- -
-
-
- true
+
-
+
+
+ Date & Time
- -
-
-
- Variant
+
-
+
+
+ true
@@ -325,17 +252,10 @@
-
-
-
-
-
-
-
-
-
- Invert Color
-
-
-
- -
+
+
-
+
+
-
@@ -369,10 +289,50 @@
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
-
-
+
+
+ Use firmware start screen
+
+
+
+ -
+
+
+ Use another start screen
+
+
+
+ -
+
0
@@ -380,86 +340,14 @@
- Use image in settings
-
-
-
- -
-
-
- Substitute image in firmware
+ Use profile start screen
-
-
-
- Qt::Vertical
-
-
-
- 20
- 13
-
-
-
-
- -
-
-
- Qt::Vertical
-
-
-
- 20
- 13
-
-
-
-
-
-
- -
-
-
-
-
-
- true
-
-
-
- 0
- 0
-
-
-
- true
-
-
-
- -
-
-
- false
-
+
- Load Image
-
-
-
- -
-
-
- Open Splash Library
-
-
- ...
-
-
-
- 16
- 16
-
+ Use library start screen
@@ -470,14 +358,24 @@
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 0
+
+
+
+
FWFileName
FlashLoadButton
- ImageFileName
- ImageLoadButton
- libraryButton
EEbackupCB
EEpromCB
cancelButton