Fix active X widgets not being rendered correctly

This commit is contained in:
Syarif Fakhri 2022-09-19 10:49:07 +08:00
parent 87324846cd
commit f69b1e1ef8
2 changed files with 22 additions and 29 deletions

View File

@ -32,12 +32,10 @@
#include "DockWidgetSideTab.h" #include "DockWidgetSideTab.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
#include "SideTabBar.h" #include "SideTabBar.h"
#include "DockAreaTitleBar.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockingStateReader.h" #include "DockingStateReader.h"
#include <QXmlStreamWriter> #include <QXmlStreamWriter>
#include <QAbstractButton>
#include <QBoxLayout> #include <QBoxLayout>
#include <QPainter> #include <QPainter>
#include <QSplitter> #include <QSplitter>
@ -51,7 +49,6 @@ struct OverlayDockContainerPrivate
CDockAreaWidget* DockArea{nullptr}; CDockAreaWidget* DockArea{nullptr};
CDockWidget* DockWidget{nullptr}; CDockWidget* DockWidget{nullptr};
QPointer<CDockManager> DockManager{nullptr}; QPointer<CDockManager> DockManager{nullptr};
QSplitter* Splitter;
CDockWidgetSideTab::SideTabBarArea Area; CDockWidgetSideTab::SideTabBarArea Area;
/** /**
@ -126,26 +123,24 @@ OverlayDockContainerPrivate::OverlayDockContainerPrivate(
CDockContainerWidget* COverlayDockContainer::parentContainer() const CDockContainerWidget* COverlayDockContainer::parentContainer() const
{ {
return qobject_cast<CDockContainerWidget*>(parent()); return internal::findParent<CDockContainerWidget*>(this);
} }
//============================================================================ //============================================================================
COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) : COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWidgetSideTab::SideTabBarArea area, CDockContainerWidget* parent) :
QFrame(parent), QSplitter(area == CDockWidgetSideTab::Bottom ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal, parent),
d(new OverlayDockContainerPrivate(this)) d(new OverlayDockContainerPrivate(this))
{ {
d->DockManager = DockManager; d->DockManager = DockManager;
d->Area = area; d->Area = area;
d->DockArea = new CDockAreaWidget(DockManager, parent); d->DockArea = new CDockAreaWidget(DockManager, parent);
d->DockArea->setObjectName("OverlayDockArea"); d->DockArea->setObjectName("overlayDockArea");
d->DockArea->setOverlayDockContainer(this); d->DockArea->setOverlayDockContainer(this);
d->DockArea->updateAutoHideButtonCheckState(); d->DockArea->updateAutoHideButtonCheckState();
d->DockArea->updateTitleBarButtonToolTip(); d->DockArea->updateTitleBarButtonToolTip();
QBoxLayout* l = new QBoxLayout(QBoxLayout::LeftToRight); setObjectName("overlaySplitter");
d->Splitter = new QSplitter(area == CDockWidgetSideTab::Bottom ? Qt::Orientation::Vertical : Qt::Orientation::Horizontal); setChildrenCollapsible(false);
d->Splitter->setObjectName("overlaySplitter");
d->Splitter->setChildrenCollapsible(false);
const auto emptyWidget = new QWidget(); const auto emptyWidget = new QWidget();
emptyWidget->setMinimumWidth(50); emptyWidget->setMinimumWidth(50);
@ -157,31 +152,26 @@ COverlayDockContainer::COverlayDockContainer(CDockManager* DockManager, CDockWid
[[fallthrough]]; [[fallthrough]];
case CDockWidgetSideTab::LeftTop: case CDockWidgetSideTab::LeftTop:
{ {
d->Splitter->addWidget(d->DockArea); addWidget(d->DockArea);
d->Splitter->addWidget(emptyWidget); addWidget(emptyWidget);
break; break;
} }
case CDockWidgetSideTab::RightBottom: case CDockWidgetSideTab::RightBottom:
[[fallthrough]]; [[fallthrough]];
case CDockWidgetSideTab::RightTop: case CDockWidgetSideTab::RightTop:
{ {
d->Splitter->addWidget(emptyWidget); addWidget(emptyWidget);
d->Splitter->addWidget(d->DockArea); addWidget(d->DockArea);
break; break;
} }
case CDockWidgetSideTab::Bottom: case CDockWidgetSideTab::Bottom:
{ {
d->Splitter->addWidget(emptyWidget); addWidget(emptyWidget);
d->Splitter->addWidget(d->DockArea); addWidget(d->DockArea);
break; break;
} }
} }
l->setContentsMargins(QMargins());
l->setSpacing(0);
l->addWidget(d->Splitter);
setLayout(l);
updateMask(); updateMask();
updateSize(); updateSize();
@ -196,7 +186,7 @@ void COverlayDockContainer::updateMask()
{ {
const auto rect = d->DockArea->frameGeometry(); const auto rect = d->DockArea->frameGeometry();
const auto topLeft = rect.topLeft(); const auto topLeft = rect.topLeft();
const auto handleSize = d->Splitter->handleWidth(); const auto handleSize = handleWidth();
if (d->Area == CDockWidgetSideTab::Bottom) if (d->Area == CDockWidgetSideTab::Bottom)
{ {
@ -220,6 +210,7 @@ void COverlayDockContainer::updateSize()
const auto rect = rootSplitter->frameGeometry(); const auto rect = rootSplitter->frameGeometry();
move(rect.topLeft()); move(rect.topLeft());
resize(rect.width(), rect.height()); resize(rect.width(), rect.height());
d->DockArea->updateGeometry();
} }
//============================================================================ //============================================================================
@ -299,7 +290,7 @@ void COverlayDockContainer::setDockSizeProportion(float SplitterProportion)
[[fallthrough]]; [[fallthrough]];
case CDockWidgetSideTab::LeftTop: case CDockWidgetSideTab::LeftTop:
{ {
d->Splitter->setSizes({ dockSize, remainingSize }); setSizes({ dockSize, remainingSize });
break; break;
} }
case CDockWidgetSideTab::RightBottom: case CDockWidgetSideTab::RightBottom:
@ -308,7 +299,7 @@ void COverlayDockContainer::setDockSizeProportion(float SplitterProportion)
[[fallthrough]]; [[fallthrough]];
case CDockWidgetSideTab::Bottom: case CDockWidgetSideTab::Bottom:
{ {
d->Splitter->setSizes({ remainingSize, dockSize }); setSizes({ remainingSize, dockSize });
break; break;
} }
} }
@ -367,7 +358,7 @@ void COverlayDockContainer::saveState(QXmlStreamWriter& s)
{ {
s.writeAttribute("SideTabBarArea", QString::number(sideTabBarArea())); s.writeAttribute("SideTabBarArea", QString::number(sideTabBarArea()));
QStringList Sizes; QStringList Sizes;
for (auto Size : d->Splitter->sizes()) for (auto Size : sizes())
{ {
Sizes << QString::number(Size); Sizes << QString::number(Size);
} }
@ -390,14 +381,14 @@ bool COverlayDockContainer::restoreState(CDockingStateReader& s, bool Testing)
Sizes.append(value); Sizes.append(value);
} }
if (Sizes.count() != d->Splitter->count()) if (Sizes.count() != count())
{ {
return false; return false;
} }
if (!Testing) if (!Testing)
{ {
d->Splitter->setSizes(Sizes); setSizes(Sizes);
} }
return true; return true;

View File

@ -33,7 +33,7 @@
#include "DockWidgetSideTab.h" #include "DockWidgetSideTab.h"
#include <QFrame> #include <QSplitter>
class QXmlStreamWriter; class QXmlStreamWriter;
@ -47,7 +47,9 @@ class CSideTabBar;
class CDockAreaWidget; class CDockAreaWidget;
class CDockingStateReader; class CDockingStateReader;
class ADS_EXPORT COverlayDockContainer : public QFrame // Note: This widget must be a QSplitter, inheriting from QWidget and keeping an internal splitter breaks ActiveX widgets
// likely due to layout issues between this widget and the internal splitter
class ADS_EXPORT COverlayDockContainer : public QSplitter
{ {
Q_OBJECT Q_OBJECT