Added new option to hide the tabbar with one open tab in forums and channels.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7450 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-07-14 21:29:51 +00:00
parent b6089f3b91
commit d6408daafc
12 changed files with 107 additions and 6 deletions

View file

@ -26,6 +26,7 @@
RSTabWidget::RSTabWidget(QWidget *parent) : QTabWidget(parent)
{
mHideTabBarWithOneTab = false;
}
QTabBar *RSTabWidget::tabBar() const
@ -41,3 +42,40 @@ void RSTabWidget::hideCloseButton(int index)
tabButton->hide();
}
}
void RSTabWidget::setHideTabBarWithOneTab(bool hideTabBar)
{
if (mHideTabBarWithOneTab == hideTabBar) {
return;
}
mHideTabBarWithOneTab = hideTabBar;
hideTabBarWithOneTab();
}
void RSTabWidget::tabInserted(int index)
{
QTabWidget::tabInserted(index);
if (mHideTabBarWithOneTab) {
hideTabBarWithOneTab();
}
}
void RSTabWidget::tabRemoved(int index)
{
QTabWidget::tabRemoved(index);
if (mHideTabBarWithOneTab) {
hideTabBarWithOneTab();
}
}
void RSTabWidget::hideTabBarWithOneTab()
{
if (mHideTabBarWithOneTab) {
tabBar()->setVisible(count() > 1);
} else {
tabBar()->show();
}
}

View file

@ -31,9 +31,20 @@ public:
RSTabWidget(QWidget *parent = 0);
void hideCloseButton(int index);
void setHideTabBarWithOneTab(bool hideTabBar);
public:
QTabBar *tabBar() const;
protected:
virtual void tabInserted(int index);
virtual void tabRemoved(int index);
private:
void hideTabBarWithOneTab();
private:
bool mHideTabBarWithOneTab;
};
#endif