From 80c49e2a62f22dd0ac735598a58cfbcc18b24b61 Mon Sep 17 00:00:00 2001 From: defnax Date: Mon, 29 Sep 2014 14:47:34 +0000 Subject: [PATCH] Added forgotten files Added some useful labels for the people page git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7575 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- .../src/gui/People/CircleWidget.cpp | 162 ++++++++++++ retroshare-gui/src/gui/People/CircleWidget.h | 54 ++++ .../src/gui/People/IdentityWidget.cpp | 145 +++++++++++ .../src/gui/People/IdentityWidget.h | 47 ++++ .../src/gui/People/IdentityWidget.ui | 17 ++ retroshare-gui/src/gui/People/PeopleDialog.ui | 231 +++++++++++------- 6 files changed, 561 insertions(+), 95 deletions(-) create mode 100644 retroshare-gui/src/gui/People/CircleWidget.cpp create mode 100644 retroshare-gui/src/gui/People/CircleWidget.h create mode 100644 retroshare-gui/src/gui/People/IdentityWidget.cpp create mode 100644 retroshare-gui/src/gui/People/IdentityWidget.h diff --git a/retroshare-gui/src/gui/People/CircleWidget.cpp b/retroshare-gui/src/gui/People/CircleWidget.cpp new file mode 100644 index 000000000..a134bf0f5 --- /dev/null +++ b/retroshare-gui/src/gui/People/CircleWidget.cpp @@ -0,0 +1,162 @@ +#include "gui/gxs/GxsIdDetails.h" +#include "gui/People/CircleWidget.h" +#include "ui_CircleWidget.h" +#include +#include +#include +#include +#include + +CircleWidget::CircleWidget(QString name/*=QString()*/ + , QWidget *parent/*=0*/) : + FlowLayoutItem(name, parent), + ui(new Ui::CircleWidget) +{ + ui->setupUi(this); + std::string desc_string = _group_info.mGroupName ; + QString cirName = QString::fromUtf8(desc_string.c_str()); + if (name=="") m_myName = cirName; + ui->label->setText(m_myName); + _scene = new QGraphicsScene(this); + _scene->addText(tr("Empty %1").arg(getName())); + ui->graphicsView->setScene(_scene); + + //To grab events + ui->graphicsView->setEnabled(false); + + ui->graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop); + + setIsCurrent(false); + setIsSelected(false); + setAcceptDrops(true); +} + +CircleWidget::~CircleWidget() +{ + delete _scene; + delete ui; +} + +void CircleWidget::updateData(const RsGroupMetaData& gxs_group_info + , const RsGxsCircleDetails& details) +{ + if (_group_info != gxs_group_info) { + _group_info=gxs_group_info; + std::string desc_string = _group_info.mGroupName ; + QString cirName = QString::fromUtf8(desc_string.c_str()); + m_myName = cirName; + ui->label->setText(m_myName); + update(); + }//if (gxs_group_info!=_group_info) + + if (_circle_details != details) { + _circle_details=details; + typedef std::set::iterator itUnknownPeers; + for (itUnknownPeers it = _circle_details.mUnknownPeers.begin() + ; it != _circle_details.mUnknownPeers.end() + ; ++it) { + RsGxsId gxs_id = *it; + if(!gxs_id.isNull()) { + emit askForGXSIdentityWidget(gxs_id); + }//if(!gxs_id.isNull()) + }//for (itUnknownPeers it = _circle_details.mUnknownPeers.begin() + + typedef std::map >::const_iterator itAllowedPeers; + for (itAllowedPeers it = _circle_details.mAllowedPeers.begin() + ; it != _circle_details.mAllowedPeers.end() + ; ++it ) { + RsPgpId id = it->first; + emit askForPGPIdentityWidget(id); + + ///** (TODO) Is it needed? + std::list gxs_id_list = it->second; + typedef std::list::const_iterator itGxsId; + for (itGxsId curs=gxs_id_list.begin() + ; curs != gxs_id_list.end() + ; ++curs) { + RsGxsId gxs_id = *curs; + if(!gxs_id.isNull()) { + emit askForGXSIdentityWidget(gxs_id); + }//if(!gxs_id.isNull()) + }//for (itGxsId curs=gxs_id_list.begin() + //*// + }//for (itAllowedPeers it = _circle_details.mAllowedPeers.begin() + + update(); + }//if (details!=_circle_details) +} + +QSize CircleWidget::sizeHint() +{ + QSize size; + size.setHeight(ui->graphicsView->size().height() + ui->label->size().height()); + size.setWidth(ui->graphicsView->size().width() > ui->label->size().width() + ?ui->graphicsView->size().width() : ui->label->size().width()); + return size; +} + +const QPixmap CircleWidget::getImage() +{ +#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) + //return ui->graphicsView->grab(); //QT5 + return this->grab(); //QT5 +#else + //return QPixmap::grabWidget(ui->graphicsView); + return QPixmap::grabWidget(this); +#endif +} + +const QPixmap CircleWidget::getDragImage() +{ +#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) + return ui->graphicsView->grab(); + //return this->grab(); //QT5 +#else + return QPixmap::grabWidget(ui->graphicsView); + //return QPixmap::grabWidget(this); +#endif +} + +void CircleWidget::addIdent(IdentityWidget *item) +{ + if (item){ + RsGxsId id = RsGxsId(item->groupInfo().mMeta.mGroupId); + if (!_list.contains(id)){ + _list[id] = item; + updateScene(); + }//if (!list.contains(item)) + }//if (item) +} + +void CircleWidget::updateScene() +{ + const qreal PI = qAtan(1.0)*4; + int count=_list.size(); + qreal pitch = (2*PI) / count; + + _scene->clear(); + + QRect r = ui->graphicsView->geometry(); + QBrush b = QBrush(QColor(Qt::black)); + QPen p = QPen(b, 4.0); + qreal topleftX = r.width()/8; + qreal topleftY = r.height()/8; + qreal radiusX = 3*topleftX; + qreal radiusY = 3*topleftY; + QGraphicsEllipseItem* ellipse = _scene->addEllipse(0, 0, radiusX*2, radiusY*2, p); + ellipse->setPos(topleftX, topleftY); + qreal sizeX = topleftX*2; + qreal sizeY = topleftY*2; + + int curs = 0; + typedef QMap::const_iterator itList; + for (itList it=_list.constBegin(); it!=_list.constEnd(); ++it){ + QPixmap pix = it.value()->getImage(); + pix = pix.scaled(sizeX, sizeY); + QGraphicsPixmapItem* item = _scene->addPixmap(pix); + qreal x = (qCos(curs*pitch)*radiusX)-(sizeX/2)+topleftX+radiusX; + qreal y = (qSin(curs*pitch)*radiusY)-(sizeY/2)+topleftY+radiusY; + item->setPos(QPointF(x, y)); + ++curs; + }//for (itList it=_list.constBegin(); it!=_list.constEnd(); ++it) +} diff --git a/retroshare-gui/src/gui/People/CircleWidget.h b/retroshare-gui/src/gui/People/CircleWidget.h new file mode 100644 index 000000000..ad598798c --- /dev/null +++ b/retroshare-gui/src/gui/People/CircleWidget.h @@ -0,0 +1,54 @@ +#ifndef CIRCLEWIDGET_H +#define CIRCLEWIDGET_H + +#include "gui/common/FlowLayout.h" +#include "gui/People/IdentityWidget.h" +#include +#include + +#include + +namespace Ui { +class CircleWidget; +} + +class CircleWidget : public FlowLayoutItem +{ + Q_OBJECT + +public: + explicit CircleWidget(QString name = QString() + , QWidget *parent = 0); + ~CircleWidget(); + void updateData(const RsGroupMetaData& gxs_group_info + , const RsGxsCircleDetails& details); + + //Start QWidget Properties + QSize sizeHint(); + //Start FlowLayoutItem Properties + virtual const QPixmap getImage(); + virtual const QPixmap getDragImage(); + //End Properties + + void addIdent(IdentityWidget* item); + const QMap idents() const {return _list;} + + const RsGroupMetaData& groupInfo() const { return _group_info;} + const RsGxsCircleDetails& circleDetails() const {return _circle_details;} + +signals: + void askForGXSIdentityWidget(RsGxsId gxs_id); + void askForPGPIdentityWidget(RsPgpId pgp_id); + +private: + void updateScene(); + + QGraphicsScene* _scene; + QMap _list; + RsGroupMetaData _group_info ; + RsGxsCircleDetails _circle_details ; + + Ui::CircleWidget *ui; +}; + +#endif // CIRCLEWIDGET_H diff --git a/retroshare-gui/src/gui/People/IdentityWidget.cpp b/retroshare-gui/src/gui/People/IdentityWidget.cpp new file mode 100644 index 000000000..9bda820b4 --- /dev/null +++ b/retroshare-gui/src/gui/People/IdentityWidget.cpp @@ -0,0 +1,145 @@ +#include "gui/People/IdentityWidget.h" +#include "ui_IdentityWidget.h" + +#include "gui/common/AvatarDefs.h" +#include + +#include +#include +#include + +IdentityWidget::IdentityWidget(const RsGxsIdGroup &gxs_group_info, QString name/*=QString()*/, QWidget *parent/*=0*/) : + FlowLayoutItem(name, parent), + _group_info(gxs_group_info), + ui(new Ui::IdentityWidget) +{ + ui->setupUi(this); + _isGXS=true; + + std::string desc_string = _group_info.mMeta.mGroupName ; + QString idName = QString::fromUtf8(desc_string.c_str()); + if (name=="") m_myName = idName; + ui->labelName->setText(m_myName); + QFont font = ui->labelName->font(); + font.setItalic(false); + ui->labelKeyId->setText(QString::fromStdString(_group_info.mMeta.mGroupId.toStdString())); + ui->labelName->setFont(font); + ui->labelKeyId->setVisible(false); + + ui->pbAdd->setVisible(false); + _scene = new QGraphicsScene(this); + /// (TODO) Get real ident icon + QImage image = GxsIdDetails::makeDefaultIcon(RsGxsId(_group_info.mMeta.mGroupId)); + _scene->addPixmap(QPixmap::fromImage(image.scaled(ui->graphicsView->width(),ui->graphicsView->height()))); + //scene->setBackgroundBrush(QBrush(QColor(qrand()%255,qrand()%255,qrand()%255))); + //scene->addText(QString("Hello, %1").arg(getName())); + ui->graphicsView->setScene(_scene); + + //To grab events + ui->graphicsView->setEnabled(false); + + ui->graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop); + + setIsCurrent(false); + setIsSelected(false); + setAcceptDrops(true); +} + +IdentityWidget::IdentityWidget(const RsPeerDetails &pgp_details, QString name/*=QString()*/, QWidget *parent/*=0*/) : + FlowLayoutItem(name, parent), + _details(pgp_details), + ui(new Ui::IdentityWidget) +{ + ui->setupUi(this); + _isGXS=false; + + QString idName = QString::fromUtf8(pgp_details.name.c_str()); + if (name=="") m_myName = idName; + ui->labelName->setText(m_myName); + QFont font = ui->labelName->font(); + font.setItalic(true); + ui->labelKeyId->setText(QString::fromStdString(pgp_details.gpg_id.toStdString())); + ui->labelName->setFont(font); + ui->labelKeyId->setVisible(false); + + ui->pbAdd->setVisible(false); + _scene = new QGraphicsScene(this); + /// (TODO) Get real ident icon + QPixmap avatar; + AvatarDefs::getAvatarFromSslId(pgp_details.id.toStdString(), avatar); + _scene->addPixmap(avatar.scaled(ui->graphicsView->width(),ui->graphicsView->height())); + //scene->setBackgroundBrush(QBrush(QColor(qrand()%255,qrand()%255,qrand()%255))); + //scene->addText(QString("Hello, %1").arg(getName())); + ui->graphicsView->setScene(_scene); + + //To grab events + ui->graphicsView->setEnabled(false); + + ui->graphicsView->setAlignment(Qt::AlignLeft | Qt::AlignTop); + + setIsCurrent(false); + setIsSelected(false); + setAcceptDrops(true); +} + +IdentityWidget::~IdentityWidget() +{ + delete _scene; + delete ui; +} + +QSize IdentityWidget::sizeHint() +{ + QSize size; + size.setHeight(ui->graphicsView->size().height() + ui->labelName->size().height()); + size.setWidth(ui->graphicsView->size().width() > ui->labelName->size().width() + ?ui->graphicsView->size().width() : ui->labelName->size().width()); + return size; +} + +const QPixmap IdentityWidget::getImage() +{ +#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) + return ui->graphicsView->grab(); + //return this->grab(); //QT5 +#else + return QPixmap::grabWidget(ui->graphicsView); + //return QPixmap::grabWidget(this); +#endif +} + +const QPixmap IdentityWidget::getDragImage() +{ +#if QT_VERSION >= QT_VERSION_CHECK (5, 0, 0) + return ui->graphicsView->grab(); + //return this->grab(); //QT5 +#else + return QPixmap::grabWidget(ui->graphicsView); + //return QPixmap::grabWidget(this); +#endif +} + +void IdentityWidget::setIsSelected(bool value) +{ + m_isSelected=value; + QFont font=ui->labelName->font(); + font.setBold(value); + ui->labelName->setFont(font); +} +/* +bool IdentityWidget::isSelected() +{ + return m_isSelected; +}*/ + +void IdentityWidget::setIsCurrent(bool value) +{ + m_isCurrent=value; + ui->labelKeyId->setVisible(value); + ui->pbAdd->setVisible(value); +} +/* +bool IdentityWidget::isCurrent() +{ + return m_isCurrent; +}*/ diff --git a/retroshare-gui/src/gui/People/IdentityWidget.h b/retroshare-gui/src/gui/People/IdentityWidget.h new file mode 100644 index 000000000..e6fc57845 --- /dev/null +++ b/retroshare-gui/src/gui/People/IdentityWidget.h @@ -0,0 +1,47 @@ +#ifndef IDENTITYWIDGET_H +#define IDENTITYWIDGET_H + +#include "gui/common/FlowLayout.h" +#include +#include +#include +#include + +namespace Ui { +class IdentityWidget; +} + +class IdentityWidget : public FlowLayoutItem +{ + Q_OBJECT + +public: + explicit IdentityWidget(const RsGxsIdGroup& gxs_group_info, QString name = QString(), QWidget *parent = 0); + explicit IdentityWidget(const RsPeerDetails& gpg_details, QString name = QString(), QWidget *parent = 0); + ~IdentityWidget(); + + //Start QWidget Properties + QSize sizeHint(); + //Start FlowLayoutItem Properties + virtual const QPixmap getImage(); + virtual const QPixmap getDragImage(); + virtual void setIsSelected(bool value); + //virtual bool isSelected(); + virtual void setIsCurrent(bool value); + //virtual bool isCurrent(); + + //End Properties + const bool isGXS() { return _isGXS; } + const RsGxsIdGroup& groupInfo() const { return _group_info; } + const RsPeerDetails& details() const { return _details; } + +private: + bool _isGXS; + RsGxsIdGroup _group_info; + RsPeerDetails _details; + QGraphicsScene* _scene; + + Ui::IdentityWidget *ui; +}; + +#endif // IDENTITYWIDGET_H diff --git a/retroshare-gui/src/gui/People/IdentityWidget.ui b/retroshare-gui/src/gui/People/IdentityWidget.ui index f648900e1..169bb9318 100644 --- a/retroshare-gui/src/gui/People/IdentityWidget.ui +++ b/retroshare-gui/src/gui/People/IdentityWidget.ui @@ -2,6 +2,14 @@ IdentityWidget + + + 0 + 0 + 102 + 153 + + 0 @@ -56,6 +64,9 @@ Name + + true + Qt::AlignCenter @@ -63,6 +74,12 @@ + + + 100 + 16777215 + + KeyId diff --git a/retroshare-gui/src/gui/People/PeopleDialog.ui b/retroshare-gui/src/gui/People/PeopleDialog.ui index eab18b882..d33094348 100644 --- a/retroshare-gui/src/gui/People/PeopleDialog.ui +++ b/retroshare-gui/src/gui/People/PeopleDialog.ui @@ -6,7 +6,7 @@ 0 0 - 913 + 727 524 @@ -19,105 +19,146 @@ - - - - - - - QFrame::Box - - - QFrame::Sunken - - - - 2 + + + + + + 11 + + + + <html><head/><body><p>Suggestions</p></body></html> + + + + + + + QFrame::Box + + + QFrame::Sunken + + + + 2 + + + + + + 0 + 0 + - - - - - 0 - 0 - - - - - 24 - 24 - - - - - - - :/images/identity/identities_32.png - - - true - - - - - - - - 10 - 75 - true - - - - <html><head/><body><p>People</p></body></html> - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Vertical - - - + + + 24 + 24 + + + + + + + :/images/identity/identities_32.png + + true - - - - 0 - 0 - 891 - 373 - + + + + + + + 10 + 75 + true + + + + <html><head/><body><p>People</p></body></html> + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + + 0 + 250 + + + + true + + + + + 0 + 0 + 707 + 248 + + + + + + + + + + + + 0 + 0 + + + + + 11 + + + + Drag people to your Circles + + + Qt::AlignCenter - - - - - true - - - - - + + + + + true + + + + + +