diff --git a/examples/autohide/mainwindow.cpp b/examples/autohide/mainwindow.cpp index 2a8f06a..acde567 100644 --- a/examples/autohide/mainwindow.cpp +++ b/examples/autohide/mainwindow.cpp @@ -47,7 +47,7 @@ CMainWindow::CMainWindow(QWidget *parent) TableDockWidget->resize(250, 150); TableDockWidget->setMinimumSize(200,150); TableDockWidget->setDefaultAutoHideDockProportion(0.5); - DockManager->addAutoHideDockWidget(CDockWidgetSideTab::SideTabBarArea::LeftTop, TableDockWidget, CDockWidget::Last); + DockManager->addAutoHideDockWidget(CDockWidgetSideTab::SideTabBarArea::Left, TableDockWidget, CDockWidget::Last); ui->menuView->addAction(TableDockWidget->toggleViewAction()); table = new QTableWidget(); @@ -58,7 +58,7 @@ CMainWindow::CMainWindow(QWidget *parent) TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); TableDockWidget->resize(250, 150); TableDockWidget->setMinimumSize(200,150); - DockManager->addAutoHideDockWidget(CDockWidgetSideTab::SideTabBarArea::LeftTop, TableDockWidget, CDockWidget::Last); + DockManager->addAutoHideDockWidget(CDockWidgetSideTab::SideTabBarArea::Left, TableDockWidget, CDockWidget::Last); ui->menuView->addAction(TableDockWidget->toggleViewAction()); QTableWidget* propertiesTable = new QTableWidget(); diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 24d0941..3206380 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -66,13 +66,11 @@ struct AutoHideDockContainerPrivate { switch (area) { - case CDockWidgetSideTab::LeftBottom: - case CDockWidgetSideTab::LeftTop: + case CDockWidgetSideTab::Left: { return LeftDockWidgetArea; } - case CDockWidgetSideTab::RightBottom: - case CDockWidgetSideTab::RightTop: + case CDockWidgetSideTab::Right: { return RightDockWidgetArea; } @@ -96,13 +94,11 @@ struct AutoHideDockContainerPrivate { switch (SideTabBarArea) { - case CDockWidgetSideTab::LeftTop: - case CDockWidgetSideTab::LeftBottom: + case CDockWidgetSideTab::Left: { return QPoint(1, _this->height() / 2); } - case CDockWidgetSideTab::RightTop: - case CDockWidgetSideTab::RightBottom: + case CDockWidgetSideTab::Right: { return QPoint(_this->width() - 1, _this->height() / 2); } @@ -139,7 +135,7 @@ struct AutoHideDockContainerPrivate } auto offset = 0; - if (SideTabBarArea == CDockWidgetSideTab::SideTabBarArea::RightTop || SideTabBarArea == CDockWidgetSideTab::SideTabBarArea::RightBottom) + if (SideTabBarArea == CDockWidgetSideTab::SideTabBarArea::Right) { offset = handleSize; } @@ -189,15 +185,13 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, CDockW addWidget(emptyWidget); break; } - case CDockWidgetSideTab::LeftBottom: - case CDockWidgetSideTab::LeftTop: + case CDockWidgetSideTab::Left: { addWidget(d->DockArea); addWidget(emptyWidget); break; } - case CDockWidgetSideTab::RightBottom: - case CDockWidgetSideTab::RightTop: + case CDockWidgetSideTab::Right: { addWidget(emptyWidget); addWidget(d->DockArea); @@ -305,14 +299,12 @@ void CAutoHideDockContainer::setDockSizeProportion(float SplitterProportion) const auto remainingSize = INT_MAX - dockSize; switch (d->SideTabBarArea) { - case CDockWidgetSideTab::LeftBottom: - case CDockWidgetSideTab::LeftTop: + case CDockWidgetSideTab::Left: { setSizes({ dockSize, remainingSize }); break; } - case CDockWidgetSideTab::RightBottom: - case CDockWidgetSideTab::RightTop: + case CDockWidgetSideTab::Right: case CDockWidgetSideTab::Bottom: { setSizes({ remainingSize, dockSize }); @@ -467,13 +459,11 @@ bool CAutoHideDockContainer::areaExistsInConfig(CDockWidgetSideTab::SideTabBarAr { switch (area) { - case CDockWidgetSideTab::LeftBottom: - case CDockWidgetSideTab::LeftTop: + case CDockWidgetSideTab::Left: { return CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar); } - case CDockWidgetSideTab::RightBottom: - case CDockWidgetSideTab::RightTop: + case CDockWidgetSideTab::Right: { return CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar); } diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 866833a..2f2c9fb 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -1099,7 +1099,7 @@ void CDockAreaWidget::closeArea() //============================================================================ void CDockAreaWidget::toggleAutoHideArea(bool Enable) { - const auto area = dockContainer()->getDockAreaPosition(this); + const auto area = dockContainer()->calculateSideTabBarArea(this); const auto DockWidget = currentDockWidget(); if (Enable == isAutoHide()) { diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 77b4304..9d7c537 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -1520,8 +1520,9 @@ CAutoHideDockContainer* CDockContainerWidget::createAndInitializeAutoHideDockWid return dockContainer; } + //============================================================================ -CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::getDockAreaPosition(CDockAreaWidget* DockAreaWidget) +CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::calculateSideTabBarArea(CDockAreaWidget* DockAreaWidget) { // Handle bottom case and top case // It's bottom if the width is wider than the height, and if it's below 50% of the window @@ -1542,39 +1543,39 @@ CDockWidgetSideTab::SideTabBarArea CDockContainerWidget::getDockAreaPosition(CDo // Then handle left and right const auto dockWidgetCenter = DockAreaWidget->mapToGlobal(dockWidgetFrameGeometry.center()); - const auto calculatedPosition = dockWidgetCenter.x() <= splitterCenter.x() ? CDockWidgetSideTab::LeftTop : CDockWidgetSideTab::RightTop; - if (calculatedPosition == CDockWidgetSideTab::RightTop) + const auto calculatedPosition = dockWidgetCenter.x() <= splitterCenter.x() ? CDockWidgetSideTab::Left : CDockWidgetSideTab::Right; + if (calculatedPosition == CDockWidgetSideTab::Right) { if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar)) { - return CDockWidgetSideTab::RightTop; + return CDockWidgetSideTab::Right; } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar)) { - return CDockWidgetSideTab::LeftTop; + return CDockWidgetSideTab::Left; } return CDockWidgetSideTab::Bottom; } - if (calculatedPosition == CDockWidgetSideTab::LeftTop) + if (calculatedPosition == CDockWidgetSideTab::Left) { if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar)) { - return CDockWidgetSideTab::LeftTop; + return CDockWidgetSideTab::Left; } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar)) { - return CDockWidgetSideTab::RightTop; + return CDockWidgetSideTab::Right; } return CDockWidgetSideTab::Bottom; } Q_ASSERT_X(false, "CDockContainerWidget::getDockAreaPosition", "Unhandled branch. All positions should be accounted for."); - return CDockWidgetSideTab::LeftTop; + return CDockWidgetSideTab::Left; } @@ -2055,22 +2056,18 @@ void CDockContainerWidget::createSideTabBarWidgets() if (CDockManager::testConfigFlag(CDockManager::DockContainerHasLeftSideBar)) { auto leftLayout = new QVBoxLayout(); - d->SideTabBarWidgets[CDockWidgetSideTab::LeftTop] = new CSideTabBar(this, Qt::Vertical); - leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::LeftTop]); + d->SideTabBarWidgets[CDockWidgetSideTab::Left] = new CSideTabBar(this, Qt::Vertical); + leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Left]); leftLayout->addStretch(1); - d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom] = new CSideTabBar(this, Qt::Vertical); - leftLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::LeftBottom]); d->Layout->addLayout(leftLayout, 1, 0); } if (CDockManager::testConfigFlag(CDockManager::DockContainerHasRightSideBar)) { auto rightLayout = new QVBoxLayout(); - d->SideTabBarWidgets[CDockWidgetSideTab::RightTop] = new CSideTabBar(this, Qt::Vertical); - rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::RightTop]); + d->SideTabBarWidgets[CDockWidgetSideTab::Right] = new CSideTabBar(this, Qt::Vertical); + rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::Right]); rightLayout->addStretch(1); - d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom] = new CSideTabBar(this, Qt::Vertical); - rightLayout->addWidget(d->SideTabBarWidgets[CDockWidgetSideTab::RightBottom]); d->Layout->addLayout(rightLayout, 1, 2); } diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h index 63e1d6d..a26e7e2 100644 --- a/src/DockContainerWidget.h +++ b/src/DockContainerWidget.h @@ -220,7 +220,7 @@ public: /** * Get's the auto hide dock side tab bar area based on the dock area widget position */ - CDockWidgetSideTab::SideTabBarArea getDockAreaPosition(CDockAreaWidget* DockAreaWidget); + CDockWidgetSideTab::SideTabBarArea calculateSideTabBarArea(CDockAreaWidget* DockAreaWidget); /** * Removes dockwidget diff --git a/src/DockWidgetSideTab.cpp b/src/DockWidgetSideTab.cpp index b62ca81..eafe96b 100644 --- a/src/DockWidgetSideTab.cpp +++ b/src/DockWidgetSideTab.cpp @@ -216,7 +216,7 @@ CDockWidgetSideTab::SideTabBarArea CDockWidgetSideTab::sideTabBarArea() const return dockAreaWidget->autoHideDockContainer()->sideTabBarArea(); } - return LeftTop; + return Left; } @@ -289,14 +289,14 @@ void CDockWidgetSideTab::updateOrientationAndSpacing(SideTabBarArea area) QFontMetrics fm(d->TitleLabel->font()); int Spacing = qRound(fm.height() / 2.0); - if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && (area == LeftTop || area == LeftBottom)) + if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && area == Left) { d->TitleLabel->hide(); d->TitleLayout->setContentsMargins(0, 0, 0, 0); d->IconLabel->setContentsMargins(Spacing / 2, Spacing / 2, Spacing / 2, Spacing / 2); return; } - if (CDockManager::testConfigFlag(CDockManager::RightSideBarPrioritizeIconOnly) && (area == RightTop || area == RightBottom)) + if (CDockManager::testConfigFlag(CDockManager::RightSideBarPrioritizeIconOnly) && area == Right) { d->TitleLabel->hide(); d->TitleLayout->setContentsMargins(0, 0, 0, 0); diff --git a/src/DockWidgetSideTab.h b/src/DockWidgetSideTab.h index 6c1d26b..76560e2 100644 --- a/src/DockWidgetSideTab.h +++ b/src/DockWidgetSideTab.h @@ -79,13 +79,10 @@ public: enum SideTabBarArea { Top, - LeftTop, - LeftBottom, - RightTop, - RightBottom, + Left, + Right, Bottom }; - Q_ENUM(SideTabBarArea) /**