Fixes width bug for 212 wide images.
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#include "ui_apppreferencesdialog.h"
|
#include "ui_apppreferencesdialog.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "flashinterface.h"
|
||||||
#ifdef JOYSTICKS
|
#ifdef JOYSTICKS
|
||||||
#include "joystick.h"
|
#include "joystick.h"
|
||||||
#include "joystickdialog.h"
|
#include "joystickdialog.h"
|
||||||
@@ -339,16 +340,26 @@ void appPreferencesDialog::on_removeProfileButton_clicked()
|
|||||||
|
|
||||||
bool appPreferencesDialog::displayImage( QString fileName )
|
bool appPreferencesDialog::displayImage( QString fileName )
|
||||||
{
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
QImage image(fileName);
|
QImage image(fileName);
|
||||||
if (image.isNull())
|
if (image.isNull())
|
||||||
{
|
|
||||||
QMessageBox::critical(this, tr("Error"), tr("Cannot load %1.").arg(fileName));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
int width=ui->imageLabel->width();
|
// This code below just figures out if the width of the latest firmware is 128 or 212. It works , but...
|
||||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, 64)));
|
QString filePath1 = settings.value("lastFlashDir", "").toString() + "/" + settings.value("firmware", "").toString() + ".bin";
|
||||||
if (width==212) {
|
QString filePath2 = settings.value("lastFlashDir", "").toString() + "/" + settings.value("firmware", "").toString() + ".hex";
|
||||||
|
QFile file(filePath1);
|
||||||
|
if (!file.exists())
|
||||||
|
filePath1 = filePath2;
|
||||||
|
int width = SPLASH_WIDTH;
|
||||||
|
FlashInterface flash(filePath1);
|
||||||
|
if (flash.hasSplash())
|
||||||
|
width = flash.getSplashWidth(); // Returns SPLASHX9D_HEIGHT if filePath1 does not exist!
|
||||||
|
// There must be a cleaner way of finding out the width of the firmware splash!
|
||||||
|
|
||||||
|
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(width, SPLASH_HEIGHT)));
|
||||||
|
if (width==SPLASHX9D_WIDTH) {
|
||||||
image=image.convertToFormat(QImage::Format_RGB32);
|
image=image.convertToFormat(QImage::Format_RGB32);
|
||||||
QRgb col;
|
QRgb col;
|
||||||
int gray, height = image.height();
|
int gray, height = image.height();
|
||||||
@@ -364,6 +375,11 @@ bool appPreferencesDialog::displayImage( QString fileName )
|
|||||||
else {
|
else {
|
||||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.convertToFormat(QImage::Format_Mono)));
|
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);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -805,47 +805,6 @@ This is used by the templated to determine which channel goes to what number out
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="6">
|
|
||||||
<widget class="QPushButton" name="SplashSelect">
|
|
||||||
<property name="text">
|
|
||||||
<string>Select Image</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="4" column="6">
|
|
||||||
<widget class="QLabel" name="imageLabel">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>128</width>
|
|
||||||
<height>64</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>128</width>
|
|
||||||
<height>64</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Panel</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Raised</enum>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="5">
|
<item row="2" column="5">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -873,13 +832,6 @@ This is used by the templated to determine which channel goes to what number out
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="6">
|
|
||||||
<widget class="QPushButton" name="clearImageButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Clear Image</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="6">
|
<item row="2" column="6">
|
||||||
<widget class="QPushButton" name="sdPathButton">
|
<widget class="QPushButton" name="sdPathButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -947,6 +899,54 @@ This is used by the templated to determine which channel goes to what number out
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="7" column="1">
|
||||||
|
<widget class="QLabel" name="imageLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>128</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>212</width>
|
||||||
|
<height>64</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::Panel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="scaledContents">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="6">
|
||||||
|
<widget class="QPushButton" name="SplashSelect">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select Image</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="6">
|
||||||
|
<widget class="QPushButton" name="clearImageButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear Image</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Reference in New Issue
Block a user