Horus model image support
This commit is contained in:
@@ -589,12 +589,24 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
|||||||
QDir qd(path);
|
QDir qd(path);
|
||||||
if (qd.exists()) {
|
if (qd.exists()) {
|
||||||
QStringList filters;
|
QStringList filters;
|
||||||
filters << "*.bmp" << "*.bmp";
|
if(IS_HORUS(board)) {
|
||||||
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
|
filters << "*.bmp" << "*.jpg" << "*.png";
|
||||||
QFileInfo fi(file);
|
foreach ( QString file, qd.entryList(filters, QDir::Files) ) {
|
||||||
QString temp = fi.completeBaseName();
|
QFileInfo fi(file);
|
||||||
if (!items.contains(temp) && temp.length() <= 10+4) {
|
QString temp = fi.fileName();
|
||||||
items.append(temp);
|
if (!items.contains(temp) && temp.length() <= 6+4) {
|
||||||
|
items.append(temp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
filters << "*.bmp";
|
||||||
|
foreach (QString file, qd.entryList(filters, QDir::Files)) {
|
||||||
|
QFileInfo fi(file);
|
||||||
|
QString temp = fi.completeBaseName();
|
||||||
|
if (!items.contains(temp) && temp.length() <= 10+4) {
|
||||||
|
items.append(temp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,22 +614,30 @@ SetupPanel::SetupPanel(QWidget * parent, ModelData & model, GeneralSettings & ge
|
|||||||
items.append(model.bitmap);
|
items.append(model.bitmap);
|
||||||
}
|
}
|
||||||
items.sort();
|
items.sort();
|
||||||
foreach ( QString file, items ) {
|
foreach (QString file, items) {
|
||||||
ui->image->addItem(file);
|
ui->image->addItem(file);
|
||||||
if (file == model.bitmap) {
|
if (file == model.bitmap) {
|
||||||
ui->image->setCurrentIndex(ui->image->count()-1);
|
ui->image->setCurrentIndex(ui->image->count()-1);
|
||||||
QString fileName = path;
|
QString fileName = path;
|
||||||
fileName.append(model.bitmap);
|
fileName.append(model.bitmap);
|
||||||
fileName.append(".bmp");
|
if (!IS_HORUS(board))
|
||||||
|
fileName.append(".bmp");
|
||||||
QImage image(fileName);
|
QImage image(fileName);
|
||||||
if (image.isNull()) {
|
if (image.isNull() && !IS_HORUS(board)) {
|
||||||
fileName = path;
|
fileName = path;
|
||||||
fileName.append(model.bitmap);
|
fileName.append(model.bitmap);
|
||||||
fileName.append(".BMP");
|
fileName.append(".BMP");
|
||||||
image.load(fileName);
|
image.load(fileName);
|
||||||
}
|
}
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled( 64,32)));;
|
if (IS_HORUS(board)) {
|
||||||
|
ui->imagePreview->setFixedSize(QSize(192, 114));
|
||||||
|
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled(192, 114)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->imagePreview->setFixedSize(QSize(64, 32));
|
||||||
|
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled(64, 32)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -835,6 +855,7 @@ void SetupPanel::on_name_editingFinished()
|
|||||||
void SetupPanel::on_image_currentIndexChanged(int index)
|
void SetupPanel::on_image_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (!lock) {
|
if (!lock) {
|
||||||
|
BoardEnum board = firmware->getBoard();
|
||||||
strncpy(model->bitmap, ui->image->currentText().toLatin1(), 10);
|
strncpy(model->bitmap, ui->image->currentText().toLatin1(), 10);
|
||||||
QString path = g.profile[g.id()].sdPath();
|
QString path = g.profile[g.id()].sdPath();
|
||||||
path.append("/IMAGES/");
|
path.append("/IMAGES/");
|
||||||
@@ -842,16 +863,24 @@ void SetupPanel::on_image_currentIndexChanged(int index)
|
|||||||
if (qd.exists()) {
|
if (qd.exists()) {
|
||||||
QString fileName=path;
|
QString fileName=path;
|
||||||
fileName.append(model->bitmap);
|
fileName.append(model->bitmap);
|
||||||
fileName.append(".bmp");
|
if (!IS_HORUS(board))
|
||||||
|
fileName.append(".bmp");
|
||||||
QImage image(fileName);
|
QImage image(fileName);
|
||||||
if (image.isNull()) {
|
if (image.isNull() && !IS_HORUS(board)) {
|
||||||
fileName=path;
|
fileName=path;
|
||||||
fileName.append(model->bitmap);
|
fileName.append(model->bitmap);
|
||||||
fileName.append(".BMP");
|
fileName.append(".BMP");
|
||||||
image.load(fileName);
|
image.load(fileName);
|
||||||
}
|
}
|
||||||
if (!image.isNull()) {
|
if (!image.isNull()) {
|
||||||
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled(64, 32)));;
|
if (IS_HORUS(board)) {
|
||||||
|
ui->imagePreview->setFixedSize(QSize(192, 114));
|
||||||
|
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled(192, 114)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ui->imagePreview->setFixedSize(QSize(64, 32));
|
||||||
|
ui->imagePreview->setPixmap(QPixmap::fromImage(image.scaled(64, 32)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ui->imagePreview->clear();
|
ui->imagePreview->clear();
|
||||||
|
|||||||
@@ -104,8 +104,8 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>64</width>
|
<width>192</width>
|
||||||
<height>32</height>
|
<height>114</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
|
|||||||
Reference in New Issue
Block a user