From f7719fb08b483ca0bc0634b131cec80952fbe2ac Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 16 Sep 2014 22:07:59 +0200 Subject: [PATCH] refs #325, improved info area * signal when tab bar is changed (goal: reload in components when info area changes) * tab bar locking (avoid unintended floating) --- src/blackgui/infoarea.cpp | 25 +++++++++++++++++++++---- src/blackgui/infoarea.h | 9 ++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index ac7deed5a..a433916f0 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -57,6 +57,14 @@ namespace BlackGui menu->addAction(CIcons::dockTop16(), "Dock all", this, SLOT(dockAllWidgets())); menu->addAction(CIcons::floatAll16(), "Float all", this, SLOT(floatAllWidgets())); menu->addAction(CIcons::floatOne16(), "Dock / float info area", this, SLOT(toggleFloating())); + QAction *lockTabBarMenuAction = new QAction(menu); + lockTabBarMenuAction->setObjectName(this->objectName().append("LockTabBar")); + lockTabBarMenuAction->setIconText("Lock tab bar"); + lockTabBarMenuAction->setIcon(CIcons::lockClosed16()); + lockTabBarMenuAction->setCheckable(true); + lockTabBarMenuAction->setChecked(this->m_lockTabBar); + menu->addAction(lockTabBarMenuAction); + connect(lockTabBarMenuAction, &QAction::toggled, this, &CInfoArea::ps_toggleTabBarLocked); bool c = false; if (!this->m_dockableWidgets.isEmpty()) @@ -143,9 +151,9 @@ namespace BlackGui { if (!infoArea) return false; if (infoArea->isFloating()) return false; - int i = getSelectedInfoAreaIndex(); - if (i < 0 || i >= this->m_dockableWidgets.size()) return false; - return this->m_dockableWidgets.at(i) == infoArea; + int tabBarIndex = getSelectedTabBarIndex(); + if (tabBarIndex < 0 || tabBarIndex >= this->m_dockableWidgets.size()) return false; + return this->getDockableWidgetByTabBarIndex(tabBarIndex) == infoArea; } void CInfoArea::dockAllWidgets() @@ -294,7 +302,10 @@ namespace BlackGui // East / West does not work (shown, but area itself empty) // South does not have any effect this->m_tabBar->setShape(QTabBar::TriangularSouth); + + // signals connect(this->m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::ps_tabBarDoubleClicked); + connect(this->m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::tabBarCurrentChanged); } if (this->countDockedWidgets() > 0) @@ -393,7 +404,8 @@ namespace BlackGui void CInfoArea::ps_tabBarDoubleClicked(int tabBarIndex) { - CDockWidgetInfoArea *dw = this->getDockableWidgetByTabIndex(tabBarIndex); + if (this->m_lockTabBar) return; + CDockWidgetInfoArea *dw = this->getDockableWidgetByTabBarIndex(tabBarIndex); if (!dw) return; dw->toggleFloating(); } @@ -449,6 +461,11 @@ namespace BlackGui this->adjustSizeForAllDockWidgets(); } + void CInfoArea::ps_toggleTabBarLocked(bool locked) + { + this->m_lockTabBar = locked; + } + void CInfoArea::ps_setTabBarPosition(QTabWidget::TabPosition position) { Q_ASSERT(position == QTabWidget::North || position == QTabWidget::South); diff --git a/src/blackgui/infoarea.h b/src/blackgui/infoarea.h index 172b5039e..d39e3d3c0 100644 --- a/src/blackgui/infoarea.h +++ b/src/blackgui/infoarea.h @@ -29,7 +29,6 @@ namespace BlackGui Q_OBJECT public: - //! Destructor virtual ~CInfoArea() {} @@ -46,6 +45,10 @@ namespace BlackGui //! Is given widget selected. Means it is not floating, and the one selected bool isSelectedInfoArea(const CDockWidgetInfoArea *infoArea) const; + signals: + //! Tab bar changed + void tabBarCurrentChanged(int index); + public slots: //! Dock all widgets void dockAllWidgets(); @@ -88,6 +91,7 @@ namespace BlackGui bool m_showTabTexts = true; bool m_infoAreaFloating = false; //!< whole info area floating bool m_showTabBar = true; //!< auto ajdust the floating widgets + bool m_lockTabBar = false; //!< locked means no double clicks possible //! Tabify the widgets void tabifyAllWidgets(); @@ -144,6 +148,9 @@ namespace BlackGui //! Show tab bar void ps_showTabBar(bool show); + //! Toogle lock tabbar + void ps_toggleTabBarLocked(bool locked); + //! Tab position for docked widgets tab //! \remarks North or South working, East / West not void ps_setTabBarPosition(QTabWidget::TabPosition position);