mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Enabled ClickFocus for CDockWidget to support focussing in case the content does not support it
Renamed FocusStyling to FocusHighlighting
This commit is contained in:
parent
2fc8bbe9c9
commit
312a8cf500
@ -196,6 +196,9 @@ static ads::CDockWidget* createFileSystemTreeDockWidget(QMenu* ViewMenu)
|
|||||||
.arg(FileSystemCount++));
|
.arg(FileSystemCount++));
|
||||||
DockWidget->setWidget(w);
|
DockWidget->setWidget(w);
|
||||||
ViewMenu->addAction(DockWidget->toggleViewAction());
|
ViewMenu->addAction(DockWidget->toggleViewAction());
|
||||||
|
// We disable focus to test focus highlighting if the dock widget content
|
||||||
|
// does not support focus
|
||||||
|
w->setFocusPolicy(Qt::NoFocus);
|
||||||
return DockWidget;
|
return DockWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -572,7 +575,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
|||||||
// CDockManager::setConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar, true);
|
// CDockManager::setConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar, true);
|
||||||
|
|
||||||
//CDockManager::setConfigFlag(CDockManager::AlwaysShowTabs, true);
|
//CDockManager::setConfigFlag(CDockManager::AlwaysShowTabs, true);
|
||||||
CDockManager::setConfigFlag(CDockManager::FocusStyling, true);
|
CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true);
|
||||||
|
|
||||||
// Now create the dock manager and its content
|
// Now create the dock manager and its content
|
||||||
d->DockManager = new CDockManager(this);
|
d->DockManager = new CDockManager(this);
|
||||||
@ -659,6 +662,7 @@ void CMainWindow::onViewToggled(bool Open)
|
|||||||
//============================================================================
|
//============================================================================
|
||||||
void CMainWindow::onViewVisibilityChanged(bool Visible)
|
void CMainWindow::onViewVisibilityChanged(bool Visible)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(Visible);
|
||||||
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
|
auto DockWidget = qobject_cast<ads::CDockWidget*>(sender());
|
||||||
if (!DockWidget)
|
if (!DockWidget)
|
||||||
{
|
{
|
||||||
|
@ -10,7 +10,7 @@ int main(int argc, char *argv[])
|
|||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QMainWindow w;
|
QMainWindow w;
|
||||||
|
|
||||||
ads::CDockManager::setConfigFlag(ads::CDockManager::FocusStyling, true);
|
ads::CDockManager::setConfigFlag(ads::CDockManager::FocusHighlighting, true);
|
||||||
auto dockManager = new ads::CDockManager(&w);
|
auto dockManager = new ads::CDockManager(&w);
|
||||||
|
|
||||||
QAction *action = new QAction("New Delete On Close", &w);
|
QAction *action = new QAction("New Delete On Close", &w);
|
||||||
|
@ -465,6 +465,11 @@ void CDockAreaTitleBar::mousePressEvent(QMouseEvent* ev)
|
|||||||
ev->accept();
|
ev->accept();
|
||||||
d->DragStartMousePos = ev->pos();
|
d->DragStartMousePos = ev->pos();
|
||||||
d->DragState = DraggingMousePressed;
|
d->DragState = DraggingMousePressed;
|
||||||
|
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting))
|
||||||
|
{
|
||||||
|
d->TabBar->currentTab()->setFocus(Qt::OtherFocusReason);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Super::mousePressEvent(ev);
|
Super::mousePressEvent(ev);
|
||||||
@ -485,6 +490,7 @@ void CDockAreaTitleBar::mouseReleaseEvent(QMouseEvent* ev)
|
|||||||
{
|
{
|
||||||
d->FloatingWidget->finishDragging();
|
d->FloatingWidget->finishDragging();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Super::mouseReleaseEvent(ev);
|
Super::mouseReleaseEvent(ev);
|
||||||
|
@ -202,7 +202,13 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
|
|||||||
{
|
{
|
||||||
DockWidget = DockWidgetTab->dockWidget();
|
DockWidget = DockWidgetTab->dockWidget();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (!DockWidget)
|
||||||
|
{
|
||||||
|
DockWidget = qobject_cast<CDockWidget*>(focusedNow);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DockWidget)
|
||||||
{
|
{
|
||||||
DockWidget = internal::findParent<CDockWidget*>(focusedNow);
|
DockWidget = internal::findParent<CDockWidget*>(focusedNow);
|
||||||
}
|
}
|
||||||
@ -226,6 +232,13 @@ void CDockFocusController::onApplicationFocusChanged(QWidget* focusedOld, QWidge
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CDockFocusController::setDockWidgetFocused(CDockWidget* focusedNow)
|
||||||
|
{
|
||||||
|
d->updateDockWidgetFocus(focusedNow);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CDockFocusController::onFocusedDockAreaViewToggled(bool Open)
|
void CDockFocusController::onFocusedDockAreaViewToggled(bool Open)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ public:
|
|||||||
template <class QWidgetPtr>
|
template <class QWidgetPtr>
|
||||||
static void setWidgetFocus(QWidgetPtr widget)
|
static void setWidgetFocus(QWidgetPtr widget)
|
||||||
{
|
{
|
||||||
if (!CDockManager::configFlags().testFlag(CDockManager::FocusStyling))
|
if (!CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,6 +75,12 @@ public:
|
|||||||
* are already inserted into its new position
|
* are already inserted into its new position
|
||||||
*/
|
*/
|
||||||
void notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget);
|
void notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
/**
|
||||||
|
* Request a focus change to the given dock widget
|
||||||
|
*/
|
||||||
|
void setDockWidgetFocused(CDockWidget* focusedNow);
|
||||||
}; // class DockFocusController
|
}; // class DockFocusController
|
||||||
}
|
}
|
||||||
// namespace ads
|
// namespace ads
|
||||||
|
@ -467,7 +467,7 @@ CDockManager::CDockManager(QWidget *parent) :
|
|||||||
d->Containers.append(this);
|
d->Containers.append(this);
|
||||||
d->loadStylesheet();
|
d->loadStylesheet();
|
||||||
|
|
||||||
if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling))
|
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting))
|
||||||
{
|
{
|
||||||
d->FocusController = new CDockFocusController(this);
|
d->FocusController = new CDockFocusController(this);
|
||||||
}
|
}
|
||||||
@ -926,6 +926,16 @@ void CDockManager::notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidg
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CDockManager::setDockWidgetFocused(CDockWidget* DockWidget)
|
||||||
|
{
|
||||||
|
if (d->FocusController)
|
||||||
|
{
|
||||||
|
d->FocusController->setDockWidgetFocused(DockWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace ads
|
} // namespace ads
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -178,7 +178,7 @@ public:
|
|||||||
FloatingContainerHasWidgetIcon = 0x80000, //!< If set, the Floating Widget icon reflects the icon of the current dock widget otherwise it displays application icon
|
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
|
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
|
//!< 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
|
FocusHighlighting = 0x200000, //!< enables styling of focused dock widget tabs or floating widget titlebar
|
||||||
|
|
||||||
DefaultDockAreaButtons = DockAreaHasCloseButton
|
DefaultDockAreaButtons = DockAreaHasCloseButton
|
||||||
| DockAreaHasUndockButton
|
| DockAreaHasUndockButton
|
||||||
@ -434,7 +434,7 @@ public:
|
|||||||
template <class QWidgetPtr>
|
template <class QWidgetPtr>
|
||||||
static void setWidgetFocus(QWidgetPtr widget)
|
static void setWidgetFocus(QWidgetPtr widget)
|
||||||
{
|
{
|
||||||
if (!CDockManager::configFlags().testFlag(CDockManager::FocusStyling))
|
if (!CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -448,6 +448,13 @@ public slots:
|
|||||||
*/
|
*/
|
||||||
void openPerspective(const QString& PerspectiveName);
|
void openPerspective(const QString& PerspectiveName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Request a focus change to the given dock widget.
|
||||||
|
* This function only has an effect, if the flag CDockManager::FocusStyling
|
||||||
|
* is enabled
|
||||||
|
*/
|
||||||
|
void setDockWidgetFocused(CDockWidget* DockWidget);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
/**
|
/**
|
||||||
* This signal is emitted if the list of perspectives changed
|
* This signal is emitted if the list of perspectives changed
|
||||||
|
@ -235,6 +235,11 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) :
|
|||||||
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
connect(d->ToggleViewAction, SIGNAL(triggered(bool)), this,
|
||||||
SLOT(toggleView(bool)));
|
SLOT(toggleView(bool)));
|
||||||
setToolbarFloatingStyle(false);
|
setToolbarFloatingStyle(false);
|
||||||
|
|
||||||
|
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting))
|
||||||
|
{
|
||||||
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
@ -285,7 +285,7 @@ CDockWidgetTab::CDockWidgetTab(CDockWidget* DockWidget, QWidget *parent) :
|
|||||||
setAttribute(Qt::WA_NoMousePropagation, true);
|
setAttribute(Qt::WA_NoMousePropagation, true);
|
||||||
d->DockWidget = DockWidget;
|
d->DockWidget = DockWidget;
|
||||||
d->createLayout();
|
d->createLayout();
|
||||||
if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling))
|
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting))
|
||||||
{
|
{
|
||||||
setFocusPolicy(Qt::ClickFocus);
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ void CDockWidgetTab::setActiveTab(bool active)
|
|||||||
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton);
|
||||||
|
|
||||||
// Focus related stuff
|
// Focus related stuff
|
||||||
if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling) && !d->DockWidget->dockManager()->isRestoringState())
|
if (CDockManager::configFlags().testFlag(CDockManager::FocusHighlighting) && !d->DockWidget->dockManager()->isRestoringState())
|
||||||
{
|
{
|
||||||
bool UpdateFocusStyle = false;
|
bool UpdateFocusStyle = false;
|
||||||
if (active && !hasFocus())
|
if (active && !hasFocus())
|
||||||
|
Loading…
Reference in New Issue
Block a user