From f331f3322bb9752d7d24896a0d51eada67ca6d98 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig <jbache@trolltech.com> Date: Fri, 19 Feb 2010 18:05:42 +0100 Subject: [PATCH] Mor polish for the sidebar --- src/libs/utils/stylehelper.cpp | 9 ++-- src/plugins/coreplugin/fancyactionbar.cpp | 3 +- src/plugins/coreplugin/fancytabwidget.cpp | 50 ++++++++++--------- src/plugins/coreplugin/manhattanstyle.cpp | 21 ++++++++ .../progressmanager/progresspie.cpp | 2 +- 5 files changed, 54 insertions(+), 31 deletions(-) diff --git a/src/libs/utils/stylehelper.cpp b/src/libs/utils/stylehelper.cpp index 887b3f201ef..7be8e7f4b81 100644 --- a/src/libs/utils/stylehelper.cpp +++ b/src/libs/utils/stylehelper.cpp @@ -147,18 +147,19 @@ void StyleHelper::setBaseColor(const QColor &color) static void verticalGradientHelper(QPainter *p, const QRect &spanRect, const QRect &rect, bool lightColored) { - QColor base = StyleHelper::baseColor(lightColored); QColor highlight = StyleHelper::highlightColor(lightColored); QColor shadow = StyleHelper::shadowColor(lightColored); QLinearGradient grad(spanRect.topRight(), spanRect.topLeft()); - grad.setColorAt(0, highlight); - grad.setColorAt(0.301, base); - grad.setColorAt(1, shadow); + grad.setColorAt(0, highlight.lighter(106)); + grad.setColorAt(1, shadow.darker(106)); p->fillRect(rect, grad); QColor light(255, 255, 255, 80); p->setPen(light); p->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0)); + QColor dark(0, 0, 0, 90); + p->setPen(dark); + p->drawLine(rect.topLeft(), rect.bottomLeft()); } void StyleHelper::verticalGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect, bool lightColored) diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp index 6afad800145..e9c84538745 100644 --- a/src/plugins/coreplugin/fancyactionbar.cpp +++ b/src/plugins/coreplugin/fancyactionbar.cpp @@ -104,7 +104,6 @@ void FancyToolButton::paintEvent(QPaintEvent *event) painter.drawLine(rect().topLeft(), rect().topRight()); painter.drawLine(rect().bottomLeft(), rect().bottomRight()); painter.restore(); - } else #endif if (isDown() || isChecked()) { @@ -193,7 +192,7 @@ void FancyActionBar::paintEvent(QPaintEvent *event) painter.setPen(dark); painter.drawLine(rect().topLeft(), rect().topRight()); painter.setPen(light); - painter.drawLine(rect().topLeft() + QPoint(0,1), rect().topRight() + QPoint(0,1)); + painter.drawLine(rect().topLeft() + QPoint(1,1), rect().topRight() + QPoint(0,1)); } QSize FancyToolButton::sizeHint() const diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp index aba60f9ea38..6cb520b4628 100644 --- a/src/plugins/coreplugin/fancytabwidget.cpp +++ b/src/plugins/coreplugin/fancytabwidget.cpp @@ -242,31 +242,30 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const if (selected) { //background - painter->fillRect(rect, QColor(220, 220, 220)); - - //highlight - painter->setPen(QColor(255, 255, 255, 150)); - painter->drawLine(rect.bottomLeft() - QPoint(-1, 1), rect.bottomRight() - QPoint(0,1)); - painter->drawLine(rect.topRight(), rect.bottomRight()); - - //shadow - painter->setPen(QColor(255, 255, 255, 50)); - painter->drawLine(rect.topLeft() - QPoint(0,2), rect.topRight() - QPoint(0,2)); - painter->setPen(QColor(0, 0, 0, 150)); - painter->drawLine(rect.topLeft() - QPoint(0,1), rect.topRight() - QPoint(0,1)); - painter->drawLine(rect.topLeft(), rect.bottomLeft()); - painter->setPen(QColor(0, 0, 0, 100)); - painter->drawLine(rect.topLeft(), rect.topRight()); - painter->setPen(QColor(0, 0, 0, 40)); - painter->drawLine(rect.topLeft() + QPoint(0,1), rect.topRight() + QPoint(0,1)); - painter->drawLine(rect.topLeft() + QPoint(1,1), rect.bottomLeft() + QPoint(1,0)); - painter->setPen(QColor(0, 0, 0, 20)); - painter->drawLine(rect.topLeft() + QPoint(0,2), rect.topRight() + QPoint(0,2)); - painter->drawLine(rect.topLeft() + QPoint(2,1), rect.bottomLeft() + QPoint(2,0)); - painter->setPen(QColor(0, 0, 0, 150)); + painter->save(); + QLinearGradient grad(rect.topLeft(), rect.topRight()); + grad.setColorAt(0, QColor(255, 255, 255, 160)); + grad.setColorAt(1, QColor(255, 255, 255, 210)); + painter->fillRect(rect.adjusted(0, 0, 0, -1), grad); + painter->restore(); + + //shadows + painter->setPen(QColor(0, 0, 0, 110)); + painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1)); painter->drawLine(rect.bottomLeft(), rect.bottomRight()); - painter->setPen(QColor(255, 255, 255, 50)); - painter->drawLine(rect.bottomLeft() + QPoint(0,1), rect.bottomRight() + QPoint(0,1)); + painter->setPen(QColor(0, 0, 0, 40)); + painter->drawLine(rect.topLeft(), rect.bottomLeft()); + painter->setPen(QColor(0, 0, 0, 10)); + painter->drawLine(rect.topLeft() + QPoint(1, 1), rect.bottomLeft() + QPoint(1, -1)); + + //highlights + painter->setPen(QColor(255, 255, 255, 90)); + painter->drawLine(rect.topLeft() + QPoint(1, -2), rect.topRight() - QPoint(0,2)); + painter->drawLine(rect.bottomLeft() + QPoint(1, 1), rect.bottomRight() + QPoint(0,1)); + painter->setPen(QColor(255, 255, 255, 160)); + painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight()); + painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1)); + painter->drawLine(rect.bottomLeft() + QPoint(1,-1), rect.bottomRight()-QPoint(0,1)); } QString tabText(this->tabText(tabIndex)); @@ -458,6 +457,9 @@ void FancyTabWidget::paintEvent(QPaintEvent *event) QColor light = Utils::StyleHelper::sidebarHighlight(); painter.setPen(light); painter.drawLine(rect.bottomLeft(), rect.bottomRight()); + painter.setPen(QColor(0, 0, 0, 20)); + painter.drawLine(rect.topLeft() + QPoint(1, 0), rect.bottomLeft() + QPoint(1, 0)); + setContentsMargins(0, 0, 0, 1); } diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp index 67ba51ade45..559026335c7 100644 --- a/src/plugins/coreplugin/manhattanstyle.cpp +++ b/src/plugins/coreplugin/manhattanstyle.cpp @@ -56,6 +56,7 @@ #include <QtGui/QStyleOption> #include <QtGui/QToolBar> #include <QtGui/QToolButton> +#include <QtGui/QAbstractItemView> // We define a currently unused state for indicating animations #define State_Animating 0x00000040 @@ -87,6 +88,7 @@ bool panelWidget(const QWidget *widget) while (p) { if (qobject_cast<const QToolBar *>(p) || qobject_cast<const QStatusBar *>(p) || + qobject_cast<const QAbstractItemView *>(p) || qobject_cast<const QMenuBar *>(p)) return styleEnabled(widget); if (p->property("panelwidget").toBool()) @@ -497,6 +499,25 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption } switch (element) { + case PE_PanelItemViewItem: + if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) { + if (vopt->state & State_Selected) { + QLinearGradient gradient; + gradient.setStart(option->rect.topLeft()); + gradient.setFinalStop(option->rect.bottomRight()); + gradient.setColorAt(0, option->palette.highlight().color().lighter(115)); + gradient.setColorAt(1, option->palette.highlight().color().darker(135)); + painter->fillRect(option->rect, Qt::blue); + } else { + if (vopt->backgroundBrush.style() != Qt::NoBrush) { + QPointF oldBO = painter->brushOrigin(); + painter->setBrushOrigin(vopt->rect.topLeft()); + painter->fillRect(vopt->rect, vopt->backgroundBrush); + painter->setBrushOrigin(oldBO); + } + } + } + break; case PE_PanelLineEdit: { painter->save(); diff --git a/src/plugins/coreplugin/progressmanager/progresspie.cpp b/src/plugins/coreplugin/progressmanager/progresspie.cpp index 45aa71eac84..a469945acfd 100644 --- a/src/plugins/coreplugin/progressmanager/progresspie.cpp +++ b/src/plugins/coreplugin/progressmanager/progresspie.cpp @@ -150,7 +150,7 @@ void ProgressBar::paintEvent(QPaintEvent *) p.drawLine(0,0, size().width(), 0); p.setPen(Utils::StyleHelper::sidebarHighlight()); - p.drawLine(0, 1, size().width(), 1); + p.drawLine(1, 1, size().width(), 1); QRect textRect = rect().adjusted(0, 0, -1, 0); textRect.setHeight(h+5); -- GitLab