Fixes some issues with navigator widget to avoid Qt size warnings.

Remarks: Some but not all warnings are gone
This commit is contained in:
Klaus Basan
2015-05-02 00:37:38 +02:00
committed by Mathew Sutcliffe
parent 018c5ae1bf
commit 91f0b99cc5
9 changed files with 59 additions and 60 deletions

View File

@@ -42,25 +42,20 @@ namespace BlackGui
InfoArea area = static_cast<InfoArea>(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<InfoArea>(areaIndex);
switch (area)
{
case InfoAreaHorizontalNavigator:
case InfoAreaVerticalNavigator:
default:
return CIcons::empty();
}
Q_UNUSED(areaIndex);
return CIcons::empty();
}
CNavigatorDockWidget *CInvisibleInfoAreaComponent::getNavigatorComponent()

View File

@@ -33,8 +33,7 @@ namespace BlackGui
enum InfoArea
{
// index must match tab index!
InfoAreaVerticalNavigator = 0,
InfoAreaHorizontalNavigator = 1
InfoAreaNavigator = 0
};
//! Consturctor

View File

@@ -2,22 +2,26 @@
<ui version="4.0">
<class>CInvisibleInfoAreaComponent</class>
<widget class="QMainWindow" name="CInvisibleInfoAreaComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Invisible info area</string>
</property>
<widget class="QWidget" name="qw_InvisibleInfoArea"/>
<widget class="QWidget" name="qw_InvisibleInfoArea">
<layout class="QVBoxLayout" name="vl_InvisibleInfoAreaComponent">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
</layout>
</widget>
<widget class="BlackGui::Components::CNavigatorDockWidget" name="comp_Navigator">
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>

View File

@@ -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

View File

@@ -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);
};

View File

@@ -2,20 +2,6 @@
<ui version="4.0">
<class>CNavigatorDockWidget</class>
<widget class="QDockWidget" name="CNavigatorDockWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>90</width>
<height>383</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="floating">
<bool>true</bool>
</property>

View File

@@ -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)

View File

@@ -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;

View File

@@ -124,7 +124,7 @@
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>3</number>
<number>0</number>
</property>
<widget class="QWidget" name="pg_MainInfoArea">
<layout class="QVBoxLayout" name="vl_MainInfoArea">
@@ -193,7 +193,22 @@
</layout>
</widget>
<widget class="QWidget" name="pg_InvisibleAreas">
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="vl_InvisibleArea">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::Components::CInvisibleInfoAreaComponent" name="comp_InvisibleInfoArea" native="true"/>
</item>