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

VerticalTabs: Add option to indentate background of items

This commit is contained in:
David Rosca 2018-02-03 16:55:06 +01:00
parent e5a55a6c69
commit ac9830381d
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
3 changed files with 19 additions and 0 deletions

View File

@ -181,6 +181,10 @@ void TabTreeDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
const bool selected = opt.state.testFlag(QStyle::State_Selected);
// Draw background
if (m_view->backgroundIndentation()) {
opt.rect.moveLeft(m_indentation * depth);
opt.rect.setWidth(opt.rect.width() - m_indentation * depth);
}
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, w);
// Draw expand button

View File

@ -66,6 +66,16 @@ QColor TabTreeView::selectedColor() const
return m_selectedColor;
}
int TabTreeView::backgroundIndentation() const
{
return m_backgroundIndentation;
}
void TabTreeView::setBackgroundIndentation(int indentation)
{
m_backgroundIndentation = indentation;
}
void TabTreeView::setSelectedColor(const QColor &color)
{
m_selectedColor = color;

View File

@ -26,6 +26,7 @@ class TabTreeView : public QTreeView
Q_OBJECT
Q_PROPERTY(QColor hoverColor READ hoverColor WRITE setHoverColor)
Q_PROPERTY(QColor selectedColor READ selectedColor WRITE setSelectedColor)
Q_PROPERTY(int backgroundIndentation READ backgroundIndentation WRITE setBackgroundIndentation)
public:
explicit TabTreeView(QWidget *parent = nullptr);
@ -36,6 +37,9 @@ public:
QColor selectedColor() const;
void setSelectedColor(const QColor &color);
int backgroundIndentation() const;
void setBackgroundIndentation(int indentation);
// In TabBar order
bool areTabsInOrder() const;
void setTabsInOrder(bool enable);
@ -67,4 +71,5 @@ private:
QPersistentModelIndex m_pressedIndex;
QPersistentModelIndex m_hoveredIndex;
bool m_tabsInOrder = false;
int m_backgroundIndentation = 0;
};