Commit a7eea182 authored by Jens Bache-Wiig's avatar Jens Bache-Wiig

Revert "Disable theming of menu bar."

This reverts commit 7b8cd427.

This basically makes creator looks uglier on most platforms
while not really fixing anything on Ubuntu. The menubar is
on ubuntu (and mac) not shown in natively compiled versions
so it effectively fixes nothing, but makes the appearance
inconsistent on other platforms.

Change-Id: I4576b4dcc722dca59a7480eba41ce8efa970533b
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 3e92cd8a
......@@ -46,6 +46,7 @@
#include <QDockWidget>
#include <QLabel>
#include <QLineEdit>
#include <QMenuBar>
#include <QPainter>
#include <QPixmap>
#include <QPixmapCache>
......@@ -96,6 +97,7 @@ bool panelWidget(const QWidget *widget)
while (p) {
if (qobject_cast<const QToolBar *>(p) ||
qobject_cast<const QStatusBar *>(p) ||
qobject_cast<const QMenuBar *>(p) ||
p->property("panelwidget").toBool())
return styleEnabled(widget);
p = p->parentWidget();
......@@ -206,12 +208,16 @@ int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
case PM_DockWidgetHandleExtent:
case PM_DockWidgetSeparatorExtent:
return 1;
case PM_MenuPanelWidth:
case PM_MenuBarHMargin:
case PM_MenuBarVMargin:
case PM_ToolBarFrameWidth:
if (panelWidget(widget))
retval = 1;
break;
case PM_ButtonShiftVertical:
case PM_ButtonShiftHorizontal:
case PM_MenuBarPanelWidth:
case PM_ToolBarItemMargin:
case PM_ToolBarItemSpacing:
if (panelWidget(widget))
......@@ -636,6 +642,52 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
}
break;
case CE_MenuBarItem:
painter->save();
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120);
bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
bool dis = !(mbi->state & State_Enabled);
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
QStyleOptionMenuItem item = *mbi;
item.rect = mbi->rect;
QPalette pal = mbi->palette;
pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black);
item.palette = pal;
QCommonStyle::drawControl(element, &item, painter, widget);
QRect r = option->rect;
if (act) {
// Fill|
QColor baseColor = Utils::StyleHelper::baseColor();
QLinearGradient grad(option->rect.topLeft(), option->rect.bottomLeft());
grad.setColorAt(0, baseColor.lighter(120));
grad.setColorAt(1, baseColor.lighter(130));
painter->fillRect(option->rect.adjusted(1, 1, -1, 0), grad);
// Outline
painter->setPen(QPen(highlightOutline, 0));
painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom()));
painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom()));
painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top()));
highlightOutline.setAlpha(60);
painter->setPen(QPen(highlightOutline, 0));
painter->drawPoint(r.topLeft());
painter->drawPoint(r.topRight());
QPalette pal = mbi->palette;
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
if (!styleHint(SH_UnderlineShortcut, mbi, widget))
alignment |= Qt::TextHideMnemonic;
pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60));
drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
drawItemText(painter, item.rect, alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
}
}
painter->restore();
break;
case CE_ComboBoxLabel:
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
if (panelWidget(widget)) {
......@@ -716,6 +768,15 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
}
break;
case CE_MenuBarEmptyArea: {
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
painter->save();
painter->setPen(Utils::StyleHelper::borderColor());
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
painter->restore();
}
break;
case CE_ToolBar:
{
QRect rect = option->rect;
......
Markdown is supported
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