mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 23:51:33 +08:00
Set splitter sizes based on proportion settable in the dock widget
This commit is contained in:
parent
214c415fa2
commit
4841d9b896
@ -46,7 +46,7 @@ CMainWindow::CMainWindow(QWidget *parent)
|
|||||||
TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget);
|
||||||
TableDockWidget->resize(250, 150);
|
TableDockWidget->resize(250, 150);
|
||||||
TableDockWidget->setMinimumSize(200,150);
|
TableDockWidget->setMinimumSize(200,150);
|
||||||
TableDockWidget->setFeature(CDockWidget::DockWidgetDeleteOnClose, true);
|
TableDockWidget->setDefaultOverlayDockProportion(2);
|
||||||
DockManager->addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea::Left, TableDockWidget);
|
DockManager->addOverlayDockWidget(CDockWidgetSideTab::SideTabBarArea::Left, TableDockWidget);
|
||||||
ui->menuView->addAction(TableDockWidget->toggleViewAction());
|
ui->menuView->addAction(TableDockWidget->toggleViewAction());
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ struct DockWidgetPrivate
|
|||||||
QList<QAction*> TitleBarActions;
|
QList<QAction*> TitleBarActions;
|
||||||
CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget;
|
CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget;
|
||||||
WidgetFactory* Factory = nullptr;
|
WidgetFactory* Factory = nullptr;
|
||||||
|
int DefaultOverlayDockProportion = 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private data constructor
|
* Private data constructor
|
||||||
@ -1133,6 +1134,18 @@ bool CDockWidget::isCurrentTab() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void CDockWidget::setDefaultOverlayDockProportion(int Proportion)
|
||||||
|
{
|
||||||
|
d->DefaultOverlayDockProportion = Proportion;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDockWidget::DefaultOverlayDockProportion() const
|
||||||
|
{
|
||||||
|
return d->DefaultOverlayDockProportion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
void CDockWidget::raise()
|
void CDockWidget::raise()
|
||||||
{
|
{
|
||||||
|
@ -511,6 +511,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
bool isCurrentTab() const;
|
bool isCurrentTab() const;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set default dock proportion when overlayed
|
||||||
|
* 4 is a quarter of the size, 2 is half the size, 1 is the entire size
|
||||||
|
*/
|
||||||
|
void setDefaultOverlayDockProportion(int Proportion);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set default dock proportion when overlayed
|
||||||
|
* 4 is a quarter of the size, 2 is half the size, 1 is the entire size
|
||||||
|
*/
|
||||||
|
int DefaultOverlayDockProportion() const;
|
||||||
|
|
||||||
public: // reimplements QFrame -----------------------------------------------
|
public: // reimplements QFrame -----------------------------------------------
|
||||||
/**
|
/**
|
||||||
* Emits titleChanged signal if title change event occurs
|
* Emits titleChanged signal if title change event occurs
|
||||||
|
@ -188,6 +188,7 @@ COverlayDockContainer::COverlayDockContainer(CDockWidget* DockWidget, CDockWidge
|
|||||||
COverlayDockContainer(DockWidget->dockManager(), area, parent)
|
COverlayDockContainer(DockWidget->dockManager(), area, parent)
|
||||||
{
|
{
|
||||||
addDockWidget(DockWidget);
|
addDockWidget(DockWidget);
|
||||||
|
setDockSizeProportion(DockWidget->DefaultOverlayDockProportion());
|
||||||
}
|
}
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
@ -234,30 +235,6 @@ void COverlayDockContainer::addDockWidget(CDockWidget* DockWidget)
|
|||||||
OldDockArea->removeDockWidget(DockWidget);
|
OldDockArea->removeDockWidget(DockWidget);
|
||||||
}
|
}
|
||||||
d->DockArea->addDockWidget(DockWidget);
|
d->DockArea->addDockWidget(DockWidget);
|
||||||
|
|
||||||
const auto dockContainerParent = parentContainer();
|
|
||||||
const auto rootSplitter = dockContainerParent->rootSplitter();
|
|
||||||
const auto rect = rootSplitter->frameGeometry();
|
|
||||||
const auto dockWidth = DockWidget->sizeHint().width();
|
|
||||||
switch (d->Area)
|
|
||||||
{
|
|
||||||
case CDockWidgetSideTab::Left:
|
|
||||||
{
|
|
||||||
d->Splitter->setSizes({ dockWidth, rect.width() - dockWidth });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CDockWidgetSideTab::Right:
|
|
||||||
{
|
|
||||||
d->Splitter->setSizes({ rect.width() - dockWidth, dockWidth });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CDockWidgetSideTab::Bottom:
|
|
||||||
{
|
|
||||||
d->Splitter->setSizes({ rect.width() - dockWidth, dockWidth });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
d->DockWidget->sideTabWidget()->updateOrientationAndSpacing(d->Area);
|
d->DockWidget->sideTabWidget()->updateOrientationAndSpacing(d->Area);
|
||||||
|
|
||||||
updateSize();
|
updateSize();
|
||||||
@ -265,6 +242,28 @@ void COverlayDockContainer::addDockWidget(CDockWidget* DockWidget)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//============================================================================
|
||||||
|
void COverlayDockContainer::setDockSizeProportion(int SplitterProportion)
|
||||||
|
{
|
||||||
|
switch (d->Area)
|
||||||
|
{
|
||||||
|
case CDockWidgetSideTab::Left:
|
||||||
|
{
|
||||||
|
d->Splitter->setSizes({ INT_MAX / SplitterProportion, INT_MAX - INT_MAX / SplitterProportion });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CDockWidgetSideTab::Right:
|
||||||
|
[[fallthrough]];
|
||||||
|
case CDockWidgetSideTab::Bottom:
|
||||||
|
{
|
||||||
|
d->Splitter->setSizes({ INT_MAX - INT_MAX / SplitterProportion, INT_MAX / SplitterProportion });
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//============================================================================
|
//============================================================================
|
||||||
CDockWidgetSideTab::SideTabBarArea COverlayDockContainer::sideTabBarArea() const
|
CDockWidgetSideTab::SideTabBarArea COverlayDockContainer::sideTabBarArea() const
|
||||||
{
|
{
|
||||||
|
@ -49,17 +49,17 @@ class CDockingStateReader;
|
|||||||
|
|
||||||
class ADS_EXPORT COverlayDockContainer : public QFrame
|
class ADS_EXPORT COverlayDockContainer : public QFrame
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OverlayDockContainerPrivate* d; ///< private data (pimpl)
|
OverlayDockContainerPrivate* d; ///< private data (pimpl)
|
||||||
friend struct OverlayDockContainerPrivate;
|
friend struct OverlayDockContainerPrivate;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject* watched, QEvent* event) override;
|
bool eventFilter(QObject* watched, QEvent* event) override;
|
||||||
void mousePressEvent(QMouseEvent* event) override;
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
void resizeEvent(QResizeEvent* event) override;
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void updateMask();
|
void updateMask();
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
CDockContainerWidget* parentContainer() const;
|
CDockContainerWidget* parentContainer() const;
|
||||||
@ -95,6 +95,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
void addDockWidget(CDockWidget* DockWidget);
|
void addDockWidget(CDockWidget* DockWidget);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set default splitter sizes. Don't use when restoring state
|
||||||
|
* As we want the size from the XML
|
||||||
|
* Takes an int which determines the size proportion of the child dock
|
||||||
|
* E.g. 4 is a quarter of the size, 2 is half the size and 1 is the entire size of the container
|
||||||
|
*/
|
||||||
|
void setDockSizeProportion(int SplitterProportion = 4);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the side tab bar area of this overlay dock container
|
* Returns the side tab bar area of this overlay dock container
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user