37 #include <QMouseEvent> 39 #include <QApplication> 42 #include <QToolButton> 43 #include <QPushButton> 101 return this->DragState == dragState;
127 auto Button =
new QToolButton();
128 Button->setAutoRaise(
true);
133 return new QPushButton();
145 bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton;
146 CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
155 auto Features = DockWidget->
features();
156 auto SizePolicy = CloseButton->sizePolicy();
159 CloseButton->setSizePolicy(SizePolicy);
162 template <
typename T>
185 GlobalDragStartMousePosition = GlobalPos;
186 DragStartMousePosition = _this->mapFromGlobal(GlobalPos);
194 if (!IconLabel || Icon.isNull())
199 if (IconSize.isValid())
201 IconLabel->setPixmap(Icon.pixmap(IconSize));
205 IconLabel->setPixmap(Icon.pixmap(_this->style()->pixelMetric(QStyle::PM_SmallIconSize,
nullptr, _this)));
207 IconLabel->setVisible(
true);
228 TitleLabel->setObjectName(
"dockWidgetTabLabel");
230 _this->connect(
TitleLabel, SIGNAL(elidedChanged(
bool)), SIGNAL(elidedChanged(
bool)));
236 CloseButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
242 int Spacing = qRound(fm.height() / 4.0);
245 QBoxLayout* Layout =
new QBoxLayout(QBoxLayout::LeftToRight);
246 Layout->setContentsMargins(2 * Spacing,0,0,0);
247 Layout->setSpacing(0);
248 _this->setLayout(Layout);
250 Layout->addSpacing(Spacing);
252 Layout->addSpacing(qRound(Spacing * 4.0 / 3.0));
253 Layout->setAlignment(Qt::AlignCenter);
265 TargetPos.rx() = qMax(TargetPos.x(), 0);
266 TargetPos.rx() = qMin(
_this->parentWidget()->rect().right() -
_this->width() + 1, TargetPos.rx());
267 _this->move(TargetPos);
276 ADS_PRINT(
"isFloating " << dockContainer->isFloating());
277 ADS_PRINT(
"areaCount " << dockContainer->dockAreaCount());
282 if (dockContainer->isFloating()
283 && (dockContainer->visibleDockAreaCount() == 1)
331 setAttribute(Qt::WA_NoMousePropagation,
true);
336 setFocusPolicy(Qt::ClickFocus);
351 if (ev->button() == Qt::LeftButton)
359 Super::mousePressEvent(ev);
367 if (ev->button() == Qt::LeftButton)
374 switch (CurrentDragState)
380 emit
moved(ev->globalPos());
392 Super::mouseReleaseEvent(ev);
402 Super::mouseMoveEvent(ev);
410 Super::mouseMoveEvent(ev);
422 auto MappedPos = mapToParent(ev->pos());
423 bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right());
450 parentWidget()->layout()->update();
469 Super::mouseMoveEvent(ev);
488 const bool isDetachable = isFloatable && isNotOnlyTabInContainer;
491 Action->setEnabled(isDetachable);
493 Action = Menu.addAction(tr(
"Close"),
this, SIGNAL(
closeRequested()));
496 Menu.exec(ev->globalPos());
515 bool UpdateFocusStyle =
false;
516 if (active && !hasFocus())
518 setFocus(Qt::OtherFocusReason);
519 UpdateFocusStyle =
true;
524 if (UpdateFocusStyle)
569 QBoxLayout* Layout = qobject_cast<QBoxLayout*>(layout());
579 d->
IconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
581 Layout->insertWidget(0,
d->
IconLabel, Qt::AlignVCenter);
582 Layout->insertSpacing(1, qRound(1.5 * Layout->contentsMargins().left() / 2.0));
584 else if (Icon.isNull())
588 Layout->removeItem(Layout->itemAt(0));
625 Super::mouseDoubleClickEvent(event);
633 Super::setVisible(visible);
675 #ifndef QT_NO_TOOLTIP 676 if (e->type() == QEvent::ToolTipChange)
678 const auto text = toolTip();
682 return Super::event(e);
static bool testConfigFlag(eConfigFlag Flag)
void setToolTip(QObjectPtr obj, const QString &tip)
bool isRestoringState() const
If this flag is set, the active tab in a tab area has a close button.
void setText(const QString &text)
void setButtonIcon(QAbstractButton *Button, QStyle::StandardPixmap StandarPixmap, ads::eIcon CustomIconId)
Declaration of CElidingLabel.
if this flag is set, the space for the close button is reserved even if the close button is not visib...
enables styling of focused dock widget tabs or floating widget titlebar
Declaration of CFloatingDockContainer class.
void repolishStyle(QWidget *w, eRepolishChildOptions Options=RepolishIgnoreChildren)
void setElideMode(Qt::TextElideMode mode)
If enabled the tab close buttons will be QToolButtons instead of QPushButtons - disabled by default...
Declaration of CFloatingDragPreview.
Declaration of CIconProvider.
If enabled, the widgets are immediately undocked into floating widgets, if disabled, only a draw preview is undocked and the real undocking is deferred until the mouse is released.
CDockOverlay * containerOverlay() const
static int startDragDistance()
Declaration of CDockManager class.