mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-24 05:22:06 +08:00
Improved title bar button tooltips and made naming consistend with context menu
This commit is contained in:
parent
9c537340c5
commit
bd0b2ad483
@ -38,6 +38,7 @@
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QPointer>
|
||||
#include <QApplication>
|
||||
|
||||
#include "DockAreaTitleBar_p.h"
|
||||
#include "ads_globals.h"
|
||||
@ -209,7 +210,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
AutoHideButton = new CTitleBarButton(testAutoHideConfigFlag(CDockManager::DockAreaHasAutoHideButton) && autoHideEnabled);
|
||||
AutoHideButton->setObjectName("dockAreaAutoHideButton");
|
||||
AutoHideButton->setAutoRaise(true);
|
||||
internal::setToolTip(AutoHideButton, QObject::tr("Toggle Auto Hide"));
|
||||
internal::setToolTip(AutoHideButton, _this->titleBarButtonToolTip(TitleBarButtonAutoHide));
|
||||
internal::setButtonIcon(AutoHideButton, QStyle::SP_DialogOkButton, ads::AutoHideIcon);
|
||||
AutoHideButton->setSizePolicy(ButtonSizePolicy);
|
||||
AutoHideButton->setCheckable(testAutoHideConfigFlag(CDockManager::AutoHideButtonCheckable));
|
||||
@ -222,7 +223,7 @@ void DockAreaTitleBarPrivate::createButtons()
|
||||
CloseButton->setObjectName("dockAreaCloseButton");
|
||||
CloseButton->setAutoRaise(true);
|
||||
internal::setButtonIcon(CloseButton, QStyle::SP_TitleBarCloseButton, ads::DockAreaCloseIcon);
|
||||
internal::setToolTip(CloseButton, _this->closeGroupToolTip());
|
||||
internal::setToolTip(CloseButton, _this->titleBarButtonToolTip(TitleBarButtonClose));
|
||||
CloseButton->setSizePolicy(ButtonSizePolicy);
|
||||
CloseButton->setIconSize(QSize(16, 16));
|
||||
Layout->addWidget(CloseButton, 0);
|
||||
@ -507,7 +508,8 @@ void CDockAreaTitleBar::onCurrentTabChanged(int Index)
|
||||
//============================================================================
|
||||
void CDockAreaTitleBar::onAutoHideButtonClicked()
|
||||
{
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea))
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea)
|
||||
|| qApp->keyboardModifiers().testFlag(Qt::ControlModifier))
|
||||
{
|
||||
d->DockArea->toggleAutoHide();
|
||||
}
|
||||
@ -698,13 +700,13 @@ void CDockAreaTitleBar::contextMenuEvent(QContextMenuEvent* ev)
|
||||
Action->setEnabled(d->DockArea->features().testFlag(CDockWidget::DockWidgetFloatable));
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(isAutoHide ? tr("Dock") : tr("Auto Hide Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||
Action = Menu.addAction(isAutoHide ? tr("Unpin (Dock)") : tr("Pin Group"), this, SLOT(onAutoHideDockAreaActionClicked()));
|
||||
auto AreaIsPinnable = d->DockArea->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(AreaIsPinnable);
|
||||
|
||||
if (!isAutoHide)
|
||||
{
|
||||
auto menu = Menu.addMenu(tr("Auto Hide Group To..."));
|
||||
auto menu = Menu.addMenu(tr("Pin Group To..."));
|
||||
menu->setEnabled(AreaIsPinnable);
|
||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||
@ -738,19 +740,47 @@ int CDockAreaTitleBar::indexOf(QWidget *widget) const
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
QString CDockAreaTitleBar::closeGroupToolTip() const
|
||||
QString CDockAreaTitleBar::titleBarButtonToolTip(TitleBarButton Button) const
|
||||
{
|
||||
if (d->DockArea->isAutoHide())
|
||||
switch (Button)
|
||||
{
|
||||
return QObject::tr("Close Overlay");
|
||||
|
||||
}
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
||||
{
|
||||
return QObject::tr("Close Active Tab");
|
||||
case TitleBarButtonAutoHide:
|
||||
if (d->DockArea->isAutoHide())
|
||||
{
|
||||
return tr("Unpin (Dock)");
|
||||
}
|
||||
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideButtonTogglesArea))
|
||||
{
|
||||
return tr("Pin Group");
|
||||
}
|
||||
else
|
||||
{
|
||||
return tr("Pin Active Tab (Press Ctrl to Pin Group)");
|
||||
}
|
||||
break;
|
||||
|
||||
case TitleBarButtonClose:
|
||||
if (d->DockArea->isAutoHide())
|
||||
{
|
||||
return tr("Close");
|
||||
}
|
||||
|
||||
if (CDockManager::testConfigFlag(CDockManager::DockAreaCloseButtonClosesTab))
|
||||
{
|
||||
return tr("Close Active Tab");
|
||||
}
|
||||
else
|
||||
{
|
||||
return tr("Close Group");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QObject::tr("Close Group") ;
|
||||
return QString();
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
* Close group tool tip based on the current state
|
||||
* Auto hide widgets can only have one dock widget so it does not make sense for the tooltip to show close group
|
||||
*/
|
||||
QString closeGroupToolTip() const;
|
||||
QString titleBarButtonToolTip(TitleBarButton Button) const;
|
||||
|
||||
Q_SIGNALS:
|
||||
/**
|
||||
|
@ -465,7 +465,7 @@ void CDockAreaWidget::setAutoHideDockContainer(CAutoHideDockContainer* AutoHideD
|
||||
{
|
||||
d->AutoHideDockContainer = AutoHideDockContainer;
|
||||
updateAutoHideButtonCheckState();
|
||||
updateTitleBarButtonToolTip();
|
||||
updateTitleBarButtonsToolTips();
|
||||
}
|
||||
|
||||
|
||||
@ -880,9 +880,12 @@ void CDockAreaWidget::updateTitleBarButtonVisibility(bool IsTopLevel) const
|
||||
|
||||
|
||||
//============================================================================
|
||||
void CDockAreaWidget::updateTitleBarButtonToolTip()
|
||||
void CDockAreaWidget::updateTitleBarButtonsToolTips()
|
||||
{
|
||||
internal::setToolTip(titleBarButton(TitleBarButtonClose), titleBar()->closeGroupToolTip());
|
||||
internal::setToolTip(titleBarButton(TitleBarButtonClose),
|
||||
titleBar()->titleBarButtonToolTip(TitleBarButtonClose));
|
||||
internal::setToolTip(titleBarButton(TitleBarButtonAutoHide),
|
||||
titleBar()->titleBarButtonToolTip(TitleBarButtonAutoHide));
|
||||
}
|
||||
|
||||
|
||||
|
@ -87,7 +87,7 @@ private Q_SLOTS:
|
||||
/*
|
||||
* Update the title bar button tooltips
|
||||
*/
|
||||
void updateTitleBarButtonToolTip();
|
||||
void updateTitleBarButtonsToolTips();
|
||||
|
||||
/**
|
||||
* Calculate the auto hide side bar location depending on the dock area
|
||||
|
@ -532,11 +532,11 @@ void CDockWidgetTab::contextMenuEvent(QContextMenuEvent* ev)
|
||||
Action->setEnabled(isDetachable);
|
||||
if (CDockManager::testAutoHideConfigFlag(CDockManager::AutoHideFeatureEnabled))
|
||||
{
|
||||
Action = Menu.addAction(tr("Auto Hide"), this, SLOT(autoHideDockWidget()));
|
||||
Action = Menu.addAction(tr("Pin"), this, SLOT(autoHideDockWidget()));
|
||||
auto IsPinnable = d->DockWidget->features().testFlag(CDockWidget::DockWidgetPinnable);
|
||||
Action->setEnabled(IsPinnable);
|
||||
|
||||
auto menu = Menu.addMenu(tr("Auto Hide To..."));
|
||||
auto menu = Menu.addMenu(tr("Pin To..."));
|
||||
menu->setEnabled(IsPinnable);
|
||||
d->createAutoHideToAction(tr("Top"), SideBarTop, menu);
|
||||
d->createAutoHideToAction(tr("Left"), SideBarLeft, menu);
|
||||
|
Loading…
Reference in New Issue
Block a user