forked from qt-creator/qt-creator
Mor polish for the sidebar
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -242,31 +242,30 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
|
||||
if (selected) {
|
||||
//background
|
||||
painter->fillRect(rect, QColor(220, 220, 220));
|
||||
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();
|
||||
|
||||
//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));
|
||||
//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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user