mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 15:39:27 -05:00
Fixed crash in context menu of the id list in IdDialog when no row is active.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8410 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
4a6b5dce8f
commit
d71d26f026
@ -1008,45 +1008,46 @@ void IdDialog::IdListCustomPopupMenu( QPoint )
|
|||||||
QMenu contextMnu( this );
|
QMenu contextMnu( this );
|
||||||
|
|
||||||
|
|
||||||
std::list<RsGxsId> own_identities ;
|
std::list<RsGxsId> own_identities ;
|
||||||
rsIdentity->getOwnIds(own_identities) ;
|
rsIdentity->getOwnIds(own_identities) ;
|
||||||
|
|
||||||
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
QTreeWidgetItem *item = ui->treeWidget_IdList->currentItem();
|
||||||
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
if (item) {
|
||||||
|
uint32_t item_flags = item->data(RSID_COL_KEYID,Qt::UserRole).toUInt() ;
|
||||||
|
|
||||||
if(!(item_flags & RSID_FILTER_OWNED_BY_YOU))
|
if(!(item_flags & RSID_FILTER_OWNED_BY_YOU))
|
||||||
{
|
{
|
||||||
if(own_identities.size() <= 1)
|
if(own_identities.size() <= 1)
|
||||||
{
|
{
|
||||||
QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
|
QAction *action = contextMnu.addAction(QIcon(":/images/chat_24.png"), tr("Chat with this person"), this, SLOT(chatIdentity()));
|
||||||
|
|
||||||
|
if(own_identities.empty())
|
||||||
|
action->setEnabled(false) ;
|
||||||
|
else
|
||||||
|
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;
|
||||||
|
|
||||||
if(own_identities.empty())
|
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
||||||
action->setEnabled(false) ;
|
{
|
||||||
else
|
RsIdentityDetails idd ;
|
||||||
action->setData(QString::fromStdString((own_identities.front()).toStdString())) ;
|
rsIdentity->getIdDetails(*it,idd) ;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMenu *mnu = contextMnu.addMenu(QIcon(":/images/chat_24.png"),tr("Chat with this person as...")) ;
|
|
||||||
|
|
||||||
for(std::list<RsGxsId>::const_iterator it=own_identities.begin();it!=own_identities.end();++it)
|
QPixmap pixmap ;
|
||||||
{
|
|
||||||
RsIdentityDetails idd ;
|
|
||||||
rsIdentity->getIdDetails(*it,idd) ;
|
|
||||||
|
|
||||||
QPixmap pixmap ;
|
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
|
||||||
|
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
||||||
|
|
||||||
if(idd.mAvatar.mSize == 0 || !pixmap.loadFromData(idd.mAvatar.mData, idd.mAvatar.mSize, "PNG"))
|
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
|
||||||
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(*it)) ;
|
action->setData(QString::fromStdString((*it).toStdString())) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QAction *action = mnu->addAction(QIcon(pixmap), QString("%1 (%2)").arg(QString::fromUtf8(idd.mNickname.c_str()), QString::fromStdString((*it).toStdString())), this, SLOT(chatIdentity()));
|
contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg()));
|
||||||
action->setData(QString::fromStdString((*it).toStdString())) ;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
contextMnu.addAction(QIcon(":/images/mail_new.png"), tr("Send message to this person"), this, SLOT(sendMsg()));
|
|
||||||
}
|
|
||||||
|
|
||||||
contextMnu.addSeparator();
|
contextMnu.addSeparator();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user