mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 10:24:45 +08:00
fix tooltips for auto hide button and close button
This commit is contained in:
parent
22402e79f5
commit
621e5e7789
@ -188,7 +188,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
AutoHideButton->setAutoRaise(true);
|
AutoHideButton->setAutoRaise(true);
|
||||||
AutoHideButton->setCheckable(true);
|
AutoHideButton->setCheckable(true);
|
||||||
AutoHideButton->setChecked(false);
|
AutoHideButton->setChecked(false);
|
||||||
internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide Group"));
|
internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide"));
|
||||||
internal::setButtonIcon(AutoHideButton, QStyle::SP_DialogOkButton, ads::AutoHideIcon);
|
internal::setButtonIcon(AutoHideButton, QStyle::SP_DialogOkButton, ads::AutoHideIcon);
|
||||||
AutoHideButton->setSizePolicy(ButtonSizePolicy);
|
AutoHideButton->setSizePolicy(ButtonSizePolicy);
|
||||||
Layout->addWidget(AutoHideButton, 0);
|
Layout->addWidget(AutoHideButton, 0);
|
||||||
@ -199,14 +199,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
|||||||
CloseButton->setObjectName("dockAreaCloseButton");
|
CloseButton->setObjectName("dockAreaCloseButton");
|
||||||
CloseButton->setAutoRaise(true);
|
CloseButton->setAutoRaise(true);
|
||||||
internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
|
internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
|
||||||
if (testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
internal::setToolTip(CloseButton, _this->closeGroupToolTip());
|
||||||
{
|
|
||||||
internal::setToolTip(CloseButton, QObject::tr("Close Active Tab"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
internal::setToolTip(CloseButton, QObject::tr("Close Group"));
|
|
||||||
}
|
|
||||||
CloseButton->setSizePolicy(ButtonSizePolicy);
|
CloseButton->setSizePolicy(ButtonSizePolicy);
|
||||||
CloseButton->setIconSize(QSize(16, 16));
|
CloseButton->setIconSize(QSize(16, 16));
|
||||||
Layout->addWidget(CloseButton, 0);
|
Layout->addWidget(CloseButton, 0);
|
||||||
@ -664,6 +657,22 @@ int CDockAreaTitleBar::indexOf(QWidget *widget) const
|
|||||||
return d->Layout->indexOf(widget);
|
return d->Layout->indexOf(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
QString CDockAreaTitleBar::closeGroupToolTip() const
|
||||||
|
{
|
||||||
|
if (d->DockArea->isOverlayed())
|
||||||
|
{
|
||||||
|
return QObject::tr("Close Overlay");
|
||||||
|
|
||||||
|
}
|
||||||
|
if (CDockManager::testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
||||||
|
{
|
||||||
|
return QObject::tr("Close Active Tab");
|
||||||
|
}
|
||||||
|
|
||||||
|
return QObject::tr("Close Group") ;
|
||||||
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent)
|
CTitleBarButton::CTitleBarButton(bool visible, QWidget* parent)
|
||||||
: tTitleBarButton(parent),
|
: tTitleBarButton(parent),
|
||||||
|
@ -155,6 +155,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
int indexOf(QWidget *widget) const;
|
int indexOf(QWidget *widget) const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close group tool tip based on the current state
|
||||||
|
* Overlayed widgets can only have one dock widget so it does not make sense for the tooltip to show close group
|
||||||
|
*/
|
||||||
|
QString closeGroupToolTip() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if a tab in the tab bar is clicked by the user
|
* This signal is emitted if a tab in the tab bar is clicked by the user
|
||||||
|
@ -832,7 +832,7 @@ void CDockAreaWidget::markTitleBarMenuOutdated()
|
|||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::updateAutoHidebuttonCheckState()
|
void CDockAreaWidget::updateAutoHideButtonCheckState()
|
||||||
{
|
{
|
||||||
auto autoHideButton = titleBarButton(TitleBarButtonAutoHide);
|
auto autoHideButton = titleBarButton(TitleBarButtonAutoHide);
|
||||||
autoHideButton->blockSignals(true);
|
autoHideButton->blockSignals(true);
|
||||||
@ -840,12 +840,21 @@ void CDockAreaWidget::updateAutoHidebuttonCheckState()
|
|||||||
autoHideButton->blockSignals(false);
|
autoHideButton->blockSignals(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
void CDockAreaWidget::updateTitleBarButtonVisibility(bool IsTopLevel) const
|
void CDockAreaWidget::updateTitleBarButtonVisibility(bool IsTopLevel) const
|
||||||
{
|
{
|
||||||
d->updateTitleBarButtonVisibility(IsTopLevel);
|
d->updateTitleBarButtonVisibility(IsTopLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockAreaWidget::updateTitleBarButtonToolTip()
|
||||||
|
{
|
||||||
|
internal::setToolTip(titleBarButton(TitleBarButtonClose), titleBar()->closeGroupToolTip());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
||||||
{
|
{
|
||||||
|
@ -154,13 +154,18 @@ protected:
|
|||||||
/*
|
/*
|
||||||
* Update the auto hide button checked state based on if it's overlayed or not
|
* Update the auto hide button checked state based on if it's overlayed or not
|
||||||
*/
|
*/
|
||||||
void updateAutoHidebuttonCheckState();
|
void updateAutoHideButtonCheckState();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the title bar button visibility based on if it's top level or not
|
* Update the title bar button visibility based on if it's top level or not
|
||||||
*/
|
*/
|
||||||
void updateTitleBarButtonVisibility(bool IsTopLevel) const;
|
void updateTitleBarButtonVisibility(bool IsTopLevel) const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Update the title bar button tooltips
|
||||||
|
*/
|
||||||
|
void updateTitleBarButtonToolTip();
|
||||||
|
|
||||||
protected Q_SLOTS:
|
protected Q_SLOTS:
|
||||||
void toggleView(bool Open);
|
void toggleView(bool Open);
|
||||||
|
|
||||||
|
@ -1058,7 +1058,8 @@ bool DockContainerWidgetPrivate::restoreOverlayDockArea(CDockingStateReader& s,
|
|||||||
|
|
||||||
dockContainer->hide();
|
dockContainer->hide();
|
||||||
DockArea = dockContainer->dockAreaWidget();
|
DockArea = dockContainer->dockAreaWidget();
|
||||||
DockArea->updateAutoHidebuttonCheckState();
|
DockArea->updateAutoHideButtonCheckState();
|
||||||
|
DockArea->updateTitleBarButtonToolTip();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (s.readNextStartElement())
|
while (s.readNextStartElement())
|
||||||
@ -1653,7 +1654,8 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area)
|
|||||||
dumpLayout();
|
dumpLayout();
|
||||||
d->emitDockAreasRemoved();
|
d->emitDockAreasRemoved();
|
||||||
area->setOverlayDockContainer(nullptr);
|
area->setOverlayDockContainer(nullptr);
|
||||||
area->updateAutoHidebuttonCheckState();
|
area->updateAutoHideButtonCheckState();
|
||||||
|
area->updateTitleBarButtonToolTip();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@ COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWid
|
|||||||
d->DockArea = new CDockAreaWidget(DockManager, parent);
|
d->DockArea = new CDockAreaWidget(DockManager, parent);
|
||||||
d->DockArea->setObjectName("OverlayDockArea");
|
d->DockArea->setObjectName("OverlayDockArea");
|
||||||
d->DockArea->setOverlayDockContainer(this);
|
d->DockArea->setOverlayDockContainer(this);
|
||||||
d->DockArea->updateAutoHidebuttonCheckState();
|
d->DockArea->updateAutoHideButtonCheckState();
|
||||||
|
d->DockArea->updateTitleBarButtonToolTip();
|
||||||
|
|
||||||
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
|
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight);
|
||||||
d->Splitter = new QSplitter(Qt::Orientation::Horizontal);
|
d->Splitter = new QSplitter(Qt::Orientation::Horizontal);
|
||||||
|
Loading…
Reference in New Issue
Block a user