1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

ComboTabBar: Improve drop indicator drawing

Code was taken and modified from KFilePlacesView
This commit is contained in:
David Rosca 2018-01-05 18:07:49 +01:00
parent 546e777c7c
commit 4c494ebfb0

View File

@ -1276,13 +1276,25 @@ void TabBarHelper::paintEvent(QPaintEvent* event)
// Draw drop indicator
if (m_dropIndicatorIndex != -1) {
p.setPen(QPen(palette().text(), 3));
QRect r = tabRect(m_dropIndicatorIndex);
const QRect tr = tabRect(m_dropIndicatorIndex);
QRect r;
if (m_dropIndicatorPosition == ComboTabBar::BeforeTab) {
r.moveLeft(r.x() - 1);
p.drawLine(r.topLeft(), r.bottomLeft());
r = QRect(qMax(0, tr.left() - 1), tr.top(), 3, tr.height());
} else {
p.drawLine(r.topRight(), r.bottomRight());
r = QRect(tr.right(), tr.top() - 3, 3, tr.height());
}
// Modified code from KFilePlacesView
QColor color = palette().brush(QPalette::Normal, QPalette::Highlight).color();
const int x = (r.left() + r.right()) / 2;
const int thickness = qRound(r.width() / 2.0);
int alpha = 255;
const int alphaDec = alpha / (thickness + 1);
for (int i = 0; i < thickness; i++) {
color.setAlpha(alpha);
alpha -= alphaDec;
p.setPen(color);
p.drawLine(x - i, r.top(), x - i, r.bottom());
p.drawLine(x + i, r.top(), x + i, r.bottom());
}
}
}