ManhattanStyle: remove QTabBar position adjustment

QTabBar style was recently updated in QMacStyle (see 175f33ed855b0).
New macOS style requires all tabs to be moved one pixel to the left, so
there's 1 pixel separator line visible between them which is always
left border of the tab with higher index. But once you start moving
a tab, you'll notice that each tab has both left and right borders.

ManhattanStyle is a proxy style what means it falls back on some other
style which can be either platform-specific ("Flat" is an example) or
cross-platform ("Dark" is based on QFusionStyle). Now, even though
ManhattanStyle does not implement a custom look of QTabBar, it does
this 1 pixel adjustment for the very first tab
(QStyleOptionTab::Beginning) and QStyleOptionTab::OnlyOneTab no matter
what style is actually used.

Unfortunately, QStyleOptionTab::TabPosition enumeration does not have a
specific value for the tab which is being moved, so it's painted as
OnlyOneTab. As a result of this additional adjustment left border of the
moving tab goes out of pixmap's geometry on macOS and it looks like it
does not have left border.

This is not right to modify QTabBar's geometry for any theme arguing
it as "otherwise it looks bad" because in general case this statement is
wrong: even Fusion style draws 2 pixel wide line on the left of each
tab. Proper solution would be to implement a custom look of QTabBar in
ManhattanStyle.

Change-Id: I9e110f3195d068c6101c412e142d3a1ff7e80852
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
Oleg Yadrov
2017-03-13 16:23:05 -07:00
parent 883492c135
commit 4fac31015f

View File

@@ -618,26 +618,6 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
return QProxyStyle::drawControl(element, option, painter, widget); return QProxyStyle::drawControl(element, option, painter, widget);
switch (element) { switch (element) {
case CE_TabBarTabShape:
// Most styles draw a single dark outline. This looks rather ugly when combined with our
// single pixel dark separator so we adjust the first tab to compensate for this
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
QStyleOptionTab adjustedTab = *tab;
if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && (
tab->position == QStyleOptionTab::Beginning ||
tab->position == QStyleOptionTab::OnlyOneTab))
{
if (option->direction == Qt::LeftToRight)
adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0);
else
adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0);
}
QProxyStyle::drawControl(element, &adjustedTab, painter, widget);
return;
}
break;
case CE_MenuItem: case CE_MenuItem:
painter->save(); painter->save();
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) { if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {