Falkon Develop
Cross-platform Qt-based web browser
tabtreedelegate.h
Go to the documentation of this file.
1/* ============================================================
2* VerticalTabs plugin for Falkon
3* Copyright (C) 2018 David Rosca <nowrep@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#pragma once
19
20#include <QAbstractButton>
21#include <QStyledItemDelegate>
22
23class QPushButton;
24
25class TabTreeView;
26class LoadingAnimator;
27
28class TabTreeCloseButton : public QAbstractButton
29{
30 Q_OBJECT
31 Q_PROPERTY(int showOnNormal READ showOnNormal WRITE setShowOnNormal)
32 Q_PROPERTY(int showOnHovered READ showOnHovered WRITE setShowOnHovered)
33 Q_PROPERTY(int showOnSelected READ showOnSelected WRITE setShowOnSelected)
34
35public:
36 explicit TabTreeCloseButton(QWidget *parent = nullptr);
37
38 int showOnNormal() const;
39 void setShowOnNormal(int show);
40
41 int showOnHovered() const;
42 void setShowOnHovered(int show);
43
44 int showOnSelected() const;
45 void setShowOnSelected(int show);
46
47 bool isVisible(bool hovered, bool selected) const;
48
49private:
50 void paintEvent(QPaintEvent *event) override;
51
52 int m_showOnNormal = 0;
53 int m_showOnHovered = 1;
54 int m_showOnSelected = 1;
55};
56
57class TabTreeDelegate : public QStyledItemDelegate
58{
59public:
60 explicit TabTreeDelegate(TabTreeView *view);
61
62 QRect expandButtonRect(const QModelIndex &index) const;
63 QRect audioButtonRect(const QModelIndex &index) const;
64 QRect closeButtonRect(const QModelIndex &index) const;
65
66 void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override;
67 QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override;
68
69private:
70 TabTreeView *m_view;
71 LoadingAnimator *m_loadingAnimator;
72 TabTreeCloseButton *m_closeButton;
73 int m_padding;
74 int m_indentation;
75};
void setShowOnHovered(int show)
bool isVisible(bool hovered, bool selected) const
void setShowOnNormal(int show)
void setShowOnSelected(int show)
TabTreeCloseButton(QWidget *parent=nullptr)
QRect audioButtonRect(const QModelIndex &index) const
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override
QRect closeButtonRect(const QModelIndex &index) const
TabTreeDelegate(TabTreeView *view)
QRect expandButtonRect(const QModelIndex &index) const
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override