19 #include "FrameWidget_p.h"
20 #include "../TitleBar_p.h"
21 #include "../TabWidget_p.h"
25 #include <QVBoxLayout>
27 #include <QTableWidget>
36 explicit VBoxLayout(FrameWidget *parent)
38 , m_frameWidget(parent)
41 ~VBoxLayout()
override;
43 void invalidate()
override
46 Q_EMIT m_frameWidget->layoutInvalidated();
49 FrameWidget *
const m_frameWidget;
52 VBoxLayout::~VBoxLayout() =
default;
54 FrameWidget::FrameWidget(
QWidget *parent, FrameOptions options,
int userType)
55 : Frame(parent, options, userType)
57 auto vlayout =
new VBoxLayout(
this);
58 vlayout->setContentsMargins(0, 0, 0, 0);
59 vlayout->setSpacing(0);
60 vlayout->addWidget(titleBar());
61 vlayout->addWidget(m_tabWidget->asWidget());
63 m_tabWidget->setTabBarAutoHide(!alwaysShowsTabs());
66 setAutoFillBackground(
true);
69 FrameWidget::~FrameWidget()
80 const qreal penWidth = 1;
81 const qreal halfPenWidth = penWidth / 2;
85 :
QColor(184, 184, 184, 184);
87 pen.setWidthF(penWidth);
92 p.drawRect(rectf.
adjusted(halfPenWidth, penWidth, -halfPenWidth, -halfPenWidth));
94 p.drawRoundedRect(rectf.
adjusted(halfPenWidth, halfPenWidth, -halfPenWidth, -halfPenWidth), 2, 2);
99 QSize FrameWidget::maxSizeHint()
const
102 const QSize waste = minSize() - dockWidgetsMinSize();
103 return waste + biggestDockWidgetMaxSize();
108 return m_tabWidget->indexOfDockWidget(dw);
113 m_tabWidget->setCurrentDockWidget(dw);
116 int FrameWidget::currentIndex_impl()
const
118 return m_tabWidget->currentIndex();
121 void FrameWidget::insertDockWidget_impl(
DockWidgetBase *dw,
int index)
123 m_tabWidget->insertDockWidget(dw, index);
128 m_tabWidget->removeDockWidget(dw);
131 void FrameWidget::setCurrentTabIndex_impl(
int index)
133 m_tabWidget->setCurrentDockWidget(index);
138 return m_tabWidget->dockwidgetAt(m_tabWidget->currentIndex());
143 return qobject_cast<DockWidgetBase *>(m_tabWidget->dockwidgetAt(index));
146 QTabBar *FrameWidget::tabBar()
const
148 auto tw =
static_cast<QTabWidget *
>(m_tabWidget->asWidget());
152 QRect FrameWidget::dragRect()
const
154 QRect rect = Frame::dragRect();
158 if (Config::self().flags() & Config::Flag_HideTitleBarWhenTabsVisible) {
159 QTabBar *tabBar = this->tabBar();
169 void FrameWidget::renameTab(
int index,
const QString &text)
171 m_tabWidget->renameTab(index, text);
174 void FrameWidget::changeTabIcon(
int index,
const QIcon &icon)
176 m_tabWidget->changeTabIcon(index, icon);
179 int FrameWidget::nonContentsHeight()
const
181 TitleBar *tb = titleBar();
182 QWidget *tabBar = this->tabBar();
184 return (tb->isVisible() ? tb->height() : 0) + (tabBar->
isVisible() ? tabBar->
height() : 0);