Added new CDockManger config flag FocusStyling

This commit is contained in:
Uwe Kindler 2020-05-23 11:10:03 +02:00
parent 26f4c9b049
commit 5652c8440e
3 changed files with 26 additions and 6 deletions

View File

@ -540,8 +540,12 @@ CDockManager::CDockManager(QWidget *parent) :
d->ContainerOverlay = new CDockOverlay(this, CDockOverlay::ModeContainerOverlay);
d->Containers.append(this);
d->loadStylesheet();
connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)),
this, SLOT(onFocusChanged(QWidget*, QWidget*)));
if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling))
{
connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)),
this, SLOT(onFocusChanged(QWidget*, QWidget*)));
}
}
//============================================================================
@ -1030,7 +1034,7 @@ void CDockManager::onFocusedDockAreaViewToggled(bool Open)
return;
}
OpenedDockAreas[0]->currentDockWidget()->tabWidget()->setFocus(Qt::OtherFocusReason);
CDockManager::setWidgetFocus(OpenedDockAreas[0]->currentDockWidget()->tabWidget());
}
@ -1040,7 +1044,7 @@ void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget)
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(DroppedWidget);
if (DockWidget)
{
DockWidget->tabWidget()->setFocus(Qt::OtherFocusReason);
CDockManager::setWidgetFocus(DockWidget->tabWidget());
emit dockWidgetDropped(DockWidget);
return;
}
@ -1052,7 +1056,7 @@ void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget)
}
DockWidget = DockArea->currentDockWidget();
DockWidget->tabWidget()->setFocus(Qt::OtherFocusReason);
CDockManager::setWidgetFocus(DockWidget->tabWidget());
}

View File

@ -171,7 +171,7 @@ public:
FloatingContainerHasWidgetIcon = 0x80000, //!< If set, the Floating Widget icon reflects the icon of the current dock widget otherwise it displays application icon
HideSingleCentralWidgetTitleBar = 0x100000, //!< If there is only one single visible dock widget in the main dock container (the dock manager) and if this flag is set, then the titlebar of this dock widget will be hidden
//!< this only makes sense for non draggable and non floatable widgets and enables the creation of some kind of "central" widget
FocusStyling = 0x200000, //!< enables styling of focused dock widget tabs or floating widget titlebar
DefaultDockAreaButtons = DockAreaHasCloseButton
| DockAreaHasUndockButton
@ -415,6 +415,21 @@ public:
*/
static int startDragDistance();
/**
* Helper function to set focus depending on the configuration of the
* FocusStyling flag
*/
template <class QWidgetPtr>
static void setWidgetFocus(QWidgetPtr widget)
{
if (!CDockManager::configFlags().testFlag(CDockManager::FocusStyling))
{
return;
}
widget->setFocus(Qt::OtherFocusReason);
}
public slots:
/**
* Opens the perspective with the given name.

View File

@ -258,6 +258,7 @@ void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap
*/
void repolishStyle(QWidget* w);
} // namespace internal
} // namespace ads