1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-03-15 10:39:51 +08:00

Improved focus styling

This commit is contained in:
Uwe Kindler 2020-05-23 14:45:49 +02:00
parent 9aa958e8b0
commit ae999f132e
4 changed files with 44 additions and 1 deletions

View File

@ -10,6 +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);
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);

View File

@ -1461,6 +1461,12 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi
} }
window()->activateWindow(); window()->activateWindow();
if (SingleDroppedDockWidget)
{
std::cout << "SingleDockWidget dropped" << std::endl;
d->DockManager->emitWidgetDroppedSignals(SingleDroppedDockWidget);
}
d->DockManager->endFloatingWidgetDrop(FloatingWidget);
} }

View File

@ -500,10 +500,16 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget)
updateDockAreaFocusStyle(FocusedArea, true); updateDockAreaFocusStyle(FocusedArea, true);
QObject::connect(FocusedArea, SIGNAL(viewToggled(bool)), _this, SLOT(onFocusedDockAreaViewToggled(bool))); QObject::connect(FocusedArea, SIGNAL(viewToggled(bool)), _this, SLOT(onFocusedDockAreaViewToggled(bool)));
auto NewFloatingWidget = FocusedDockWidget->dockContainer()->floatingWidget();
if (NewFloatingWidget)
{
NewFloatingWidget->setProperty("FocusedDockWidget", QVariant::fromValue(DockWidget));
}
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
// This code is required for styling the floating widget titlebar for linux // This code is required for styling the floating widget titlebar for linux
// depending on the current focus state // depending on the current focus state
auto NewFloatingWidget = FocusedDockWidget->dockContainer()->floatingWidget();
if (FloatingWidget == NewFloatingWidget) if (FloatingWidget == NewFloatingWidget)
{ {
return; return;
@ -1061,6 +1067,28 @@ void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget)
} }
//===========================================================================
void CDockManager::endFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget)
{
if (!FloatingWidget)
{
return;
}
auto vDockWidget = FloatingWidget->property("FocusedDockWidget");
if (!vDockWidget.isValid())
{
return;
}
auto DockWidget = vDockWidget.value<CDockWidget*>();
if (DockWidget)
{
std::cout << "Dropped focus dock widget " << DockWidget->objectName().toStdString() << std::endl;
CDockManager::setWidgetFocus(DockWidget->tabWidget());
}
}
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -128,6 +128,14 @@ protected:
*/ */
void emitWidgetDroppedSignals(QWidget* DroppedWidget); void emitWidgetDroppedSignals(QWidget* DroppedWidget);
/**
* This function is called, if a floating widget has been dropped into
* an new position.
* When this function is called, all dock widgets of the FloatingWidget
* are already inserted into its new position
*/
void endFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget);
/** /**
* Show the floating widgets that has been created floating * Show the floating widgets that has been created floating
*/ */