fixed multiple glitches in Mail UI

This commit is contained in:
csoler 2022-11-25 15:15:19 +01:00
parent 2d024c0d6f
commit ea4df6306b
5 changed files with 56 additions and 13 deletions

View File

@ -127,11 +127,45 @@ FriendSelectionWidget::FriendSelectionWidget(QWidget *parent)
/* Refresh style to have the correct text color */
Rshare::refreshStyleSheet(this, false);
mEventHandlerId_identities = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) {
RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_identities, RsEventType::GXS_IDENTITY );
mEventHandlerId_peers = 0;
rsEvents->registerEventsHandler( [this](std::shared_ptr<const RsEvent> event) {
RsQThreadUtils::postToObject( [this,event]() { handleEvent_main_thread(event); }) ;}, mEventHandlerId_peers, RsEventType::PEER_CONNECTION );
}
void FriendSelectionWidget::handleEvent_main_thread(std::shared_ptr<const RsEvent> event)
{
const RsGxsIdentityEvent *fe = dynamic_cast<const RsGxsIdentityEvent*>(event.get());
if(fe)
{
updateDisplay(true);
update(); // Qt flush
return;
}
const RsConnectionEvent *fp = dynamic_cast<const RsConnectionEvent*>(event.get());
if(fp)
switch(fp->mConnectionInfoCode)
{
case RsConnectionEventCode::PEER_REMOVED:
case RsConnectionEventCode::PEER_ADDED:
updateDisplay(true);
update(); // Qt flush
break;
default: break ;
}
}
FriendSelectionWidget::~FriendSelectionWidget()
{
delete ui;
rsEvents->unregisterEventsHandler(mEventHandlerId_peers);
rsEvents->unregisterEventsHandler(mEventHandlerId_identities);
delete ui;
}
void FriendSelectionWidget::changeEvent(QEvent *e)

View File

@ -24,6 +24,7 @@
#include <QWidget>
#include <QDialog>
#include "retroshare/rsevents.h"
#include <gui/gxs/RsGxsUpdateBroadcastPage.h>
namespace Ui {
@ -151,6 +152,8 @@ private:
void setSelectedIds_internal(IdType idType, const std::set<std::string> &ids, bool add);
private:
void handleEvent_main_thread(std::shared_ptr<const RsEvent> event);
bool mStarted;
RSTreeWidgetItemCompareRole *mCompareRole;
Modus mListModus;
@ -173,6 +176,9 @@ private:
QList<QAction*> mContextMenuActions;
std::set<std::string> mPreSelectedIds; // because loading of GxsIds is asynchroneous we keep selected Ids from the client in a list here and use it to initialize after loading them.
RsEventsHandlerId_t mEventHandlerId_identities;
RsEventsHandlerId_t mEventHandlerId_peers;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(FriendSelectionWidget::ShowTypes)

View File

@ -585,8 +585,9 @@ QVariant RsMessageModel::userRole(const Rs::Msgs::MsgInfoSummary& fmpe,int col)
{
switch(col)
{
case COLUMN_THREAD_AUTHOR: return displayRole(fmpe,col);
case COLUMN_THREAD_AUTHOR: return QVariant(QString::fromStdString(fmpe.from.toStdString()));
case COLUMN_THREAD_MSGID: return QVariant(QString::fromStdString(fmpe.msgId));
case COLUMN_THREAD_TO: return QVariant(QString::fromStdString(fmpe.to.toStdString()));
default:
return QVariant();
}

View File

@ -679,10 +679,13 @@ void MessageWidget::fill(const std::string &msgId)
link = RetroShareLink::createMessage(msgInfo.from.toRsPeerId(), "");
}
if (((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.from.toRsPeerId() == ownId) || msgInfo.from.type()!=MsgAddress::MSG_ADDRESS_TYPE_RSPEERID) {
if ((msgInfo.msgflags & RS_MSG_SYSTEM) && msgInfo.from.toRsPeerId() == ownId)
{
ui.fromText->setText("[Notification]");
if (toolButtonReply) toolButtonReply->setEnabled(false);
} else {
}
else
{
ui.fromText->setText(link.toHtml());
ui.fromText->setToolTip(tooltip_string) ;
if (toolButtonReply) toolButtonReply->setEnabled(true);

View File

@ -379,12 +379,15 @@ void MessagesDialog::postModelUpdate()
sel.select(i.sibling(i.row(),0),i.sibling(i.row(),RsMessageModel::COLUMN_THREAD_NB_COLUMNS-1));
}
ui.messageTreeWidget->selectionModel()->select(sel,QItemSelectionModel::SelectCurrent);
// Restoring selection should not trigger anything, especially the re-display of the msg, which
// in turn will change the read status.
whileBlocking(ui.messageTreeWidget->selectionModel())->select(sel,QItemSelectionModel::SelectCurrent);
if (!mTmpSavedCurrentId.isEmpty()) {
QModelIndex index = mMessageProxyModel->mapFromSource(mMessageModel->getIndexOfMessage(mTmpSavedCurrentId.toStdString()));
if (index.isValid()) {
ui.messageTreeWidget->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select);
whileBlocking(ui.messageTreeWidget->selectionModel())->setCurrentIndex(index, QItemSelectionModel::Select);
}
}
}
@ -898,7 +901,7 @@ void MessagesDialog::changeBox(int box_row)
switch(box_row)
{
case ROW_INBOX: mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_INBOX );
break;
break;
case ROW_OUTBOX: mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_OUTBOX);
break;
case ROW_DRAFTBOX: mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_DRAFTS);
@ -913,7 +916,8 @@ void MessagesDialog::changeBox(int box_row)
insertMsgTxtAndFiles(ui.messageTreeWidget->currentIndex());
ui.messageTreeWidget->setPlaceholderText(placeholderText);
}
ui.messageTreeWidget->setColumnHidden(RsMessageModel::COLUMN_THREAD_READ,box_row!=ROW_INBOX);
}
else
{
mMessageModel->setCurrentBox(Rs::Msgs::BoxName::BOX_NONE);
@ -993,21 +997,16 @@ void MessagesDialog::clicked(const QModelIndex& proxy_index)
case RsMessageModel::COLUMN_THREAD_READ:
{
mMessageModel->setMsgReadStatus(real_index, !isMessageRead(proxy_index));
//Already updated by currentChanged
//insertMsgTxtAndFiles(proxy_index);
updateMessageSummaryList();
return;
}
case RsMessageModel::COLUMN_THREAD_STAR:
{
mMessageModel->setMsgStar(real_index, !hasMessageStar(proxy_index));
updateMessageSummaryList();
return;
}
case RsMessageModel::COLUMN_THREAD_SPAM:
{
mMessageModel->setMsgJunk(real_index, !hasMessageSpam(proxy_index));
updateMessageSummaryList();
return;
}
}