From 5e50423915f15c4d4adf1d56a0f287af60a78394 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 27 Mar 2015 22:16:12 +0000 Subject: [PATCH] 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 --- .../src/gui/common/FriendSelectionWidget.cpp | 6 +- .../src/gui/msgs/MessageComposer.cpp | 59 +++++++--- retroshare-gui/src/gui/msgs/MessageComposer.h | 1 + .../src/gui/msgs/MessageComposer.ui | 109 ++++++++---------- 4 files changed, 97 insertions(+), 78 deletions(-) diff --git a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp index 9568703c8..8108f6416 100644 --- a/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp +++ b/retroshare-gui/src/gui/common/FriendSelectionWidget.cpp @@ -528,7 +528,9 @@ void FriendSelectionWidget::secured_fillList() if (!rsIdentity->getIdDetails(RsGxsId(*gxsIt), detail)) continue; /* BAD */ - QPixmap identicon = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(*gxsIt))) ; + QList icons ; + GxsIdDetails::getIcons(detail,icons,GxsIdDetails::ICON_TYPE_AVATAR) ; + QIcon identicon = icons.front() ; // make a widget per friend gxsItem = new RSTreeWidgetItem(mCompareRole, IDTYPE_GXS); @@ -538,7 +540,7 @@ void FriendSelectionWidget::secured_fillList() //gxsItem->setTextColor(COLUMN_NAME, textColorOnline()); 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_SORT, "2 " + name); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.cpp b/retroshare-gui/src/gui/msgs/MessageComposer.cpp index 26dac2295..be8effc9b 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.cpp +++ b/retroshare-gui/src/gui/msgs/MessageComposer.cpp @@ -135,14 +135,14 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) m_completer = NULL; ui.distantFrame->hide(); + ui.respond_to_CB->setEnabled(false) ; + ui.fromLabel->setEnabled(false) ; Settings->loadWidgetInformation(this); setAttribute ( Qt::WA_DeleteOnClose, true ); ui.hashBox->hide(); - ui.signMessage_CB->setChecked(true) ; - ui.signMessage_CB->setEnabled(false) ; // connect up the buttons. connect( ui.actionSend, SIGNAL( triggered (bool)), this, SLOT( sendMessage( ) ) ); @@ -217,8 +217,8 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) /* initialize friends list */ ui.friendSelectionWidget->setHeaderText(tr("Send To:")); ui.friendSelectionWidget->setModus(FriendSelectionWidget::MODUS_MULTI); - ui.friendSelectionWidget->setShowType(FriendSelectionWidget::SHOW_GROUP - | FriendSelectionWidget::SHOW_SSL + ui.friendSelectionWidget->setShowType(//FriendSelectionWidget::SHOW_GROUP // removed this because it's too confusing. + FriendSelectionWidget::SHOW_SSL | FriendSelectionWidget::SHOW_GXS); ui.friendSelectionWidget->start(); @@ -295,17 +295,19 @@ MessageComposer::MessageComposer(QWidget *parent, Qt::WindowFlags flags) ui.recipientWidget->setColumnCount(COLUMN_RECIPIENT_COUNT); QHeaderView *header = ui.recipientWidget->horizontalHeader(); - header->resizeSection(COLUMN_RECIPIENT_TYPE, 70); + header->resizeSection(COLUMN_RECIPIENT_TYPE, 120); header->resizeSection(COLUMN_RECIPIENT_ICON, 22); QHeaderView_setSectionResizeMode(header, COLUMN_RECIPIENT_TYPE, 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); /* Set own item delegate */ QItemDelegate *delegate = new MessageItemDelegate(this); ui.recipientWidget->setItemDelegateForColumn(COLUMN_RECIPIENT_ICON, delegate); + connect(ui.recipientWidget,SIGNAL(cellChanged(int,int)),this,SLOT(updateCells(int,int))) ; + addEmptyRecipient(); // load settings @@ -344,6 +346,36 @@ MessageComposer::~MessageComposer() 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) { Settings->beginGroup(QString("MessageComposer")); @@ -740,6 +772,8 @@ void MessageComposer::peerStatusChanged(const QString& peer_id, int status) } } } + + } void MessageComposer::setFileList(const std::list& 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); 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())) { @@ -1519,13 +1551,14 @@ void MessageComposer::setRecipientToRow(int row, enumType type, destinationType std::cerr << "Can't get peer details from " << gid << std::endl; return ; } - - QPixmap identicon = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(gid))) ; + + QList 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())) ; - icon = QIcon(identicon); - - ui.distantFrame->show(); + + if(!icons.empty()) + icon = icons.front() ; } break ; diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.h b/retroshare-gui/src/gui/msgs/MessageComposer.h index 260684bf0..d9c0b6c97 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.h +++ b/retroshare-gui/src/gui/msgs/MessageComposer.h @@ -99,6 +99,7 @@ private slots: void toggleContacts(); void buildCompleter(); void updatecontactsviewicons(); + void updateCells(int,int) ; void filterComboBoxChanged(int); diff --git a/retroshare-gui/src/gui/msgs/MessageComposer.ui b/retroshare-gui/src/gui/msgs/MessageComposer.ui index 604f4283c..ffc3d11c8 100644 --- a/retroshare-gui/src/gui/msgs/MessageComposer.ui +++ b/retroshare-gui/src/gui/msgs/MessageComposer.ui @@ -6,8 +6,8 @@ 0 0 - 814 - 696 + 925 + 747 @@ -220,6 +220,47 @@ 1 + + + + + 0 + 0 + + + + + 167 + 167 + + + + Qt::NoFocus + + + Italic + + + + + + + :/images/textedit/textitalic.png:/images/textedit/textitalic.png + + + + 24 + 24 + + + + true + + + true + + + @@ -445,47 +486,6 @@ - - - - - 0 - 0 - - - - - 167 - 167 - - - - Qt::NoFocus - - - Italic - - - - - - - :/images/textedit/textitalic.png:/images/textedit/textitalic.png - - - - 24 - 24 - - - - true - - - true - - - @@ -577,7 +577,7 @@ - + Qt::Horizontal @@ -651,23 +651,6 @@ - - - - <html><head/><body><p>Cryptographically sign message to distant peers. This is prevents intermediate peers to spoof your identity.</p></body></html> - - - - - - - :/images/stock_signature_ok.png:/images/stock_signature_ok.png - - - true - - - @@ -1046,8 +1029,8 @@ border-image: url(:/images/closepressed.png) 0 0 - 814 - 21 + 925 + 25