diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index a474510..f0bf1fe 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -216,6 +216,7 @@ struct MainWindowPrivate QFileSystemModel* m = new QFileSystemModel(w); m->setRootPath(QDir::currentPath()); w->setModel(m); + w->setRootIndex(m->index(QDir::currentPath())); ads::CDockWidget* DockWidget = new ads::CDockWidget(QString("Filesystem %1") .arg(FileSystemCount++)); DockWidget->setWidget(w); @@ -650,10 +651,10 @@ CMainWindow::CMainWindow(QWidget *parent) : // uncomment the following line to enable focus highlighting of the dock // widget that has the focus - //CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true); + CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true); // uncomment if you would like to enable dock widget auto hiding - CDockManager::setConfigFlag(CDockManager::DefaultAutoHideConfig, true); + CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig); // uncomment if you would like to enable an equal distribution of the // available size of a splitter to all contained dock widgets @@ -748,7 +749,7 @@ void CMainWindow::onViewToggled(bool Open) return; } - //qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")"; + qDebug() << DockWidget->objectName() << " viewToggled(" << Open << ")"; } diff --git a/examples/autohide/mainwindow.cpp b/examples/autohide/mainwindow.cpp index 42dc49c..4ae68be 100644 --- a/examples/autohide/mainwindow.cpp +++ b/examples/autohide/mainwindow.cpp @@ -27,7 +27,7 @@ CMainWindow::CMainWindow(QWidget *parent) CDockManager::setConfigFlag(CDockManager::OpaqueSplitterResize, true); CDockManager::setConfigFlag(CDockManager::XmlCompressionEnabled, false); CDockManager::setConfigFlag(CDockManager::FocusHighlighting, true); - CDockManager::setConfigFlag(CDockManager::DefaultAutoHideConfig, true); + CDockManager::setAutoHideConfigFlags(CDockManager::DefaultAutoHideConfig); DockManager = new CDockManager(this); // Set central widget @@ -47,7 +47,7 @@ CMainWindow::CMainWindow(QWidget *parent) TableDockWidget->setMinimumSizeHintMode(CDockWidget::MinimumSizeHintFromDockWidget); TableDockWidget->setMinimumSize(200,150); const auto autoHideContainer = DockManager->addAutoHideDockWidget(SideBarLocation::Left, TableDockWidget, CDockWidget::Last); - autoHideContainer->setSize(480, 100); + autoHideContainer->setSize(480); ui->menuView->addAction(TableDockWidget->toggleViewAction()); table = new QTableWidget(); diff --git a/src/AutoHideDockContainer.cpp b/src/AutoHideDockContainer.cpp index 5745908..6256b78 100644 --- a/src/AutoHideDockContainer.cpp +++ b/src/AutoHideDockContainer.cpp @@ -18,7 +18,7 @@ //============================================================================ -/// \file AutoHideDockContainer.h +/// \file AutoHideDockContainer.cpp /// \author Syarif Fakhri /// \date 05.09.2022 /// \brief Implementation of CAutoHideDockContainer class @@ -27,14 +27,7 @@ //============================================================================ // INCLUDES //============================================================================ -#include -#include "DockManager.h" -#include "DockWidgetSideTab.h" -#include "DockWidgetTab.h" -#include "SideTabBar.h" -#include "DockAreaWidget.h" -#include "DockingStateReader.h" -#include "ResizeHandle.h" +#include "AutoHideDockContainer.h" #include #include @@ -43,6 +36,16 @@ #include #include +#include "DockManager.h" +#include "DockWidgetTab.h" +#include "DockAreaWidget.h" +#include "DockingStateReader.h" +#include "ResizeHandle.h" +#include "DockComponentsFactory.h" +#include "AutoHideSideBar.h" +#include "AutoHideTab.h" + + #include namespace ads @@ -103,11 +106,11 @@ struct AutoHideDockContainerPrivate CAutoHideDockContainer* _this; CDockAreaWidget* DockArea{nullptr}; CDockWidget* DockWidget{nullptr}; - QPointer DockManager{nullptr}; SideBarLocation SideTabBarArea; QBoxLayout* Layout; CResizeHandle* ResizeHandle = nullptr; QSize Size; // creates invalid size + QPointer SideTab; /** * Private data constructor @@ -164,7 +167,14 @@ AutoHideDockContainerPrivate::AutoHideDockContainerPrivate( //============================================================================ CDockContainerWidget* CAutoHideDockContainer::parentContainer() const { - return internal::findParent(this); + if (d->DockArea) + { + return d->DockArea->dockContainer(); + } + else + { + return internal::findParent(this); + } } @@ -173,8 +183,10 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, SideBa Super(parent), d(new AutoHideDockContainerPrivate(this)) { - d->DockManager = DockManager; + hide(); // auto hide dock container is initially always hidden d->SideTabBarArea = area; + d->SideTab = componentsFactory()->createDockWidgetSideTab(nullptr); + connect(d->SideTab, &CAutoHideTab::pressed, this, &CAutoHideDockContainer::toggleCollapseState); d->DockArea = new CDockAreaWidget(DockManager, parent); d->DockArea->setObjectName("autoHideDockArea"); d->DockArea->setAutoHideDockContainer(this); @@ -195,7 +207,6 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockManager* DockManager, SideBa d->Layout->insertWidget(resizeHandleLayoutPosition(area), d->ResizeHandle); d->Size = d->DockArea->size(); - updateSize(); parent->registerAutoHideWidget(this); } @@ -206,6 +217,7 @@ CAutoHideDockContainer::CAutoHideDockContainer(CDockWidget* DockWidget, SideBarL CAutoHideDockContainer(DockWidget->dockManager(), area, parent) { addDockWidget(DockWidget); + hide(); } @@ -214,9 +226,8 @@ void CAutoHideDockContainer::updateSize() { auto dockContainerParent = parentContainer(); auto rect = dockContainerParent->contentRect(); - qDebug() << "Size " << d->Size; - switch (sideTabBarArea()) + switch (sideBarLocation()) { case SideBarLocation::Top: resize(rect.width(), qMin(rect.height(), d->Size.height() - ResizeMargin)); @@ -255,20 +266,33 @@ CAutoHideDockContainer::~CAutoHideDockContainer() // Remove event filter in case there are any queued messages qApp->removeEventFilter(this); - if (d->DockManager) + if (parentContainer()) { parentContainer()->removeAutoHideWidget(this); } + if (d->SideTab) + { + delete d->SideTab; + } + delete d; } //============================================================================ -CSideTabBar* CAutoHideDockContainer::sideTabBar() const +CAutoHideSideBar* CAutoHideDockContainer::sideBar() const { return parentContainer()->sideTabBar(d->SideTabBarArea); } + +//============================================================================ +CAutoHideTab* CAutoHideDockContainer::autoHideTab() const +{ + return d->SideTab; +} + + //============================================================================ CDockWidget* CAutoHideDockContainer::dockWidget() const { @@ -285,13 +309,13 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget) } d->DockWidget = DockWidget; + d->SideTab->setDockWidget(DockWidget); CDockAreaWidget* OldDockArea = DockWidget->dockAreaWidget(); if (OldDockArea) { OldDockArea->removeDockWidget(DockWidget); } d->DockArea->addDockWidget(DockWidget); - d->DockWidget->sideTabWidget()->updateOrientationAndSpacing(d->SideTabBarArea); // Prevent overriding of d->Size parameter when this function is called during // state restoring @@ -308,7 +332,7 @@ void CAutoHideDockContainer::addDockWidget(CDockWidget* DockWidget) //============================================================================ -SideBarLocation CAutoHideDockContainer::sideTabBarArea() const +SideBarLocation CAutoHideDockContainer::sideBarLocation() const { return d->SideTabBarArea; } @@ -326,8 +350,8 @@ void CAutoHideDockContainer::moveContentsToParent() // If we unpin the auto hide dock widget, then we insert it into the same // location like it had as a auto hide widget. This brings the least surprise // to the user and he does not have to search where the widget was inserted. + d->DockWidget->setDockArea(nullptr); parentContainer()->addDockWidget(d->getDockWidgetArea(d->SideTabBarArea), d->DockWidget); - parentContainer()->removeDockArea(d->DockArea); } @@ -337,9 +361,11 @@ void CAutoHideDockContainer::cleanupAndDelete() const auto dockWidget = d->DockWidget; if (dockWidget) { - dockWidget->sideTabWidget()->removeFromSideTabBar(); - dockWidget->sideTabWidget()->setParent(dockWidget); - dockWidget->sideTabWidget()->hide(); + + auto SideTab = d->SideTab; + SideTab->removeFromSideBar(); + SideTab->setParent(nullptr); + SideTab->hide(); } hide(); @@ -350,40 +376,11 @@ void CAutoHideDockContainer::cleanupAndDelete() //============================================================================ void CAutoHideDockContainer::saveState(QXmlStreamWriter& s) { + s.writeStartElement("Widget"); + s.writeAttribute("Name", d->DockWidget->objectName()); + s.writeAttribute("Closed", QString::number(d->DockWidget->isClosed() ? 1 : 0)); s.writeAttribute("Size", QString::number(d->isHorizontal() ? d->Size.height() : d->Size.width())); - - qDebug() << ": saveState Size: " << d->Size; - qDebug() << ": saveState Size " << QString::number(d->isHorizontal() ? d->Size.height() : d->Size.width()); -} - - -//============================================================================ -bool CAutoHideDockContainer::restoreState(CDockingStateReader& s, bool Testing) -{ - bool ok; - int Size = s.attributes().value("Size").toInt(&ok); - if (!ok) - { - return false; - } - - if (Testing) - { - return true; - } - - if (d->isHorizontal()) - { - d->Size.setHeight(Size); - } - else - { - d->Size.setWidth(Size); - qDebug() << ": restoreState Width " << Size; - } - - qDebug() << ": restoreState Size: " << d->Size; - return true; + s.writeEndElement(); } @@ -392,18 +389,16 @@ void CAutoHideDockContainer::toggleView(bool Enable) { if (Enable) { - const auto dockWidget = d->DockWidget; - if (dockWidget) + if (d->SideTab) { - dockWidget->sideTabWidget()->show(); + d->SideTab->show(); } } else { - const auto dockWidget = d->DockWidget; - if (dockWidget) + if (d->SideTab) { - dockWidget->sideTabWidget()->hide(); + d->SideTab->hide(); } hide(); qApp->removeEventFilter(this); @@ -425,12 +420,12 @@ void CAutoHideDockContainer::collapseView(bool Enable) d->updateResizeHandleSizeLimitMax(); raise(); show(); - d->DockManager->setDockWidgetFocused(d->DockWidget); + d->DockWidget->dockManager()->setDockWidgetFocused(d->DockWidget); qApp->installEventFilter(this); } ADS_PRINT("CAutoHideDockContainer::collapseView " << Enable); - d->DockWidget->sideTabWidget()->updateStyle(); + d->SideTab->updateStyle(); } @@ -440,9 +435,19 @@ void CAutoHideDockContainer::toggleCollapseState() collapseView(isVisible()); } -void CAutoHideDockContainer::setSize(int width, int height) + +//============================================================================ +void CAutoHideDockContainer::setSize(int Size) { - d->Size = QSize(width, height); + if (d->isHorizontal()) + { + d->Size.setHeight(Size); + } + else + { + d->Size.setWidth(Size); + } + updateSize(); } @@ -495,7 +500,7 @@ bool CAutoHideDockContainer::eventFilter(QObject* watched, QEvent* event) // because the side tab click handler will call collapseView(). If we // do not ignore this here, then we will collapse the container and the side tab // click handler will uncollapse it - auto SideTab = d->DockWidget->sideTabWidget(); + auto SideTab = d->SideTab; pos = SideTab->mapFromGlobal(me->globalPos()); if (SideTab->rect().contains(pos)) { diff --git a/src/AutoHideDockContainer.h b/src/AutoHideDockContainer.h index a26f545..9823ac0 100644 --- a/src/AutoHideDockContainer.h +++ b/src/AutoHideDockContainer.h @@ -31,9 +31,8 @@ //============================================================================ #include "ads_globals.h" -#include "DockWidgetSideTab.h" - #include +#include "AutoHideTab.h" class QXmlStreamWriter; @@ -43,9 +42,10 @@ struct AutoHideDockContainerPrivate; class CDockManager; class CDockWidget; class CDockContainerWidget; -class CSideTabBar; +class CAutoHideSideBar; class CDockAreaWidget; class CDockingStateReader; +struct SideTabBarPrivate; /** * Auto hide container for hosting an auto hide dock widget @@ -53,29 +53,40 @@ class CDockingStateReader; class ADS_EXPORT CAutoHideDockContainer : public QFrame { Q_OBJECT - Q_PROPERTY(ads::SideBarLocation sideTabBarArea READ sideTabBarArea) + Q_PROPERTY(int sideBarLocation READ sideBarLocation) private: AutoHideDockContainerPrivate* d; ///< private data (pimpl) friend struct AutoHideDockContainerPrivate; + friend CAutoHideSideBar; + friend SideTabBarPrivate; protected: bool eventFilter(QObject* watched, QEvent* event) override; void resizeEvent(QResizeEvent* event) override; + + /** + * Updates the size considering the size limits and the resize margins + */ void updateSize(); - CDockContainerWidget* parentContainer() const; + /* + * Saves the state and size + */ + void saveState(QXmlStreamWriter& Stream); public: using Super = QFrame; /** * Create Auto Hide widget with a dock manager */ - CAutoHideDockContainer(CDockManager* DockManager, SideBarLocation area, CDockContainerWidget* parent); + CAutoHideDockContainer(CDockManager* DockManager, SideBarLocation area, + CDockContainerWidget* parent); /** * Create Auto Hide widget with the given dock widget */ - CAutoHideDockContainer(CDockWidget* DockWidget, SideBarLocation area, CDockContainerWidget* parent); + CAutoHideDockContainer(CDockWidget* DockWidget, SideBarLocation area, + CDockContainerWidget* parent); /** * Virtual Destructor @@ -85,7 +96,12 @@ public: /** * Get's the side tab bar */ - CSideTabBar* sideTabBar() const; + CAutoHideSideBar* sideBar() const; + + /** + * Returns the side tab + */ + CAutoHideTab* autoHideTab() const; /** * Get's the dock widget in this dock container @@ -100,13 +116,18 @@ public: /** * Returns the side tab bar area of this Auto Hide dock container */ - SideBarLocation sideTabBarArea() const; + SideBarLocation sideBarLocation() const; /** * Returns the dock area widget of this Auto Hide dock container */ CDockAreaWidget* dockAreaWidget() const; + /** + * Returns the parent container that hosts this auto hide container + */ + CDockContainerWidget* parentContainer() const; + /** * Moves the contents to the parent container widget * Used before removing this Auto Hide dock container @@ -118,16 +139,6 @@ public: */ void cleanupAndDelete(); - /* - * Saves the state and size - */ - void saveState(QXmlStreamWriter& Stream); - - /* - * Restores the size of the splitter - */ - bool restoreState(CDockingStateReader& Stream, bool Testing); - /* * Toggles the auto Hide dock container widget * This will also hide the side tab widget @@ -146,13 +157,13 @@ public: void toggleCollapseState(); /** - * Use this instead of resize. This will ensure the size is consistent internally. - * E.g. If you set a height less than the parent height when it's vertical - * It will simply be rescaled to the parent height while the width will be resized + * Use this instead of resize. + * Depending on the sidebar location this will set the width or heigth + * of this auto hide container. */ - void setSize(int width, int height); + void setSize(int Size); }; -} - +} // namespace ads +//----------------------------------------------------------------------------- #endif diff --git a/src/SideTabBar.cpp b/src/AutoHideSideBar.cpp similarity index 59% rename from src/SideTabBar.cpp rename to src/AutoHideSideBar.cpp index 8f81a87..9fd7709 100644 --- a/src/SideTabBar.cpp +++ b/src/AutoHideSideBar.cpp @@ -18,42 +18,44 @@ //============================================================================ -/// \file DockWidgetTab.h +/// \file AutoHideSideBar.cpp /// \author Syarif Fakhri /// \date 05.09.2022 -/// \brief Implementation of CSideTabBar class +/// \brief Implementation of CAutoHideSideBar class //============================================================================ - //============================================================================ // INCLUDES //============================================================================ -#include "SideTabBar.h" +#include "AutoHideSideBar.h" #include #include #include +#include #include "DockContainerWidget.h" -#include "DockWidgetSideTab.h" #include "DockWidgetTab.h" #include "DockFocusController.h" #include "AutoHideDockContainer.h" +#include "DockAreaWidget.h" +#include "DockingStateReader.h" +#include "AutoHideTab.h" namespace ads { /** * Private data class of CSideTabBar class (pimpl) */ -struct SideTabBarPrivate +struct AutoHideSideBarPrivate { /** * Private data constructor */ - SideTabBarPrivate(CSideTabBar* _public); + AutoHideSideBarPrivate(CAutoHideSideBar* _public); - CSideTabBar* _this; + CAutoHideSideBar* _this; CDockContainerWidget* ContainerWidget; QBoxLayout* TabsLayout; Qt::Orientation Orientation; @@ -66,19 +68,19 @@ struct SideTabBarPrivate { return Qt::Horizontal == Orientation; } -}; // struct SideTabBarPrivate +}; // struct AutoHideSideBarPrivate //============================================================================ -SideTabBarPrivate::SideTabBarPrivate(CSideTabBar* _public) : +AutoHideSideBarPrivate::AutoHideSideBarPrivate(CAutoHideSideBar* _public) : _this(_public) { } //============================================================================ -CSideTabBar::CSideTabBar(CDockContainerWidget* parent, SideBarLocation area) : +CAutoHideSideBar::CAutoHideSideBar(CDockContainerWidget* parent, SideBarLocation area) : Super(parent), - d(new SideTabBarPrivate(this)) + d(new AutoHideSideBarPrivate(this)) { d->SideTabArea = area; d->ContainerWidget = parent; @@ -111,11 +113,12 @@ CSideTabBar::CSideTabBar(CDockContainerWidget* parent, SideBarLocation area) : //============================================================================ -CSideTabBar::~CSideTabBar() +CAutoHideSideBar::~CAutoHideSideBar() { + qDebug() << "~CSideTabBar() "; // The SideTabeBar is not the owner of the tabs and to prevent deletion // we set the parent here to nullptr to remove it from the children - auto Tabs = findChildren(QString(), Qt::FindDirectChildrenOnly); + auto Tabs = findChildren(QString(), Qt::FindDirectChildrenOnly); for (auto Tab : Tabs) { Tab->setParent(nullptr); @@ -125,47 +128,30 @@ CSideTabBar::~CSideTabBar() //============================================================================ -void CSideTabBar::insertSideTab(int Index, CDockWidgetSideTab* SideTab) +void CAutoHideSideBar::insertTab(int Index, CAutoHideTab* SideTab) { + SideTab->installEventFilter(this); + SideTab->setSideBar(this); d->TabsLayout->insertWidget(Index, SideTab); - SideTab->setSideTabBar(this); show(); } //============================================================================ -CAutoHideDockContainer* CSideTabBar::insertDockWidget(int Index, CDockWidget* DockWidget) +CAutoHideDockContainer* CAutoHideSideBar::insertDockWidget(int Index, CDockWidget* DockWidget) { - CDockWidgetSideTab* Tab = new CDockWidgetSideTab(DockWidget); - auto area = sideTabBarArea(); - qDebug() << "area " << area; - Tab->setSideTabBar(this); - Tab->updateOrientationAndSpacing(area); - d->TabsLayout->insertWidget(Index, Tab); - Tab->show(); - - auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, area, d->ContainerWidget); - AutoHideContainer->hide(); + auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, d->SideTabArea, d->ContainerWidget); DockWidget->dockManager()->dockFocusController()->clearDockWidgetFocus(DockWidget); - Tab->updateStyle(); - - connect(Tab, &CDockWidgetSideTab::pressed, AutoHideContainer, &CAutoHideDockContainer::toggleCollapseState); - show(); + auto Tab = AutoHideContainer->autoHideTab(); + insertTab(Index, Tab); return AutoHideContainer; } //============================================================================ -void CSideTabBar::removeDockWidget(CDockWidget* DockWidget) +void CAutoHideSideBar::removeTab(CAutoHideTab* SideTab) { - -} - - -//============================================================================ -void CSideTabBar::removeSideTab(CDockWidgetSideTab* SideTab) -{ - qDebug() << "CSideTabBar::removeSideTab " << SideTab->text(); + SideTab->removeEventFilter(this); d->TabsLayout->removeWidget(SideTab); if (d->TabsLayout->isEmpty()) { @@ -175,41 +161,115 @@ void CSideTabBar::removeSideTab(CDockWidgetSideTab* SideTab) //============================================================================ -void CSideTabBar::paintEvent(QPaintEvent* event) +bool CAutoHideSideBar::event(QEvent* e) { - Q_UNUSED(event) + switch (e->type()) + { + case QEvent::ChildRemoved: + if (d->TabsLayout->isEmpty()) + { + hide(); + } + break; - QStyleOption option; - option.initFrom(this); - QPainter painter(this); - style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this); + case QEvent::Resize: + if (d->TabsLayout->count()) + { + auto ev = static_cast(e); + auto Tab = tabAt(0); + int Size = d->isHorizontal() ? ev->size().height() : ev->size().width(); + int TabSize = d->isHorizontal() ? Tab->size().height() : Tab->size().width(); + // If the size of the side bar is less than the size of the first tab + // then there are no visible tabs in this side bar. This check will + // fail if someone will force a very big border via CSS!! + if (Size < TabSize) + { + hide(); + } + } + else + { + hide(); + } + break; + + default: + break; + } + return Super::event(e); } //============================================================================ -Qt::Orientation CSideTabBar::orientation() const +bool CAutoHideSideBar::eventFilter(QObject *watched, QEvent *event) +{ + if (event->type() != QEvent::ShowToParent) + { + return false; + } + + // As soon as on tab is shhown, we need to show the side tab bar + auto Tab = qobject_cast(watched); + if (Tab) + { + show(); + } + return false; +} + +//============================================================================ +Qt::Orientation CAutoHideSideBar::orientation() const { return d->Orientation; } //============================================================================ -CDockWidgetSideTab* CSideTabBar::tabAt(int index) const +CAutoHideTab* CAutoHideSideBar::tabAt(int index) const { - return qobject_cast(d->TabsLayout->itemAt(index)->widget()); + return qobject_cast(d->TabsLayout->itemAt(index)->widget()); } //============================================================================ -int CSideTabBar::tabCount() const +int CAutoHideSideBar::tabCount() const { return d->TabsLayout->count(); } //============================================================================ -SideBarLocation CSideTabBar::sideTabBarArea() const +SideBarLocation CAutoHideSideBar::sideBarLocation() const { return d->SideTabArea; } + + +//============================================================================ +void CAutoHideSideBar::saveState(QXmlStreamWriter& s) const +{ + if (!tabCount()) + { + return; + } + + s.writeStartElement("SideBar"); + s.writeAttribute("Area", QString::number(sideBarLocation())); + s.writeAttribute("Tabs", QString::number(tabCount())); + + for (auto i = 0; i < tabCount(); ++i) + { + auto Tab = tabAt(i); + if (!Tab) + { + continue; + } + + Tab->dockWidget()->autoHideDockContainer()->saveState(s); + } + + s.writeEndElement(); } + + +} // namespace ads diff --git a/src/SideTabBar.h b/src/AutoHideSideBar.h similarity index 60% rename from src/SideTabBar.h rename to src/AutoHideSideBar.h index ecafb6e..11f7345 100644 --- a/src/SideTabBar.h +++ b/src/AutoHideSideBar.h @@ -1,5 +1,5 @@ -#ifndef SideTabBarH -#define SideTabBarH +#ifndef AutoHideSideBarH +#define AutoHideSideBarH /******************************************************************************* ** Qt Advanced Docking System ** Copyright (C) 2017 Uwe Kindler @@ -20,42 +20,63 @@ //============================================================================ -/// \file DockWidgetTab.h +/// \file AutoHideSideBar.h /// \author Syarif Fakhri /// \date 05.09.2022 -/// \brief Declaration of CSideTabBar class +/// \brief Declaration of CAutoHideSideBar class //============================================================================ //============================================================================ // INCLUDES //============================================================================ #include -#include "DockWidgetSideTab.h" #include "ads_globals.h" +#include "AutoHideTab.h" + +class QXmlStreamWriter; namespace ads { -struct SideTabBarPrivate; +struct AutoHideSideBarPrivate; +class DockContainerWidgetPrivate; class CDockContainerWidget; -class CDockWidgetSideTab; +class CAutoHideTab; class CAutoHideDockContainer; +class CDockingStateReader; /** - * Side tab widget that is shown at the edges of a dock container. + * Side tab bar widget that is shown at the edges of a dock container. + * The tab bar is only visible, if it contains visible content, that means if + * it contains visible tabs. If it is empty or all tabs are hidden, then the + * side bar is also hidden. As soon as one single tab becomes visible, this + * tab bar will be shown. */ -class ADS_EXPORT CSideTabBar : public QFrame +class ADS_EXPORT CAutoHideSideBar : public QFrame { Q_OBJECT - Q_PROPERTY(ads::SideBarLocation sideTabBarArea READ sideTabBarArea) + Q_PROPERTY(int sideBarLocation READ sideBarLocation) Q_PROPERTY(Qt::Orientation orientation READ orientation) private: - SideTabBarPrivate* d; ///< private data (pimpl) - friend struct SideTabBarPrivate; + AutoHideSideBarPrivate* d; ///< private data (pimpl) + friend struct AutoHideSideBarPrivate; friend class DockWidgetSideTab; + friend DockContainerWidgetPrivate; protected: - void paintEvent(QPaintEvent* event) override; + virtual bool event(QEvent* e) override; + virtual bool eventFilter(QObject *watched, QEvent *event) override; + + /** + * Saves the state into the given stream + */ + void saveState(QXmlStreamWriter& Stream) const; + + /** + * Inserts the given dock widget tab at the given position. + * An Index value of -1 appends the side tab at the end. + */ + void insertTab(int Index, CAutoHideTab* SideTab); public: using Super = QFrame; @@ -63,33 +84,25 @@ public: /** * Default Constructor */ - CSideTabBar(CDockContainerWidget* parent, SideBarLocation area); + CAutoHideSideBar(CDockContainerWidget* parent, SideBarLocation area); /** * Virtual Destructor */ - virtual ~CSideTabBar(); - - /** - * Inserts the given dock widget tab at the given position. - */ - void insertSideTab(int Index, CDockWidgetSideTab* SideTab); + virtual ~CAutoHideSideBar(); /** * Removes the given DockWidgetSideTab from the tabbar */ - void removeSideTab(CDockWidgetSideTab* SideTab); + void removeTab(CAutoHideTab* SideTab); /** - * Insert dock widget + * Insert dock widget into the side bar. + * The function creates the auto hide dock container, inserts the + * auto hide tab */ CAutoHideDockContainer* insertDockWidget(int Index, CDockWidget* DockWidget); - /** - * Remove dock widget from sidebar - */ - void removeDockWidget(CDockWidget* DockWidget); - /** * Returns orientation of side tab. */ @@ -98,7 +111,7 @@ public: /* * get the side tab widget at position, returns nullptr if it's out of bounds */ - CDockWidgetSideTab* tabAt(int index) const; + CAutoHideTab* tabAt(int index) const; /* * Gets the count of the tab widgets @@ -108,7 +121,7 @@ public: /** * Getter for side tab bar area property */ - SideBarLocation sideTabBarArea() const; + SideBarLocation sideBarLocation() const; Q_SIGNALS: void sideTabAutoHideToggleRequested(); diff --git a/src/DockWidgetSideTab.cpp b/src/AutoHideTab.cpp similarity index 57% rename from src/DockWidgetSideTab.cpp rename to src/AutoHideTab.cpp index e4e6423..b0b4471 100644 --- a/src/DockWidgetSideTab.cpp +++ b/src/AutoHideTab.cpp @@ -18,24 +18,23 @@ //============================================================================ -/// \file DockWidgetTab.h +/// \file AutoHideTab.cpp /// \author Syarif Fakhri /// \date 05.09.2022 -/// \brief Implementation of CDockWidgetSideTab class +/// \brief Implementation of CAutoHideTab class //============================================================================ //============================================================================ // INCLUDES //============================================================================ -#include -#include "DockWidgetSideTab.h" -#include "SideTabBar.h" +#include "AutoHideTab.h" #include +#include "AutoHideDockContainer.h" +#include "AutoHideSideBar.h" #include "DockAreaWidget.h" #include "DockManager.h" - #include "DockWidget.h" namespace ads @@ -43,22 +42,28 @@ namespace ads /** * Private data class of CDockWidgetTab class (pimpl) */ -struct DockWidgetSideTabPrivate +struct AutoHideTabPrivate { - CDockWidgetSideTab* _this; - CDockWidget* DockWidget; - CSideTabBar* SideTabBar; + CAutoHideTab* _this; + CDockWidget* DockWidget = nullptr; + CAutoHideSideBar* SideBar = nullptr; Qt::Orientation Orientation{Qt::Vertical}; /** * Private data constructor */ - DockWidgetSideTabPrivate(CDockWidgetSideTab* _public); + AutoHideTabPrivate(CAutoHideTab* _public); + + /** + * Update the orientation, visibility and spacing based on the area of + * the side bar + */ + void updateOrientation(); }; // struct DockWidgetTabPrivate //============================================================================ -DockWidgetSideTabPrivate::DockWidgetSideTabPrivate(CDockWidgetSideTab* _public) : +AutoHideTabPrivate::AutoHideTabPrivate(CAutoHideTab* _public) : _this(_public) { @@ -66,37 +71,78 @@ DockWidgetSideTabPrivate::DockWidgetSideTabPrivate(CDockWidgetSideTab* _public) //============================================================================ -void CDockWidgetSideTab::setSideTabBar(CSideTabBar* SideTabBar) +void AutoHideTabPrivate::updateOrientation() { - d->SideTabBar = SideTabBar; -} + auto area = SideBar->sideBarLocation(); + _this->setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical); - -//============================================================================ -void CDockWidgetSideTab::removeFromSideTabBar() -{ - if (d->SideTabBar == nullptr) + if (_this->icon().isNull()) { return; } - d->SideTabBar->removeSideTab(this); - setSideTabBar(nullptr); + + bool IconOnly = false; + switch (area) + { + case SideBarLocation::Left: + IconOnly = CDockManager::testConfigFlag(CDockManager::LeftSideBarIconOnly); + break; + + case SideBarLocation::Right: + IconOnly = CDockManager::testConfigFlag(CDockManager::RightSideBarIconOnly); + break; + + case SideBarLocation::Top: + IconOnly = CDockManager::testConfigFlag(CDockManager::BottomSideBarIconOnly); + break; + + case SideBarLocation::Bottom: + IconOnly = CDockManager::testConfigFlag(CDockManager::TopSideBarIconOnly); + break; + } + + if (IconOnly) + { + _this->setText(""); + _this->setOrientation(Qt::Horizontal); + } +} + + +//============================================================================ +void CAutoHideTab::setSideBar(CAutoHideSideBar* SideTabBar) +{ + d->SideBar = SideTabBar; + if (d->SideBar) + { + d->updateOrientation(); + } +} + + +//============================================================================ +void CAutoHideTab::removeFromSideBar() +{ + if (d->SideBar == nullptr) + { + return; + } + d->SideBar->removeTab(this); + setSideBar(nullptr); } //============================================================================ -CDockWidgetSideTab::CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent) : +CAutoHideTab::CAutoHideTab(QWidget* parent) : Super(parent), - d(new DockWidgetSideTabPrivate(this)) + d(new AutoHideTabPrivate(this)) { setAttribute(Qt::WA_NoMousePropagation); - d->DockWidget = DockWidget; - setText(DockWidget->windowTitle()); setFocusPolicy(Qt::NoFocus); } //============================================================================ -CDockWidgetSideTab::~CDockWidgetSideTab() +CAutoHideTab::~CAutoHideTab() { qDebug() << "~CDockWidgetSideTab()"; delete d; @@ -104,20 +150,19 @@ CDockWidgetSideTab::~CDockWidgetSideTab() //============================================================================ -void CDockWidgetSideTab::updateStyle() +void CAutoHideTab::updateStyle() { - internal::repolishStyle(this, internal::RepolishDirectChildren); + internal::repolishStyle(this, internal::RepolishDirectChildren); update(); } //============================================================================ -SideBarLocation CDockWidgetSideTab::sideTabBarArea() const +SideBarLocation CAutoHideTab::sideBarLocation() const { - auto dockAreaWidget = d->DockWidget->dockAreaWidget(); - if (dockAreaWidget && dockAreaWidget->isAutoHide()) + if (d->SideBar) { - return dockAreaWidget->autoHideDockContainer()->sideTabBarArea(); + return d->SideBar->sideBarLocation(); } return Left; @@ -125,7 +170,7 @@ SideBarLocation CDockWidgetSideTab::sideTabBarArea() const //============================================================================ -void CDockWidgetSideTab::setOrientation(Qt::Orientation Orientation) +void CAutoHideTab::setOrientation(Qt::Orientation Orientation) { d->Orientation = Orientation; CPushButton::setButtonOrientation((Qt::Horizontal == Orientation) @@ -135,53 +180,16 @@ void CDockWidgetSideTab::setOrientation(Qt::Orientation Orientation) //============================================================================ -Qt::Orientation CDockWidgetSideTab::orientation() const +Qt::Orientation CAutoHideTab::orientation() const { return d->Orientation; } //============================================================================ -void CDockWidgetSideTab::updateOrientationAndSpacing(SideBarLocation area) +bool CAutoHideTab::isActiveTab() const { - setOrientation((area == Bottom || area == Top) ? Qt::Horizontal : Qt::Vertical); - - if (icon().isNull()) - { - return; - } - - if (CDockManager::testConfigFlag(CDockManager::LeftSideBarPrioritizeIconOnly) && area == Left) - { - setText(""); - setOrientation(Qt::Horizontal); - return; - } - if (CDockManager::testConfigFlag(CDockManager::RightSideBarPrioritizeIconOnly) && area == Right) - { - setText(""); - setOrientation(Qt::Horizontal); - return; - } - if (CDockManager::testConfigFlag(CDockManager::BottomSideBarPrioritizeIconOnly) && area == Bottom) - { - setText(""); - setOrientation(Qt::Horizontal); - return; - } - if (CDockManager::testConfigFlag(CDockManager::TopSideBarPrioritizeIconOnly) && area == Top) - { - setText(""); - setOrientation(Qt::Horizontal); - return; - } -} - - -//============================================================================ -bool CDockWidgetSideTab::isActiveTab() const -{ - if (d->DockWidget->autoHideDockContainer()) + if (d->DockWidget && d->DockWidget->autoHideDockContainer()) { return d->DockWidget->autoHideDockContainer()->isVisible(); } @@ -191,9 +199,22 @@ bool CDockWidgetSideTab::isActiveTab() const //============================================================================ -CDockWidget* CDockWidgetSideTab::dockWidget() const +CDockWidget* CAutoHideTab::dockWidget() const { return d->DockWidget; } + +//============================================================================ +void CAutoHideTab::setDockWidget(CDockWidget* DockWidget) +{ + if (!DockWidget) + { + return; + } + d->DockWidget = DockWidget; + setText(DockWidget->windowTitle()); + setIcon(d->DockWidget->icon()); +} + } diff --git a/src/DockWidgetSideTab.h b/src/AutoHideTab.h similarity index 76% rename from src/DockWidgetSideTab.h rename to src/AutoHideTab.h index f9c2bc6..d3783b9 100644 --- a/src/DockWidgetSideTab.h +++ b/src/AutoHideTab.h @@ -1,5 +1,5 @@ -#ifndef DockWidgetSideTabH -#define DockWidgetSideTabH +#ifndef AutoHideTabH +#define AutoHideTabH /******************************************************************************* ** Qt Advanced Docking System ** Copyright (C) 2017 Uwe Kindler @@ -20,10 +20,10 @@ //============================================================================ -/// \file DockWidgetTab.h +/// \file AutoHideTab.h /// \author Syarif Fakhri /// \date 05.09.2022 -/// \brief Declaration of CDockWidgetSideTab class +/// \brief Declaration of CAutoHideTab class //============================================================================ //============================================================================ @@ -35,9 +35,9 @@ namespace ads { -struct DockWidgetSideTabPrivate; +struct AutoHideTabPrivate; class CDockWidget; -class CSideTabBar; +class CAutoHideSideBar; class CDockWidgetTab; struct SideTabIconLabelPrivate; @@ -46,27 +46,27 @@ struct SideTabIconLabelPrivate; * The dock widget tab is shown in the side tab bar to switch between * pinned dock widgets */ -class ADS_EXPORT CDockWidgetSideTab : public CPushButton +class ADS_EXPORT CAutoHideTab : public CPushButton { Q_OBJECT - Q_PROPERTY(ads::SideBarLocation sideTabBarArea READ sideTabBarArea) + Q_PROPERTY(int sideBarLocation READ sideBarLocation) Q_PROPERTY(Qt::Orientation orientation READ orientation) Q_PROPERTY(bool activeTab READ isActiveTab) private: - DockWidgetSideTabPrivate* d; ///< private data (pimpl) - friend struct DockWidgetSideTabPrivate; + AutoHideTabPrivate* d; ///< private data (pimpl) + friend struct AutoHideTabPrivate; friend class CDockWidget; friend class CAutoHideDockContainer; protected: - friend class CSideTabBar; + friend class CAutoHideSideBar; friend class CDockAreaWidget; friend class CDockContainerWidget; - void setSideTabBar(CSideTabBar *SideTabBar); - void removeFromSideTabBar(); + void setSideBar(CAutoHideSideBar *SideTabBar); + void removeFromSideBar(); public: using Super = CPushButton; @@ -76,12 +76,12 @@ public: * param[in] DockWidget The dock widget this title bar belongs to * param[in] parent The parent widget of this title bar */ - CDockWidgetSideTab(CDockWidget* DockWidget, QWidget* parent = nullptr); + CAutoHideTab(QWidget* parent = nullptr); /** * Virtual Destructor */ - virtual ~CDockWidgetSideTab(); + virtual ~CAutoHideTab(); /** * Update stylesheet style if a property changes @@ -91,7 +91,7 @@ public: /** * Getter for side tab bar area property */ - SideBarLocation sideTabBarArea() const; + SideBarLocation sideBarLocation() const; /** * Set orientation vertical or horizontal @@ -104,12 +104,8 @@ public: Qt::Orientation orientation() const; /** - * Update the orientation, visibility and spacing based on the area and the config - */ - void updateOrientationAndSpacing(SideBarLocation area); - - /** - * Returns true, if this is the active tab. The tab is active if the auto hide widget is visible + * Returns true, if this is the active tab. The tab is active if the auto + * hide widget is visible */ bool isActiveTab() const; @@ -117,7 +113,12 @@ public: * returns the dock widget this belongs to */ CDockWidget* dockWidget() const; -}; // class DockWidgetSideTab + + /** + * Sets the dock widget that is controlled by this tab + */ + void setDockWidget(CDockWidget* DockWidget); +}; // class AutoHideTab } // namespace ads //----------------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 70c0276..ba62e48 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,8 +27,8 @@ set(ads_SRCS FloatingDragPreview.cpp IconProvider.cpp DockComponentsFactory.cpp - SideTabBar.cpp - DockWidgetSideTab.cpp + AutoHideSideBar.cpp + AutoHideTab.cpp AutoHideDockContainer.cpp PushButton.cpp ResizeHandle.cpp @@ -53,8 +53,8 @@ set(ads_HEADERS FloatingDragPreview.h IconProvider.h DockComponentsFactory.h - SideTabBar.h - DockWidgetSideTab.h + AutoHideSideBar.h + AutoHideTab.h AutoHideDockContainer.h PushButton.h ResizeHandle.h diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index c116e3b..c6d5523 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -29,6 +29,7 @@ // INCLUDES //============================================================================ #include +#include #include "DockAreaWidget.h" #include @@ -52,7 +53,7 @@ #include "DockAreaTitleBar.h" #include "DockComponentsFactory.h" #include "DockWidgetTab.h" -#include "DockWidgetSideTab.h" +#include "DockingStateReader.h" namespace ads @@ -819,7 +820,7 @@ void CDockAreaWidget::updateTitleBarVisibility() d->TitleBar->setVisible(isAutoHide() ? true : !Hidden); // Titlebar must always be visible when auto hidden so it can be dragged auto tabBar = d->TitleBar->tabBar(); tabBar->setVisible(isAutoHide() ? false : !Hidden); // Never show tab bar when auto hidden - d->TitleBar->autoHideTitleLabel()->setVisible(CDockManager::testConfigFlag(CDockManager::AutoHideDockAreaHasTitle) && isAutoHide()); // Always show when auto hidden, never otherwise + d->TitleBar->autoHideTitleLabel()->setVisible(isAutoHide()); // Always show when auto hidden, never otherwise updateTitleBarButtonVisibility(Container->topLevelDockArea() == this); } } @@ -868,13 +869,6 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : ""; s.writeAttribute("Current", Name); - // To keep the saved XML data small, we only save the allowed areas and the - // dock area flags if the values are different from the default values - if (isAutoHide()) - { - autoHideDockContainer()->saveState(s); - } - if (d->AllowedAreas != DefaultAllowedAreas) { s.writeAttribute("AllowedAreas", QString::number(d->AllowedAreas, 16)); @@ -894,6 +888,98 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const } +//============================================================================ +bool CDockAreaWidget::restoreState(CDockingStateReader& s, CDockAreaWidget*& CreatedWidget, + bool Testing, CDockContainerWidget* Container) +{ + bool Ok; +#ifdef ADS_DEBUG_PRINT + int Tabs = s.attributes().value("Tabs").toInt(&Ok); + if (!Ok) + { + return false; + } +#endif + + QString CurrentDockWidget = s.attributes().value("Current").toString(); + ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: " + << CurrentDockWidget); + + auto DockManager = Container->dockManager(); + CDockAreaWidget* DockArea = nullptr; + if (!Testing) + { + DockArea = new CDockAreaWidget(DockManager, Container); + const auto AllowedAreasAttribute = s.attributes().value("AllowedAreas"); + if (!AllowedAreasAttribute.isEmpty()) + { + DockArea->setAllowedAreas((DockWidgetArea)AllowedAreasAttribute.toInt(nullptr, 16)); + } + + const auto FlagsAttribute = s.attributes().value("Flags"); + if (!FlagsAttribute.isEmpty()) + { + DockArea->setDockAreaFlags((CDockAreaWidget::DockAreaFlags)FlagsAttribute.toInt(nullptr, 16)); + } + } + + while (s.readNextStartElement()) + { + if (s.name() != QLatin1String("Widget")) + { + continue; + } + + auto ObjectName = s.attributes().value("Name"); + if (ObjectName.isEmpty()) + { + return false; + } + + bool Closed = s.attributes().value("Closed").toInt(&Ok); + if (!Ok) + { + return false; + } + + s.skipCurrentElement(); + CDockWidget* DockWidget = DockManager->findDockWidget(ObjectName.toString()); + if (!DockWidget || Testing) + { + continue; + } + + ADS_PRINT("Dock Widget found - parent " << DockWidget->parent()); + // We hide the DockArea here to prevent the short display (the flashing) + // of the dock areas during application startup + DockArea->hide(); + DockArea->addDockWidget(DockWidget); + DockWidget->setToggleViewActionChecked(!Closed); + DockWidget->setClosedState(Closed); + DockWidget->setProperty(internal::ClosedProperty, Closed); + DockWidget->setProperty(internal::DirtyProperty, false); + } + + if (Testing) + { + return true; + } + + if (!DockArea->dockWidgetsCount()) + { + delete DockArea; + DockArea = nullptr; + } + else + { + DockArea->setProperty("currentDockWidget", CurrentDockWidget); + } + + CreatedWidget = DockArea; + return true; +} + + //============================================================================ CDockWidget* CDockAreaWidget::nextOpenDockWidget(CDockWidget* DockWidget) const { diff --git a/src/DockAreaWidget.h b/src/DockAreaWidget.h index 6a5b5f2..4059a83 100644 --- a/src/DockAreaWidget.h +++ b/src/DockAreaWidget.h @@ -33,8 +33,8 @@ #include #include "ads_globals.h" +#include "AutoHideTab.h" #include "DockWidget.h" -#include "DockWidgetSideTab.h" QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter) QT_FORWARD_DECLARE_CLASS(QAbstractButton) @@ -46,6 +46,7 @@ class CDockManager; class CDockContainerWidget; class DockContainerWidgetPrivate; class CDockAreaTitleBar; +class CDockingStateReader; /** @@ -296,6 +297,13 @@ public: */ void saveState(QXmlStreamWriter& Stream) const; + /** + * Restores a dock area. + * \see restoreChildNodes() for details + */ + static bool restoreState(CDockingStateReader& Stream, CDockAreaWidget*& CreatedWidget, + bool Testing, CDockContainerWidget* ParentContainer); + /** * This functions returns the dock widget features of all dock widget in * this area. @@ -362,6 +370,7 @@ public: */ bool containsCentralWidget() const; + public Q_SLOTS: /** * This activates the tab for the given tab index. diff --git a/src/DockComponentsFactory.cpp b/src/DockComponentsFactory.cpp index 3e7ebc1..05259d7 100644 --- a/src/DockComponentsFactory.cpp +++ b/src/DockComponentsFactory.cpp @@ -8,6 +8,7 @@ //============================================================================ // INCLUDES //============================================================================ +#include #include "DockComponentsFactory.h" #include @@ -17,7 +18,6 @@ #include "DockAreaTitleBar.h" #include "DockWidget.h" #include "DockAreaWidget.h" -#include "DockWidgetSideTab.h" namespace ads { @@ -31,9 +31,9 @@ CDockWidgetTab* CDockComponentsFactory::createDockWidgetTab(CDockWidget* DockWid } //============================================================================ -CDockWidgetSideTab* CDockComponentsFactory::createDockWidgetSideTab(CDockWidget *DockWidget) const +CAutoHideTab* CDockComponentsFactory::createDockWidgetSideTab(CDockWidget *DockWidget) const { - return new CDockWidgetSideTab(DockWidget); + return new CAutoHideTab(DockWidget); } diff --git a/src/DockComponentsFactory.h b/src/DockComponentsFactory.h index 3e726ae..0d2b7d4 100644 --- a/src/DockComponentsFactory.h +++ b/src/DockComponentsFactory.h @@ -19,7 +19,7 @@ class CDockAreaTitleBar; class CDockAreaTabBar; class CDockAreaWidget; class CDockWidget; -class CDockWidgetSideTab; +class CAutoHideTab; @@ -51,7 +51,7 @@ public: * This default implementation just creates a dock widget side tab with * new CDockWidgetTab(DockWidget). */ - virtual CDockWidgetSideTab* createDockWidgetSideTab(CDockWidget* DockWidget) const; + virtual CAutoHideTab* createDockWidgetSideTab(CDockWidget* DockWidget) const; /** * This default implementation just creates a dock area tab bar with diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 3826137..ee71d21 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -29,6 +29,8 @@ // INCLUDES //============================================================================ #include +#include +#include #include "DockContainerWidget.h" #include @@ -49,9 +51,7 @@ #include "DockOverlay.h" #include "ads_globals.h" #include "DockSplitter.h" -#include "SideTabBar.h" #include "DockWidgetTab.h" -#include "DockWidgetSideTab.h" #include "DockAreaTitleBar.h" #include "DockFocusController.h" @@ -139,7 +139,7 @@ public: unsigned int zOrderIndex = 0; QList DockAreas; QList AutoHideWidgets; - QMap SideTabBarWidgets; + QMap SideTabBarWidgets; QGridLayout* Layout = nullptr; QSplitter* RootSplitter = nullptr; bool isFloating = false; @@ -250,13 +250,6 @@ public: bool restoreDockArea(CDockingStateReader& Stream, QWidget*& CreatedWidget, bool Testing); - /** - * Restores the auto hide dock area. - * Assumes that there are no auto hidden dock areas, and then restores all the dock areas that - * exist in the XML - */ - bool restoreAutoHideDockArea(CDockingStateReader& s, SideBarLocation area, bool Testing); - /** * Restores a auto hide side bar */ @@ -898,6 +891,8 @@ void DockContainerWidgetPrivate::saveChildNodesState(QXmlStreamWriter& s, QWidge } } + +//============================================================================ void DockContainerWidgetPrivate::saveAutoHideWidgetsState(QXmlStreamWriter& s) { for (const auto sideTabBar : SideTabBarWidgets.values()) @@ -907,23 +902,7 @@ void DockContainerWidgetPrivate::saveAutoHideWidgetsState(QXmlStreamWriter& s) continue; } - s.writeStartElement("SideBar"); - s.writeAttribute("Area", QString::number(sideTabBar->sideTabBarArea())); - s.writeAttribute("Tabs", QString::number(sideTabBar->tabCount())); - - for (auto i = 0; i < sideTabBar->tabCount(); ++i) - { - auto Tab = sideTabBar->tabAt(i); - if (!Tab) - { - continue; - } - - auto DockArea = Tab->dockWidget()->dockAreaWidget(); - DockArea->saveState(s); - } - - s.writeEndElement(); + sideTabBar->saveState(s); } } @@ -1043,187 +1022,19 @@ bool DockContainerWidgetPrivate::restoreSplitter(CDockingStateReader& s, return true; } -//============================================================================ -bool DockContainerWidgetPrivate::restoreAutoHideDockArea(CDockingStateReader& s, SideBarLocation area, bool Testing) -{ - bool Ok; -#ifdef ADS_DEBUG_PRINT - int Tabs = s.attributes().value("Tabs").toInt(&Ok); - if (!Ok) - { - return false; - } -#endif - - QString CurrentDockWidget = s.attributes().value("Current").toString(); - ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: " - << CurrentDockWidget); - - if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled)) - { - return false; - } - - CDockAreaWidget* DockArea = nullptr; - CAutoHideDockContainer* dockContainer = nullptr; - if (!Testing) - { - dockContainer = new CAutoHideDockContainer(DockManager, area, _this); - if (!dockContainer->restoreState(s, Testing)) - { - return false; - } - - dockContainer->hide(); - DockArea = dockContainer->dockAreaWidget(); - DockArea->updateAutoHideButtonCheckState(); - DockArea->updateTitleBarButtonToolTip(); - } - - while (s.readNextStartElement()) - { - if (s.name() != QLatin1String("Widget")) - { - continue; - } - - auto ObjectName = s.attributes().value("Name"); - if (ObjectName.isEmpty()) - { - return false; - } - - bool Closed = s.attributes().value("Closed").toInt(&Ok); - if (!Ok) - { - return false; - } - - s.skipCurrentElement(); - CDockWidget* DockWidget = DockManager->findDockWidget(ObjectName.toString()); - if (!DockWidget || Testing) - { - continue; - } - - ADS_PRINT("Dock Widget found - parent " << DockWidget->parent()); - // We hide the DockArea here to prevent the short display (the flashing) - // of the dock areas during application startup - DockArea->hide(); - DockWidget->setToggleViewActionChecked(!Closed); - DockWidget->setClosedState(Closed); - DockWidget->setProperty(internal::ClosedProperty, Closed); - DockWidget->setProperty(internal::DirtyProperty, false); - _this->sideTabBar(area)->insertSideTab(-1, DockWidget->sideTabWidget()); - DockArea->autoHideDockContainer()->addDockWidget(DockWidget); - DockWidget->sideTabWidget()->updateStyle(); // Needed as the side tab widget get it's left/right property from the overlay dock container which was just added - DockArea->autoHideDockContainer()->toggleView(!Closed); - } - - if (dockContainer && !dockContainer->dockWidget()) - { - dockContainer->cleanupAndDelete(); - } - - return true; -} - //============================================================================ bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s, QWidget*& CreatedWidget, bool Testing) { - bool Ok; -#ifdef ADS_DEBUG_PRINT - int Tabs = s.attributes().value("Tabs").toInt(&Ok); - if (!Ok) - { - return false; - } -#endif - - QString CurrentDockWidget = s.attributes().value("Current").toString(); - ADS_PRINT("Restore NodeDockArea Tabs: " << Tabs << " Current: " - << CurrentDockWidget); - CDockAreaWidget* DockArea = nullptr; - if (!Testing) + auto Result = CDockAreaWidget::restoreState(s, DockArea, Testing, _this); + if (Result && DockArea) { - DockArea = new CDockAreaWidget(DockManager, _this); - const auto AllowedAreasAttribute = s.attributes().value("AllowedAreas"); - if (!AllowedAreasAttribute.isEmpty()) - { - DockArea->setAllowedAreas((DockWidgetArea)AllowedAreasAttribute.toInt(nullptr, 16)); - } - - const auto FlagsAttribute = s.attributes().value("Flags"); - if (!FlagsAttribute.isEmpty()) - { - DockArea->setDockAreaFlags((CDockAreaWidget::DockAreaFlags)FlagsAttribute.toInt(nullptr, 16)); - } - } - - while (s.readNextStartElement()) - { - if (s.name() != QLatin1String("Widget")) - { - continue; - } - - auto ObjectName = s.attributes().value("Name"); - if (ObjectName.isEmpty()) - { - return false; - } - - bool Closed = s.attributes().value("Closed").toInt(&Ok); - if (!Ok) - { - return false; - } - - s.skipCurrentElement(); - CDockWidget* DockWidget = DockManager->findDockWidget(ObjectName.toString()); - if (!DockWidget || Testing) - { - continue; - } - - const auto oldDockArea = DockWidget->dockAreaWidget(); - if (oldDockArea) - { - oldDockArea->removeDockWidget(DockWidget); - } - - ADS_PRINT("Dock Widget found - parent " << DockWidget->parent()); - // We hide the DockArea here to prevent the short display (the flashing) - // of the dock areas during application startup - DockArea->hide(); - DockArea->addDockWidget(DockWidget); - DockWidget->setToggleViewActionChecked(!Closed); - DockWidget->setClosedState(Closed); - DockWidget->setProperty(internal::ClosedProperty, Closed); - DockWidget->setProperty(internal::DirtyProperty, false); - } - - if (Testing) - { - return true; - } - - if (!DockArea->dockWidgetsCount()) - { - delete DockArea; - DockArea = nullptr; - } - else - { - DockArea->setProperty("currentDockWidget", CurrentDockWidget); appendDockAreas({DockArea}); } - CreatedWidget = DockArea; - return true; + return Result; } @@ -1232,14 +1043,14 @@ bool DockContainerWidgetPrivate::restoreSideBar(CDockingStateReader& s, QWidget*& CreatedWidget, bool Testing) { Q_UNUSED(CreatedWidget) - // Simply ignore side bar auto hide widgets + // Simply ignore side bar auto hide widgets from saved state if + // auto hide support is disabled if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled)) { return true; } bool Ok; - //int Tabs = s.attributes().value("Tabs").toInt(&Ok); auto Area = (ads::SideBarLocation)s.attributes().value("Area").toInt(&Ok); if (!Ok) { @@ -1248,15 +1059,47 @@ bool DockContainerWidgetPrivate::restoreSideBar(CDockingStateReader& s, while (s.readNextStartElement()) { - if (s.name() != QLatin1String("Area")) + if (s.name() != QLatin1String("Widget")) { continue; } - if (!restoreAutoHideDockArea(s, Area, Testing)) - { - return false; - } + auto Name = s.attributes().value("Name"); + if (Name.isEmpty()) + { + return false; + } + + bool Ok; + bool Closed = s.attributes().value("Closed").toInt(&Ok); + if (!Ok) + { + return false; + } + + int Size = s.attributes().value("Size").toInt(&Ok); + if (!Ok) + { + return false; + } + + s.skipCurrentElement(); + CDockWidget* DockWidget = DockManager->findDockWidget(Name.toString()); + if (!DockWidget || Testing) + { + continue; + } + const auto oldDockArea = DockWidget->dockAreaWidget(); + if (oldDockArea) + { + oldDockArea->removeDockWidget(DockWidget); + } + + auto SideBar = _this->sideTabBar(Area); + auto AutoHideContainer = SideBar->insertDockWidget(-1, DockWidget); + AutoHideContainer->setSize(Size); + DockWidget->setProperty(internal::ClosedProperty, Closed); + DockWidget->setProperty(internal::DirtyProperty, false); } return true; @@ -1487,13 +1330,11 @@ CDockContainerWidget::CDockContainerWidget(CDockManager* DockManager, QWidget *p { d->DockManager->registerDockContainer(this); createRootSplitter(); - if (CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled)) - { - createSideTabBarWidgets(); - } + createSideTabBarWidgets(); } } + //============================================================================ CDockContainerWidget::~CDockContainerWidget() { @@ -1538,26 +1379,18 @@ CDockAreaWidget* CDockContainerWidget::addDockWidget(DockWidgetArea area, CDockW CAutoHideDockContainer* CDockContainerWidget::createAndSetupAutoHideContainer( SideBarLocation area, CDockWidget* DockWidget, CDockWidget::eAutoHideInsertOrder insertOrder) { - if (d->DockManager != DockWidget->dockManager()) - { - DockWidget->setDockManager(d->DockManager); // Auto hide Dock Container needs a valid dock manager - } if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled)) { Q_ASSERT_X(false, "CDockContainerWidget::createAndInitializeDockWidgetOverlayContainer", "Requested area does not exist in config"); return nullptr; } + if (d->DockManager != DockWidget->dockManager()) + { + DockWidget->setDockManager(d->DockManager); // Auto hide Dock Container needs a valid dock manager + } - DockWidget->sideTabWidget()->updateOrientationAndSpacing(area); - sideTabBar(area)->insertSideTab(insertOrder == CDockWidget::First ? 0 : -1, DockWidget->sideTabWidget()); - DockWidget->sideTabWidget()->show(); - - const auto AutoHideContainer = new CAutoHideDockContainer(DockWidget, area, this); - AutoHideContainer->hide(); - d->DockManager->dockFocusController()->clearDockWidgetFocus(DockWidget); - - return AutoHideContainer; + return sideTabBar(area)->insertDockWidget(insertOrder == CDockWidget::First ? 0 : -1, DockWidget); } @@ -1736,6 +1569,13 @@ void CDockContainerWidget::addDockArea(CDockAreaWidget* DockAreaWidget, void CDockContainerWidget::removeDockArea(CDockAreaWidget* area) { ADS_PRINT("CDockContainerWidget::removeDockArea"); + // If it is an auto hide area, then there is nothing much to do + if (area->isAutoHide()) + { + area->setAutoHideDockContainer(nullptr); + return; + } + area->disconnect(this); d->DockAreas.removeAll(area); CDockSplitter* Splitter = internal::findParent(area); @@ -1751,24 +1591,6 @@ void CDockContainerWidget::removeDockArea(CDockAreaWidget* area) *p = nullptr; } - if (area->isAutoHide()) - { - // Removing an area from an auto hide container widget implies deleting the whole auto hide widget - // So cleanup will be done when the auto hide container widget is deleted - // Note: there is no parent splitter - CDockWidget* TopLevelWidget = topLevelDockWidget(); - - // Updated the title bar visibility of the dock widget if there is only - // one single visible dock widget - CDockWidget::emitTopLevelEventForWidget(TopLevelWidget, true); - dumpLayout(); - d->emitDockAreasRemoved(); - area->setAutoHideDockContainer(nullptr); - area->updateAutoHideButtonCheckState(); - area->updateTitleBarButtonToolTip(); - return; - } - // If splitter has more than 1 widgets, we are finished and can leave if (Splitter->count() > 1) { @@ -1897,7 +1719,7 @@ void CDockContainerWidget::dropFloatingWidget(CFloatingDockContainer* FloatingWi auto autoHideWidgets = FloatingWidget->dockContainer()->autoHideWidgets(); for (const auto autohideWidget : autoHideWidgets) { - createAndSetupAutoHideContainer(autohideWidget->sideTabBarArea(), autohideWidget->dockWidget(), autohideWidget->dockWidget()->autoHideInsertOrder()); + createAndSetupAutoHideContainer(autohideWidget->sideBarLocation(), autohideWidget->dockWidget(), autohideWidget->dockWidget()->autoHideInsertOrder()); } if (DockArea) @@ -2134,27 +1956,32 @@ void CDockContainerWidget::createRootSplitter() //============================================================================ void CDockContainerWidget::createSideTabBarWidgets() { + if (!CDockManager::testConfigFlag(CDockManager::AutoHideFeatureEnabled)) + { + return; + } + { auto Area = SideBarLocation::Left; - d->SideTabBarWidgets[Area] = new CSideTabBar(this, Area); + d->SideTabBarWidgets[Area] = new CAutoHideSideBar(this, Area); d->Layout->addWidget(d->SideTabBarWidgets[Area], 1, 0); } { auto Area = SideBarLocation::Right; - d->SideTabBarWidgets[Area] = new CSideTabBar(this, Area); + d->SideTabBarWidgets[Area] = new CAutoHideSideBar(this, Area); d->Layout->addWidget(d->SideTabBarWidgets[Area], 1, 2); } { auto Area = SideBarLocation::Bottom; - d->SideTabBarWidgets[Area] = new CSideTabBar(this, Area); + d->SideTabBarWidgets[Area] = new CAutoHideSideBar(this, Area); d->Layout->addWidget(d->SideTabBarWidgets[Area], 2, 1); } { auto Area = SideBarLocation::Top; - d->SideTabBarWidgets[Area] = new CSideTabBar(this, Area); + d->SideTabBarWidgets[Area] = new CAutoHideSideBar(this, Area); d->Layout->addWidget(d->SideTabBarWidgets[Area], 0, 1); } } @@ -2304,7 +2131,7 @@ void CDockContainerWidget::closeOtherAreas(CDockAreaWidget* KeepOpenArea) } //============================================================================ -CSideTabBar* CDockContainerWidget::sideTabBar(SideBarLocation area) const +CAutoHideSideBar* CDockContainerWidget::sideTabBar(SideBarLocation area) const { return d->SideTabBarWidgets[area]; } @@ -2331,6 +2158,13 @@ QRect CDockContainerWidget::contentRectGlobal() const } return internal::globalGeometry(d->RootSplitter); } + + +//=========================================================================== +CDockManager* CDockContainerWidget::dockManager() const +{ + return d->DockManager; +} } // namespace ads //--------------------------------------------------------------------------- diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h index 709d555..e8737e8 100644 --- a/src/DockContainerWidget.h +++ b/src/DockContainerWidget.h @@ -33,8 +33,8 @@ #include #include "ads_globals.h" +#include "AutoHideTab.h" #include "DockWidget.h" -#include "DockWidgetSideTab.h" QT_FORWARD_DECLARE_CLASS(QXmlStreamWriter) @@ -51,7 +51,7 @@ struct FloatingDockContainerPrivate; class CFloatingDragPreview; struct FloatingDragPreviewPrivate; class CDockingStateReader; -class CSideTabBar; +class CAutoHideSideBar; /** @@ -321,7 +321,7 @@ public: /** * Returns the side tab widget for the given area */ - CSideTabBar* sideTabBar(SideBarLocation area) const; + CAutoHideSideBar* sideTabBar(SideBarLocation area) const; /** @@ -342,6 +342,11 @@ public: */ QRect contentRectGlobal() const; + /** + * Returns the dock manager that owns this container + */ + CDockManager* dockManager() const; + Q_SIGNALS: /** diff --git a/src/DockFocusController.cpp b/src/DockFocusController.cpp index f1d3435..322ff29 100644 --- a/src/DockFocusController.cpp +++ b/src/DockFocusController.cpp @@ -8,6 +8,7 @@ //============================================================================ // INCLUDES //============================================================================ +#include #include "DockFocusController.h" #include @@ -25,7 +26,6 @@ #include "FloatingDockContainer.h" #include "DockManager.h" #include "DockAreaTitleBar.h" -#include "DockWidgetSideTab.h" #ifdef Q_OS_LINUX #include "linux/FloatingWidgetTitleBar.h" @@ -70,8 +70,6 @@ static void updateDockWidgetFocusStyle(CDockWidget* DockWidget, bool Focused) DockWidget->setProperty("focused", Focused); DockWidget->tabWidget()->setProperty("focused", Focused); DockWidget->tabWidget()->updateStyle(); - DockWidget->sideTabWidget()->setProperty("focused", Focused); - DockWidget->sideTabWidget()->updateStyle(); internal::repolishStyle(DockWidget); } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index cb55869..5b4aefa 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -93,7 +93,7 @@ enum eStateFileVersion }; static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig; -static CDockManager::AutoHideFlags StaticAutoHideConfigFlags = CDockManager::DefaultAutoHideConfig; +static CDockManager::AutoHideFlags StaticAutoHideConfigFlags; // auto hide feature is disabled by default static QString FloatingContainersTitle; @@ -718,8 +718,6 @@ QByteArray CDockManager::saveState(int version) const s.writeEndElement(); s.writeEndDocument(); - std::cout << xmldata.toStdString() << std::endl; - return ConfigFlags.testFlag(XmlCompressionEnabled) ? qCompress(xmldata, 9) : xmldata; } @@ -1158,7 +1156,7 @@ void CDockManager::setConfigFlags(const ConfigFlags Flags) //=========================================================================== -void CDockManager::setConfigFlags(const AutoHideFlags Flags) +void CDockManager::setAutoHideConfigFlags(const AutoHideFlags Flags) { StaticAutoHideConfigFlags = Flags; } @@ -1172,7 +1170,7 @@ void CDockManager::setConfigFlag(eConfigFlag Flag, bool On) //=========================================================================== -void CDockManager::setConfigFlag(eAutoHideFlag Flag, bool On) +void CDockManager::setAutoHideConfigFlag(eAutoHideFlag Flag, bool On) { internal::setFlag(StaticAutoHideConfigFlags, Flag, On); } diff --git a/src/DockManager.h b/src/DockManager.h index 19ea2a0..810ebbf 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -54,7 +54,7 @@ struct DockAreaWidgetPrivate; class CIconProvider; class CDockComponentsFactory; class CDockFocusController; -class CSideTabBar; +class CAutoHideSideBar; /** * The central dock manager that maintains the complete docking system. @@ -86,7 +86,7 @@ private: friend struct FloatingDragPreviewPrivate; friend class CDockAreaTitleBar; friend class CAutoHideDockContainer; - friend CSideTabBar; + friend CAutoHideSideBar; protected: @@ -226,21 +226,25 @@ public: }; Q_DECLARE_FLAGS(ConfigFlags, eConfigFlag) + + /** + * These global configuration flags configure some dock manager auto hide + * settings + * Set the dock manager flags, before you create the dock manager instance. + */ enum eAutoHideFlag { - AutoHideFeatureEnabled = 0x01, + AutoHideFeatureEnabled = 0x01, //!< enables / disables auto hide feature DockAreaHasAutoHideButton = 0x02, //!< If the flag is set each dock area has a auto hide menu button - LeftSideBarPrioritizeIconOnly = 0x04, //!< If the flag is set left side bar will prioritize showing icons only over text - RightSideBarPrioritizeIconOnly = 0x08, //!< If the flag is set right side bar will prioritize showing icons only over text - BottomSideBarPrioritizeIconOnly = 0x10,//!< If the flag is set bottom side bar will prioritize showing icons only over text - TopSideBarPrioritizeIconOnly = 0x20, //!< If the flag is set top side bar will prioritize showing icons only over text - AutoHideDockAreaHasTitle = 0x40, //!< If the flag is set overlay dock area title bar will show the window title - AutoHideButtonTogglesArea = 0x80, //!< If the flag is set, the auto hide button enables auto hiding for all dock widgets in an area, if disabled, only the current dock widget will be toggled + LeftSideBarIconOnly = 0x04, //!< If the flag is set left side bar will show only icon if a the dock widget has an icon assigned + RightSideBarIconOnly = 0x08, //!< If the flag is set right side bar will show only icon if a the dock widget has an icon assigned + BottomSideBarIconOnly = 0x10,//!< If the flag is set bottom side show only icon if a the dock widget has an icon assigned + TopSideBarIconOnly = 0x20, //!< If the flag is set top side bar show only icon if a the dock widget has an icon assigned + AutoHideButtonTogglesArea = 0x40, //!< If the flag is set, the auto hide button enables auto hiding for all dock widgets in an area, if disabled, only the current dock widget will be toggled AutoHideButtonCheckable = 0x80, //!< If the flag is set, the auto hide button will be checked and unchecked depending on the auto hide state. Mainly for styling purposes. DefaultAutoHideConfig = AutoHideFeatureEnabled - | DockAreaHasAutoHideButton - | AutoHideDockAreaHasTitle, ///< the default configuration for left and right side bars + | DockAreaHasAutoHideButton ///< the default configuration for left and right side bars }; Q_DECLARE_FLAGS(AutoHideFlags, eAutoHideFlag) @@ -281,7 +285,7 @@ public: * Call this function before you create the dock manager and before * your create the first dock widget. */ - static void setConfigFlags(const AutoHideFlags Flags); + static void setAutoHideConfigFlags(const AutoHideFlags Flags); /** * Set a certain config flag. @@ -293,7 +297,7 @@ public: * Set a certain overlay config flag. * \see setConfigFlags() */ - static void setConfigFlag(eAutoHideFlag Flag, bool On = true); + static void setAutoHideConfigFlag(eAutoHideFlag Flag, bool On = true); /** * Returns true if the given config flag is set diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index d3d63b4..be44c37 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -29,6 +29,8 @@ // INCLUDES //============================================================================ #include +#include +#include #include "DockWidgetTab.h" #include "DockWidget.h" @@ -51,8 +53,6 @@ #include #include -#include "SideTabBar.h" -#include "DockWidgetSideTab.h" #include "DockContainerWidget.h" #include "DockAreaWidget.h" #include "DockManager.h" @@ -79,7 +79,6 @@ struct DockWidgetPrivate QBoxLayout* Layout = nullptr; QWidget* Widget = nullptr; CDockWidgetTab* TabWidget = nullptr; - CDockWidgetSideTab* SideTabWidget = nullptr; CDockWidget::DockWidgetFeatures Features = CDockWidget::DefaultDockWidgetFeatures; CDockManager* DockManager = nullptr; CDockAreaWidget* DockArea = nullptr; @@ -96,6 +95,7 @@ struct DockWidgetPrivate CDockWidget::eMinimumSizeHintMode MinimumSizeHintMode = CDockWidget::MinimumSizeHintFromDockWidget; WidgetFactory* Factory = nullptr; CDockWidget::eAutoHideInsertOrder AutoHideInsertOrder = CDockWidget::Last; + QPointer SideTabWidget; /** * Private data constructor @@ -245,6 +245,8 @@ void DockWidgetPrivate::updateParentDockArea() } } + +//============================================================================ void DockWidgetPrivate::closeAutoHideDockWidgetsIfNeeded() { if (_this->dockContainer() && _this->dockContainer()->openedDockWidgets().isEmpty() && !_this->dockManager()->isRestoringState()) @@ -323,9 +325,6 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) : setObjectName(title); d->TabWidget = componentsFactory()->createDockWidgetTab(this); - d->SideTabWidget = componentsFactory()->createDockWidgetSideTab(this); - - connect(d->SideTabWidget, &CDockWidgetSideTab::pressed, this, &CDockWidget::onDockWidgetSideTabClicked); d->ToggleViewAction = new QAction(title, this); d->ToggleViewAction->setCheckable(true); @@ -343,10 +342,6 @@ CDockWidget::CDockWidget(const QString &title, QWidget *parent) : CDockWidget::~CDockWidget() { ADS_PRINT("~CDockWidget()"); - if (d->SideTabWidget) - { - delete d->SideTabWidget; - } delete d; } @@ -440,6 +435,8 @@ CDockWidgetTab* CDockWidget::tabWidget() const return d->TabWidget; } + +//============================================================================ CAutoHideDockContainer* CDockWidget::autoHideDockContainer() const { if (!d->DockArea) @@ -525,12 +522,26 @@ CDockAreaWidget* CDockWidget::dockAreaWidget() const } //============================================================================ -CDockWidgetSideTab* CDockWidget::sideTabWidget() const +CAutoHideTab* CDockWidget::sideTabWidget() const { return d->SideTabWidget; } +//============================================================================ +void CDockWidget::setSideTabWidget(CAutoHideTab* SideTab) const +{ + d->SideTabWidget = SideTab; +} + + +//============================================================================ +bool CDockWidget::isAutoHide() const +{ + return !d->SideTabWidget.isNull(); +} + + //============================================================================ bool CDockWidget::isFloating() const { @@ -738,6 +749,10 @@ bool CDockWidget::event(QEvent *e) { d->TabWidget->setText(title); } + if (d->SideTabWidget) + { + d->SideTabWidget->setText(title); + } if (d->ToggleViewAction) { d->ToggleViewAction->setText(title); @@ -788,7 +803,12 @@ void CDockWidget::setTabToolTip(const QString &text) void CDockWidget::setIcon(const QIcon& Icon) { d->TabWidget->setIcon(Icon); - d->SideTabWidget->setIcon(Icon); + + if (d->SideTabWidget) + { + d->SideTabWidget->setIcon(Icon); + } + if (!d->ToggleViewAction->isCheckable()) { d->ToggleViewAction->setIcon(Icon); @@ -1079,17 +1099,6 @@ void CDockWidget::showNormal() } } -//============================================================================ -void CDockWidget::onDockWidgetSideTabClicked() -{ - const auto autoHideContainer = autoHideDockContainer(); - if (!autoHideContainer) - { - return; - } - - autoHideContainer->toggleCollapseState(); -} //============================================================================ bool CDockWidget::isFullScreen() const diff --git a/src/DockWidget.h b/src/DockWidget.h index 60df0e3..76f2dce 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -46,8 +46,9 @@ class CDockContainerWidget; class CDockAreaWidget; class DockContainerWidgetPrivate; class CFloatingDockContainer; -class CDockWidgetSideTab; +class CAutoHideTab; class CAutoHideDockContainer; +class CAutoHideSideBar; /** * The QDockWidget class provides a widget that can be docked inside a @@ -78,6 +79,7 @@ protected: friend struct DockWidgetTabPrivate; friend struct DockAreaTitleBarPrivate; friend class CAutoHideDockContainer; + friend CAutoHideSideBar; /** * Assigns the dock manager that manages this dock widget @@ -315,12 +317,6 @@ public: */ CDockWidgetTab* tabWidget() const; - /** - * Returns the auto hide dock container of this dock widget - * or 0 if there is none - */ - CAutoHideDockContainer* autoHideDockContainer() const; - /** * Sets, whether the dock widget is movable, closable, and floatable. */ @@ -365,9 +361,27 @@ public: CDockAreaWidget* dockAreaWidget() const; /** - * Returns the side tab widget for this dock + * Returns the side tab widget for this dock, if this dock widget is in + * a auto hide container. If it is not in a auto hide container, then this + * function returns a nullptr, */ - CDockWidgetSideTab* sideTabWidget() const; + CAutoHideTab* sideTabWidget() const; + + /** + * Assign a side tab widget if this dock widget is an auto hide container + */ + void setSideTabWidget(CAutoHideTab* SideTab) const; + + /** + * Returns true, if this dock widget is in an auto hide container + */ + bool isAutoHide() const; + + /** + * Returns the auto hide dock container of this dock widget + * or 0 if there is none + */ + CAutoHideDockContainer* autoHideDockContainer() const; /** * This property holds whether the dock widget is floating. @@ -611,10 +625,6 @@ public Q_SLOTS: */ void showNormal(); - /** - * Toggles the dock auto hide container when the side tab is clicked - */ - void onDockWidgetSideTabClicked(); Q_SIGNALS: /** diff --git a/src/ResizeHandle.h b/src/ResizeHandle.h index 81264b1..1b5af32 100644 --- a/src/ResizeHandle.h +++ b/src/ResizeHandle.h @@ -24,7 +24,7 @@ class ADS_EXPORT CResizeHandle : public QFrame { Q_OBJECT Q_DISABLE_COPY(CResizeHandle) - Q_PROPERTY(bool opaqueResize READ opaqueResize WRITE setOpaqueResize) + Q_PROPERTY(bool opaqueResize READ opaqueResize WRITE setOpaqueResize) private: ResizeHandlePrivate* d; ///< private data (pimpl) friend struct ResizeHandlePrivate; diff --git a/src/ads_globals.h b/src/ads_globals.h index 006ccb7..3260f87 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -132,7 +132,7 @@ enum eBitwiseOperator /** - * Each dock container supports 4 sidbars + * Each dock container supports 4 sidebars */ enum SideBarLocation { diff --git a/src/src.pro b/src/src.pro index 101f7a3..79344b1 100644 --- a/src/src.pro +++ b/src/src.pro @@ -49,8 +49,8 @@ HEADERS += \ DockComponentsFactory.h \ DockFocusController.h \ AutoHideDockContainer.h \ - SideTabBar.h \ - DockWidgetSideTab.h \ + AutoHideSideBar.h \ + AutoHideTab.h \ PushButton.h \ ResizeHandle.h @@ -74,8 +74,8 @@ SOURCES += \ DockComponentsFactory.cpp \ DockFocusController.cpp \ AutoHideDockContainer.cpp \ - SideTabBar.cpp \ - DockWidgetSideTab.cpp \ + AutoHideSideBar.cpp \ + AutoHideTab.cpp \ PushButton.cpp \ ResizeHandle.cpp diff --git a/src/stylesheets/default.css b/src/stylesheets/default.css index fd431b1..155de9e 100644 --- a/src/stylesheets/default.css +++ b/src/stylesheets/default.css @@ -18,7 +18,7 @@ ads--CDockContainerWidget > QSplitter { } ads--CDockContainerWidget ads--CDockSplitter::handle { - background: palette(dark); + background: palette(dark); } @@ -26,13 +26,39 @@ ads--CDockContainerWidget ads--CDockSplitter::handle { * CDockAreaWidget *****************************************************************************/ ads--CDockAreaWidget { - background: palette(window); + background: palette(window); +} + +ads--CTitleBarButton { + padding: 0px 0px; +} + + +#tabsMenuButton::menu-indicator { + image: none; +} + +#tabsMenuButton { + qproperty-icon: url(:/ads/images/tabs-menu-button.svg); + qproperty-iconSize: 16px; +} + +#dockAreaCloseButton { + qproperty-icon: url(:/ads/images/close-button.svg), + url(:/ads/images/close-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + +#detachGroupButton { + qproperty-icon: url(:/ads/images/detach-button.svg), + url(:/ads/images/detach-button-disabled.svg) disabled; + qproperty-iconSize: 16px; } /***************************************************************************** - * CDockWidgetTab + * CDockWidgetTab and close button styling *****************************************************************************/ ads--CDockWidgetTab { background: palette(window); @@ -57,6 +83,26 @@ ads--CDockWidgetTab[activeTab="true"] QLabel { } +#tabCloseButton { + margin-top: 2px; + background: none; + border: none; + padding: 0px -2px; + qproperty-icon: url(:/ads/images/close-button.svg), + url(:/ads/images/close-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + +#tabCloseButton:hover { + border: 1px solid rgba(0, 0, 0, 32); + background: rgba(0, 0, 0, 16); +} + +#tabCloseButton:pressed { + background: rgba(0, 0, 0, 32); +} + + /***************************************************************************** * CDockWidget *****************************************************************************/ @@ -74,60 +120,6 @@ QScrollArea#dockWidgetScrollArea { } -/***************************************************************************** - * Dock widget tab styling - *****************************************************************************/ -#tabCloseButton { - margin-top: 2px; - background: none; - border: none; - padding: 0px -2px; - qproperty-icon: url(:/ads/images/close-button.svg), - url(:/ads/images/close-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - -#tabCloseButton:hover { - border: 1px solid rgba(0, 0, 0, 32); - background: rgba(0, 0, 0, 16); -} - -#tabCloseButton:pressed { - background: rgba(0, 0, 0, 32); -} - - - -/***************************************************************************** - * Dock area title bar and buttons styling - *****************************************************************************/ - ads--CTitleBarButton { - padding: 0px 0px; -} - - -#tabsMenuButton::menu-indicator { - image: none; -} - -#tabsMenuButton { - qproperty-icon: url(:/ads/images/tabs-menu-button.svg); - qproperty-iconSize: 16px; -} - -#dockAreaCloseButton { - qproperty-icon: url(:/ads/images/close-button.svg), - url(:/ads/images/close-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - -#detachGroupButton { - qproperty-icon: url(:/ads/images/detach-button.svg), - url(:/ads/images/detach-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - - /***************************************************************************** * * Styling of auto hide functionality @@ -136,86 +128,80 @@ QScrollArea#dockWidgetScrollArea { /***************************************************************************** - * CDockWidgetSideTab + * CAutoHideTab *****************************************************************************/ -ads--CDockWidgetSideTab { - /*background: palette(window);*/ - qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ -} - - -ads--CDockWidgetSideTab { +ads--CAutoHideTab { + qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ background: none; border: none; padding-left: 2px; padding-right: 0px; text-align: center; + margin-right: 6px; + min-height: 20; } -ads--CDockWidgetSideTab[sideTabBarArea="0"], -ads--CDockWidgetSideTab[sideTabBarArea="2"] { +ads--CAutoHideTab[sideBarLocation="0"], +ads--CAutoHideTab[sideBarLocation="2"] { border-top: 5px solid rgba(0, 0, 0, 48); - margin-right: 6px; - min-height: 20; + } -ads--CDockWidgetSideTab[sideTabBarArea="1"], -ads--CDockWidgetSideTab[sideTabBarArea="3"] { +ads--CAutoHideTab[sideBarLocation="1"], +ads--CAutoHideTab[sideBarLocation="3"] { border-bottom: 5px solid rgba(0, 0, 0, 48); - margin-right: 6px; - min-height: 20; } -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"], -ads--CDockWidgetSideTab:hover[sideTabBarArea="2"] { +ads--CAutoHideTab:hover[sideBarLocation="0"], +ads--CAutoHideTab:hover[sideBarLocation="2"] { border-top: 5px solid palette(highlight); color: palette(highlight); } -ads--CDockWidgetSideTab:hover[sideTabBarArea="1"], -ads--CDockWidgetSideTab:hover[sideTabBarArea="3"] { +ads--CAutoHideTab:hover[sideBarLocation="1"], +ads--CAutoHideTab:hover[sideBarLocation="3"] { border-bottom: 5px solid palette(highlight); color: palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"], -ads--CDockWidgetSideTab[sideTabBarArea="2"][activeTab="true"] { +ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="2"][activeTab="true"] { border-top: 5px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"], -ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"] { +ads--CAutoHideTab[sideBarLocation="1"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="3"][activeTab="true"] { border-bottom: 5px solid palette(highlight); } /***************************************************************************** - * CSideTabBar + * CAutoHideSideBar *****************************************************************************/ -ads--CSideTabBar{ +ads--CAutoHideSideBar{ background: palette(window); } -ads--CSideTabBar[sideTabBarArea="0"] { +ads--CAutoHideSideBar[sideBarLocation="0"] { border-bottom: 1px solid palette(dark); } -ads--CSideTabBar[sideTabBarArea="1"] { +ads--CAutoHideSideBar[sideBarLocation="1"] { border-right: 1px solid palette(dark); } -ads--CSideTabBar[sideTabBarArea="2"] { +ads--CAutoHideSideBar[sideBarLocation="2"] { border-left: 1px solid palette(dark); } -ads--CSideTabBar[sideTabBarArea="3"] { +ads--CAutoHideSideBar[sideBarLocation="3"] { border-top: 1px solid palette(dark); } @@ -292,19 +278,19 @@ ads--CResizeHandle { } -ads--CAutoHideDockContainer[sideTabBarArea="0"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="0"] ads--CResizeHandle { border-top: 1px solid palette(dark); } -ads--CAutoHideDockContainer[sideTabBarArea="1"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="1"] ads--CResizeHandle { border-left: 1px solid palette(dark); } -ads--CAutoHideDockContainer[sideTabBarArea="2"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="2"] ads--CResizeHandle { border-right: 1px solid palette(dark); } -ads--CAutoHideDockContainer[sideTabBarArea="3"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="3"] ads--CResizeHandle { border-top: 1px solid palette(dark); } diff --git a/src/stylesheets/default_linux.css b/src/stylesheets/default_linux.css index ac41491..28d2b5a 100644 --- a/src/stylesheets/default_linux.css +++ b/src/stylesheets/default_linux.css @@ -1,26 +1,67 @@ /* * Default style sheet on Linux Platforms */ + +/***************************************************************************** + * CDockContainerWidget + *****************************************************************************/ ads--CDockContainerWidget { - background: palette(dark); + background: palette(window); } + + +/***************************************************************************** + * CDockSplitter + *****************************************************************************/ ads--CDockContainerWidget > QSplitter{ - padding: 1 0 1 0; + padding: 1 0 1 0; } ads--CDockContainerWidget ads--CDockSplitter::handle { - background: palette(dark); + background: palette(dark); } + +/***************************************************************************** + * CDockAreaWidget + *****************************************************************************/ ads--CDockAreaWidget { - background: palette(window); - border: 1px solid white; + background: palette(window); } ads--CDockAreaWidget #tabsMenuButton::menu-indicator { - image: none; + image: none; } + +ads--CTitleBarButton { + padding: 0px 0px; +} + + +#tabsMenuButton { + qproperty-icon: url(:/ads/images/tabs-menu-button.svg); + qproperty-iconSize: 16px; +} + + +#dockAreaCloseButton { + qproperty-icon: url(:/ads/images/close-button.svg), + url(:/ads/images/close-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + + +#detachGroupButton { + qproperty-icon: url(:/ads/images/detach-button.svg), + url(:/ads/images/detach-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + + +/***************************************************************************** + * CDockWidgetTab and close button styling + *****************************************************************************/ ads--CDockWidgetTab { background: palette(window); border-color: palette(light); @@ -29,20 +70,47 @@ ads--CDockWidgetTab { padding: 0 0px; } + ads--CDockWidgetTab[activeTab="true"] { background: qlineargradient(spread : pad, x1 : 0, y1 : 0, x2 : 0, y2 : 0.5, stop : 0 palette(window), stop:1 palette(light)); /*background: palette(highlight);*/ } + ads--CDockWidgetTab QLabel { color: palette(dark); } + ads--CDockWidgetTab[activeTab="true"] QLabel { color: palette(foreground); } + +#tabCloseButton { + margin-top: 2px; + background: none; + border: none; + padding: 0px -2px; + qproperty-icon: url(:/ads/images/close-button.svg), + url(:/ads/images/close-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + +#tabCloseButton:hover { + border: 1px solid rgba(0, 0, 0, 32); + background: rgba(0, 0, 0, 16); +} + +#tabCloseButton:pressed { + background: rgba(0, 0, 0, 32); +} + + +/***************************************************************************** + * CDockWidget + *****************************************************************************/ ads--CDockWidget { background: palette(light); border-color: palette(light); @@ -50,52 +118,16 @@ ads--CDockWidget { border-width: 1px 0 0 0; } -ads--CTitleBarButton { - padding: 0px 0px; -} QScrollArea#dockWidgetScrollArea { padding: 0px; border: none; } -#tabCloseButton { - margin-top: 2px; - background: none; - border: none; - padding: 0px -2px; - qproperty-icon: url(:/ads/images/close-button.svg), - url(:/ads/images/close-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - -#tabCloseButton:hover { - border: 1px solid rgba(0, 0, 0, 32); - background: rgba(0, 0, 0, 16); -} - -#tabCloseButton:pressed { - background: rgba(0, 0, 0, 32); -} - -#tabsMenuButton { - qproperty-icon: url(:/ads/images/tabs-menu-button.svg); - qproperty-iconSize: 16px; -} - -#dockAreaCloseButton { - qproperty-icon: url(:/ads/images/close-button.svg), - url(:/ads/images/close-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - -#detachGroupButton { - qproperty-icon: url(:/ads/images/detach-button.svg), - url(:/ads/images/detach-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - +/***************************************************************************** + * Floating widget styling + *****************************************************************************/ ads--CFloatingWidgetTitleBar { background: palette(midlight); qproperty-maximizeIcon: url(:/ads/images/maximize-button.svg); @@ -122,3 +154,177 @@ ads--CFloatingWidgetTitleBar { #floatingTitleCloseButton:pressed { background: rgba(0, 0, 0, 48); } + + +/***************************************************************************** + * + * Styling of auto hide functionality + * + *****************************************************************************/ + + +/***************************************************************************** + * CAutoHideTab + *****************************************************************************/ +ads--CAutoHideTab { + qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ + padding-left: 2px; + padding-right: 0px; + text-align: center; + margin-right: 6px; + min-height: 20; + border: none; +} + +ads--CAutoHideTab[sideBarLocation="1"], +ads--CAutoHideTab[sideBarLocation="3"] { + border-bottom: 5px solid rgba(0, 0, 0, 48); +} + + +ads--CAutoHideTab[sideBarLocation="0"], +ads--CAutoHideTab[sideBarLocation="2"] { + border-top: 5px solid rgba(0, 0, 0, 48); +} + + +ads--CAutoHideTab:hover[sideBarLocation="0"], +ads--CAutoHideTab:hover[sideBarLocation="2"] { + border-top: 5px solid palette(highlight); + color: palette(highlight); +} + + +ads--CAutoHideTab:hover[sideBarLocation="1"], +ads--CAutoHideTab:hover[sideBarLocation="3"] { + border-bottom: 5px solid palette(highlight); + color: palette(highlight); +} + +ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="2"][activeTab="true"] { + border-top: 5px solid palette(highlight); +} + + +ads--CAutoHideTab[sideBarLocation="1"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="3"][activeTab="true"] { + border-bottom: 5px solid palette(highlight); +} + + +/***************************************************************************** + * CAutoHideSideBar + *****************************************************************************/ +ads--CAutoHideSideBar{ + background: palette(window); +} + + +ads--CAutoHideSideBar[sideBarLocation="0"] { + border-bottom: 1px solid palette(dark); +} + +ads--CAutoHideSideBar[sideBarLocation="1"] { + border-right: 1px solid palette(dark); +} + +ads--CAutoHideSideBar[sideBarLocation="2"] { + border-left: 1px solid palette(dark); +} + +ads--CAutoHideSideBar[sideBarLocation="3"] { + border-top: 1px solid palette(dark); +} + + +/***************************************************************************** + * CAutoHideDockContainer + *****************************************************************************/ +ads--CAutoHideDockContainer { + background: palette(window); +} + + +ads--CAutoHideDockContainer ads--CDockAreaTitleBar { + background: palette(highlight); + padding: 0px; + border: none; +} + + +/* + * This is required because the ads--CDockAreaWidget[focused="true"] will + * overwrite the ads--CAutoHideDockContainer ads--CDockAreaTitleBar rule + */ +ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar { + background: palette(highlight); + padding: 0px; + border: none; +} + + +#autoHideTitleLabel { + padding-left: 4px; + color: palette(light); +} + + +/***************************************************************************** + * CAutoHideDockContainer titlebar buttons + *****************************************************************************/ +#dockAreaAutoHideButton { + qproperty-icon: url(:/ads/images/vs-pin-button.svg); + qproperty-iconSize: 16px; +} + +ads--CAutoHideDockContainer #dockAreaAutoHideButton { + qproperty-icon: url(:/ads/images/vs-pin-button-pinned-focused.svg); + qproperty-iconSize: 16px; +} + + +ads--CAutoHideDockContainer #dockAreaCloseButton{ + qproperty-icon: url(:/ads/images/close-button-focused.svg) +} + + +ads--CAutoHideDockContainer ads--CTitleBarButton:hover { + background: rgba(255, 255, 255, 48); +} + +ads--CAutoHideDockContainer ads--CTitleBarButton:pressed { + background: rgba(255, 255, 255, 96); +} + +/***************************************************************************** + * CAutoHideDockContainer Titlebar and Buttons + *****************************************************************************/ + + +/***************************************************************************** + * CResizeHandle + *****************************************************************************/ +ads--CResizeHandle { + background: palette(window); +} + + +ads--CAutoHideDockContainer[sideBarLocation="0"] ads--CResizeHandle { + border-top: 1px solid palette(dark); +} + +ads--CAutoHideDockContainer[sideBarLocation="1"] ads--CResizeHandle { + border-left: 1px solid palette(dark); +} + +ads--CAutoHideDockContainer[sideBarLocation="2"] ads--CResizeHandle { + border-right: 1px solid palette(dark); +} + +ads--CAutoHideDockContainer[sideBarLocation="3"] ads--CResizeHandle { + border-top: 1px solid palette(dark); +} + + + diff --git a/src/stylesheets/focus_highlighting.css b/src/stylesheets/focus_highlighting.css index d559716..1e09c43 100644 --- a/src/stylesheets/focus_highlighting.css +++ b/src/stylesheets/focus_highlighting.css @@ -35,6 +35,39 @@ ads--CDockAreaWidget { } +ads--CDockAreaTitleBar { + background: transparent; + border-bottom: 2px solid palette(light); + padding-bottom: 0px; +} + +ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar { + border-bottom: 2px solid palette(highlight); +} + +ads--CTitleBarButton { + padding: 0px 0px; +} + + +#tabsMenuButton::menu-indicator { + image: none; +} + + +#dockAreaCloseButton { + qproperty-icon: url(:/ads/images/close-button.svg), + url(:/ads/images/close-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + +#detachGroupButton { + qproperty-icon: url(:/ads/images/detach-button.svg), + url(:/ads/images/detach-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + + /***************************************************************************** * CDockWidgetTab @@ -63,28 +96,6 @@ ads--CDockWidgetTab[activeTab="true"] QLabel { } - -/***************************************************************************** - * CDockWidget - *****************************************************************************/ -ads--CDockWidget { - background: palette(light); - border-color: palette(light); - border-style: solid; - border-width: 1px 0 0 0; -} - - -QScrollArea#dockWidgetScrollArea { - padding: 0px; - border: none; -} - - - -/***************************************************************************** - * Dock widget tab styling - *****************************************************************************/ #tabCloseButton { margin-top: 2px; background: none; @@ -129,38 +140,19 @@ ads--CDockWidgetTab[focused="true"] QLabel { /***************************************************************************** - * Dock area title bar and buttons styling + * CDockWidget *****************************************************************************/ - ads--CDockAreaTitleBar { - background: transparent; - border-bottom: 2px solid palette(light); - padding-bottom: 0px; -} - -ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar { - border-bottom: 2px solid palette(highlight); -} - -ads--CTitleBarButton { - padding: 0px 0px; +ads--CDockWidget { + background: palette(light); + border-color: palette(light); + border-style: solid; + border-width: 1px 0 0 0; } -#tabsMenuButton::menu-indicator { - image: none; -} - - -#dockAreaCloseButton { - qproperty-icon: url(:/ads/images/close-button.svg), - url(:/ads/images/close-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - -#detachGroupButton { - qproperty-icon: url(:/ads/images/detach-button.svg), - url(:/ads/images/detach-button-disabled.svg) disabled; - qproperty-iconSize: 16px; +QScrollArea#dockWidgetScrollArea { + padding: 0px; + border: none; } @@ -173,15 +165,15 @@ ads--CTitleBarButton { /***************************************************************************** - * CDockWidgetSideTab + * CAutoHideTab *****************************************************************************/ -ads--CDockWidgetSideTab { +ads--CAutoHideTab { /*background: palette(window);*/ qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ } -ads--CDockWidgetSideTab { +ads--CAutoHideTab { background: none; border: none; padding-left: 2px; @@ -190,16 +182,16 @@ ads--CDockWidgetSideTab { } -ads--CDockWidgetSideTab[sideTabBarArea="0"], -ads--CDockWidgetSideTab[sideTabBarArea="2"] { +ads--CAutoHideTab[sideBarLocation="0"], +ads--CAutoHideTab[sideBarLocation="2"] { border-top: 5px solid rgba(0, 0, 0, 48); margin-right: 6px; min-height: 20; } -ads--CDockWidgetSideTab[sideTabBarArea="1"], -ads--CDockWidgetSideTab[sideTabBarArea="3"] { +ads--CAutoHideTab[sideBarLocation="1"], +ads--CAutoHideTab[sideBarLocation="3"] { border-bottom: 5px solid rgba(0, 0, 0, 48); margin-right: 6px; min-height: 20; @@ -207,52 +199,52 @@ ads--CDockWidgetSideTab[sideTabBarArea="3"] { -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"], -ads--CDockWidgetSideTab:hover[sideTabBarArea="2"] { +ads--CAutoHideTab:hover[sideBarLocation="0"], +ads--CAutoHideTab:hover[sideBarLocation="2"] { border-top: 5px solid palette(highlight); color: palette(highlight); } -ads--CDockWidgetSideTab:hover[sideTabBarArea="1"], -ads--CDockWidgetSideTab:hover[sideTabBarArea="3"] { +ads--CAutoHideTab:hover[sideBarLocation="1"], +ads--CAutoHideTab:hover[sideBarLocation="3"] { border-bottom: 5px solid palette(highlight); color: palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"], -ads--CDockWidgetSideTab[sideTabBarArea="2"][activeTab="true"] { +ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="2"][activeTab="true"] { border-top: 5px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"], -ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"] { +ads--CAutoHideTab[sideBarLocation="1"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="3"][activeTab="true"] { border-bottom: 5px solid palette(highlight); } /***************************************************************************** - * CSideTabBar + * CAutoHideSideBar *****************************************************************************/ -ads--CSideTabBar{ +ads--CAutoHideSideBar{ background: palette(window); } -ads--CSideTabBar[sideTabBarArea="0"] { +ads--CAutoHideSideBar[sideBarLocation="0"] { border-bottom: 1px solid palette(dark); } -ads--CSideTabBar[sideTabBarArea="1"] { +ads--CAutoHideSideBar[sideBarLocation="1"] { border-right: 1px solid palette(dark); } -ads--CSideTabBar[sideTabBarArea="2"] { +ads--CAutoHideSideBar[sideBarLocation="2"] { border-left: 1px solid palette(dark); } -ads--CSideTabBar[sideTabBarArea="3"] { +ads--CAutoHideSideBar[sideBarLocation="3"] { border-top: 1px solid palette(dark); } @@ -329,19 +321,19 @@ ads--CResizeHandle { } -ads--CAutoHideDockContainer[sideTabBarArea="0"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="0"] ads--CResizeHandle { border-top: 1px solid palette(dark); } -ads--CAutoHideDockContainer[sideTabBarArea="1"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="1"] ads--CResizeHandle { border-left: 1px solid palette(dark); } -ads--CAutoHideDockContainer[sideTabBarArea="2"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="2"] ads--CResizeHandle { border-right: 1px solid palette(dark); } -ads--CAutoHideDockContainer[sideTabBarArea="3"] ads--CResizeHandle { +ads--CAutoHideDockContainer[sideBarLocation="3"] ads--CResizeHandle { border-top: 1px solid palette(dark); } diff --git a/src/stylesheets/focus_highlighting_linux.css b/src/stylesheets/focus_highlighting_linux.css index f16ab5e..3a78cef 100644 --- a/src/stylesheets/focus_highlighting_linux.css +++ b/src/stylesheets/focus_highlighting_linux.css @@ -1,9 +1,18 @@ /* * Default style sheet on Linux Platforms with focus highlighting flag enabled */ + +/***************************************************************************** + * CDockContainerWidget + *****************************************************************************/ ads--CDockContainerWidget { - background: palette(dark); + background: palette(window); } + + +/***************************************************************************** + * CDockSplitter + *****************************************************************************/ ads--CDockContainerWidget > QSplitter{ padding: 1 0 1 0; } @@ -13,15 +22,64 @@ ads--CDockContainerWidget ads--CDockSplitter::handle { background: palette(dark); } + +/***************************************************************************** + * CDockAreaWidget + *****************************************************************************/ ads--CDockAreaWidget { background: palette(window); - border: 1px solid white; } ads--CDockAreaWidget #tabsMenuButton::menu-indicator { image: none; } + +ads--CTitleBarButton { + padding: 0px 0px; +} + + +#tabsMenuButton { + qproperty-icon: url(:/ads/images/tabs-menu-button.svg); + qproperty-iconSize: 16px; +} + + +#dockAreaCloseButton { + qproperty-icon: url(:/ads/images/close-button.svg), + url(:/ads/images/close-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + + +#detachGroupButton { + qproperty-icon: url(:/ads/images/detach-button.svg), + url(:/ads/images/detach-button-disabled.svg) disabled; + qproperty-iconSize: 16px; +} + + + +/***************************************************************************** + * CDockAreaTitleBar + *****************************************************************************/ +ads--CDockAreaTitleBar { + background: transparent; + border-bottom: 2px solid palette(light); + padding-bottom: 0px; +} + +ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar { + background: transparent; + border-bottom: 2px solid palette(highlight); + padding-bottom: 0px; +} + + +/***************************************************************************** + * CDockWidgetTab and close button styling + *****************************************************************************/ ads--CDockWidgetTab { background: palette(window); border-color: palette(light); @@ -44,33 +102,6 @@ ads--CDockWidgetTab[activeTab="true"] QLabel { color: palette(foreground); } -ads--CDockWidget { - background: palette(light); - border-color: palette(light); - border-style: solid; - border-width: 1px 0 0 0; -} - -ads--CTitleBarButton { - padding: 0px 0px; -} - -QScrollArea#dockWidgetScrollArea { - padding: 0px; - border: none; -} - -#dockAreaCloseButton { - qproperty-icon: url(:/ads/images/close-button.svg), - url(:/ads/images/close-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} - -#detachGroupButton { - qproperty-icon: url(:/ads/images/detach-button.svg), - url(:/ads/images/detach-button-disabled.svg) disabled; - qproperty-iconSize: 16px; -} #tabCloseButton { margin-top: 2px; @@ -92,27 +123,21 @@ QScrollArea#dockWidgetScrollArea { } -#tabsMenuButton { - qproperty-icon: url(:/ads/images/tabs-menu-button.svg); - qproperty-iconSize: 16px; -} - - /* Focus related styling */ ads--CDockWidgetTab[focused="true"] { background: palette(highlight); border-color: palette(highlight); } -ads--CDockWidgetTab[focused="true"]>#tabCloseButton { +ads--CDockWidgetTab[focused="true"] > #tabCloseButton { qproperty-icon: url(:/ads/images/close-button-focused.svg) } -ads--CDockWidgetTab[focused="true"]>#tabCloseButton:hover { +ads--CDockWidgetTab[focused="true"] > #tabCloseButton:hover { background: rgba(255, 255, 255, 48); } -ads--CDockWidgetTab[focused="true"]>#tabCloseButton:pressed { +ads--CDockWidgetTab[focused="true"] > #tabCloseButton:pressed { background: rgba(255, 255, 255, 92); } @@ -120,19 +145,28 @@ ads--CDockWidgetTab[focused="true"] QLabel { color: palette(light); } -ads--CDockAreaTitleBar { - background: transparent; - border-bottom: 2px solid palette(light); - padding-bottom: 0px; -} -ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar { - background: transparent; - border-bottom: 2px solid palette(highlight); - padding-bottom: 0px; +/***************************************************************************** + * CDockWidget + *****************************************************************************/ +ads--CDockWidget { + background: palette(light); + border-color: palette(light); + border-style: solid; + border-width: 1px 0 0 0; } +QScrollArea#dockWidgetScrollArea { + padding: 0px; + border: none; +} + + + +/***************************************************************************** + * Floating widget styling + *****************************************************************************/ ads--CFloatingWidgetTitleBar { qproperty-maximizeIcon: url(:/ads/images/maximize-button.svg); qproperty-normalIcon: url(:/ads/images/restore-button.svg); @@ -197,3 +231,174 @@ ads--CFloatingDockContainer[isActiveWindow="true"] #floatingTitleMaximizeButton: } */ + +/***************************************************************************** + * + * Styling of auto hide functionality + * + *****************************************************************************/ + + +/***************************************************************************** + * CAutoHideTab + *****************************************************************************/ +ads--CAutoHideTab { + qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ + padding-left: 2px; + padding-right: 0px; + text-align: center; + margin-right: 6px; + min-height: 20; + border: none; +} + +ads--CAutoHideTab[sideBarLocation="1"], +ads--CAutoHideTab[sideBarLocation="3"] { + border-bottom: 5px solid rgba(0, 0, 0, 48); +} + + +ads--CAutoHideTab[sideBarLocation="0"], +ads--CAutoHideTab[sideBarLocation="2"] { + border-top: 5px solid rgba(0, 0, 0, 48); +} + + +ads--CAutoHideTab:hover[sideBarLocation="0"], +ads--CAutoHideTab:hover[sideBarLocation="2"] { + border-top: 5px solid palette(highlight); + color: palette(highlight); +} + + +ads--CAutoHideTab:hover[sideBarLocation="1"], +ads--CAutoHideTab:hover[sideBarLocation="3"] { + border-bottom: 5px solid palette(highlight); + color: palette(highlight); +} + +ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="2"][activeTab="true"] { + border-top: 5px solid palette(highlight); +} + + +ads--CAutoHideTab[sideBarLocation="1"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="3"][activeTab="true"] { + border-bottom: 5px solid palette(highlight); +} + + +/***************************************************************************** + * CAutoHideSideBar + *****************************************************************************/ +ads--CAutoHideSideBar{ + background: palette(window); +} + + +ads--CAutoHideSideBar[sideBarLocation="0"] { + border-bottom: 1px solid palette(dark); +} + +ads--CAutoHideSideBar[sideBarLocation="1"] { + border-right: 1px solid palette(dark); +} + +ads--CAutoHideSideBar[sideBarLocation="2"] { + border-left: 1px solid palette(dark); +} + +ads--CAutoHideSideBar[sideBarLocation="3"] { + border-top: 1px solid palette(dark); +} + + +/***************************************************************************** + * CAutoHideDockContainer + *****************************************************************************/ +ads--CAutoHideDockContainer { + background: palette(window); +} + + +ads--CAutoHideDockContainer ads--CDockAreaTitleBar { + background: palette(highlight); + padding: 0px; + border: none; +} + + +/* + * This is required because the ads--CDockAreaWidget[focused="true"] will + * overwrite the ads--CAutoHideDockContainer ads--CDockAreaTitleBar rule + */ +ads--CAutoHideDockContainer ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar { + background: palette(highlight); + padding: 0px; + border: none; +} + + +#autoHideTitleLabel { + padding-left: 4px; + color: palette(light); +} + + +/***************************************************************************** + * CAutoHideDockContainer titlebar buttons + *****************************************************************************/ +#dockAreaAutoHideButton { + qproperty-icon: url(:/ads/images/vs-pin-button.svg); + qproperty-iconSize: 16px; +} + +ads--CAutoHideDockContainer #dockAreaAutoHideButton { + qproperty-icon: url(:/ads/images/vs-pin-button-pinned-focused.svg); + qproperty-iconSize: 16px; +} + + +ads--CAutoHideDockContainer #dockAreaCloseButton{ + qproperty-icon: url(:/ads/images/close-button-focused.svg) +} + + +ads--CAutoHideDockContainer ads--CTitleBarButton:hover { + background: rgba(255, 255, 255, 48); +} + +ads--CAutoHideDockContainer ads--CTitleBarButton:pressed { + background: rgba(255, 255, 255, 96); +} + +/***************************************************************************** + * CAutoHideDockContainer Titlebar and Buttons + *****************************************************************************/ + + +/***************************************************************************** + * CResizeHandle + *****************************************************************************/ +ads--CResizeHandle { + background: palette(window); +} + + +ads--CAutoHideDockContainer[sideBarLocation="0"] ads--CResizeHandle { + border-top: 1px solid palette(dark); +} + +ads--CAutoHideDockContainer[sideBarLocation="1"] ads--CResizeHandle { + border-left: 1px solid palette(dark); +} + +ads--CAutoHideDockContainer[sideBarLocation="2"] ads--CResizeHandle { + border-right: 1px solid palette(dark); +} + +ads--CAutoHideDockContainer[sideBarLocation="3"] ads--CResizeHandle { + border-top: 1px solid palette(dark); +} + diff --git a/src/stylesheets/visual_studio_light.css b/src/stylesheets/visual_studio_light.css index 8e01c52..845c3d6 100644 --- a/src/stylesheets/visual_studio_light.css +++ b/src/stylesheets/visual_studio_light.css @@ -149,13 +149,13 @@ ads--CDockAreaWidget[focused="true"] ads--CDockAreaTitleBar { * Styling of auto hide functionality *---------------------------------------------------------------------------- */ -ads--CDockWidgetSideTab { +ads--CAutoHideTab { /*background: palette(window);*/ qproperty-iconSize: 16px 16px;/* this is optional in case you would like to change icon size*/ } -ads--CDockWidgetSideTab +ads--CAutoHideTab { background: none; border: none; @@ -164,8 +164,8 @@ ads--CDockWidgetSideTab text-align: center; } -ads--CDockWidgetSideTab[sideTabBarArea="0"], -ads--CDockWidgetSideTab[sideTabBarArea="2"] +ads--CAutoHideTab[sideBarLocation="0"], +ads--CAutoHideTab[sideBarLocation="2"] { border-top: 5px solid rgba(0, 0, 0, 48); margin-right: 6px; @@ -173,8 +173,8 @@ ads--CDockWidgetSideTab[sideTabBarArea="2"] } -ads--CDockWidgetSideTab[sideTabBarArea="1"], -ads--CDockWidgetSideTab[sideTabBarArea="3"] +ads--CAutoHideTab[sideBarLocation="1"], +ads--CAutoHideTab[sideBarLocation="3"] { border-bottom: 5px solid rgba(0, 0, 0, 48); margin-right: 6px; @@ -183,30 +183,30 @@ ads--CDockWidgetSideTab[sideTabBarArea="3"] -ads--CDockWidgetSideTab:hover[sideTabBarArea="0"], -ads--CDockWidgetSideTab:hover[sideTabBarArea="2"] +ads--CAutoHideTab:hover[sideBarLocation="0"], +ads--CAutoHideTab:hover[sideBarLocation="2"] { border-top: 5px solid palette(highlight); color: palette(highlight); } -ads--CDockWidgetSideTab:hover[sideTabBarArea="1"], -ads--CDockWidgetSideTab:hover[sideTabBarArea="3"] +ads--CAutoHideTab:hover[sideBarLocation="1"], +ads--CAutoHideTab:hover[sideBarLocation="3"] { border-bottom: 5px solid palette(highlight); color: palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="0"][activeTab="true"], -ads--CDockWidgetSideTab[sideTabBarArea="2"][activeTab="true"] +ads--CAutoHideTab[sideBarLocation="0"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="2"][activeTab="true"] { border-top: 5px solid palette(highlight); } -ads--CDockWidgetSideTab[sideTabBarArea="1"][activeTab="true"], -ads--CDockWidgetSideTab[sideTabBarArea="3"][activeTab="true"] +ads--CAutoHideTab[sideBarLocation="1"][activeTab="true"], +ads--CAutoHideTab[sideBarLocation="3"][activeTab="true"] { border-bottom: 5px solid palette(highlight); } @@ -227,7 +227,7 @@ ads--CAutoHideDockContainer::handle:horizontal { } */ -/*ads--CAutoHideDockContainer[sideTabBarArea="0"]:handle { +/*ads--CAutoHideDockContainer[sideBarLocation="0"]:handle { border: 1px solid palette(dark); background: white; }*/