1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-23 00:05:17 +03:00

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.
This commit is contained in:
Kjell Kernen 2014-02-23 22:24:43 +01:00
parent 08812f2546
commit c289689105
10 changed files with 201 additions and 262 deletions

View file

@ -280,28 +280,8 @@ bool appPreferencesDialog::displayImage( QString fileName )
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;
}

View file

@ -956,7 +956,10 @@ This is used by the templated to determine which channel goes to what number out
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>1</number>
</property>
<property name="text">
<string/>

View file

@ -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()

View file

@ -279,7 +279,7 @@
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<property name="text">
<string/>
@ -374,12 +374,21 @@
</layout>
</widget>
<tabstops>
<tabstop>BurnFlashButton</tabstop>
<tabstop>FWFileName</tabstop>
<tabstop>FlashLoadButton</tabstop>
<tabstop>DateField</tabstop>
<tabstop>SVNField</tabstop>
<tabstop>ModField</tabstop>
<tabstop>useProfileImageCB</tabstop>
<tabstop>useFwImageCB</tabstop>
<tabstop>useLibraryImageCB</tabstop>
<tabstop>useAnotherImageCB</tabstop>
<tabstop>EEbackupCB</tabstop>
<tabstop>patchcalib_CB</tabstop>
<tabstop>patchhw_CB</tabstop>
<tabstop>EEpromCB</tabstop>
<tabstop>cancelButton</tabstop>
<tabstop>BurnFlashButton</tabstop>
</tabstops>
<resources>
<include location="companion.qrc"/>

View file

@ -61,29 +61,15 @@ 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)));
}
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->setPixmap( makePixMap( image, "taranis" ));
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:

View file

@ -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));
}

View file

@ -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

View file

@ -3,7 +3,6 @@
#include "appdata.h"
#include <QtGui>
#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<splashLabel *>()) {
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();
}

View file

@ -17,7 +17,6 @@ public:
~splashLibrary();
private slots:
void shrink() ;
void dclose();
void onButtonPressed(int button);
void on_nextPage_clicked();

View file

@ -6,22 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>662</width>
<height>356</height>
<width>650</width>
<height>374</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>662</width>
<height>356</height>
</size>
</property>
<property name="windowTitle">
<string/>
</property>
@ -39,10 +33,16 @@
</property>
<property name="minimumSize">
<size>
<width>50</width>
<width>34</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>34</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
@ -54,12 +54,15 @@
</property>
</widget>
</item>
<item row="0" column="1">
<item row="0" column="2">
<layout class="QGridLayout" name="gridLayout">
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<item row="0" column="0">
<widget class="splashLabel" name="FwImage_01">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -72,7 +75,7 @@
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -105,7 +108,7 @@
<item row="0" column="1">
<widget class="splashLabel" name="FwImage_02">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -113,55 +116,12 @@
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">border:1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="splashLabel" name="FwImage_03">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -191,7 +151,7 @@
<item row="0" column="3">
<widget class="splashLabel" name="FwImage_04">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -199,12 +159,12 @@
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -234,20 +194,20 @@
<item row="1" column="0">
<widget class="splashLabel" name="FwImage_05">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<width>0</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -277,20 +237,14 @@
<item row="1" column="1">
<widget class="splashLabel" name="FwImage_06">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -320,20 +274,14 @@
<item row="1" column="2">
<widget class="splashLabel" name="FwImage_07">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -363,20 +311,14 @@
<item row="1" column="3">
<widget class="splashLabel" name="FwImage_08">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -406,20 +348,20 @@
<item row="2" column="0">
<widget class="splashLabel" name="FwImage_09">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<width>0</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -449,20 +391,14 @@
<item row="2" column="1">
<widget class="splashLabel" name="FwImage_10">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -492,20 +428,14 @@
<item row="2" column="2">
<widget class="splashLabel" name="FwImage_11">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -535,20 +465,14 @@
<item row="2" column="3">
<widget class="splashLabel" name="FwImage_12">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -578,20 +502,20 @@
<item row="3" column="0">
<widget class="splashLabel" name="FwImage_13">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<width>0</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -621,20 +545,14 @@
<item row="3" column="1">
<widget class="splashLabel" name="FwImage_14">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -664,20 +582,14 @@
<item row="3" column="2">
<widget class="splashLabel" name="FwImage_15">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -707,20 +619,14 @@
<item row="3" column="3">
<widget class="splashLabel" name="FwImage_16">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -750,20 +656,20 @@
<item row="4" column="0">
<widget class="splashLabel" name="FwImage_17">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<width>0</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -793,20 +699,14 @@
<item row="4" column="1">
<widget class="splashLabel" name="FwImage_18">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -836,20 +736,14 @@
<item row="4" column="2">
<widget class="splashLabel" name="FwImage_19">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -879,7 +773,44 @@
<item row="4" column="3">
<widget class="splashLabel" name="FwImage_20">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>214</width>
<height>66</height>
</size>
</property>
<property name="mouseTracking">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true">border:1px;</string>
</property>
<property name="frameShape">
<enum>QFrame::Panel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="splashLabel" name="FwImage_03">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -887,12 +818,12 @@
<property name="minimumSize">
<size>
<width>130</width>
<height>66</height>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>130</width>
<width>214</width>
<height>66</height>
</size>
</property>
@ -921,7 +852,7 @@
</item>
</layout>
</item>
<item row="0" column="2">
<item row="0" column="4">
<widget class="QToolButton" name="nextPage">
<property name="enabled">
<bool>false</bool>
@ -934,10 +865,16 @@
</property>
<property name="minimumSize">
<size>
<width>50</width>
<width>34</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>34</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>...</string>
</property>
@ -949,6 +886,32 @@
</property>
</widget>
</item>
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>