From df69ef47a03dbfdbe0f874a17af70a4388dcb0b3 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 15 Apr 2020 16:27:39 +0200 Subject: [PATCH] [UI] Default sizes for dock widgets plus some smaller fixes: * renamings * reset all to defaults * sizes --- src/blackgui/components/cockpitcomponent.cpp | 2 +- .../components/cockpitinfoareacomponent.cpp | 3 ++- .../components/maininfoareacomponent.cpp | 5 ++--- src/blackgui/dockwidgetinfoarea.cpp | 2 +- src/blackgui/infoarea.cpp | 20 ++++++++++++++++--- src/blackgui/infoarea.h | 5 ++++- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/blackgui/components/cockpitcomponent.cpp b/src/blackgui/components/cockpitcomponent.cpp index 2e2584602..96ede28ce 100644 --- a/src/blackgui/components/cockpitcomponent.cpp +++ b/src/blackgui/components/cockpitcomponent.cpp @@ -75,7 +75,7 @@ namespace BlackGui if (!this->isParentDockWidgetFloating()) { return; } // manually setting size, all other approaches failed - static const QSize defaultSizeShown(300, 400); + static const QSize defaultSizeShown(500, 600); static const QSize defaultSizeHidden(300, 150); // keep old size diff --git a/src/blackgui/components/cockpitinfoareacomponent.cpp b/src/blackgui/components/cockpitinfoareacomponent.cpp index 15a99f50c..22c78c291 100644 --- a/src/blackgui/components/cockpitinfoareacomponent.cpp +++ b/src/blackgui/components/cockpitinfoareacomponent.cpp @@ -35,13 +35,14 @@ namespace BlackGui QSize CCockpitInfoAreaComponent::getPreferredSizeWhenFloating(int areaIndex) const { + // see also CMainInfoAreaComponent::getPreferredSizeWhenFloating Q_UNUSED(areaIndex) return QSize(600, 400); } const QPixmap &CCockpitInfoAreaComponent::indexToPixmap(int areaIndex) const { - InfoArea area = static_cast(areaIndex); + const InfoArea area = static_cast(areaIndex); switch (area) { case InfoAreaAudio: return CIcons::appAudio16(); diff --git a/src/blackgui/components/maininfoareacomponent.cpp b/src/blackgui/components/maininfoareacomponent.cpp index d3a666551..ed7279c04 100644 --- a/src/blackgui/components/maininfoareacomponent.cpp +++ b/src/blackgui/components/maininfoareacomponent.cpp @@ -156,7 +156,6 @@ namespace BlackGui case InfoAreaUsers: case InfoAreaLog: case InfoAreaSimulator: - return QSize(400, 300); case InfoAreaMapping: case InfoAreaInterpolation: case InfoAreaSettings: @@ -165,9 +164,9 @@ namespace BlackGui case InfoAreaRadar: return QSize(600, 400); case InfoAreaFlightPlan: - return QSize(625, 500); + return QSize(800, 600); default: - return QSize(400, 300); + return QSize(600, 400); } } diff --git a/src/blackgui/dockwidgetinfoarea.cpp b/src/blackgui/dockwidgetinfoarea.cpp index 323a3ca4b..ddf92650f 100644 --- a/src/blackgui/dockwidgetinfoarea.cpp +++ b/src/blackgui/dockwidgetinfoarea.cpp @@ -133,7 +133,7 @@ namespace BlackGui { const bool r = widgetsWithDockWidgetInfoAreaComponent.removeOne(iac); Q_ASSERT(r); // why is the nested component not in the child list? - Q_UNUSED(r); + Q_UNUSED(r) } } return widgetsWithDockWidgetInfoAreaComponent; diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index 9fdc3b7bd..c1171f47c 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -94,7 +94,8 @@ namespace BlackGui { menu->addAction(CIcons::dockTop16(), "Dock all", this, &CInfoArea::dockAllWidgets); menu->addAction(CIcons::floatAll16(), "Float all", this, &CInfoArea::floatAllWidgets); - menu->addAction(CIcons::refresh16(), "Reset all to defaults", this, &CInfoArea::resetAllWidgetSettings); + menu->addAction(CIcons::refresh16(), "Reset all floating to defaults", this, &CInfoArea::resetAllFloatingWidgetSettings); + menu->addAction(CIcons::refresh16(), "Reset all to defaults", this, &CInfoArea::resetAllWidgetSettings); menu->addAction(CIcons::floatOne16(), QStringLiteral("Dock / float '%1'").arg(this->windowTitle()), this, &CInfoArea::toggleFloatingWholeInfoArea); QAction *lockTabBarMenuAction = new QAction(menu); @@ -354,11 +355,20 @@ namespace BlackGui } } + void CInfoArea::resetAllFloatingWidgetSettings() + { + for (CDockWidgetInfoArea *dw : as_const(m_dockWidgetInfoAreas)) + { + if (!dw || !dw->isFloating()) { continue; } + dw->resetSettings(); + } + } + void CInfoArea::resetAllWidgetSettings() { for (CDockWidgetInfoArea *dw : as_const(m_dockWidgetInfoAreas)) { - if (!dw->isFloating()) { continue; } + if (!dw || !dw->isFloating()) { continue; } dw->resetSettings(); } } @@ -573,7 +583,7 @@ namespace BlackGui { if (!sGui || sGui->isShuttingDown()) { return; } this->setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::East); - bool init = m_tabBar ? false : true; + const bool init = m_tabBar ? false : true; for (int i = 0; i < m_dockWidgetInfoAreas.size(); i++) { @@ -605,7 +615,10 @@ namespace BlackGui { after->setFloating(false); } + + // we can not tabify first if (!first) { continue; } + this->tabifyDockWidget(first, after); } @@ -834,6 +847,7 @@ namespace BlackGui QPointer myself(this); QTimer::singleShot(1000, this, [ = ] { + if (!myself) { return; } myself->emitInfoAreaStatus(); }); } diff --git a/src/blackgui/infoarea.h b/src/blackgui/infoarea.h index 8dc3fa799..83b781f88 100644 --- a/src/blackgui/infoarea.h +++ b/src/blackgui/infoarea.h @@ -104,7 +104,10 @@ namespace BlackGui //! All floating info areas on top void allFloatingOnTop(); - //! Reset all widgets + //! Reset all floating widget settings + void resetAllFloatingWidgetSettings(); + + //! Reset all widget settings void resetAllWidgetSettings(); //! Toggle dock / floating of the whole info area