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:
parent
e5a55a6c69
commit
ac9830381d
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user