12 #include "SideBarWidget_p.h"
16 #include <QVBoxLayout>
17 #include <QHBoxLayout>
19 #include <QAbstractButton>
21 #include <QStyleOptionToolButton>
26 : SideBar(location, parent)
30 m_layout->setSpacing(1);
31 m_layout->setContentsMargins(0, 0, 0, 0);
32 m_layout->addStretch();
37 auto button = createButton(dw,
this);
38 button->setText(dw->
title());
39 connect(dw, &DockWidgetBase::titleChanged, button, &SideBarButton::setText);
40 connect(dw, &DockWidgetBase::isOverlayedChanged, button, [button] {
45 connect(button, &SideBarButton::clicked,
this, [
this, dw] {
49 const int count = m_layout->count();
50 m_layout->insertWidget(count - 1, button);
58 SideBarButton *SideBarWidget::createButton(
DockWidgetBase *dw, SideBarWidget *parent)
const
60 return new SideBarButton(dw, parent);
63 SideBarButton::SideBarButton(
DockWidgetBase *dw, SideBarWidget *parent)
70 bool SideBarButton::isVertical()
const
72 return m_sideBar->isVertical();
83 QPixmap pixmap((isVertical() ? size().transposed() : size()) * devicePixelRatioF());
84 pixmap.setDevicePixelRatio(devicePixelRatioF());
90 initStyleOption(&opt);
104 pen.setWidth(isHovered ? 2 : 1);
111 pixmap = pixmap.transformed(
QTransform().rotate(90));
114 p.drawPixmap(rect(), pixmap);
117 QSize SideBarButton::sizeHint()
const
121 : (hint +
QSize(0, 2));