diff --git a/src/blackgui/components/cockpitcomcomponent.cpp b/src/blackgui/components/cockpitcomcomponent.cpp new file mode 100644 index 000000000..74ae36831 --- /dev/null +++ b/src/blackgui/components/cockpitcomcomponent.cpp @@ -0,0 +1,38 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "cockpitcomcomponent.h" +#include "ui_cockpitcomcomponent.h" +#include "../stylesheetutility.h" + +using namespace BlackGui; + +namespace BlackGui +{ + namespace Components + { + CCockpitComComponent::CCockpitComComponent(QWidget *parent) : + QFrame(parent), + CDockWidgetInfoAreaComponent(this), + ui(new Ui::CCockpitMainComponent) + { + ui->setupUi(this); + } + + CCockpitComComponent::~CCockpitComComponent() + { } + + void CCockpitComComponent::paintEvent(QPaintEvent *event) + { + Q_UNUSED(event); + CStyleSheetUtility::useStyleSheetInDerivedWidget(this); + } + + } // namespace +} // namespace diff --git a/src/blackgui/components/cockpitcomcomponent.h b/src/blackgui/components/cockpitcomcomponent.h new file mode 100644 index 000000000..a915d435c --- /dev/null +++ b/src/blackgui/components/cockpitcomcomponent.h @@ -0,0 +1,47 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKGUI_COCKPITCOMCOMPONENT_H +#define BLACKGUI_COCKPITCOMCOMPONENT_H + +#include "dockwidgetinfoareacomponent.h" +#include +#include + +namespace Ui { class CCockpitMainComponent; } + +namespace BlackGui +{ + namespace Components + { + //! The main cockpit area + class CCockpitComComponent : + public QFrame, + public CDockWidgetInfoAreaComponent + { + Q_OBJECT + + public: + //! Constructor + explicit CCockpitComComponent(QWidget *parent = nullptr); + + //! Destructor + ~CCockpitComComponent(); + + //! \copydoc QWidget::paintEvent + virtual void paintEvent(QPaintEvent *event) override; + + private: + QScopedPointer ui; + }; + + } // namespace +} // namespace + +#endif // guard diff --git a/src/blackgui/components/cockpitcomcomponent.ui b/src/blackgui/components/cockpitcomcomponent.ui new file mode 100644 index 000000000..97cd4d969 --- /dev/null +++ b/src/blackgui/components/cockpitcomcomponent.ui @@ -0,0 +1,618 @@ + + + CCockpitMainComponent + + + + 0 + 0 + 363 + 99 + + + + + 0 + 0 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QLayout::SetDefaultConstraint + + + 4 + + + 2 + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + COM2: + + + qw_ComPanelCom2Active + + + + + + + + 0 + 0 + + + + DDD.990 + + + 128.800 + + + 7 + + + false + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + COM1: + + + qw_ComPanelCom1Active + + + + + + + + 0 + 0 + + + + DDD.990 + + + 123.750 + + + 7 + + + false + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + standby: + + + + + + + + 0 + 0 + + + + DDD.990 + + + 123.750 + + + 7 + + + false + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Toggle COM 1 standby/active + + + + + + + :/diagona/icons/diagona/icons/arrow-circle-double-135.png:/diagona/icons/diagona/icons/arrow-circle-double-135.png + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + standby: + + + + + + + + 0 + 0 + + + + DDD.990 + + + 123.750 + + + 7 + + + false + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Toggle COM 2 standby/active + + + + + + + :/diagona/icons/diagona/icons/arrow-circle-double-135.png:/diagona/icons/diagona/icons/arrow-circle-double-135.png + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::NoFrame + + + XPDR: + + + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 2 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + 9999 + + + 7000 + + + 4 + + + false + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 3 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + + + + + + 0 + 0 + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + SELCAL: + + + + + + + + 0 + 0 + + + + test SELCAL + + + Test + + + + :/diagona/icons/diagona/icons/speaker-volume.png:/diagona/icons/diagona/icons/speaker-volume.png + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + BlackGui::CTransponderModeSelector + QComboBox +
blackgui/transpondermodeselector.h
+
+
+ + + + +
diff --git a/src/blackgui/components/cockpitinfoareacomponent.cpp b/src/blackgui/components/cockpitinfoareacomponent.cpp new file mode 100644 index 000000000..6e71a4c0f --- /dev/null +++ b/src/blackgui/components/cockpitinfoareacomponent.cpp @@ -0,0 +1,54 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#include "cockpitinfoareacomponent.h" +#include "ui_cockpitinfoareacomponent.h" +#include "blackmisc/icons.h" + +using namespace BlackMisc; + +namespace BlackGui +{ + namespace Components + { + + CCockpitInfoAreaComponent::CCockpitInfoAreaComponent(QWidget *parent) : + CInfoArea(parent), + ui(new Ui::CCockpitInfoAreaComponent) + { + ui->setupUi(this); + initInfoArea(); + if (this->statusBar()) + { + this->statusBar()->hide(); + } + } + + CCockpitInfoAreaComponent::~CCockpitInfoAreaComponent() + { } + + void CCockpitInfoAreaComponent::toggleFloating() + { + CInfoArea::toggleFloating(); + } + + QSize CCockpitInfoAreaComponent::getPreferredSizeWhenFloating(int areaIndex) const + { + Q_UNUSED(areaIndex); + return QSize(600, 400); + } + + const QPixmap &CCockpitInfoAreaComponent::indexToPixmap(int areaIndex) const + { + Q_UNUSED(areaIndex); + return CIcons::empty16(); + } + + } // namespace +} // namespace diff --git a/src/blackgui/components/cockpitinfoareacomponent.h b/src/blackgui/components/cockpitinfoareacomponent.h new file mode 100644 index 000000000..a75865436 --- /dev/null +++ b/src/blackgui/components/cockpitinfoareacomponent.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2013 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COCKPITINFOAREACOMPONENT_H +#define BLACKGUI_COCKPITINFOAREACOMPONENT_H + +#include "../infoarea.h" +#include +#include + +namespace Ui { class CCockpitInfoAreaComponent; } +namespace BlackGui +{ + namespace Components + { + //! The cockpit itself is part of the main info area, but itself also an info area. + //! hence windows can be docked in the cockpit too. + class CCockpitInfoAreaComponent : public CInfoArea + { + Q_OBJECT + + public: + //! Destructor + explicit CCockpitInfoAreaComponent(QWidget *parent = nullptr); + + //! Destructor + ~CCockpitInfoAreaComponent(); + + public slots: + //! CInfoArea::toggleFloating + virtual void toggleFloating() override; + + protected: + //! \copydoc CInfoArea::getPreferredSizeWhenFloating + virtual QSize getPreferredSizeWhenFloating(int areaIndex) const override; + + //! \copydoc CInfoArea::indexToPixmap + virtual const QPixmap &indexToPixmap(int areaIndex) const override; + + private: + QScopedPointer ui; + }; + + } // namespace +} // namespace +#endif // guard diff --git a/src/blackgui/components/cockpitinfoareacomponent.ui b/src/blackgui/components/cockpitinfoareacomponent.ui new file mode 100644 index 000000000..f2a1a8104 --- /dev/null +++ b/src/blackgui/components/cockpitinfoareacomponent.ui @@ -0,0 +1,109 @@ + + + CCockpitInfoAreaComponent + + + + 0 + 0 + 80 + 75 + + + + MainWindow + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + Qt::TopDockWidgetArea + + + Voice rooms + + + 8 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + BlackGui::CDockWidgetInfoArea + QDockWidget +
blackgui/dockwidgetinfoarea.h
+ 1 +
+ + BlackGui::Components::CCockpitComComponent + QFrame +
blackgui/components/cockpitcomcomponent.h
+ 1 +
+ + BlackGui::Components::CVoiceRoomsComponent + QFrame +
blackgui/components/voiceroomscomponent.h
+ 1 +
+
+ + +
diff --git a/src/blackgui/components/dockwidgetinfoareacomponent.cpp b/src/blackgui/components/dockwidgetinfoareacomponent.cpp index 8f0e61b9f..354e6bb4d 100644 --- a/src/blackgui/components/dockwidgetinfoareacomponent.cpp +++ b/src/blackgui/components/dockwidgetinfoareacomponent.cpp @@ -17,6 +17,7 @@ namespace BlackGui CDockWidgetInfoAreaComponent::CDockWidgetInfoAreaComponent(QWidget *parent) { // it the parent is already an info area at this time, we keep it + // otherwise we expect the info area to set it later CDockWidgetInfoArea *ia = dynamic_cast(parent); if (ia) { @@ -24,6 +25,21 @@ namespace BlackGui } } + bool CDockWidgetInfoAreaComponent::setParentDockWidgetInfoArea(CDockWidgetInfoArea *parentDockableWidget) + { + // sanity check + if (this->m_parentDockableInfoArea) + { + // we already have a value + // changes should not happen + Q_ASSERT(this->m_parentDockableInfoArea == parentDockableWidget); + return this->m_parentDockableInfoArea == parentDockableWidget; + } + + m_parentDockableInfoArea = parentDockableWidget; + return true; + } + const CInfoArea *CDockWidgetInfoAreaComponent::getParentInfoArea() const { Q_ASSERT(this->m_parentDockableInfoArea); diff --git a/src/blackgui/components/dockwidgetinfoareacomponent.h b/src/blackgui/components/dockwidgetinfoareacomponent.h index e1893a0a5..d9ef3544c 100644 --- a/src/blackgui/components/dockwidgetinfoareacomponent.h +++ b/src/blackgui/components/dockwidgetinfoareacomponent.h @@ -33,7 +33,8 @@ namespace BlackGui const BlackGui::CDockWidgetInfoArea *getDockWidget() const { return m_parentDockableInfoArea; } //! Corresponding dockable widget in info area - void setParentDockableWidget(BlackGui::CDockWidgetInfoArea *parentDockableWidget) { m_parentDockableInfoArea = parentDockableWidget; } + //! \remarks Usually set from CDockWidgetInfoArea when it is fully initialized + bool setParentDockWidgetInfoArea(BlackGui::CDockWidgetInfoArea *parentDockableWidget); //! The parent info area const CInfoArea *getParentInfoArea() const; diff --git a/src/blackgui/components/maininfoareacomponent.cpp b/src/blackgui/components/maininfoareacomponent.cpp index b6875320b..ec4030935 100644 --- a/src/blackgui/components/maininfoareacomponent.cpp +++ b/src/blackgui/components/maininfoareacomponent.cpp @@ -33,9 +33,7 @@ namespace BlackGui } CMainInfoAreaComponent::~CMainInfoAreaComponent() - { - delete ui; - } + { } CAtcStationComponent *CMainInfoAreaComponent::getAtcStationComponent() { @@ -82,6 +80,7 @@ namespace BlackGui InfoArea area = static_cast(areaIndex); switch (area) { + case InfoAreaCockpit: case InfoAreaAircrafts: case InfoAreaAtc: case InfoAreaUsers: @@ -112,6 +111,8 @@ namespace BlackGui InfoArea area = static_cast(areaIndex); switch (area) { + case InfoAreaCockpit: + return CIcons::appCockpit16(); case InfoAreaUsers: return CIcons::appUsers16(); case InfoAreaWeather: @@ -136,5 +137,5 @@ namespace BlackGui return CIcons::empty(); } } - } -} + } // namespace +} // namespace diff --git a/src/blackgui/components/maininfoareacomponent.h b/src/blackgui/components/maininfoareacomponent.h index 901e0536c..690050d0d 100644 --- a/src/blackgui/components/maininfoareacomponent.h +++ b/src/blackgui/components/maininfoareacomponent.h @@ -23,9 +23,9 @@ #include "logcomponent.h" #include #include +#include namespace Ui { class CMainInfoAreaComponent; } - namespace BlackGui { namespace Components @@ -47,16 +47,17 @@ namespace BlackGui enum InfoArea { // index must match tab index! - InfoAreaAircrafts = 0, - InfoAreaAtc = 1, - InfoAreaUsers = 2, - InfoAreaTextMessages = 3, - InfoAreaSimulator = 4, - InfoAreaFlightPlan = 5, - InfoAreaWeather = 6, - InfoAreaMappings = 7, - InfoAreaLog = 8, - InfoAreaSettings = 9, + InfoAreaCockpit = 0, + InfoAreaAircrafts = 1, + InfoAreaAtc = 2, + InfoAreaUsers = 3, + InfoAreaTextMessages = 4, + InfoAreaSimulator = 5, + InfoAreaFlightPlan = 6, + InfoAreaWeather = 7, + InfoAreaMappings = 8, + InfoAreaLog = 9, + InfoAreaSettings = 10, InfoAreaNone = -1 }; @@ -105,8 +106,7 @@ namespace BlackGui virtual const QPixmap &indexToPixmap(int areaIndex) const override; private: - Ui::CMainInfoAreaComponent *ui = nullptr; - + QScopedPointer ui; }; } } diff --git a/src/blackgui/components/maininfoareacomponent.ui b/src/blackgui/components/maininfoareacomponent.ui index 58ac66e0e..b116e5ca0 100644 --- a/src/blackgui/components/maininfoareacomponent.ui +++ b/src/blackgui/components/maininfoareacomponent.ui @@ -6,8 +6,8 @@ 0 0 - 1207 - 97 + 1266 + 55 @@ -39,11 +39,44 @@ QMainWindow::AllowTabbedDocks|QMainWindow::AnimatedDocks|QMainWindow::ForceTabbedDocks + + + Qt::TopDockWidgetArea + + + Cockpit + + + 4 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + - 0 - 0 + 127 + 38 @@ -103,8 +136,8 @@ - 0 - 0 + 127 + 38 @@ -164,8 +197,8 @@ - 0 - 0 + 127 + 38 @@ -210,8 +243,8 @@ - 0 - 0 + 127 + 38 @@ -256,8 +289,8 @@ - 0 - 0 + 127 + 38 @@ -302,8 +335,8 @@ - 0 - 0 + 127 + 38 @@ -348,8 +381,8 @@ - 0 - 0 + 80 + 38 @@ -397,8 +430,8 @@ - 0 - 0 + 127 + 38 @@ -443,8 +476,8 @@ - 0 - 0 + 80 + 38 @@ -489,8 +522,8 @@ - 0 - 0 + 127 + 38 @@ -534,6 +567,18 @@ + + BlackGui::CDockWidgetInfoArea + QDockWidget +
blackgui/dockwidgetinfoarea.h
+ 1 +
+ + BlackGui::Components::CCockpitInfoAreaComponent + QWidget +
blackgui/components/cockpitinfoareacomponent.h
+ 1 +
BlackGui::Components::CAtcStationComponent QTabWidget @@ -570,12 +615,6 @@
blackgui/components/settingscomponent.h
1
- - BlackGui::CDockWidgetInfoArea - QDockWidget -
blackgui/dockwidgetinfoarea.h
- 1 -
BlackGui::Components::CLogComponent QFrame diff --git a/src/blackgui/dockwidgetinfoarea.cpp b/src/blackgui/dockwidgetinfoarea.cpp index 6eeb7fa27..777c23707 100644 --- a/src/blackgui/dockwidgetinfoarea.cpp +++ b/src/blackgui/dockwidgetinfoarea.cpp @@ -76,15 +76,18 @@ namespace BlackGui void CDockWidgetInfoArea::initalFloating() { - CDockWidget::initalFloating(); + CDockWidget::initalFloating(); // initial floating to init position & size QList infoAreaDockWidgets = this->findEmbeddedDockWidgetInfoAreaComponents(); foreach(CDockWidgetInfoAreaComponent * dwia, infoAreaDockWidgets) { - dwia->setParentDockableWidget(this); + // KWB: potentially a risk when this object is deleted + // put under normal situations the child object will be deleted as well, and we have + // no multi-threaded GUI + dwia->setParentDockWidgetInfoArea(this); } } - QList CDockWidgetInfoArea::findEmbeddedDockWidgetInfoAreaComponents() const + QList CDockWidgetInfoArea::findEmbeddedDockWidgetInfoAreaComponents() { QList widgets = this->findChildren(); QList widgetsWithDockWidgetInfoAreaComponent; @@ -96,6 +99,27 @@ namespace BlackGui widgetsWithDockWidgetInfoAreaComponent.append(dwc); } } + QList nestedInfoAreas = this->findNestedInfoAreas(); + if (nestedInfoAreas.isEmpty()) return widgetsWithDockWidgetInfoAreaComponent; + + // we have to exclude the nested embedded areas + foreach(CDockWidgetInfoArea * ia, nestedInfoAreas) + { + QList nestedInfoAreaComponents = ia->findEmbeddedDockWidgetInfoAreaComponents(); + if (nestedInfoAreaComponents.isEmpty()) continue; + foreach(CDockWidgetInfoAreaComponent * iac, nestedInfoAreaComponents) + { + bool r = widgetsWithDockWidgetInfoAreaComponent.removeOne(iac); + Q_ASSERT(r); // why is the nested component not in the child list? + Q_UNUSED(r); + } + } return widgetsWithDockWidgetInfoAreaComponent; } + + QList CDockWidgetInfoArea::findNestedInfoAreas() + { + QList nestedInfoAreas = this->findChildren(); + return nestedInfoAreas; + } } diff --git a/src/blackgui/dockwidgetinfoarea.h b/src/blackgui/dockwidgetinfoarea.h index 70a326d72..1e23e93fb 100644 --- a/src/blackgui/dockwidgetinfoarea.h +++ b/src/blackgui/dockwidgetinfoarea.h @@ -51,8 +51,13 @@ namespace BlackGui virtual void initalFloating() override; private: - //! Find all embedded runtime components - QList findEmbeddedDockWidgetInfoAreaComponents() const; + //! Find all embedded dock widget components. These are components marked as CDockWidgetInfoAreaComponent + //! \remarks Only directly embedded info area components, not those of nested info areas + QList findEmbeddedDockWidgetInfoAreaComponents(); + + //! Nested info areas + QList findNestedInfoAreas(); + }; } // namespace diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index 553912a7d..93acd5537 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -32,7 +32,7 @@ namespace BlackGui // after(!) GUI is established if (this->m_dockableWidgets.isEmpty()) { - this->m_dockableWidgets = this->findChildren(); + this->m_dockableWidgets = this->getOwnDockWidgetAreas(); Q_ASSERT(!this->m_dockableWidgets.isEmpty()); } @@ -50,32 +50,40 @@ namespace BlackGui // initial style sheet setting this->ps_onStyleSheetChanged(); + + // status bar + if (this->statusBar()) + { + this->statusBar()->hide(); + this->statusBar()->setMaximumHeight(0); + } } void CInfoArea::addToContextMenu(QMenu *menu) const { if (!menu) return; - 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 hasWidgets = this->countDockedWidgets() > 0; - if (!this->m_dockableWidgets.isEmpty()) + if (hasWidgets) { - bool c = false; + 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); menu->addSeparator(); QMenu *subMenuToggleFloat = new QMenu("Toggle Float/Dock", menu); QMenu *subMenuDisplay = new QMenu("Display", menu); QSignalMapper *signalMapperToggleFloating = new QSignalMapper(menu); QSignalMapper *signalMapperDisplay = new QSignalMapper(menu); + bool c = false; for (int i = 0; i < this->m_dockableWidgets.size(); i++) { @@ -263,55 +271,62 @@ namespace BlackGui this->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::East); bool init = this->m_tabBar ? false : true; - if (!this->m_dockableWidgets.isEmpty()) + for (int i = 0; i < this->m_dockableWidgets.size(); i++) { - for (int i = 0; i < this->m_dockableWidgets.size(); i++) - { - CDockWidgetInfoArea *first = i > 0 ? this->m_dockableWidgets.at(i - 1) : nullptr; - CDockWidgetInfoArea *after = this->m_dockableWidgets.at(i); - Q_ASSERT(after); + CDockWidgetInfoArea *first = i > 0 ? this->m_dockableWidgets.at(i - 1) : nullptr; + CDockWidgetInfoArea *after = this->m_dockableWidgets.at(i); + Q_ASSERT(after); - // trick, init widget as floating - // this completely initializes the tab bar and all docked widgets - if (init) - { - QPoint offset(i * 25, i * 20); - after->setVisible(false); - after->setFloating(true); - after->setOffsetWhenFloating(offset); - after->setPreferredSizeWhenFloating(getPreferredSizeWhenFloating(i)); - after->setFloating(false); - after->setVisible(true); - after->resetWasAlreadyFLoating(); - } - else - { - after->setFloating(false); - } - if (!first) { continue; } - this->tabifyDockWidget(first, after); + // trick, init widget as floating + // this completely initializes the tab bar and all docked widgets + if (init) + { + QPoint offset(i * 25, i * 20); + after->setVisible(false); + after->setFloating(true); + after->setOffsetWhenFloating(offset); + after->setPreferredSizeWhenFloating(getPreferredSizeWhenFloating(i)); + after->setFloating(false); + after->setVisible(true); + after->resetWasAlreadyFLoating(); } + else + { + after->setFloating(false); + } + if (!first) { continue; } + this->tabifyDockWidget(first, after); } // as now tabified, now set tab if (!this->m_tabBar) { this->m_tabBar = this->findChild(); - Q_ASSERT(m_tabBar); - QString qss = CStyleSheetUtility::instance().style(CStyleSheetUtility::fileNameDockWidgetTab()); - this->m_tabBar->setStyleSheet(qss); - this->m_tabBar->setObjectName("comp_MainInfoAreaDockWidgetTab"); - this->m_tabBar->setMovable(false); - this->m_tabBar->setElideMode(Qt::ElideNone); - this->setTabPixmaps(); - // East / West does not work (shown, but area itself empty) - // South does not have any effect - this->m_tabBar->setShape(QTabBar::TriangularSouth); + // if we have > 1 docked widgets, we have a tab bar + if (this->m_tabBar) + { + QString qss = CStyleSheetUtility::instance().style(CStyleSheetUtility::fileNameDockWidgetTab()); + this->m_tabBar->setStyleSheet(qss); + this->m_tabBar->setObjectName("comp_MainInfoAreaDockWidgetTab"); + this->m_tabBar->setMovable(false); + this->m_tabBar->setElideMode(Qt::ElideNone); + this->setTabPixmaps(); - // signals - connect(this->m_tabBar, &QTabBar::tabBarDoubleClicked, this, &CInfoArea::ps_tabBarDoubleClicked); - connect(this->m_tabBar, &QTabBar::currentChanged, this, &CInfoArea::tabBarCurrentChanged); + // 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); + } + else + { + // <= 1 dock widget + this->m_tabBar = new QTabBar(this); + this->m_tabBar->hide(); + } } if (this->countDockedWidgets() > 0) @@ -358,6 +373,30 @@ namespace BlackGui } } + QList CInfoArea::getOwnDockWidgetAreas() + { + QList infoAreas = this->findChildren(); + if (infoAreas.isEmpty()) { return infoAreas; } + + // nested info areas? + QList childInfoAreas = this->getChildInfoAreas(); + if (childInfoAreas.isEmpty()) { return infoAreas; } + + // we have child info areas (nested), we need to remove those from the list + for (CInfoArea *ia : childInfoAreas) + { + QList nestedDockWidgets = ia->getOwnDockWidgetAreas(); + if (nestedDockWidgets.isEmpty()) { continue; } + for (CDockWidgetInfoArea *ndw : nestedDockWidgets) + { + bool r = infoAreas.removeOne(ndw); + Q_ASSERT(r); + Q_UNUSED(r); + } + } + return infoAreas; + } + int CInfoArea::countDockedWidgets() const { if (!this->m_tabBar) return 0;