Merge pull request #2727 from PYRET1C/browse_image

[WIP] This is the gui part of the commit where the wire feed is refreshed
This commit is contained in:
csoler 2023-05-27 14:33:23 +02:00 committed by GitHub
commit 266f84759e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 15 deletions

View File

@ -61,13 +61,12 @@
WireDialog::WireDialog(QWidget *parent)
: MainPage(parent), mGroupSet(GROUP_SET_ALL)
, mAddDialog(nullptr), mGroupSelected(nullptr), mWireQueue(nullptr)
, mHistoryIndex(-1)
, mHistoryIndex(-1), mEventHandlerId(0)
{
ui.setupUi(this);
connect( ui.toolButton_createAccount, SIGNAL(clicked()), this, SLOT(createGroup()));
connect( ui.toolButton_createPulse, SIGNAL(clicked()), this, SLOT(createPulse()));
connect( ui.toolButton_refresh, SIGNAL(clicked()), this, SLOT(refreshGroups()));
connect(ui.comboBox_groupSet, SIGNAL(currentIndexChanged(int)), this, SLOT(selectGroupSet(int)));
connect(ui.comboBox_filterTime, SIGNAL(currentIndexChanged(int)), this, SLOT(selectFilterTime(int)));
@ -91,6 +90,48 @@ WireDialog::WireDialog(QWidget *parent)
// load settings
processSettings(true);
// Needs to be asynced because this function is called by another thread!
rsEvents->registerEventsHandler(
[this](std::shared_ptr<const RsEvent> event)
{ RsQThreadUtils::postToObject([=]() { handleEvent_main_thread(event); }, this ); },
mEventHandlerId, RsEventType::WIRE );
}
void WireDialog::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
const RsWireEvent *e = dynamic_cast<const RsWireEvent*>(event.get());
if(e)
{
#ifdef GXSWIRE_DEBUG
RsDbg() << " Refreshing the feed if there is a matching event. "<< std::endl;
#endif
// The following switch statements refresh the wire feed whenever there is a new event
switch(e->mWireEventCode)
{
case RsWireEventCode::NEW_POST:
case RsWireEventCode::NEW_REPLY:
case RsWireEventCode::NEW_LIKE:
case RsWireEventCode::NEW_REPUBLISH:
case RsWireEventCode::POST_UPDATED:
case RsWireEventCode::NEW_WIRE:
case RsWireEventCode::FOLLOW_STATUS_CHANGED:
default:
refreshGroups();
break;
}
}
}
WireDialog::~WireDialog()
@ -99,7 +140,9 @@ WireDialog::~WireDialog()
processSettings(false);
clearTwitterView();
delete(mWireQueue);
delete(mWireQueue);
rsEvents->unregisterEventsHandler(mEventHandlerId);
}
void WireDialog::processSettings(bool load)

View File

@ -164,6 +164,10 @@ private:
std::map<RsGxsGroupId, RsWireGroup> mAllGroups;
std::vector<RsWireGroup> mOwnGroups;
// This function and variable below it handle the events for the wire
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
RsEventsHandlerId_t mEventHandlerId;
int32_t mHistoryIndex;
std::vector<WireViewHistory> mHistory;

View File

@ -100,13 +100,6 @@
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_refresh">
<property name="text">
<string>Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="RSComboBox" name="groupChooser"/>
</item>
@ -189,7 +182,6 @@
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
@ -208,8 +200,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>220</width>
<height>444</height>
<width>224</width>
<height>465</height>
</rect>
</property>
<layout class="QVBoxLayout" name="groupsWidget_VL">
@ -387,8 +379,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>521</width>
<height>437</height>
<width>523</width>
<height>462</height>
</rect>
</property>
<property name="styleSheet">