forked from qt-creator/qt-creator
Fix missing tabfocus with manhattanstyle
I added a new focus rect for combo boxes with manhattan style. To reduce the visual impact I follow the same policy we use on windows where we do not show the focus rect unless it is called upon by tabfocus.
This commit is contained in:
@@ -475,6 +475,17 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
QColor lighter(255, 255, 255, 37);
|
QColor lighter(255, 255, 255, 37);
|
||||||
painter->fillRect(rect, lighter);
|
painter->fillRect(rect, lighter);
|
||||||
}
|
}
|
||||||
|
if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) {
|
||||||
|
QColor highlight = option->palette.highlight().color();
|
||||||
|
highlight.setAlphaF(0.4);
|
||||||
|
painter->setPen(QPen(highlight.lighter(), 1));
|
||||||
|
highlight.setAlphaF(0.3);
|
||||||
|
painter->setBrush(highlight);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
QRectF rect = option->rect;
|
||||||
|
rect.translate(0.5, 0.5);
|
||||||
|
painter->drawRoundedRect(rect.adjusted(2, 2, -3, -3), 2, 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -819,24 +830,6 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
|
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolbutton->state & State_HasFocus) {
|
|
||||||
QStyleOptionFocusRect fr;
|
|
||||||
fr.QStyleOption::operator=(*toolbutton);
|
|
||||||
fr.rect.adjust(3, 3, -3, -3);
|
|
||||||
if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup)
|
|
||||||
fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator,
|
|
||||||
toolbutton, widget), 0);
|
|
||||||
QPen oldPen = painter->pen();
|
|
||||||
QColor focusColor = Utils::StyleHelper::panelTextColor();
|
|
||||||
focusColor.setAlpha(120);
|
|
||||||
QPen outline(focusColor, 1);
|
|
||||||
outline.setStyle(Qt::DotLine);
|
|
||||||
painter->setPen(outline);
|
|
||||||
QRect r = option->rect.adjusted(2, 2, -2, -2);
|
|
||||||
painter->drawRect(r);
|
|
||||||
painter->setPen(oldPen);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStyleOptionToolButton label = *toolbutton;
|
QStyleOptionToolButton label = *toolbutton;
|
||||||
|
|
||||||
label.palette = panelPalette(option->palette, lightColored(widget));
|
label.palette = panelPalette(option->palette, lightColored(widget));
|
||||||
@@ -938,6 +931,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
} else {
|
} else {
|
||||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -376,6 +376,7 @@ NavigationSubWidget::NavigationSubWidget(NavigationWidget *parentWidget)
|
|||||||
|
|
||||||
m_navigationComboBox = new NavComboBox(this);
|
m_navigationComboBox = new NavComboBox(this);
|
||||||
m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
m_navigationComboBox->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||||
|
m_navigationComboBox->setFocusPolicy(Qt::TabFocus);
|
||||||
m_navigationComboBox->setMinimumContentsLength(0);
|
m_navigationComboBox->setMinimumContentsLength(0);
|
||||||
m_navigationWidget = 0;
|
m_navigationWidget = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -385,6 +385,7 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
|
|||||||
bar->setFixedHeight(panelHeight);
|
bar->setFixedHeight(panelHeight);
|
||||||
|
|
||||||
m_projectsBox = new QComboBox;
|
m_projectsBox = new QComboBox;
|
||||||
|
m_projectsBox->setFocusPolicy(Qt::TabFocus);
|
||||||
f.setBold(false);
|
f.setBold(false);
|
||||||
m_projectsBox->setFont(f);
|
m_projectsBox->setFont(f);
|
||||||
m_projectsBox->ensurePolished();
|
m_projectsBox->ensurePolished();
|
||||||
|
|||||||
Reference in New Issue
Block a user