From c28968910510e19d5ad05c231ce4ea406a85c047 Mon Sep 17 00:00:00 2001 From: Kjell Kernen Date: Sun, 23 Feb 2014 22:24:43 +0100 Subject: [PATCH] All splash imgage display dialogs now use common code. The splash image library displayed all images in 128x64 mono format. Changed this to display either in 128x64 mono or 212x64 gray scale depending on profile information. --- companion/src/apppreferencesdialog.cpp | 26 +-- companion/src/apppreferencesdialog.ui | 5 +- companion/src/burndialog.cpp | 21 +- companion/src/burndialog.ui | 13 +- companion/src/customizesplashdialog.cpp | 68 +++--- companion/src/helpers.cpp | 22 ++ companion/src/helpers.h | 2 + companion/src/splashlibrary.cpp | 8 +- companion/src/splashlibrary.h | 1 - companion/src/splashlibrary.ui | 297 +++++++++++------------- 10 files changed, 201 insertions(+), 262 deletions(-) diff --git a/companion/src/apppreferencesdialog.cpp b/companion/src/apppreferencesdialog.cpp index c416ff3db..96f5268c3 100644 --- a/companion/src/apppreferencesdialog.cpp +++ b/companion/src/apppreferencesdialog.cpp @@ -279,29 +279,9 @@ bool appPreferencesDialog::displayImage( QString fileName ) int width = SPLASH_WIDTH; if (g.profile[g.id()].fwType().contains("taranis")) width = SPLASHX9D_WIDTH; - - ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT))); - if (width==SPLASHX9D_WIDTH) { - image=image.convertToFormat(QImage::Format_RGB32); - QRgb col; - int gray, 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)); - } - else { - ui->imageLabel->setPixmap(QPixmap::fromImage(image.convertToFormat(QImage::Format_Mono))); - } - if (width == SPLASH_WIDTH) - ui->imageLabel->setFixedSize(SPLASH_WIDTH, SPLASH_HEIGHT); - else - ui->imageLabel->setFixedSize(SPLASHX9D_WIDTH, SPLASHX9D_HEIGHT); - + + ui->imageLabel->setPixmap( makePixMap( image, g.profile[g.id()].fwType())); + ui->imageLabel->setFixedSize(width, SPLASH_HEIGHT); return true; } diff --git a/companion/src/apppreferencesdialog.ui b/companion/src/apppreferencesdialog.ui index f6ace593c..bdaaff9d4 100644 --- a/companion/src/apppreferencesdialog.ui +++ b/companion/src/apppreferencesdialog.ui @@ -956,7 +956,10 @@ This is used by the templated to determine which channel goes to what number out QFrame::Panel - QFrame::Raised + QFrame::Plain + + + 1 diff --git a/companion/src/burndialog.cpp b/companion/src/burndialog.cpp index dfc9d62b4..617c7ea9e 100644 --- a/companion/src/burndialog.cpp +++ b/companion/src/burndialog.cpp @@ -311,26 +311,7 @@ void burnDialog::displaySplash() 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))); - } + ui->imageLabel->setPixmap( makePixMap( image, g.profile[g.id()].fwType())); } void burnDialog::updateUI() diff --git a/companion/src/burndialog.ui b/companion/src/burndialog.ui index 89107b672..772304390 100644 --- a/companion/src/burndialog.ui +++ b/companion/src/burndialog.ui @@ -279,7 +279,7 @@ QFrame::Panel - QFrame::Raised + QFrame::Plain @@ -374,12 +374,21 @@ + BurnFlashButton FWFileName FlashLoadButton + DateField + SVNField + ModField + useProfileImageCB + useFwImageCB + useLibraryImageCB + useAnotherImageCB EEbackupCB + patchcalib_CB + patchhw_CB EEpromCB cancelButton - BurnFlashButton diff --git a/companion/src/customizesplashdialog.cpp b/companion/src/customizesplashdialog.cpp index 09c55aec3..42bf463da 100644 --- a/companion/src/customizesplashdialog.cpp +++ b/companion/src/customizesplashdialog.cpp @@ -41,7 +41,7 @@ bool Side::displayImage( QString fileName, Source pictSource ) if (fileName.isEmpty()) return false; - + // Determine which picture format to use if (pictSource == FW ){ FlashInterface flash(fileName); @@ -49,7 +49,7 @@ bool Side::displayImage( QString fileName, Source pictSource ) return false; else image = flash.getSplash(); - *format = (flash.getSplashWidth()==WIDTH_TARANIS ? LCDTARANIS : LCD9X); + *format = (flash.getSplashWidth()==WIDTH_TARANIS ? LCDTARANIS : LCD9X); } else { image.load(fileName); @@ -61,48 +61,34 @@ bool Side::displayImage( QString fileName, Source pictSource ) if (image.isNull()) { return false; } - // Prepare and display image + // Load image if (*format==LCDTARANIS) { - 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)); - } - } - imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2))); + imageLabel->setPixmap( makePixMap( image, "taranis" )); + imageLabel->setFixedSize(WIDTH_TARANIS*2, HEIGHT_TARANIS*2); } - else - imageLabel->setPixmap(QPixmap::fromImage(image.scaled(imageLabel->width()/2, imageLabel->height()/2).convertToFormat(QImage::Format_Mono))); - - if (*format == LCD9X) - imageLabel->setFixedSize(WIDTH_9X*2, HEIGHT_9X*2); - else - imageLabel->setFixedSize(WIDTH_TARANIS*2, HEIGHT_TARANIS*2); - + else { + imageLabel->setPixmap( makePixMap( image, "9x" )); + imageLabel->setFixedSize(WIDTH_9X*2, HEIGHT_9X*2); + } + switch (pictSource){ - case FW: - fileNameEdit->setText(QObject::tr("FW: %1").arg(fileName)); - *saveToFileName = fileName; - *source=FW; - break; - case PICT: - fileNameEdit->setText(QObject::tr("Pict: %1").arg(fileName)); - *saveToFileName = fileName; - *source=PICT; - break; - case PROFILE: - fileNameEdit->setText(QObject::tr("Profile image")); - *saveToFileName = fileName; - *source=PROFILE; - break; - default: - break; + case FW: + fileNameEdit->setText(QObject::tr("FW: %1").arg(fileName)); + *saveToFileName = fileName; + *source=FW; + break; + case PICT: + fileNameEdit->setText(QObject::tr("Pict: %1").arg(fileName)); + *saveToFileName = fileName; + *source=PICT; + break; + case PROFILE: + fileNameEdit->setText(QObject::tr("Profile image")); + *saveToFileName = fileName; + *source=PROFILE; + break; + default: + break; } saveButton->setEnabled(true); libraryButton->setEnabled(true); diff --git a/companion/src/helpers.cpp b/companion/src/helpers.cpp index 99dec9a63..2c7f9fc0c 100644 --- a/companion/src/helpers.cpp +++ b/companion/src/helpers.cpp @@ -2,6 +2,7 @@ #include "appdata.h" #include "helpers.h" #include "simulatordialog.h" +#include "flashinterface.h" QString getPhaseName(int val, char * phasename) { @@ -946,3 +947,24 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx) QObject::tr("Simulator for this firmware is not yet available")); } } + +QPixmap makePixMap( QImage image, QString firmwareType ) +{ + if (firmwareType.contains( "taranis" )) { + image = image.convertToFormat(QImage::Format_RGB32); + QRgb col; + int gray; + for (int i = 0; i < image.width(); ++i) { + for (int j = 0; j < image.height(); ++j) { + col = image.pixel(i, j); + gray = qGray(col); + image.setPixel(i, j, qRgb(gray, gray, gray)); + } + } + image = image.scaled(SPLASHX9D_WIDTH, SPLASHX9D_HEIGHT); + } + else { + image = image.scaled(SPLASH_WIDTH, SPLASH_HEIGHT).convertToFormat(QImage::Format_Mono); + } + return(QPixmap::fromImage(image)); +} diff --git a/companion/src/helpers.h b/companion/src/helpers.h index fdebcb170..5d667e5d8 100644 --- a/companion/src/helpers.h +++ b/companion/src/helpers.h @@ -128,4 +128,6 @@ QString getFrSkySrc(int index); void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx); +QPixmap makePixMap( QImage image, QString firmwareType ); + #endif // HELPERS_H diff --git a/companion/src/splashlibrary.cpp b/companion/src/splashlibrary.cpp index 5685406b7..d35dd48a6 100644 --- a/companion/src/splashlibrary.cpp +++ b/companion/src/splashlibrary.cpp @@ -3,7 +3,6 @@ #include "appdata.h" #include #include "helpers.h" -//#include "splashlabel.h" #include "flashinterface.h" #include "helpers.h" @@ -23,7 +22,6 @@ splashLibrary::splashLibrary(QWidget *parent, QString * fileName) : QDialog(pare foreach(splashLabel *sl, findChildren()) { connect(sl, SIGNAL(buttonPressed(int)), this, SLOT(onButtonPressed(int))); } - resize(0, 0); } splashLibrary::~splashLibrary() { @@ -40,7 +38,7 @@ void splashLibrary::setupPage(int page) { if ((i + 20 * page) < imageList.size()) { QImage image(imageList.at(i + 20 * page)); if (!image.isNull()) { - sl[i]->setPixmap(QPixmap::fromImage(image.scaled(SPLASH_WIDTH, SPLASH_HEIGHT).convertToFormat(QImage::Format_Mono))); + sl[i]->setPixmap(makePixMap(image, g.profile[g.id()].fwType())); sl[i]->setEnabled(true); sl[i]->setId((i + 20 * page)); sl[i]->setStyleSheet("border:1px solid; border-color:#999999;"); @@ -104,10 +102,6 @@ void splashLibrary::getFileList() { } } -void splashLibrary::shrink() { - resize(0, 0); -} - void splashLibrary::dclose() { close(); } diff --git a/companion/src/splashlibrary.h b/companion/src/splashlibrary.h index 9da9d58e4..0d9123a74 100644 --- a/companion/src/splashlibrary.h +++ b/companion/src/splashlibrary.h @@ -17,7 +17,6 @@ public: ~splashLibrary(); private slots: - void shrink() ; void dclose(); void onButtonPressed(int button); void on_nextPage_clicked(); diff --git a/companion/src/splashlibrary.ui b/companion/src/splashlibrary.ui index 15e1b54a0..5ce1e2502 100644 --- a/companion/src/splashlibrary.ui +++ b/companion/src/splashlibrary.ui @@ -6,22 +6,16 @@ 0 0 - 662 - 356 + 650 + 374 - + 0 0 - - - 662 - 356 - - @@ -39,10 +33,16 @@ - 50 + 34 0 + + + 34 + 16777215 + + ... @@ -54,12 +54,15 @@ - + + + QLayout::SetNoConstraint + - + 0 0 @@ -72,7 +75,7 @@ - 130 + 214 66 @@ -105,7 +108,7 @@ - + 0 0 @@ -113,55 +116,12 @@ 130 - 66 + 0 - 130 - 66 - - - - true - - - border:1px; - - - QFrame::Panel - - - QFrame::Plain - - - 0 - - - - - - true - - - - - - - - 0 - 0 - - - - - 130 - 66 - - - - - 130 + 214 66 @@ -191,7 +151,7 @@ - + 0 0 @@ -199,12 +159,12 @@ 130 - 66 + 0 - 130 + 214 66 @@ -234,20 +194,20 @@ - + 0 0 - 130 + 0 66 - 130 + 214 66 @@ -277,20 +237,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -320,20 +274,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -363,20 +311,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -406,20 +348,20 @@ - + 0 0 - 130 + 0 66 - 130 + 214 66 @@ -449,20 +391,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -492,20 +428,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -535,20 +465,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -578,20 +502,20 @@ - + 0 0 - 130 + 0 66 - 130 + 214 66 @@ -621,20 +545,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -664,20 +582,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -707,20 +619,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -750,20 +656,20 @@ - + 0 0 - 130 + 0 66 - 130 + 214 66 @@ -793,20 +699,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -836,20 +736,14 @@ - + 0 0 - - - 130 - 66 - - - 130 + 214 66 @@ -879,7 +773,44 @@ - + + 0 + 0 + + + + + 214 + 66 + + + + true + + + border:1px; + + + QFrame::Panel + + + QFrame::Plain + + + 0 + + + + + + true + + + + + + + 0 0 @@ -887,12 +818,12 @@ 130 - 66 + 0 - 130 + 214 66 @@ -921,7 +852,7 @@ - + false @@ -934,10 +865,16 @@ - 50 + 34 0 + + + 34 + 16777215 + + ... @@ -949,6 +886,32 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + +