From 91f0b99cc52781c490e88694a33e5e1a51681dcd Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 2 May 2015 00:37:38 +0200 Subject: [PATCH] Fixes some issues with navigator widget to avoid Qt size warnings. Remarks: Some but not all warnings are gone --- .../components/invisibleinfoareacomponent.cpp | 19 +++++-------- .../components/invisibleinfoareacomponent.h | 3 +- .../components/invisibleinfoareacomponent.ui | 28 +++++++++++-------- .../components/navigatordockwidget.cpp | 13 ++++----- src/blackgui/components/navigatordockwidget.h | 2 +- .../components/navigatordockwidget.ui | 14 ---------- src/blackgui/infoarea.cpp | 7 +++-- src/blackgui/infoarea.h | 14 +++++----- src/swiftgui_standard/swiftguistd.ui | 19 +++++++++++-- 9 files changed, 59 insertions(+), 60 deletions(-) diff --git a/src/blackgui/components/invisibleinfoareacomponent.cpp b/src/blackgui/components/invisibleinfoareacomponent.cpp index 0ad304216..26b891453 100644 --- a/src/blackgui/components/invisibleinfoareacomponent.cpp +++ b/src/blackgui/components/invisibleinfoareacomponent.cpp @@ -42,25 +42,20 @@ namespace BlackGui InfoArea area = static_cast(areaIndex); switch (area) { - case InfoAreaHorizontalNavigator: - return QSize(400, 50); - case InfoAreaVerticalNavigator: - return QSize(50, 400); + case InfoAreaNavigator: + { + return this->ui->comp_Navigator->minimumSize(); + } default: + Q_ASSERT_X(false, Q_FUNC_INFO, "Unknown index for invisible info area"); return QSize(0, 0); } } const QPixmap &CInvisibleInfoAreaComponent::indexToPixmap(int areaIndex) const { - InfoArea area = static_cast(areaIndex); - switch (area) - { - case InfoAreaHorizontalNavigator: - case InfoAreaVerticalNavigator: - default: - return CIcons::empty(); - } + Q_UNUSED(areaIndex); + return CIcons::empty(); } CNavigatorDockWidget *CInvisibleInfoAreaComponent::getNavigatorComponent() diff --git a/src/blackgui/components/invisibleinfoareacomponent.h b/src/blackgui/components/invisibleinfoareacomponent.h index 48f03378d..2e0bde586 100644 --- a/src/blackgui/components/invisibleinfoareacomponent.h +++ b/src/blackgui/components/invisibleinfoareacomponent.h @@ -33,8 +33,7 @@ namespace BlackGui enum InfoArea { // index must match tab index! - InfoAreaVerticalNavigator = 0, - InfoAreaHorizontalNavigator = 1 + InfoAreaNavigator = 0 }; //! Consturctor diff --git a/src/blackgui/components/invisibleinfoareacomponent.ui b/src/blackgui/components/invisibleinfoareacomponent.ui index 2f0935dd2..61a981fc2 100644 --- a/src/blackgui/components/invisibleinfoareacomponent.ui +++ b/src/blackgui/components/invisibleinfoareacomponent.ui @@ -2,22 +2,26 @@ CInvisibleInfoAreaComponent - - - 0 - 0 - 800 - 600 - - Invisible info area - + + + + 0 + + + 0 + + + 0 + + + 0 + + + - - false - QDockWidget::AllDockWidgetFeatures diff --git a/src/blackgui/components/navigatordockwidget.cpp b/src/blackgui/components/navigatordockwidget.cpp index ac70241cb..1da4d180f 100644 --- a/src/blackgui/components/navigatordockwidget.cpp +++ b/src/blackgui/components/navigatordockwidget.cpp @@ -31,6 +31,7 @@ namespace BlackGui this->allowStatusBar(false); ui->setupUi(this); this->ps_onStyleSheetsChanged(); + this->buildNavigator(1); } CNavigatorDockWidget::~CNavigatorDockWidget() @@ -90,10 +91,7 @@ namespace BlackGui // set the real values c = gridLayout->columnCount(); r = gridLayout->rowCount(); - this->setMinimumSizeForWidgets(r, c); - - // sizes - QSize ws(gridLayout->sizeHint()); + QSize ws = this->setMinimumSizeForWidgets(r, c); this->resize(ws); // see documentation, required as layout was changed @@ -151,14 +149,15 @@ namespace BlackGui return (c * rows) < items ? c + 1 : c; } - void CNavigatorDockWidget::setMinimumSizeForWidgets(int rows, int columns) + QSize CNavigatorDockWidget::setMinimumSizeForWidgets(int rows, int columns) { - int w = 10 * columns; - int h = 10 * rows; + int w = 20 * columns; + int h = 20 * rows; QSize min(w, h); this->ui->qw_NavigatorDockWidgetOuter->setMinimumSize(min); this->ui->fr_NavigatorDockWidgetInner->setMinimumSize(min); this->setMinimumSize(min); + return min; } } // ns diff --git a/src/blackgui/components/navigatordockwidget.h b/src/blackgui/components/navigatordockwidget.h index 3ed68a264..60c515e79 100644 --- a/src/blackgui/components/navigatordockwidget.h +++ b/src/blackgui/components/navigatordockwidget.h @@ -70,7 +70,7 @@ namespace BlackGui int columnsForRows(int rows); //! Set widgets to their minimum size - void setMinimumSizeForWidgets(int rows, int columns); + QSize setMinimumSizeForWidgets(int rows, int columns); }; diff --git a/src/blackgui/components/navigatordockwidget.ui b/src/blackgui/components/navigatordockwidget.ui index e86fe5ce2..b8f4d6eff 100644 --- a/src/blackgui/components/navigatordockwidget.ui +++ b/src/blackgui/components/navigatordockwidget.ui @@ -2,20 +2,6 @@ CNavigatorDockWidget - - - 0 - 0 - 90 - 383 - - - - - 0 - 0 - - true diff --git a/src/blackgui/infoarea.cpp b/src/blackgui/infoarea.cpp index 96090f4e9..44a424ece 100644 --- a/src/blackgui/infoarea.cpp +++ b/src/blackgui/infoarea.cpp @@ -622,13 +622,14 @@ namespace BlackGui return this->m_tabBar->count(); } - CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByTabBarIndex(int tabBarIndex) + CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByTabBarIndex(int tabBarIndex) const { - if (tabBarIndex >= this->m_dockWidgetInfoAreas.count() || tabBarIndex < 0) return nullptr; + if (tabBarIndex >= this->m_dockWidgetInfoAreas.count() || tabBarIndex < 0) { return nullptr; } + if (!this->m_tabBar) { return nullptr; } return getDockWidgetInfoAreaByWindowTitle(this->m_tabBar->tabText(tabBarIndex)); } - CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByWindowTitle(const QString &title) + CDockWidgetInfoArea *CInfoArea::getDockWidgetInfoAreaByWindowTitle(const QString &title) const { Q_ASSERT(!title.isEmpty()); for (CDockWidgetInfoArea *dw : this->m_dockWidgetInfoAreas) diff --git a/src/blackgui/infoarea.h b/src/blackgui/infoarea.h index 547cd1754..02e90c1e9 100644 --- a/src/blackgui/infoarea.h +++ b/src/blackgui/infoarea.h @@ -139,7 +139,7 @@ namespace BlackGui //! Init area after(!) GUI is initialized void initInfoArea(); - protected: + protected slots: //! Tab position for docked widgets tab //! \remarks North or South working, East / West not void ps_setTabBarPosition(QTabWidget::TabPosition position); @@ -161,18 +161,18 @@ namespace BlackGui //! Valid area index? bool isValidAreaIndex(int areaIndex) const; - //! Corresponding dockable widget for given tab index - CDockWidgetInfoArea *getDockWidgetInfoAreaByTabBarIndex(int tabBarIndex); - - //! Corresponding dockable widget for given window title - CDockWidgetInfoArea *getDockWidgetInfoAreaByWindowTitle(const QString &title); - //! Corresponding dockable widget for given window title int getAreaIndexByWindowTitle(const QString &title) const; //! Tab bar index by title int getTabBarIndexByTitle(const QString &title) const; + //! Corresponding dockable widget for given tab index + CDockWidgetInfoArea *getDockWidgetInfoAreaByTabBarIndex(int tabBarIndex) const; + + //! Corresponding dockable widget for given window title + CDockWidgetInfoArea *getDockWidgetInfoAreaByWindowTitle(const QString &title) const; + //! Widget to tab bar index int dockWidgetInfoAreaToTabBarIndex(const CDockWidgetInfoArea *dockWidgetInfoArea) const; diff --git a/src/swiftgui_standard/swiftguistd.ui b/src/swiftgui_standard/swiftguistd.ui index 3ab0397e1..3b9f6a2df 100644 --- a/src/swiftgui_standard/swiftguistd.ui +++ b/src/swiftgui_standard/swiftguistd.ui @@ -124,7 +124,7 @@ QFrame::NoFrame - 3 + 0 @@ -193,7 +193,22 @@ - + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 +