-
Notifications
You must be signed in to change notification settings - Fork 0
/
DockTitle.h
50 lines (42 loc) · 1.5 KB
/
DockTitle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <QWidget>
class QTabBar;
class QDockWidget;
class DockTitle : public QWidget
{
Q_OBJECT
public:
explicit DockTitle(QDockWidget *parent);
void setTabBar(QTabBar *tabBar);
QSize sizeHint() const override;
Q_SIGNALS:
void openNewDock();
void dockCloseRequested(QDockWidget *dock);
void contextMenuRequested(QPoint pos, QTabBar *tabBar, QDockWidget *dock);
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseDoubleClickEvent(QMouseEvent *event) override;
void contextMenuEvent(QContextMenuEvent *event) override;
private:
void paintTab(const QRect &rect, const QString &text,
int index, int current, int last);
int tabCount() const;
int currentTabIndex() const;
int tabContainingPoint(const QPoint &point);
QSize tabSize(int index) const;
QString tabText(int index) const;
QRect tabRect(int index) const;
QDockWidget *tabDock(int index);
const QDockWidget *tabDock(int index) const;
void updateTabSizes();
QSize calculateMinimumTabSize(const QString &text) const;
void setCurrentTab(int index);
void openTabsList(const QPoint &position);
QTabBar *mTabBar{ };
QList<QSize> mTabSizes;
int mTabsListButtonWidth{ };
bool mMousePressIntercepted{ };
};