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 */
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!
rsEvents->registerEventsHandler(

View File

@ -70,8 +70,8 @@ static const uint32_t DELAY_BETWEEN_GROUP_STATISTICS_UPDATE = 120; // do not upd
*/
/** Constructor */
GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *parent,bool allow_dist_sync)
: MainPage(parent)
GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl,const QString& settings_name, QWidget *parent,bool allow_dist_sync)
: MainPage(parent),mSettingsName(settings_name)
{
/* Invoke the Qt Designer generated object setup routine */
ui = new Ui::GxsGroupFrameDialog();
@ -166,7 +166,6 @@ void GxsGroupFrameDialog::initUi()
}
// load settings
mSettingsName = settingsGroupName();
processSettings(true);
if (groupFrameSettingsType() != GroupFrameSettings::Nothing) {
@ -1177,6 +1176,8 @@ void GxsGroupFrameDialog::updateGroupStatisticsReal(const RsGxsGroupId &groupId)
}
void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const
{
if(!mCachedGroupStats.empty())
{
stats = GxsServiceStatistic(); // clears everything
@ -1192,6 +1193,33 @@ void GxsGroupFrameDialog::getServiceStatistics(GxsServiceStatistic& stats) const
stats.mNumChildMsgsNew += s.mNumChildMsgsNew ;
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

View File

@ -71,7 +71,7 @@ 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();
bool navigate(const RsGxsGroupId &groupId, const RsGxsMessageId& msgId);

View File

@ -49,7 +49,7 @@
/** Constructor */
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!
rsEvents->registerEventsHandler(

View File

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