attempt to fix the display of new msgs and icon in GXS toolbar items at start

This commit is contained in:
csoler 2022-12-27 23:01:26 +01:00
parent 74dbef06be
commit 0ce6b5f375
5 changed files with 47 additions and 19 deletions

View File

@ -43,7 +43,7 @@ public:
/** Constructor */ /** Constructor */
PostedDialog::PostedDialog(QWidget *parent): PostedDialog::PostedDialog(QWidget *parent):
GxsGroupFrameDialog(rsPosted, parent), mEventHandlerId(0) GxsGroupFrameDialog(rsPosted, settingsGroupName(),parent), mEventHandlerId(0)
{ {
// Needs to be asynced because this function is likely to be called by another thread! // Needs to be asynced because this function is likely to be called by another thread!
rsEvents->registerEventsHandler( rsEvents->registerEventsHandler(

View File

@ -70,8 +70,8 @@ static const uint32_t DELAY_BETWEEN_GROUP_STATISTICS_UPDATE = 120; // do not upd
*/ */
/** Constructor */ /** Constructor */
GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent,bool allow_dist_sync) GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl,const QString& settings_name, QWidget *parent,bool allow_dist_sync)
: MainPage(parent) : MainPage(parent),mSettingsName(settings_name)
{ {
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui = new Ui::GxsGroupFrameDialog(); ui = new Ui::GxsGroupFrameDialog();
@ -166,7 +166,6 @@ void GxsGroupFrameDialog::initUi()
} }
// load settings // load settings
mSettingsName = settingsGroupName();
processSettings(true); processSettings(true);
if (groupFrameSettingsType() != GroupFrameSettings::Nothing) { if (groupFrameSettingsType() != GroupFrameSettings::Nothing) {
@ -1178,6 +1177,8 @@ void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId)
void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const
{ {
if(!mCachedGroupStats.empty())
{
stats = GxsServiceStatistic(); // clears everything stats = GxsServiceStatistic(); // clears everything
for(auto& it: mCachedGroupStats) for(auto& it: mCachedGroupStats)
@ -1192,6 +1193,33 @@ void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const
stats.mNumChildMsgsNew += s.mNumChildMsgsNew ; stats.mNumChildMsgsNew += s.mNumChildMsgsNew ;
stats.mNumChildMsgsUnread += s.mNumChildMsgsUnread ; stats.mNumChildMsgsUnread += s.mNumChildMsgsUnread ;
} }
// Also save the service statistics in conf file, so that we can display it right away at start.
Settings->beginGroup(mSettingsName);
Settings->setValue("NumMsgs", stats.mNumMsgs );
Settings->setValue("NumGrps", stats.mNumGrps );
Settings->setValue("SizeOfMessages", stats.mSizeOfMsgs );
Settings->setValue("NumThreadMsgsNew", stats.mNumThreadMsgsNew );
Settings->setValue("NumThreadMsgsUnread",stats.mNumThreadMsgsUnread);
Settings->setValue("NumChildMsgsNew", stats.mNumChildMsgsNew );
Settings->setValue("NumChildMsgsUnread", stats.mNumChildMsgsUnread );
Settings->endGroup();
}
else // Get statistics from settings if no cache is already present: allows to display at start.
{
Settings->beginGroup(mSettingsName);
stats.mNumMsgs = Settings->value("NumMsgs",QVariant(0)).toInt();
stats.mNumGrps = Settings->value("NumGrps",QVariant(0)).toInt();
stats.mSizeOfMsgs = Settings->value("SizeOfMessages",QVariant(0)).toInt();
stats.mNumThreadMsgsNew = Settings->value("NumThreadMsgsNew",QVariant(0)).toInt();
stats.mNumThreadMsgsUnread = Settings->value("NumThreadMsgsUnread",QVariant(0)).toInt();
stats.mNumChildMsgsNew = Settings->value("NumChildMsgsNew",QVariant(0)).toInt();
stats.mNumChildMsgsUnread = Settings->value("NumChildMsgsUnread",QVariant(0)).toInt();
Settings->endGroup();
}
} }
TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class

View File

@ -71,7 +71,7 @@ public:
}; };
public: public:
GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent = 0,bool allow_dist_sync=false); GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, const QString& settings_name,QWidget *parent = 0,bool allow_dist_sync=false);
virtual ~GxsGroupFrameDialog(); virtual ~GxsGroupFrameDialog();
bool navigate(const RsGxsGroupId &groupId, const RsGxsMessageId& msgId); bool navigate(const RsGxsGroupId &groupId, const RsGxsMessageId& msgId);

View File

@ -49,7 +49,7 @@
/** Constructor */ /** Constructor */
GxsChannelDialog::GxsChannelDialog(QWidget *parent): GxsChannelDialog::GxsChannelDialog(QWidget *parent):
GxsGroupFrameDialog(rsGxsChannels, parent, true), mEventHandlerId(0) GxsGroupFrameDialog(rsGxsChannels, settingsGroupName(),parent, true), mEventHandlerId(0)
{ {
// Needs to be asynced because this function is called by another thread! // Needs to be asynced because this function is called by another thread!
rsEvents->registerEventsHandler( rsEvents->registerEventsHandler(

View File

@ -40,7 +40,7 @@ public:
/** Constructor */ /** Constructor */
GxsForumsDialog::GxsForumsDialog(QWidget *parent) : GxsForumsDialog::GxsForumsDialog(QWidget *parent) :
GxsGroupFrameDialog(rsGxsForums, parent), mEventHandlerId(0) GxsGroupFrameDialog(rsGxsForums, settingsGroupName(),parent), mEventHandlerId(0)
{ {
mCountChildMsgs = true; mCountChildMsgs = true;