mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 01:05:10 +03:00
Splash Editor modified
This commit is contained in:
parent
9badcb3513
commit
c7b7cd2ba9
5 changed files with 432 additions and 304 deletions
|
@ -12,7 +12,7 @@ customizeSplashDialog::customizeSplashDialog(QWidget *parent) :
|
|||
ui(new Ui::customizeSplashDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->libraryButton->setIcon(CompanionIcon("library.png"));
|
||||
ui->leftLibraryButton->setIcon(CompanionIcon("library.png"));
|
||||
ui->HowToLabel->clear();
|
||||
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
|
||||
}
|
||||
|
@ -22,40 +22,40 @@ customizeSplashDialog::~customizeSplashDialog()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_FlashLoadButton_clicked()
|
||||
void customizeSplashDialog::on_leftLoadButton_clicked()
|
||||
{
|
||||
QSettings settings;
|
||||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open"), settings.value("lastFlashDir").toString(), FLASH_FILES_FILTER);
|
||||
if (!fileName.isEmpty()) {
|
||||
ui->ImageLoadButton->setDisabled(true);
|
||||
ui->libraryButton->setDisabled(true);
|
||||
ui->SaveFlashButton->setDisabled(true);
|
||||
ui->SaveImageButton->setDisabled(true);
|
||||
ui->ImageFileName->clear();
|
||||
ui->imageLabel->clear();
|
||||
ui->rightLoadButton->setDisabled(true);
|
||||
ui->leftLibraryButton->setDisabled(true);
|
||||
ui->leftSaveButton->setDisabled(true);
|
||||
ui->rightSaveButton->setDisabled(true);
|
||||
ui->rightFileName->clear();
|
||||
ui->leftImageLabel->clear();
|
||||
ui->HowToLabel->clear();
|
||||
ui->HowToLabel->setStyleSheet("background:rgb(255, 255, 0)");
|
||||
QFile file(fileName);
|
||||
if (!file.exists()) {
|
||||
ui->FWFileName->clear();
|
||||
ui->leftFileName->clear();
|
||||
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
|
||||
return;
|
||||
}
|
||||
if (fileName.isEmpty()) {
|
||||
ui->FWFileName->clear();
|
||||
ui->leftFileName->clear();
|
||||
ui->HowToLabel->append("<center>" + tr("Select an original firmware file") + "</center>");
|
||||
return;
|
||||
}
|
||||
|
||||
ui->FWFileName->setText(fileName);
|
||||
ui->leftFileName->setText(fileName);
|
||||
FlashInterface flash(fileName);
|
||||
if (flash.hasSplash()) {
|
||||
ui->HowToLabel->append("<center>" + tr("Select an image to customize your splash <br />or save actual firmware splash") + "</center>");
|
||||
ui->ImageLoadButton->setEnabled(true);
|
||||
ui->libraryButton->setEnabled(true);
|
||||
ui->SaveImageButton->setEnabled(true);
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(flash.getSplash()));
|
||||
ui->imageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2);
|
||||
ui->rightLoadButton->setEnabled(true);
|
||||
ui->leftLibraryButton->setEnabled(true);
|
||||
ui->rightSaveButton->setEnabled(true);
|
||||
ui->leftImageLabel->setPixmap(QPixmap::fromImage(flash.getSplash()));
|
||||
ui->leftImageLabel->setFixedSize(flash.getSplashWidth()*2,flash.getSplashHeight()*2);
|
||||
} else {
|
||||
QMessageBox::information(this, tr("Error"), tr("Could not find bitmap to replace in file"));
|
||||
return;
|
||||
|
@ -64,7 +64,7 @@ void customizeSplashDialog::on_FlashLoadButton_clicked()
|
|||
}
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_ImageLoadButton_clicked() {
|
||||
void customizeSplashDialog::on_rightLoadButton_clicked() {
|
||||
QString supportedImageFormats;
|
||||
for (int formatIndex = 0; formatIndex < QImageReader::supportedImageFormats().count(); formatIndex++) {
|
||||
supportedImageFormats += QLatin1String(" *.") + QImageReader::supportedImageFormats()[formatIndex];
|
||||
|
@ -82,8 +82,8 @@ void customizeSplashDialog::on_ImageLoadButton_clicked() {
|
|||
return;
|
||||
}
|
||||
ui->HowToLabel->clear();
|
||||
ui->ImageFileName->setText(fileName);
|
||||
if (ui->imageLabel->width()==424) {
|
||||
ui->rightFileName->setText(fileName);
|
||||
if (ui->leftImageLabel->width()==424) {
|
||||
image=image.convertToFormat(QImage::Format_RGB32);
|
||||
QRgb col;
|
||||
int gray;
|
||||
|
@ -98,16 +98,19 @@ void customizeSplashDialog::on_ImageLoadButton_clicked() {
|
|||
image.setPixel(i, j, qRgb(gray, gray, gray));
|
||||
}
|
||||
}
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2)));
|
||||
ui->leftImageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->leftImageLabel->width()/2, ui->leftImageLabel->height()/2)));
|
||||
} else {
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
|
||||
ui->leftImageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->leftImageLabel->width()/2, ui->leftImageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
|
||||
}
|
||||
ui->SaveFlashButton->setEnabled(true);
|
||||
ui->leftSaveButton->setEnabled(true);
|
||||
ui->HowToLabel->append("<center>" + tr("Save your custimized firmware") + "</center>");
|
||||
}
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_libraryButton_clicked() {
|
||||
void customizeSplashDialog::on_rightLibraryButton_clicked() {
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_leftLibraryButton_clicked() {
|
||||
QString fileName;
|
||||
|
||||
splashLibrary *ld = new splashLibrary(this,&fileName);
|
||||
|
@ -119,8 +122,8 @@ void customizeSplashDialog::on_libraryButton_clicked() {
|
|||
return;
|
||||
}
|
||||
ui->HowToLabel->clear();
|
||||
ui->ImageFileName->setText(fileName);
|
||||
if (ui->imageLabel->width()==424) {
|
||||
ui->rightFileName->setText(fileName);
|
||||
if (ui->leftImageLabel->width()==424) {
|
||||
image=image.convertToFormat(QImage::Format_RGB32);
|
||||
QRgb col;
|
||||
int gray;
|
||||
|
@ -135,16 +138,16 @@ void customizeSplashDialog::on_libraryButton_clicked() {
|
|||
image.setPixel(i, j, qRgb(gray, gray, gray));
|
||||
}
|
||||
}
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2)));
|
||||
ui->leftImageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->leftImageLabel->width()/2, ui->leftImageLabel->height()/2)));
|
||||
} else {
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
|
||||
ui->leftImageLabel->setPixmap(QPixmap::fromImage(image.scaled(ui->leftImageLabel->width()/2, ui->leftImageLabel->height()/2).convertToFormat(QImage::Format_Mono)));
|
||||
}
|
||||
ui->SaveFlashButton->setEnabled(true);
|
||||
ui->leftSaveButton->setEnabled(true);
|
||||
ui->HowToLabel->append("<center>" + tr("Save your custimized firmware") + "</center>");
|
||||
}
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_SaveFlashButton_clicked()
|
||||
void customizeSplashDialog::on_leftSaveButton_clicked()
|
||||
{
|
||||
QString fileName;
|
||||
QSettings settings;
|
||||
|
@ -153,13 +156,13 @@ void customizeSplashDialog::on_SaveFlashButton_clicked()
|
|||
if (fileName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
FlashInterface flash(ui->FWFileName->text());
|
||||
FlashInterface flash(ui->leftFileName->text());
|
||||
if (!flash.hasSplash()) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Error reading file %1").arg(fileName));
|
||||
return;
|
||||
}
|
||||
settings.setValue("lastFlashDir", QFileInfo(fileName).dir().absolutePath());
|
||||
QImage image = ui->imageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
|
||||
QImage image = ui->leftImageLabel->pixmap()->toImage().scaled(flash.getSplashWidth(), flash.getSplashHeight());
|
||||
flash.setSplash(image);
|
||||
if (flash.saveFlash(fileName) > 0) {
|
||||
ui->HowToLabel->setStyleSheet("background:rgb(0,255.0);");
|
||||
|
@ -170,14 +173,21 @@ void customizeSplashDialog::on_SaveFlashButton_clicked()
|
|||
}
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_InvertColorButton_clicked()
|
||||
void customizeSplashDialog::on_rightInvertButton_clicked()
|
||||
{
|
||||
QImage image = ui->imageLabel->pixmap()->toImage();
|
||||
QImage image = ui->rightImageLabel->pixmap()->toImage();
|
||||
image.invertPixels();
|
||||
ui->imageLabel->setPixmap(QPixmap::fromImage(image));
|
||||
ui->rightImageLabel->setPixmap(QPixmap::fromImage(image));
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_SaveImageButton_clicked()
|
||||
void customizeSplashDialog::on_leftInvertButton_clicked()
|
||||
{
|
||||
QImage image = ui->leftImageLabel->pixmap()->toImage();
|
||||
image.invertPixels();
|
||||
ui->leftImageLabel->setPixmap(QPixmap::fromImage(image));
|
||||
}
|
||||
|
||||
void customizeSplashDialog::on_rightSaveButton_clicked()
|
||||
{
|
||||
QString fileName;
|
||||
QSettings settings;
|
||||
|
@ -185,7 +195,7 @@ void customizeSplashDialog::on_SaveImageButton_clicked()
|
|||
fileName = QFileDialog::getSaveFileName(this, tr("Write to file"), settings.value("lastImagesDir").toString(), tr("PNG images (*.png);;"), 0, QFileDialog::DontConfirmOverwrite);
|
||||
if (!fileName.isEmpty()) {
|
||||
settings.setValue("lastImagesDir", QFileInfo(fileName).dir().absolutePath());
|
||||
QImage image = ui->imageLabel->pixmap()->toImage().scaled(ui->imageLabel->width()/2, ui->imageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
|
||||
QImage image = ui->leftImageLabel->pixmap()->toImage().scaled(ui->leftImageLabel->width()/2, ui->leftImageLabel->height()/2).convertToFormat(QImage::Format_Indexed8);
|
||||
image.save(fileName, "PNG");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue