diff --git a/retroshare-gui/src/gui/common/UIStateHelper.cpp b/retroshare-gui/src/gui/common/UIStateHelper.cpp index d27b21fae..d341358e7 100644 --- a/retroshare-gui/src/gui/common/UIStateHelper.cpp +++ b/retroshare-gui/src/gui/common/UIStateHelper.cpp @@ -311,6 +311,9 @@ bool UIStateHelper::isWidgetVisible(QWidget *widget) } if (visible) { + int visibleCount = 0; + int invisibleCount = 0; + QMap::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; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp index 406d68147..4b54c9ebd 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.cpp @@ -29,7 +29,7 @@ #include "gui/common/UIStateHelper.h" #include "gui/settings/rsharesettings.h" #include "gui/feeds/SubFileItem.h" - +#include "gui/notifyqt.h" #include #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()) { diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h index 4abe12bca..c983c964f 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidget.h @@ -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; diff --git a/retroshare-gui/src/gui/settings/ChannelPage.cpp b/retroshare-gui/src/gui/settings/ChannelPage.cpp index d9b40b632..b7ca6930b 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.cpp +++ b/retroshare-gui/src/gui/settings/ChannelPage.cpp @@ -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); } diff --git a/retroshare-gui/src/gui/settings/ChannelPage.ui b/retroshare-gui/src/gui/settings/ChannelPage.ui index 48159fd9e..ab8ac4b84 100644 --- a/retroshare-gui/src/gui/settings/ChannelPage.ui +++ b/retroshare-gui/src/gui/settings/ChannelPage.ui @@ -12,6 +12,34 @@ + + + Tabs + + + + + + + + + + + + General + + + + + + Load posts in background (Thread) + + + + + + + Qt::Vertical @@ -24,18 +52,6 @@ - - - - Tabs - - - - - - - - diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 9a29c39bb..3d4477a39 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -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) { diff --git a/retroshare-gui/src/gui/settings/rsharesettings.h b/retroshare-gui/src/gui/settings/rsharesettings.h index 9ac5acd80..38e02a8f7 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.h +++ b/retroshare-gui/src/gui/settings/rsharesettings.h @@ -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);