mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 21:25:44 +08:00
Improved highlighting focused dock widget
This commit is contained in:
parent
f54869fbf7
commit
056e1ef947
@ -94,7 +94,8 @@ struct DockManagerPrivate
|
|||||||
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
|
CDockManager::eViewMenuInsertionOrder MenuInsertionOrder = CDockManager::MenuAlphabeticallySorted;
|
||||||
bool RestoringState = false;
|
bool RestoringState = false;
|
||||||
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
|
QVector<CFloatingDockContainer*> UninitializedFloatingWidgets;
|
||||||
QPointer<CDockWidget> FocusedDockWidget;
|
QPointer<CDockWidget> FocusedDockWidget = nullptr;
|
||||||
|
QPointer<CDockAreaWidget> FocusedArea = nullptr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@ -881,6 +882,12 @@ CIconProvider& CDockManager::iconProvider()
|
|||||||
//===========================================================================
|
//===========================================================================
|
||||||
void CDockManager::onFocusObjectChanged(QObject *focusObject)
|
void CDockManager::onFocusObjectChanged(QObject *focusObject)
|
||||||
{
|
{
|
||||||
|
if (!focusObject)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::cout << "\n\nCDockManager::onFocusObjectChanged " << focusObject->metaObject()->className() << std::endl;
|
||||||
|
|
||||||
auto FocusWidget = qobject_cast<QWidget*>(focusObject);
|
auto FocusWidget = qobject_cast<QWidget*>(focusObject);
|
||||||
if (!FocusWidget)
|
if (!FocusWidget)
|
||||||
{
|
{
|
||||||
@ -889,46 +896,39 @@ void CDockManager::onFocusObjectChanged(QObject *focusObject)
|
|||||||
|
|
||||||
CDockWidget* DockWidget = nullptr;
|
CDockWidget* DockWidget = nullptr;
|
||||||
|
|
||||||
std::cout << "CDockManager::onFocusObjectChanged " << focusObject->objectName().toStdString()
|
|
||||||
<< " meta: " << focusObject->metaObject()->className() << std::endl;
|
|
||||||
|
|
||||||
auto DockWidgetTab = qobject_cast<CDockWidgetTab*>(focusObject);
|
auto DockWidgetTab = qobject_cast<CDockWidgetTab*>(focusObject);
|
||||||
if (DockWidgetTab)
|
if (DockWidgetTab)
|
||||||
{
|
{
|
||||||
DockWidget = DockWidgetTab->dockWidget();
|
DockWidget = DockWidgetTab->dockWidget();
|
||||||
|
std::cout << "TabText: " << DockWidgetTab->text().toStdString() << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DockWidget = internal::findParent<CDockWidget*>(FocusWidget);
|
DockWidget = internal::findParent<CDockWidget*>(FocusWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Focus Object " << focusObject->objectName().toStdString()
|
||||||
|
<< " meta: " << focusObject->metaObject()->className() << std::endl;
|
||||||
if (!DockWidget)
|
if (!DockWidget)
|
||||||
{
|
{
|
||||||
return;
|
std::cout << "!DockWidget" << std::endl;
|
||||||
}
|
|
||||||
|
|
||||||
if (d->FocusedDockWidget.data() == DockWidget)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<CDockWidget*> DockWidgets;
|
QList<CDockWidget*> DockWidgets;
|
||||||
CDockAreaWidget* OldFocusedDockArea = nullptr;
|
|
||||||
CDockAreaWidget* NewFocusedDockArea = nullptr;
|
CDockAreaWidget* NewFocusedDockArea = nullptr;
|
||||||
if (d->FocusedDockWidget)
|
if (d->FocusedDockWidget)
|
||||||
{
|
{
|
||||||
|
std::cout << "focuse = false: " << d->FocusedDockWidget->objectName().toStdString() << std::endl;
|
||||||
d->FocusedDockWidget->setProperty("focused", false);
|
d->FocusedDockWidget->setProperty("focused", false);
|
||||||
d->FocusedDockWidget->tabWidget()->setProperty("focused", false);
|
d->FocusedDockWidget->tabWidget()->setProperty("focused", false);
|
||||||
OldFocusedDockArea = d->FocusedDockWidget->dockAreaWidget();
|
|
||||||
if (OldFocusedDockArea)
|
|
||||||
{
|
|
||||||
OldFocusedDockArea->setProperty("focused", false);
|
|
||||||
}
|
|
||||||
DockWidgets.append(d->FocusedDockWidget);
|
DockWidgets.append(d->FocusedDockWidget);
|
||||||
}
|
}
|
||||||
d->FocusedDockWidget = DockWidget;
|
d->FocusedDockWidget = DockWidget;
|
||||||
|
std::cout << "d->FocusedDockWidget " << d->FocusedDockWidget->objectName().toStdString() << std::endl;
|
||||||
d->FocusedDockWidget->setProperty("focused", true);
|
d->FocusedDockWidget->setProperty("focused", true);
|
||||||
d->FocusedDockWidget->tabWidget()->setProperty("focused", true);
|
d->FocusedDockWidget->tabWidget()->setProperty("focused", true);
|
||||||
|
connect(d->FocusedDockWidget, SIGNAL(closed()), this, SLOT(onFocusedDockWidgetClosed()));
|
||||||
NewFocusedDockArea = d->FocusedDockWidget->dockAreaWidget();
|
NewFocusedDockArea = d->FocusedDockWidget->dockAreaWidget();
|
||||||
if (NewFocusedDockArea)
|
if (NewFocusedDockArea)
|
||||||
{
|
{
|
||||||
@ -942,22 +942,31 @@ void CDockManager::onFocusObjectChanged(QObject *focusObject)
|
|||||||
internal::repolishStyle(DockWidget);
|
internal::repolishStyle(DockWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OldFocusedDockArea == NewFocusedDockArea)
|
if (!NewFocusedDockArea || (d->FocusedArea == NewFocusedDockArea))
|
||||||
{
|
{
|
||||||
|
std::cout << "d->FocusedArea == NewFocusedDockArea" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OldFocusedDockArea)
|
if (d->FocusedArea)
|
||||||
{
|
{
|
||||||
internal::repolishStyle(OldFocusedDockArea);
|
std::cout << "Repolish OldFocusedDockArea" << std::endl;
|
||||||
internal::repolishStyle(OldFocusedDockArea->titleBar());
|
d->FocusedArea->setProperty("focused", false);
|
||||||
|
internal::repolishStyle(d->FocusedArea);
|
||||||
|
internal::repolishStyle(d->FocusedArea->titleBar());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NewFocusedDockArea)
|
std::cout << "Repolish NewFocusedDockArea" << std::endl;
|
||||||
{
|
NewFocusedDockArea->setProperty("focused", true);
|
||||||
internal::repolishStyle(NewFocusedDockArea);
|
internal::repolishStyle(NewFocusedDockArea);
|
||||||
internal::repolishStyle(NewFocusedDockArea->titleBar());
|
internal::repolishStyle(NewFocusedDockArea->titleBar());
|
||||||
|
d->FocusedArea = NewFocusedDockArea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//===========================================================================
|
||||||
|
void CDockManager::onFocusedDockWidgetClosed()
|
||||||
|
{
|
||||||
|
std::cout << "CDockManager::onFocusedDockWidgetClosed()" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onFocusObjectChanged(QObject *focusObject);
|
void onFocusObjectChanged(QObject *focusObject);
|
||||||
|
void onFocusedDockWidgetClosed();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
@ -468,6 +468,11 @@ void CDockWidgetTab::setActiveTab(bool active)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (active && !hasFocus())
|
||||||
|
{
|
||||||
|
std::cout << "setFocus(Qt::OtherFocusReason);" << std::endl;
|
||||||
|
setFocus(Qt::OtherFocusReason);
|
||||||
|
}
|
||||||
d->IsActiveTab = active;
|
d->IsActiveTab = active;
|
||||||
updateStyle();
|
updateStyle();
|
||||||
update();
|
update();
|
||||||
|
Loading…
Reference in New Issue
Block a user