UI/Qt: Use a globe in place of missing tab favicons
Commit 16e218b7f6 removed the fallback
favicon in order to stop showing the Ladybird logo on these tabs. But
with collapsed vertical tabs, we would then render nothing. We now use
the already-existing globe chrome icon, which is tweaked here to look a
bit better when painted larger than it was previously.
This commit is contained in:
parent
a7f1ed7a10
commit
a7b9ba5711
2 changed files with 26 additions and 15 deletions
|
|
@ -129,6 +129,20 @@ static void draw_vertical_tab_bar_icon(QPainter& painter, QColor const& color, b
|
|||
draw_stroked_icon_path(painter, arrow, color, 1.85);
|
||||
}
|
||||
|
||||
static void draw_globe_icon(QPainter& painter, QColor const& color)
|
||||
{
|
||||
painter.setPen(chrome_icon_pen(color, 1.55));
|
||||
painter.setBrush(Qt::NoBrush);
|
||||
|
||||
auto outline_rect = QRectF(3.5, 3.5, 13, 13);
|
||||
painter.drawEllipse(outline_rect);
|
||||
painter.drawLine(QPointF(outline_rect.left() + 1.3, 10), QPointF(outline_rect.right() - 1.3, 10));
|
||||
|
||||
QRectF meridian_rect(6.5, outline_rect.top(), 7.0, outline_rect.height());
|
||||
painter.drawArc(meridian_rect, 90 * 16, 180 * 16);
|
||||
painter.drawArc(meridian_rect, 270 * 16, 180 * 16);
|
||||
}
|
||||
|
||||
static QPixmap create_transparent_icon_pixmap(QSize logical_size, qreal device_pixel_ratio)
|
||||
{
|
||||
QPixmap pixmap(physical_size_for_device_pixel_ratio(logical_size, device_pixel_ratio));
|
||||
|
|
@ -188,11 +202,7 @@ static QPixmap create_chrome_icon_pixmap(ChromeIcon icon, QColor color, qreal de
|
|||
painter.drawLine(QPointF(12.1, 12.1), QPointF(16.0, 16.0));
|
||||
break;
|
||||
case ChromeIcon::Globe:
|
||||
painter.setPen(chrome_icon_pen(color, 1.55));
|
||||
painter.drawEllipse(QRectF(4.4, 4.4, 11.2, 11.2));
|
||||
painter.drawLine(QPointF(5.5, 10.0), QPointF(14.5, 10.0));
|
||||
painter.drawArc(QRectF(7.1, 4.4, 5.8, 11.2), 90 * 16, 180 * 16);
|
||||
painter.drawArc(QRectF(7.1, 4.4, 5.8, 11.2), 270 * 16, 180 * 16);
|
||||
draw_globe_icon(painter, color);
|
||||
break;
|
||||
case ChromeIcon::Folder: {
|
||||
painter.setPen(chrome_icon_pen(color, 1.6));
|
||||
|
|
|
|||
|
|
@ -285,16 +285,17 @@ void TabBar::paintEvent(QPaintEvent*)
|
|||
}
|
||||
|
||||
auto icon = tabIcon(index);
|
||||
if (icon.isNull())
|
||||
icon = create_chrome_icon(ChromeIcon::Globe, palette());
|
||||
|
||||
if (is_collapsed_vertical) {
|
||||
if (!icon.isNull()) {
|
||||
QRect icon_rect {
|
||||
tab_rect.center().x() - (TAB_ICON_SIZE / 2),
|
||||
tab_rect.center().y() - (TAB_ICON_SIZE / 2),
|
||||
TAB_ICON_SIZE,
|
||||
TAB_ICON_SIZE,
|
||||
};
|
||||
icon.paint(&painter, icon_rect);
|
||||
}
|
||||
QRect icon_rect {
|
||||
tab_rect.center().x() - (TAB_ICON_SIZE / 2),
|
||||
tab_rect.center().y() - (TAB_ICON_SIZE / 2),
|
||||
TAB_ICON_SIZE,
|
||||
TAB_ICON_SIZE,
|
||||
};
|
||||
icon.paint(&painter, icon_rect);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +305,7 @@ void TabBar::paintEvent(QPaintEvent*)
|
|||
if (auto* right_button = tabButton(index, QTabBar::RightSide); right_button && right_button->isVisible())
|
||||
contents_rect.setRight(min(contents_rect.right(), right_button->geometry().left() - 6));
|
||||
|
||||
if (!icon.isNull() && contents_rect.width() > 26) {
|
||||
if (contents_rect.width() > 26) {
|
||||
QRect icon_rect {
|
||||
contents_rect.left(),
|
||||
contents_rect.top() + ((contents_rect.height() - TAB_ICON_SIZE) / 2),
|
||||
|
|
|
|||
Loading…
Reference in a new issue