Skip to content

Commit

Permalink
TextureInfo: Display issues in multiple lines
Browse files Browse the repository at this point in the history
  • Loading branch information
chsterz committed Sep 6, 2017
1 parent 23f1615 commit fd3722b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 39 deletions.
35 changes: 26 additions & 9 deletions plugins/quickinspector/textureextension/texturetab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<br>");
ui->infoLabel->setText(text + newLine);
}

TextureTab::~TextureTab()
{
}
2 changes: 2 additions & 0 deletions plugins/quickinspector/textureextension/texturetab.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class TextureTab : public QWidget
~TextureTab();

private:
void addInfoLine(bool isProblem, const QString &newLine);

std::unique_ptr<Ui::TextureTab> ui;
};
}
Expand Down
38 changes: 8 additions & 30 deletions plugins/quickinspector/textureextension/texturetab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>661</width>
<width>1172</width>
<height>300</height>
</rect>
</property>
Expand Down Expand Up @@ -38,45 +38,23 @@
<item>
<widget class="QLabel" name="caption">
<property name="text">
<string>&lt;b&gt;Identified Problems&lt;/b&gt;</string>
<string>&lt;b&gt;Identified Problems:&lt;/b&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="textureWasteLabel">
<property name="text">
<string>Texture Waste:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="unicolorWarningLabel">
<property name="text">
<string>Unicolor texture, use rectangle instead.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="horizontalBorderImageLabel">
<property name="text">
<string>Border Image</string>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="verticalBorderImageLabel">
<widget class="QLabel" name="infoLabel">
<property name="text">
<string>TextLabel</string>
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="fullTransparencyWarningLabel">
<property name="text">
<string>Texture is fully transparent. Use margins and anchoring instead of empty spacers.</string>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
Expand Down

0 comments on commit fd3722b

Please sign in to comment.