fixed icons in FriendSelectionWidget and MsgComposer. Also added disable/enable for From field depending on which type of recipient is used.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8087 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-03-27 22:16:12 +00:00
parent 9fc94b87ae
commit 5e50423915
4 changed files with 97 additions and 78 deletions

View File

@ -528,7 +528,9 @@ void FriendSelectionWidget::secured_fillList()
if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail)) if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail))
continue; /* BAD */ continue; /* BAD */
QPixmap identicon = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(*gxsIt))) ; QList<QIcon> icons ;
GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ;
QIcon identicon = icons.front() ;
// make a widget per friend // make a widget per friend
gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS); gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS);
@ -538,7 +540,7 @@ void FriendSelectionWidget::secured_fillList()
//gxsItem->setTextColor(COLUMN_NAME, textColorOnline()); //gxsItem->setTextColor(COLUMN_NAME, textColorOnline());
gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags()); gxsItem->setFlags(Qt::ItemIsUserCheckable | gxsItem->flags());
gxsItem->setIcon(COLUMN_NAME, QIcon(identicon)); gxsItem->setIcon(COLUMN_NAME, identicon);
gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString())); gxsItem->setData(COLUMN_DATA, ROLE_ID, QString::fromStdString(detail.mId.toStdString()));
gxsItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name); gxsItem->setData(COLUMN_DATA, ROLE_SORT, "2 " + name);

View File

@ -135,14 +135,14 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
m_completer = NULL; m_completer = NULL;
ui.distantFrame->hide(); ui.distantFrame->hide();
ui.respond_to_CB->setEnabled(false) ;
ui.fromLabel->setEnabled(false) ;
Settings->loadWidgetInformation(this); Settings->loadWidgetInformation(this);
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
ui.hashBox->hide(); ui.hashBox->hide();
ui.signMessage_CB->setChecked(true) ;
ui.signMessage_CB->setEnabled(false) ;
// connect up the buttons. // connect up the buttons.
connect( ui.actionSend, SIGNAL( triggered (bool)), this, SLOT( sendMessage( ) ) ); connect( ui.actionSend, SIGNAL( triggered (bool)), this, SLOT( sendMessage( ) ) );
@ -217,8 +217,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
/* initialize friends list */ /* initialize friends list */
ui.friendSelectionWidget->setHeaderText(tr("Send To:")); ui.friendSelectionWidget->setHeaderText(tr("Send To:"));
ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI); ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI);
ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP ui.friendSelectionWidget->setShowType(//FriendSelectionWidget::SHOW_GROUP // removed this because it's too confusing.
| FriendSelectionWidget::SHOW_SSL FriendSelectionWidget::SHOW_SSL
| FriendSelectionWidget::SHOW_GXS); | FriendSelectionWidget::SHOW_GXS);
ui.friendSelectionWidget->start(); ui.friendSelectionWidget->start();
@ -295,17 +295,19 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags)
ui.recipientWidget->setColumnCount(COLUMN_RECIPIENT_COUNT); ui.recipientWidget->setColumnCount(COLUMN_RECIPIENT_COUNT);
QHeaderView *header = ui.recipientWidget->horizontalHeader(); QHeaderView *header = ui.recipientWidget->horizontalHeader();
header->resizeSection(COLUMN_RECIPIENT_TYPE, 70); header->resizeSection(COLUMN_RECIPIENT_TYPE, 120);
header->resizeSection(COLUMN_RECIPIENT_ICON, 22); header->resizeSection(COLUMN_RECIPIENT_ICON, 22);
QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_TYPE, QHeaderView::Fixed); QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_TYPE, QHeaderView::Fixed);
QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_ICON, QHeaderView::Fixed); QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_ICON, QHeaderView::Fixed);
QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_NAME, QHeaderView::Interactive); QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_NAME, QHeaderView::Fixed);
header->setStretchLastSection(true); header->setStretchLastSection(true);
/* Set own item delegate */ /* Set own item delegate */
QItemDelegate *delegate = new MessageItemDelegate(this); QItemDelegate *delegate = new MessageItemDelegate(this);
ui.recipientWidget->setItemDelegateForColumn(COLUMN_RECIPIENT_ICON, delegate); ui.recipientWidget->setItemDelegateForColumn(COLUMN_RECIPIENT_ICON, delegate);
connect(ui.recipientWidget,SIGNAL(cellChanged(int,int)),this,SLOT(updateCells(int,int))) ;
addEmptyRecipient(); addEmptyRecipient();
// load settings // load settings
@ -344,6 +346,36 @@ MessageComposer::~MessageComposer()
delete(m_compareRole); delete(m_compareRole);
} }
void MessageComposer::updateCells(int,int)
{
int rowCount = ui.recipientWidget->rowCount();
int row;
bool has_gxs = false ;
for (row = 0; row < rowCount; ++row)
{
enumType type;
destinationType dtype ;
std::string id;
if (getRecipientFromRow(row, type,dtype, id) && !id.empty() )
if(dtype == PEER_TYPE_GXS)
has_gxs = true ;
}
if(has_gxs)
{
ui.respond_to_CB->setEnabled(true) ;
ui.distantFrame->show();
ui.fromLabel->setEnabled(true);
}
else
{
ui.respond_to_CB->setEnabled(false) ;
ui.distantFrame->hide() ;
ui.fromLabel->setEnabled(false);
}
}
void MessageComposer::processSettings(bool bLoad) void MessageComposer::processSettings(bool bLoad)
{ {
Settings->beginGroup(QString("MessageComposer")); Settings->beginGroup(QString("MessageComposer"));
@ -740,6 +772,8 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status)
} }
} }
} }
} }
void MessageComposer::setFileList(const std::list<DirDetails>& dir_info) void MessageComposer::setFileList(const std::list<DirDetails>& dir_info)
@ -1364,8 +1398,6 @@ bool MessageComposer::sendMessage_internal(bool bDraftbox)
QMessageBox::warning(this, tr("RetroShare"), tr("Please insert at least one recipient."), QMessageBox::Ok); QMessageBox::warning(this, tr("RetroShare"), tr("Please insert at least one recipient."), QMessageBox::Ok);
return false; // Don't send with no recipient return false; // Don't send with no recipient
} }
if(ui.signMessage_CB->isChecked())
mi.msgflags |= RS_MSG_SIGNED ;
if(mi.rsgxsid_srcId.isNull() && !(mi.rsgxsid_msgto.empty() && mi.rsgxsid_msgcc.empty() && mi.rsgxsid_msgbcc.empty())) if(mi.rsgxsid_srcId.isNull() && !(mi.rsgxsid_msgto.empty() && mi.rsgxsid_msgcc.empty() && mi.rsgxsid_msgbcc.empty()))
{ {
@ -1519,13 +1551,14 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType
std::cerr << "Can't get peer details from " << gid << std::endl; std::cerr << "Can't get peer details from " << gid << std::endl;
return ; return ;
} }
QPixmap identicon = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(gid))) ; QList<QIcon> icons ;
GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ;
name = tr("%2 <%2@%1>").arg(QString::fromStdString(gid.toStdString())).arg(QString::fromUtf8(detail.mNickname.c_str())) ; name = tr("%2 <%2@%1>").arg(QString::fromStdString(gid.toStdString())).arg(QString::fromUtf8(detail.mNickname.c_str())) ;
icon = QIcon(identicon);
if(!icons.empty())
ui.distantFrame->show(); icon = icons.front() ;
} }
break ; break ;

View File

@ -99,6 +99,7 @@ private slots:
void toggleContacts(); void toggleContacts();
void buildCompleter(); void buildCompleter();
void updatecontactsviewicons(); void updatecontactsviewicons();
void updateCells(int,int) ;
void filterComboBoxChanged(int); void filterComboBoxChanged(int);

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>814</width> <width>925</width>
<height>696</height> <height>747</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -220,6 +220,47 @@
<property name="horizontalSpacing"> <property name="horizontalSpacing">
<number>1</number> <number>1</number>
</property> </property>
<item row="0" column="8">
<widget class="QToolButton" name="italicbtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>167</width>
<height>167</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Italic</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/textitalic.png</normaloff>:/images/textedit/textitalic.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="12"> <item row="0" column="12">
<widget class="QToolButton" name="imagebtn"> <widget class="QToolButton" name="imagebtn">
<property name="minimumSize"> <property name="minimumSize">
@ -445,47 +486,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="8">
<widget class="QToolButton" name="italicbtn">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>167</width>
<height>167</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Italic</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/textedit/textitalic.png</normaloff>:/images/textedit/textitalic.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="10"> <item row="0" column="10">
<widget class="QToolButton" name="colorbtn"> <widget class="QToolButton" name="colorbtn">
<property name="minimumSize"> <property name="minimumSize">
@ -577,7 +577,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="16"> <item row="0" column="15">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
@ -651,23 +651,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="0" column="14">
<widget class="QPushButton" name="signMessage_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Cryptographically sign message to distant peers. This is prevents intermediate peers to spoof your identity.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/stock_signature_ok.png</normaloff>:/images/stock_signature_ok.png</iconset>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>
@ -1046,8 +1029,8 @@ border-image: url(:/images/closepressed.png)
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>814</width> <width>925</width>
<height>21</height> <height>25</height>
</rect> </rect>
</property> </property>
</widget> </widget>