mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-10 17:13:39 +01:00
move duplicated code to annonymous namespace static function
update
This commit is contained in:
parent
8579cce85c
commit
b4fe7ac7e2
@ -55,6 +55,38 @@ using namespace Internal;
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
const int FancyTabBar::m_textPadding = 4;
|
||||
|
||||
|
||||
namespace {
|
||||
static void selectTab(QPainter* p, const QRect& rect) {
|
||||
// background
|
||||
p->save();
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 140));
|
||||
grad.setColorAt(1, QColor(255, 255, 255, 210));
|
||||
p->fillRect(rect.adjusted(0, 0, 0, -1), grad);
|
||||
p->restore();
|
||||
|
||||
// shadows
|
||||
p->setPen(QColor(0, 0, 0, 110));
|
||||
p->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1));
|
||||
p->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
p->setPen(QColor(0, 0, 0, 40));
|
||||
p->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
|
||||
// highlights
|
||||
p->setPen(QColor(255, 255, 255, 50));
|
||||
p->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2));
|
||||
p->drawLine(rect.bottomLeft() + QPoint(0, 1),
|
||||
rect.bottomRight() + QPoint(0, 1));
|
||||
p->setPen(QColor(255, 255, 255, 40));
|
||||
p->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
|
||||
p->drawLine(rect.topRight() + QPoint(0, 1),
|
||||
rect.bottomRight() - QPoint(0, 1));
|
||||
p->drawLine(rect.bottomLeft() + QPoint(0, -1),
|
||||
rect.bottomRight() - QPoint(0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
void FancyTabProxyStyle::drawControl(ControlElement element,
|
||||
const QStyleOption* option, QPainter* p,
|
||||
const QWidget* widget) const {
|
||||
@ -73,32 +105,7 @@ void FancyTabProxyStyle::drawControl(ControlElement element,
|
||||
const QString text = v_opt->text;
|
||||
|
||||
if (selected) {
|
||||
// background
|
||||
p->save();
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 140));
|
||||
grad.setColorAt(1, QColor(255, 255, 255, 210));
|
||||
p->fillRect(rect.adjusted(0, 0, 0, -1), grad);
|
||||
p->restore();
|
||||
|
||||
// shadows
|
||||
p->setPen(QColor(0, 0, 0, 110));
|
||||
p->drawLine(rect.topLeft() + QPoint(1, -1), rect.topRight() - QPoint(0, 1));
|
||||
p->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
p->setPen(QColor(0, 0, 0, 40));
|
||||
p->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
|
||||
// highlights
|
||||
p->setPen(QColor(255, 255, 255, 50));
|
||||
p->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0, 2));
|
||||
p->drawLine(rect.bottomLeft() + QPoint(0, 1),
|
||||
rect.bottomRight() + QPoint(0, 1));
|
||||
p->setPen(QColor(255, 255, 255, 40));
|
||||
p->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
|
||||
p->drawLine(rect.topRight() + QPoint(0, 1),
|
||||
rect.bottomRight() - QPoint(0, 1));
|
||||
p->drawLine(rect.bottomLeft() + QPoint(0, -1),
|
||||
rect.bottomRight() - QPoint(0, 1));
|
||||
selectTab(p, rect);
|
||||
}
|
||||
|
||||
QTransform m;
|
||||
@ -394,34 +401,7 @@ void FancyTabBar::paintTab(QPainter* painter, int tabIndex) const {
|
||||
bool selected = (tabIndex == m_currentIndex);
|
||||
|
||||
if (selected) {
|
||||
// background
|
||||
painter->save();
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
grad.setColorAt(0, QColor(255, 255, 255, 140));
|
||||
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(0, 0, 0, 40));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
|
||||
// highlights
|
||||
painter->setPen(QColor(255, 255, 255, 50));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, -2),
|
||||
rect.topRight() - QPoint(0, 2));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(0, 1),
|
||||
rect.bottomRight() + QPoint(0, 1));
|
||||
painter->setPen(QColor(255, 255, 255, 40));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
|
||||
painter->drawLine(rect.topRight() + QPoint(0, 1),
|
||||
rect.bottomRight() - QPoint(0, 1));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(0, -1),
|
||||
rect.bottomRight() - QPoint(0, 1));
|
||||
selectTab(painter, rect);
|
||||
}
|
||||
|
||||
QString tabText(painter->fontMetrics().elidedText(this->tabText(tabIndex),
|
||||
|
Loading…
Reference in New Issue
Block a user