Commit 6c55cb45 authored by Alessandro Portale's avatar Alessandro Portale
Browse files

Hide the Mode Tab Icons when they become too small



When resizing the Qt Creator main window to a smaller size, at some
point the mode tab icons will shrink to fit all tabs into the window.
The icon size will if necessary shrink to tiny sizes below 8px,
which is pointless.

Let's add some code that hides the icons when a tab becomes smaller
than a certain size.

Task-Number: QTCREATORBUG-7879

Change-Id: I590379a2ec52a8a86e998c08b29d54aca800e542
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent edab369b
......@@ -275,15 +275,16 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
}
QString tabText(this->tabText(tabIndex));
QRect tabTextRect(tabRect(tabIndex));
QRect tabTextRect(rect);
const bool drawIcon = rect.height() > 36;
QRect tabIconRect(tabTextRect);
tabTextRect.translate(0, -2);
tabTextRect.translate(0, drawIcon ? -2 : 1);
QFont boldFont(painter->font());
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
boldFont.setBold(true);
painter->setFont(boldFont);
painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::TextWordWrap;
const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap;
if (enabled) {
painter->drawText(tabTextRect, textFlags, tabText);
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
......@@ -307,9 +308,11 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
if (!enabled)
painter->setOpacity(0.7);
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
tabIconRect.adjust(0, 4, 0, -textHeight);
Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
if (drawIcon) {
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
tabIconRect.adjust(0, 4, 0, -textHeight);
Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
}
painter->translate(0, -1);
painter->drawText(tabTextRect, textFlags, tabText);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment