Added a new setting to channels to enable/disable threaded loading.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7484 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-08-06 17:41:22 +00:00
parent 27c2ed0a97
commit f60b37a213
7 changed files with 83 additions and 24 deletions

View File

@ -311,6 +311,9 @@ bool UIStateHelper::isWidgetVisible(QWidget *widget)
}
if (visible) {
int visibleCount = 0;
int invisibleCount = 0;
QMap<long, UIStateHelperData*>::iterator dataIt;
for (dataIt = mData.begin(); dataIt != mData.end(); ++dataIt) {
UIStateHelperData *data = dataIt.value();
@ -323,32 +326,42 @@ bool UIStateHelper::isWidgetVisible(QWidget *widget)
if (states & (UISTATE_LOADING_VISIBLE | UISTATE_LOADING_INVISIBLE)) {
if (states & UISTATE_LOADING_VISIBLE) {
if (!data->mLoading) {
visible = false;
break;
if (data->mLoading) {
++visibleCount;
} else {
++invisibleCount;
}
} else if (states & UISTATE_LOADING_INVISIBLE) {
if (data->mLoading) {
visible = false;
break;
++invisibleCount;
} else {
++visibleCount;
}
}
}
if (states & (UISTATE_ACTIVE_VISIBLE | UISTATE_ACTIVE_INVISIBLE)) {
if (states & UISTATE_ACTIVE_VISIBLE) {
if (!data->mActive) {
visible = false;
break;
if (data->mActive) {
++visibleCount;
} else {
++invisibleCount;
}
} else if (states & UISTATE_ACTIVE_INVISIBLE) {
if (data->mActive) {
visible = false;
break;
++invisibleCount;
} else {
++visibleCount;
}
}
}
}
if (visibleCount + invisibleCount) {
if (!visibleCount) {
visible = false;
}
}
}
return visible;

View File

@ -29,7 +29,7 @@
#include "gui/common/UIStateHelper.h"
#include "gui/settings/rsharesettings.h"
#include "gui/feeds/SubFileItem.h"
#include "gui/notifyqt.h"
#include <algorithm>
#define CHAN_DEFAULT_IMAGE ":/images/channels.png"
@ -57,6 +57,7 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
/* Setup UI helper */
mStateHelper->addWidget(mTokenTypePosts, ui->progressBar, UISTATE_LOADING_VISIBLE);
mStateHelper->addWidget(mTokenTypePosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
mStateHelper->addWidget(mTokenTypePosts, ui->filterLineEdit);
mStateHelper->addWidget(mTokenTypeRelatedPosts, ui->loadingLabel, UISTATE_LOADING_VISIBLE);
@ -67,8 +68,10 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
mStateHelper->addWidget(mTokenTypeGroupData, ui->logoLabel);
mStateHelper->addWidget(mTokenTypeGroupData, ui->subscribeToolButton);
/* Connect signals */
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createMsg()));
connect(ui->subscribeToolButton, SIGNAL(subscribe(bool)), this, SLOT(subscribeGroup(bool)));
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
/* add filter actions */
ui->filterLineEdit->addFilter(QIcon(), tr("Title"), FILTER_TITLE, tr("Search Title"));
@ -114,6 +117,7 @@ GxsChannelPostsWidget::GxsChannelPostsWidget(const RsGxsGroupId &channelId, QWid
/* Initialize GUI */
setAutoDownload(false);
settingsChanged();
setGroupId(channelId);
}
@ -144,6 +148,13 @@ void GxsChannelPostsWidget::processSettings(bool load)
mInProcessSettings = false;
}
void GxsChannelPostsWidget::settingsChanged()
{
mUseThread = Settings->getChannelLoadThread();
mStateHelper->setWidgetVisible(ui->progressBar, mUseThread);
}
void GxsChannelPostsWidget::groupNameChanged(const QString &name)
{
if (groupId().isNull()) {

View File

@ -71,7 +71,7 @@ protected:
virtual void insertPosts(const uint32_t &token, GxsMessageFramePostThread *thread);
virtual void insertRelatedPosts(const uint32_t &token);
virtual void clearPosts();
virtual bool useThread() { return true; }
virtual bool useThread() { return mUseThread; }
virtual void fillThreadCreatePost(const QVariant &post, bool related, int current, int count);
private slots:
@ -80,6 +80,7 @@ private slots:
void subscribeGroup(bool subscribe);
void filterChanged(int filter);
void setViewMode(int viewMode);
void settingsChanged();
private:
void processSettings(bool load);
@ -96,6 +97,7 @@ private:
QAction *mAutoDownloadAction;
bool mInProcessSettings;
bool mUseThread;
/* UI - from Designer */
Ui::GxsChannelPostsWidget *ui;

View File

@ -36,6 +36,7 @@ ChannelPage::~ChannelPage()
/** Saves the changes on this page */
bool ChannelPage::save(QString &/*errmsg*/)
{
Settings->setChannelLoadThread(ui.loadThreadCheckBox->isChecked());
ui.groupFrameSettingsWidget->saveSettings(GroupFrameSettings::Channel);
return true;
@ -44,5 +45,6 @@ bool ChannelPage::save(QString &/*errmsg*/)
/** Loads the settings for this page */
void ChannelPage::load()
{
ui.loadThreadCheckBox->setChecked(Settings->getChannelLoadThread());
ui.groupFrameSettingsWidget->loadSettings(GroupFrameSettings::Channel);
}

View File

@ -12,6 +12,34 @@
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QGroupBox" name="tabsGroupBox">
<property name="title">
<string>Tabs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="GroupFrameSettingsWidget" name="groupFrameSettingsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>General</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="loadThreadCheckBox">
<property name="text">
<string>Load posts in background (Thread)</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -24,18 +52,6 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QGroupBox" name="tabsGroupBox">
<property name="title">
<string>Tabs</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="GroupFrameSettingsWidget" name="groupFrameSettingsWidget" native="true"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -968,6 +968,17 @@ void RshareSettings::setForumLoadEmbeddedImages(bool value)
setValueToGroup("Forum", "LoadEmbeddedImages", value);
}
/* Channel */
bool RshareSettings::getChannelLoadThread()
{
return valueFromGroup("Channel", "LoadThread", true).toBool();
}
void RshareSettings::setChannelLoadThread(bool value)
{
setValueToGroup("Channel", "LoadThread", value);
}
/* GroupFrame settings */
static QString groupFrameSettingsTypeToString(GroupFrameSettings::Type type)
{

View File

@ -292,6 +292,10 @@ public:
bool getForumLoadEmbeddedImages();
void setForumLoadEmbeddedImages(bool value);
/* Channel */
bool getChannelLoadThread();
void setChannelLoadThread(bool value);
/* GroupFrame settings */
bool getGroupFrameSettings(GroupFrameSettings::Type type, GroupFrameSettings &groupFrameSettings);
void setGroupFrameSettings(GroupFrameSettings::Type type, const GroupFrameSettings &groupFrameSettings);