diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp index 36580c1fd..34efb2638 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.cpp @@ -22,9 +22,11 @@ */ #include +#include #include #include "gui/Circles/CreateCircleDialog.h" +#include "gui/gxs/GxsIdDetails.h" #include #include @@ -50,10 +52,6 @@ CreateCircleDialog::CreateCircleDialog() /* Setup Queue */ mCircleQueue = new TokenQueue(rsGxsCircles->getTokenService(), this); mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this); - - //QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message"); - //setWindowTitle(text); - //Settings->loadWidgetInformation(this); ui.headerFrame->setHeaderImage(QPixmap(":/images/circles/circles_64.png")); @@ -67,6 +65,9 @@ CreateCircleDialog::CreateCircleDialog() connect(ui.treeWidget_membership, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedMember(QTreeWidgetItem*, QTreeWidgetItem*))); connect(ui.treeWidget_IdList, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(selectedId(QTreeWidgetItem*, QTreeWidgetItem*))); + connect(ui.treeWidget_IdList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(IdListCustomPopupMenu(QPoint))); + connect(ui.treeWidget_membership, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(MembershipListCustomPopupMenu(QPoint))); + connect(ui.IdFilter, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); //connect(ui.toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId())); @@ -122,12 +123,13 @@ void CreateCircleDialog::editNewId(bool isExternal) if (isExternal) { setupForExternalCircle(); - ui.headerFrame->setHeaderText(tr("Create New External Circle")); + ui.headerFrame->setHeaderText(tr("Create New Circle")); + ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create")); } else { setupForPersonalCircle(); - ui.headerFrame->setHeaderText(tr("Create New Personal Circle")); + ui.headerFrame->setHeaderText(tr("Create New Circle")); } /* enable stuff that might be locked */ @@ -139,14 +141,14 @@ void CreateCircleDialog::setupForPersonalCircle() /* hide distribution line */ - ui.groupBox_title->setTitle(tr("Personal Circle Details")); + ui.groupBox_title->setTitle(tr("Circle Details")); ui.frame_PgpTypes->hide(); ui.frame_Distribution->hide(); ui.idChooserLabel->hide(); ui.idChooser->hide(); //ui.toolButton_NewId->hide(); - getPgpIdentities(); + //getPgpIdentities(); } void CreateCircleDialog::setupForExternalCircle() @@ -154,7 +156,8 @@ void CreateCircleDialog::setupForExternalCircle() mIsExternalCircle = true; /* show distribution line */ - ui.groupBox_title->setTitle(tr("External Circle Details")); + ui.groupBox_title->setTitle(tr("Circle Details")); + ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Update")); ui.frame_PgpTypes->show(); ui.frame_Distribution->show(); ui.idChooserLabel->show(); @@ -220,6 +223,7 @@ void CreateCircleDialog::addMember(const QString& keyId, const QString& idtype, member->setText(RSCIRCLEID_COL_NICKNAME, nickname); member->setText(RSCIRCLEID_COL_KEYID, keyId); member->setText(RSCIRCLEID_COL_IDTYPE, idtype); + //member->setIcon(RSCIRCLEID_COL_NICKNAME, pixmap); tree->addTopLevelItem(member); } @@ -522,7 +526,7 @@ void CreateCircleDialog::loadCircle(uint32_t token) updateCircleGUI(); } -void CreateCircleDialog::getPgpIdentities() +/*void CreateCircleDialog::getPgpIdentities() { std::cerr << "CreateCircleDialog::getPgpIdentities()"; std::cerr << std::endl; @@ -556,7 +560,7 @@ void CreateCircleDialog::getPgpIdentities() } filterIds(); -} +}*/ void CreateCircleDialog::requestGxsIdentities() @@ -616,6 +620,11 @@ void CreateCircleDialog::loadIdentities(uint32_t token) QString keyId = QString::fromStdString(data.mMeta.mGroupId.toStdString()); QString nickname = QString::fromUtf8(data.mMeta.mGroupName.c_str()); QString idtype = tr("Anon Id"); + + QPixmap pixmap ; + + if(data.mImage.mSize == 0 || !pixmap.loadFromData(data.mImage.mData, data.mImage.mSize, "PNG")) + pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(data.mMeta.mGroupId))) ; if (data.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID) { if (data.mPgpKnown) { @@ -629,6 +638,7 @@ void CreateCircleDialog::loadIdentities(uint32_t token) QTreeWidgetItem *item = new QTreeWidgetItem(); item->setText(RSCIRCLEID_COL_NICKNAME, nickname); + item->setIcon(RSCIRCLEID_COL_NICKNAME, QIcon(pixmap)); item->setText(RSCIRCLEID_COL_KEYID, keyId); item->setText(RSCIRCLEID_COL_IDTYPE, idtype); tree->addTopLevelItem(item); @@ -693,10 +703,39 @@ void CreateCircleDialog::filterIds() ui.treeWidget_IdList->filterItems(filterColumn, text); } -void CreateCircleDialog::createNewGxsId() +void CreateCircleDialog::createNewGxsId() { IdEditDialog dlg(this); dlg.setupNewId(false); dlg.exec(); //ui.idChooser->setDefaultId(dlg.getLastIdName()); } + +void CreateCircleDialog::IdListCustomPopupMenu( QPoint ) +{ + QMenu contextMnu( this ); + + QTreeWidgetItem *item = ui.treeWidget_IdList->currentItem(); + if (item) { + + contextMnu.addAction(QIcon(":/images/edit_add24.png"), tr("Add Member"), this, SLOT(addMember())); + + } + + contextMnu.exec(QCursor::pos()); +} + +void CreateCircleDialog::MembershipListCustomPopupMenu( QPoint ) +{ + QMenu contextMnu( this ); + + QTreeWidgetItem *item = ui.treeWidget_membership->currentItem(); + if (item) { + + contextMnu.addAction(QIcon(":/images/delete.png"), tr("Remove Member"), this, SLOT(removeMember())); + + } + + contextMnu.exec(QCursor::pos()); +} + diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.h b/retroshare-gui/src/gui/Circles/CreateCircleDialog.h index fe08d0dab..a2c364ddb 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.h +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.h @@ -41,7 +41,7 @@ public: void editNewId(bool isExternal); void editExistingId(const RsGxsGroupId &circleId, const bool &clearList = true); - void addMember(const QString &keyId, const QString &idtype, const QString &nickname ); + void addMember(const QString &keyId, const QString &idtype, const QString &nickname); void addMember(const RsGxsIdGroup &idGroup); void addCircle(const RsGxsCircleDetails &cirDetails); @@ -57,6 +57,10 @@ private slots: void createCircle(); void filterChanged(const QString &text); void createNewGxsId(); + + /** Create the context popup menu and it's submenus */ + void IdListCustomPopupMenu( QPoint point ); + void MembershipListCustomPopupMenu( QPoint point); private: @@ -73,7 +77,7 @@ private: void requestCircle(const RsGxsGroupId &groupId); void requestGxsIdentities(); - void getPgpIdentities(); + //void getPgpIdentities(); void filterIds(); diff --git a/retroshare-gui/src/gui/Circles/CreateCircleDialog.ui b/retroshare-gui/src/gui/Circles/CreateCircleDialog.ui index 377d00c90..057dad28b 100644 --- a/retroshare-gui/src/gui/Circles/CreateCircleDialog.ui +++ b/retroshare-gui/src/gui/Circles/CreateCircleDialog.ui @@ -49,6 +49,9 @@ + + Qt::CustomContextMenu + true @@ -128,7 +131,7 @@ - Known Identities + Known People @@ -186,6 +189,9 @@ + + Qt::CustomContextMenu + true @@ -240,7 +246,11 @@ - + + + Circle name + + diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index d36ec3b1d..8d7e3f8f1 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -68,7 +68,8 @@ #define RSID_COL_NICKNAME 0 #define RSID_COL_KEYID 1 -#define RSID_COL_IDTYPE 2 +#define RSID_COL_LASTUSED 2 +#define RSID_COL_IDTYPE 3 #define RSIDREP_COL_NAME 0 #define RSIDREP_COL_OPINION 1 @@ -164,9 +165,9 @@ IdDialog::IdDialog(QWidget *parent) : connect(ui->messageButton, SIGNAL(clicked()), this, SLOT(sendMsg())); -#ifdef UNFINISHED_CODE + ui->avlabel->setPixmap(QPixmap(":/images/user/friends64.png")); -#endif + ui->headerTextLabel->setText(tr("People")); /* Initialize splitter */ @@ -192,12 +193,20 @@ IdDialog::IdDialog(QWidget *parent) : ui->filterLineEdit->addFilter(QIcon(), headerText, RSID_COL_NICKNAME, QString("%1 %2").arg(tr("Search"), headerText)); headerText = headerItem->text(RSID_COL_KEYID); ui->filterLineEdit->addFilter(QIcon(), headerItem->text(RSID_COL_KEYID), RSID_COL_KEYID, QString("%1 %2").arg(tr("Search"), headerText)); + + /* Set initial section sizes */ + QHeaderView * circlesheader = ui->treeWidget_membership->header () ; + circlesheader->resizeSection (CIRCLEGROUP_CIRCLE_COL_GROUPNAME, 280); /* Setup tree */ ui->idTreeWidget->sortByColumn(RSID_COL_NICKNAME, Qt::AscendingOrder); ui->idTreeWidget->enableColumnCustomize(true); ui->idTreeWidget->setColumnCustomizable(RSID_COL_NICKNAME, false); + + ui->idTreeWidget->setColumnHidden(RSID_COL_IDTYPE, true); + ui->idTreeWidget->setColumnHidden(RSID_COL_LASTUSED, true); + /* Set initial column width */ int fontWidth = QFontMetricsF(ui->idTreeWidget->font()).width("W"); @@ -213,9 +222,6 @@ IdDialog::IdDialog(QWidget *parent) : // Hiding RepList until that part is finished. //ui->treeWidget_RepList->setVisible(false); ui->toolButton_Reputation->setVisible(false); -#ifdef UNFINISHED_CODE - ui->todoPushButton->hide() ; -#endif QString hlp_str = tr( "

  Identities

\ @@ -242,6 +248,8 @@ IdDialog::IdDialog(QWidget *parent) : connect(ui->pushButton_extCircle, SIGNAL(clicked()), this, SLOT(createExternalCircle())); connect(ui->pushButton_editCircle, SIGNAL(clicked()), this, SLOT(editExistingCircle())); connect(ui->treeWidget_membership, SIGNAL(itemSelectionChanged()), this, SLOT(circle_selected())); + connect(ui->treeWidget_membership, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(CircleListCustomPopupMenu(QPoint))); + /* Setup TokenQueue */ mCircleQueue = new TokenQueue(rsGxsCircles->getTokenService(), this); @@ -292,20 +300,20 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token) mStateHelper->setActive(CIRCLESDIALOG_GROUPMETA, true); /* add the top level item */ - QTreeWidgetItem *personalCirclesItem = new QTreeWidgetItem(); - personalCirclesItem->setText(0, tr("Personal Circles")); - ui->treeWidget_membership->addTopLevelItem(personalCirclesItem); + //QTreeWidgetItem *personalCirclesItem = new QTreeWidgetItem(); + //personalCirclesItem->setText(0, tr("Personal Circles")); + //ui->treeWidget_membership->addTopLevelItem(personalCirclesItem); QTreeWidgetItem *externalAdminCirclesItem = new QTreeWidgetItem(); - externalAdminCirclesItem->setText(0, tr("External Circles (Admin)")); + externalAdminCirclesItem->setText(0, tr("Circles (Admin)")); ui->treeWidget_membership->addTopLevelItem(externalAdminCirclesItem); QTreeWidgetItem *externalSubCirclesItem = new QTreeWidgetItem(); - externalSubCirclesItem->setText(0, tr("External Circles (Subscribed)")); + externalSubCirclesItem->setText(0, tr("Circles (Subscribed)")); ui->treeWidget_membership->addTopLevelItem(externalSubCirclesItem); QTreeWidgetItem *externalOtherCirclesItem = new QTreeWidgetItem(); - externalOtherCirclesItem->setText(0, tr("External Circles (Other)")); + externalOtherCirclesItem->setText(0, tr("Circles (Other)")); ui->treeWidget_membership->addTopLevelItem(externalOtherCirclesItem); for(vit = groupInfo.begin(); vit != groupInfo.end(); ++vit) @@ -321,7 +329,7 @@ void IdDialog::loadCircleGroupMeta(const uint32_t &token) if (vit->mCircleType == GXS_CIRCLE_TYPE_LOCAL) { - personalCirclesItem->addChild(groupItem); + //personalCirclesItem->addChild(groupItem); } else { @@ -364,6 +372,20 @@ void IdDialog::editExistingCircle() dlg.exec(); } +void IdDialog::CircleListCustomPopupMenu( QPoint ) +{ + QMenu contextMnu( this ); + + QTreeWidgetItem *item = ui->treeWidget_membership->currentItem(); + if (item) { + + contextMnu.addAction(QIcon(IMAGE_EDIT), tr("Edit Circle"), this, SLOT(editExistingCircle())); + + } + + contextMnu.exec(QCursor::pos()); +} + static void set_item_background(QTreeWidgetItem *item, uint32_t type) { QBrush brush; @@ -494,6 +516,24 @@ void IdDialog::todo() ""); } +static QString getHumanReadableDuration(uint32_t seconds) +{ + if(seconds < 60) + return QString(QObject::tr("%1 seconds ago")).arg(seconds) ; + else if(seconds < 120) + return QString(QObject::tr("%1 minute ago")).arg(seconds/60) ; + else if(seconds < 3600) + return QString(QObject::tr("%1 minutes ago")).arg(seconds/60) ; + else if(seconds < 7200) + return QString(QObject::tr("%1 hour ago")).arg(seconds/3600) ; + else if(seconds < 24*3600) + return QString(QObject::tr("%1 hours ago")).arg(seconds/3600) ; + else if(seconds < 2*24*3600) + return QString(QObject::tr("%1 day ago")).arg(seconds/86400) ; + else + return QString(QObject::tr("%1 days ago")).arg(seconds/86400) ; +} + void IdDialog::processSettings(bool load) { Settings->beginGroup("IdDialog"); @@ -617,8 +657,13 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item, item->setText(RSID_COL_NICKNAME, QString::fromUtf8(data.mMeta.mGroupName.c_str()).left(RSID_MAXIMUM_NICKNAME_SIZE)); item->setText(RSID_COL_KEYID, QString::fromStdString(data.mMeta.mGroupId.toStdString())); + + time_t now = time(NULL) ; + item->setText(RSID_COL_LASTUSED, getHumanReadableDuration(now - data.mLastUsageTS)) ; item->setData(RSID_COL_KEYID, Qt::UserRole,QVariant(item_flags)) ; + + item->setData(RSID_COL_LASTUSED, Qt::UserRole, QString::number(now - data.mLastUsageTS)); if(isOwnId) { @@ -770,24 +815,6 @@ void IdDialog::requestIdDetails() mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDDIALOG_IDDETAILS); } -static QString getHumanReadableDuration(uint32_t seconds) -{ - if(seconds < 60) - return QString(QObject::tr("%1 seconds ago")).arg(seconds) ; - else if(seconds < 120) - return QString(QObject::tr("%1 minute ago")).arg(seconds/60) ; - else if(seconds < 3600) - return QString(QObject::tr("%1 minutes ago")).arg(seconds/60) ; - else if(seconds < 7200) - return QString(QObject::tr("%1 hour ago")).arg(seconds/3600) ; - else if(seconds < 24*3600) - return QString(QObject::tr("%1 hours ago")).arg(seconds/3600) ; - else if(seconds < 2*24*3600) - return QString(QObject::tr("%1 day ago")).arg(seconds/86400) ; - else - return QString(QObject::tr("%1 days ago")).arg(seconds/86400) ; -} - void IdDialog::insertIdDetails(uint32_t token) { mStateHelper->setLoading(IDDIALOG_IDDETAILS, false); @@ -843,9 +870,9 @@ void IdDialog::insertIdDetails(uint32_t token) #ifdef ID_DEBUG std::cerr << "Setting header frame image : " << pix.width() << " x " << pix.height() << std::endl; #endif -#ifdef UNFINISHED_CODE + ui->avlabel->setPixmap(pixmap); -#endif + ui->avatarLabel->setPixmap(pixmap); if (data.mPgpKnown) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.h b/retroshare-gui/src/gui/Identity/IdDialog.h index 1400cc99a..53da66809 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.h +++ b/retroshare-gui/src/gui/Identity/IdDialog.h @@ -78,6 +78,7 @@ private slots: /** Create the context popup menu and it's submenus */ void IdListCustomPopupMenu( QPoint point ); + void CircleListCustomPopupMenu( QPoint point); void circle_selected(); private: diff --git a/retroshare-gui/src/gui/Identity/IdDialog.ui b/retroshare-gui/src/gui/Identity/IdDialog.ui index cde80a882..bd6b40043 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdDialog.ui @@ -6,8 +6,8 @@ 0 0 - 1226 - 1085 + 826 + 579 @@ -19,8 +19,8 @@ - - + + @@ -103,7 +103,7 @@
- + Qt::Horizontal @@ -169,7 +169,7 @@ - + 0 0 @@ -193,6 +193,11 @@ Identity ID + + + Last Activity + + Owned by @@ -200,453 +205,524 @@ - - - - People - - - - - - - - 0 - 0 - - - - Identity info - - - - - - 6 - - - - - true - - - true - - - - - - - Identity name : - - - - - - - Identity ID : - - - - - - - Owner node ID : - - - - - - - true - - - true - - - - - - - true - - - true - - - - - - - Owner node name : - - - - - - - true - - - true - - - - - - - Type: - - - - - - - - - - Last used: - - - - - - - - - - - - - - - 0 - 0 - - - - - 128 - 128 - - - - - 128 - 128 - - - - QFrame::Box - - - QFrame::Sunken - - - Your Avatar - - - true - - - Qt::AlignCenter - - - - - - - - 48 - 48 - - - - - 48 - 48 - - - - Send message - - - - - - - :/images/mail-message-new.png:/images/mail-message-new.png - - - - 48 - 48 - - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - - - 0 - 0 - - - - Reputation - - - - - - - - - 75 - true - - - - Overall - - - - - - - true - - - - - - - Implicit - - - - - - - true - - - - - - - Opinion - - - - - - - true - - - - - - - Peers - - - - - - - true - - - - - - - - - Qt::NoFocus - - - Edit reputation - - - - :/images/edit_24.png:/images/edit_24.png - - - - 24 - 24 - - - - Qt::ToolButtonTextBesideIcon - - - true - - - - - - - - - - - 0 - 0 - - - - Tweak Opinion - - - - - - Accept (+100) - - - - - - - Positive (+10) - - - - - - - Negative (-10) - - - - - - - Ban (-100) - - - - - - - - - Custom - - - - - - - -100 - - - 100 - - - - - - - - - Modify - - - - - - - -
- - - - - - Circles - - + + + 0 + + + + Circles + + + + - - - true + + + Create Circle - - - Name - - - - - IDs - - - - - Public Circles - - - - - Personal Circles - - - - - - - Edit Circle - - - - - - - Create External Circle - - - - + + + Edit Circle + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + - - - +
+ + + + Qt::CustomContextMenu + + + true + + + + Name + + + + + IDs + + + + + Public Circles + + + + + Personal Circles + + + + +
+ + + + Person + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + 12 + + + + + + 64 + 64 + + + + + 64 + 64 + + + + + + + + + + true + + + + + + + People + + + + + + + + 48 + 48 + + + + + 48 + 48 + + + + Send message + + + + + + + :/images/mail-message-new.png:/images/mail-message-new.png + + + + 48 + 48 + + + + true + + + + + + + + + + Identity info + + + + + + 6 + + + + + Identity name : + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Identity ID : + + + + + + + Owner node ID : + + + + + + + true + + + true + + + + + + + true + + + true + + + + + + + true + + + true + + + + + + + Owner node name : + + + + + + + true + + + true + + + + + + + Type: + + + + + + + + + + Last used: + + + + + + + + + + + + + + + 0 + 0 + + + + + 128 + 128 + + + + + 128 + 128 + + + + QFrame::Box + + + QFrame::Sunken + + + Your Avatar + + + true + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + 0 + 0 + + + + Reputation + + + + + + + + + 75 + true + + + + Overall + + + + + + + true + + + + + + + Implicit + + + + + + + true + + + + + + + Opinion + + + + + + + true + + + + + + + Peers + + + + + + + true + + + + + + + + + Qt::NoFocus + + + Edit reputation + + + + :/images/edit_24.png:/images/edit_24.png + + + + 24 + 24 + + + + Qt::ToolButtonTextBesideIcon + + + true + + + + + + + + + + + 0 + 0 + + + + Tweak Opinion + + + + + + Accept (+100) + + + + + + + Positive (+10) + + + + + + + Negative (-10) + + + + + + + Ban (-100) + + + + + + + + + Custom + + + + + + + -100 + + + 100 + + + + + + + + + Modify + + + + + + + + + + detailsGroupBox + headerFrame + @@ -686,16 +762,16 @@ - - StyledLabel - QLabel -
gui/common/StyledLabel.h
-
StyledElidedLabel QLabel
gui/common/StyledElidedLabel.h
+ + StyledLabel + QLabel +
gui/common/StyledLabel.h
+
RSTreeWidget QTreeWidget @@ -709,13 +785,6 @@
idTreeWidget - lineEdit_Nickname - lineEdit_KeyId - lineEdit_GpgId - lineEdit_GpgName - line_RatingOverall - line_RatingImplicit - line_RatingOwn