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) RSTabWidget::RSTabWidget(QWidget *parent) : QTabWidget(parent)
{ {
mHideTabBarWithOneTab = false;
} }
QTabBar *RSTabWidget::tabBar() const QTabBar *RSTabWidget::tabBar() const
@ -41,3 +42,40 @@ void RSTabWidget::hideCloseButton(int index)
tabButton->hide(); 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); RSTabWidget(QWidget *parent = 0);
void hideCloseButton(int index); void hideCloseButton(int index);
void setHideTabBarWithOneTab(bool hideTabBar);
public: public:
QTabBar *tabBar() const; QTabBar *tabBar() const;
protected:
virtual void tabInserted(int index);
virtual void tabRemoved(int index);
private:
void hideTabBarWithOneTab();
private:
bool mHideTabBarWithOneTab;
}; };
#endif #endif

View File

@ -192,6 +192,11 @@ void GxsGroupFrameDialog::setSingleTab(bool singleTab)
} }
} }
void GxsGroupFrameDialog::setHideTabBarWithOneTab(bool hideTabBarWithOneTab)
{
ui->messageTabWidget->setHideTabBarWithOneTab(hideTabBarWithOneTab);
}
void GxsGroupFrameDialog::updateDisplay(bool complete) void GxsGroupFrameDialog::updateDisplay(bool complete)
{ {
if (complete || !getGrpIds().empty() || !getGrpIdsMeta().empty()) { if (complete || !getGrpIds().empty() || !getGrpIdsMeta().empty()) {

View File

@ -83,6 +83,7 @@ protected:
RsGxsGroupId groupId() { return mGroupId; } RsGxsGroupId groupId() { return mGroupId; }
void setSingleTab(bool singleTab); void setSingleTab(bool singleTab);
void setHideTabBarWithOneTab(bool hideTabBarWithOneTab);
bool getCurrentGroupName(QString& name); bool getCurrentGroupName(QString& name);
virtual RetroShareLink::enumType getLinkType() = 0; virtual RetroShareLink::enumType getLinkType() = 0;

View File

@ -100,6 +100,7 @@ QString GxsChannelDialog::icon(IconType type)
void GxsChannelDialog::settingsChanged() void GxsChannelDialog::settingsChanged()
{ {
setSingleTab(!Settings->getChannelOpenAllInNewTab()); setSingleTab(!Settings->getChannelOpenAllInNewTab());
setHideTabBarWithOneTab(Settings->getChannelHideTabBarWithOneTab());
} }
GxsGroupDialog *GxsChannelDialog::createNewGroupDialog(TokenQueue *tokenQueue) GxsGroupDialog *GxsChannelDialog::createNewGroupDialog(TokenQueue *tokenQueue)

View File

@ -104,6 +104,7 @@ QString GxsForumsDialog::icon(IconType type)
void GxsForumsDialog::settingsChanged() void GxsForumsDialog::settingsChanged()
{ {
setSingleTab(!Settings->getForumOpenAllInNewTab()); setSingleTab(!Settings->getForumOpenAllInNewTab());
setHideTabBarWithOneTab(Settings->getForumHideTabBarWithOneTab());
} }
GxsGroupDialog *GxsForumsDialog::createNewGroupDialog(TokenQueue *tokenQueue) GxsGroupDialog *GxsForumsDialog::createNewGroupDialog(TokenQueue *tokenQueue)

View File

@ -38,6 +38,7 @@ ChannelPage::~ChannelPage()
bool ChannelPage::save(QString &/*errmsg*/) bool ChannelPage::save(QString &/*errmsg*/)
{ {
Settings->setChannelOpenAllInNewTab(ui.openAllInNewTabCheckBox->isChecked()); Settings->setChannelOpenAllInNewTab(ui.openAllInNewTabCheckBox->isChecked());
Settings->setChannelHideTabBarWithOneTab(ui.hideTabBarWithOneTabCheckBox->isChecked());
return true; return true;
} }
@ -46,4 +47,5 @@ bool ChannelPage::save(QString &/*errmsg*/)
void ChannelPage::load() void ChannelPage::load()
{ {
ui.openAllInNewTabCheckBox->setChecked(Settings->getChannelOpenAllInNewTab()); ui.openAllInNewTabCheckBox->setChecked(Settings->getChannelOpenAllInNewTab());
ui.hideTabBarWithOneTabCheckBox->setChecked(Settings->getChannelHideTabBarWithOneTab());
} }

View File

@ -25,9 +25,9 @@
</spacer> </spacer>
</item> </item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="gxsGroupBox"> <widget class="QGroupBox" name="tabsGroupBox">
<property name="title"> <property name="title">
<string>New channel</string> <string>Tabs</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
@ -37,6 +37,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="hideTabBarWithOneTabCheckBox">
<property name="text">
<string>Hide tabbar with one open tab</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -40,6 +40,7 @@ bool ForumPage::save(QString &/*errmsg*/)
Settings->setForumMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked()); Settings->setForumMsgSetToReadOnActivate(ui.setMsgToReadOnActivate->isChecked());
Settings->setForumExpandNewMessages(ui.expandNewMessages->isChecked()); Settings->setForumExpandNewMessages(ui.expandNewMessages->isChecked());
Settings->setForumOpenAllInNewTab(ui.openAllInNewTabCheckBox->isChecked()); Settings->setForumOpenAllInNewTab(ui.openAllInNewTabCheckBox->isChecked());
Settings->setForumHideTabBarWithOneTab(ui.hideTabBarWithOneTabCheckBox->isChecked());
Settings->setForumLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked()); Settings->setForumLoadEmbeddedImages(ui.loadEmbeddedImages->isChecked());
return true; return true;
@ -51,5 +52,6 @@ void ForumPage::load()
ui.setMsgToReadOnActivate->setChecked(Settings->getForumMsgSetToReadOnActivate()); ui.setMsgToReadOnActivate->setChecked(Settings->getForumMsgSetToReadOnActivate());
ui.expandNewMessages->setChecked(Settings->getForumExpandNewMessages()); ui.expandNewMessages->setChecked(Settings->getForumExpandNewMessages());
ui.openAllInNewTabCheckBox->setChecked(Settings->getForumOpenAllInNewTab()); ui.openAllInNewTabCheckBox->setChecked(Settings->getForumOpenAllInNewTab());
ui.hideTabBarWithOneTabCheckBox->setChecked(Settings->getForumHideTabBarWithOneTab());
ui.loadEmbeddedImages->setChecked(Settings->getForumLoadEmbeddedImages()); ui.loadEmbeddedImages->setChecked(Settings->getForumLoadEmbeddedImages());
} }

View File

@ -55,9 +55,9 @@
</spacer> </spacer>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QGroupBox" name="gxsGroupBox"> <widget class="QGroupBox" name="tabsGroupBox">
<property name="title"> <property name="title">
<string>New forum</string> <string>Tabs</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
@ -67,6 +67,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="hideTabBarWithOneTabCheckBox">
<property name="text">
<string>Hide tabbar with one open tab</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@ -985,7 +985,7 @@ void RshareSettings::setForumExpandNewMessages(bool value)
bool RshareSettings::getForumOpenAllInNewTab() bool RshareSettings::getForumOpenAllInNewTab()
{ {
return valueFromGroup("ForumDialog", "OpenAllInNewTab", true).toBool(); return valueFromGroup("ForumDialog", "OpenAllInNewTab", false).toBool();
} }
void RshareSettings::setForumOpenAllInNewTab(bool value) void RshareSettings::setForumOpenAllInNewTab(bool value)
@ -993,9 +993,19 @@ void RshareSettings::setForumOpenAllInNewTab(bool value)
setValueToGroup("ForumDialog", "OpenAllInNewTab", value); setValueToGroup("ForumDialog", "OpenAllInNewTab", value);
} }
bool RshareSettings::getForumHideTabBarWithOneTab()
{
return valueFromGroup("ForumDialog", "HideTabBarWithOneTab", true).toBool();
}
void RshareSettings::setForumHideTabBarWithOneTab(bool value)
{
setValueToGroup("ForumDialog", "HideTabBarWithOneTab", value);
}
bool RshareSettings::getChannelOpenAllInNewTab() bool RshareSettings::getChannelOpenAllInNewTab()
{ {
return valueFromGroup("ChannelDialog", "OpenAllInNewTab", true).toBool(); return valueFromGroup("ChannelDialog", "OpenAllInNewTab", false).toBool();
} }
void RshareSettings::setChannelOpenAllInNewTab(bool value) void RshareSettings::setChannelOpenAllInNewTab(bool value)
@ -1003,6 +1013,16 @@ void RshareSettings::setChannelOpenAllInNewTab(bool value)
setValueToGroup("ChannelDialog", "OpenAllInNewTab", value); setValueToGroup("ChannelDialog", "OpenAllInNewTab", value);
} }
bool RshareSettings::getChannelHideTabBarWithOneTab()
{
return valueFromGroup("ChannelDialog", "HideTabBarWithOneTab", true).toBool();
}
void RshareSettings::setChannelHideTabBarWithOneTab(bool value)
{
setValueToGroup("ChannelDialog", "HideTabBarWithOneTab", value);
}
/* time before idle */ /* time before idle */
uint RshareSettings::getMaxTimeBeforeIdle() uint RshareSettings::getMaxTimeBeforeIdle()
{ {

View File

@ -301,10 +301,16 @@ public:
void setForumExpandNewMessages(bool value); void setForumExpandNewMessages(bool value);
bool getForumOpenAllInNewTab(); bool getForumOpenAllInNewTab();
void setForumOpenAllInNewTab(bool value); void setForumOpenAllInNewTab(bool value);
bool getForumHideTabBarWithOneTab();
void setForumHideTabBarWithOneTab(bool value);
bool getForumLoadEmbeddedImages(); bool getForumLoadEmbeddedImages();
void setForumLoadEmbeddedImages(bool value); void setForumLoadEmbeddedImages(bool value);
/* Channels */
bool getChannelOpenAllInNewTab(); bool getChannelOpenAllInNewTab();
void setChannelOpenAllInNewTab(bool value); void setChannelOpenAllInNewTab(bool value);
bool getChannelHideTabBarWithOneTab();
void setChannelHideTabBarWithOneTab(bool value);
/* time before idle */ /* time before idle */
uint getMaxTimeBeforeIdle(); uint getMaxTimeBeforeIdle();