From fd3722b56f5bf0370f3335e47ba9ec45fb417cdb Mon Sep 17 00:00:00 2001 From: Christoph Sterz Date: Wed, 6 Sep 2017 11:17:48 +0200 Subject: [PATCH] TextureInfo: Display issues in multiple lines --- .../textureextension/texturetab.cpp | 35 ++++++++++++----- .../textureextension/texturetab.h | 2 + .../textureextension/texturetab.ui | 38 ++++--------------- 3 files changed, 36 insertions(+), 39 deletions(-) diff --git a/plugins/quickinspector/textureextension/texturetab.cpp b/plugins/quickinspector/textureextension/texturetab.cpp index 6de69577af..dda1778814 100644 --- a/plugins/quickinspector/textureextension/texturetab.cpp +++ b/plugins/quickinspector/textureextension/texturetab.cpp @@ -94,27 +94,44 @@ TextureTab::TextureTab(PropertyWidget *parent) connect(zoom, SIGNAL(currentIndexChanged(int)), ui->textureView, SLOT(setZoomLevel(int))); connect(ui->textureView, SIGNAL(zoomLevelChanged(int)), zoom, SLOT(setCurrentIndex(int))); connect(toggleTextureWasteAction, SIGNAL(toggled(bool)), ui->textureView, SLOT(setTextureWasteVisualizationEnabled(bool))); - connect(ui->textureView, SIGNAL(textureInfoNecessary(bool)), ui->textureInfo, SLOT(setVisible(bool))); + + // Texture issues infobar + connect(ui->textureView, &TextureViewWidget::textureInfoNecessary, + [&](bool infoNecessary) { + ui->textureInfo->setVisible(infoNecessary); + if (!infoNecessary) + ui->infoLabel->setText(QString()); + }); connect(ui->textureView, &TextureViewWidget::textureWasteFound, [&](bool isProblem, int percent, int bytes) { - ui->textureWasteLabel->setText(tr("Transparency Waste:") + QString::number(percent) + tr("% or ") + formatBytes(bytes)); - ui->textureWasteLabel->setVisible(isProblem); + addInfoLine(isProblem, tr("Transparency Waste: ") + QString::number(percent) + tr("% or ") + formatBytes(bytes) + tr(".")); + }); + connect(ui->textureView, &TextureViewWidget::textureIsUnicolor, + [&](bool isProblem) { + addInfoLine(isProblem, tr("Texture has only one color, consider using a widget or a rectangle.")); + }); + connect(ui->textureView, &TextureViewWidget::textureIsFullyTransparent, + [&](bool isProblem) { + addInfoLine(isProblem, tr("Texture is fully transparent, consider using margins or anchoring.")); }); - connect(ui->textureView, SIGNAL(textureIsUnicolor(bool)), ui->unicolorWarningLabel, SLOT(setVisible(bool))); - connect(ui->textureView, SIGNAL(textureIsFullyTransparent(bool)), ui->fullTransparencyWarningLabel, SLOT(setVisible(bool))); connect(ui->textureView, &TextureViewWidget::textureHasHorizontalBorderImageSavings, [&](bool isProblem, int percentSaved) { - ui->horizontalBorderImageLabel->setText(tr("Using a horizontal Border Image for this texture would save ") + QString::number(percentSaved) + tr("%.")); - ui->horizontalBorderImageLabel->setVisible(isProblem); + addInfoLine(isProblem, tr("Using a horizontal Border Image for this texture would save ") + QString::number(percentSaved) + tr("%.")); }); connect(ui->textureView, &TextureViewWidget::textureHasVerticalBorderImageSavings, [&](bool isProblem, int percentSaved) { - ui->verticalBorderImageLabel->setText(tr("Using a vertical Border Image for this texture would save ") + QString::number(percentSaved) + tr("%.")); - ui->verticalBorderImageLabel->setVisible(isProblem); + addInfoLine(isProblem, tr("Using a vertical Border Image for this texture would save ") + QString::number(percentSaved) + tr("%.")); }); zoom->setCurrentIndex(ui->textureView->zoomLevelIndex()); } +void TextureTab::addInfoLine(bool isProblem, const QString& newLine) { + if (!isProblem) return; + auto text = ui->infoLabel->text(); + if (!text.isEmpty()) text = text + QStringLiteral("
"); + ui->infoLabel->setText(text + newLine); +} + TextureTab::~TextureTab() { } diff --git a/plugins/quickinspector/textureextension/texturetab.h b/plugins/quickinspector/textureextension/texturetab.h index b54a00e0b5..ae3ec73fad 100644 --- a/plugins/quickinspector/textureextension/texturetab.h +++ b/plugins/quickinspector/textureextension/texturetab.h @@ -49,6 +49,8 @@ class TextureTab : public QWidget ~TextureTab(); private: + void addInfoLine(bool isProblem, const QString &newLine); + std::unique_ptr ui; }; } diff --git a/plugins/quickinspector/textureextension/texturetab.ui b/plugins/quickinspector/textureextension/texturetab.ui index 4f2e6f53d6..ceb4a88634 100644 --- a/plugins/quickinspector/textureextension/texturetab.ui +++ b/plugins/quickinspector/textureextension/texturetab.ui @@ -6,7 +6,7 @@ 0 0 - 661 + 1172 300 @@ -38,45 +38,23 @@ - <b>Identified Problems</b> + <b>Identified Problems:</b> Qt::RichText - - - - - - Texture Waste: - - - - - - - Unicolor texture, use rectangle instead. - - - - - - - Border Image + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - + - TextLabel + - - - - - - Texture is fully transparent. Use margins and anchoring instead of empty spacers. + + Qt::RichText