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
This commit is contained in:
defnax 2014-09-29 14:47:34 +00:00
parent cef70ef3df
commit 80c49e2a62
6 changed files with 561 additions and 95 deletions

View File

@ -0,0 +1,162 @@
#include "gui/gxs/GxsIdDetails.h"
#include "gui/People/CircleWidget.h"
#include "ui_CircleWidget.h"
#include <retroshare/rspeers.h>
#include <QDrag>
#include <QMimeData>
#include <QGraphicsProxyWidget>
#include <QtCore/qmath.h>
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<RsGxsId>::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<RsPgpId, std::list<RsGxsId> >::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<RsGxsId> gxs_id_list = it->second;
typedef std::list<RsGxsId>::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<RsGxsId, IdentityWidget*>::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)
}

View File

@ -0,0 +1,54 @@
#ifndef CIRCLEWIDGET_H
#define CIRCLEWIDGET_H
#include "gui/common/FlowLayout.h"
#include "gui/People/IdentityWidget.h"
#include <QWidget>
#include <QGraphicsScene>
#include <retroshare/rsgxscircles.h>
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<RsGxsId, IdentityWidget*> 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<RsGxsId, IdentityWidget*> _list;
RsGroupMetaData _group_info ;
RsGxsCircleDetails _circle_details ;
Ui::CircleWidget *ui;
};
#endif // CIRCLEWIDGET_H

View File

@ -0,0 +1,145 @@
#include "gui/People/IdentityWidget.h"
#include "ui_IdentityWidget.h"
#include "gui/common/AvatarDefs.h"
#include <gui/gxs/GxsIdDetails.h>
#include <QDrag>
#include <QMimeData>
#include <QGraphicsProxyWidget>
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;
}*/

View File

@ -0,0 +1,47 @@
#ifndef IDENTITYWIDGET_H
#define IDENTITYWIDGET_H
#include "gui/common/FlowLayout.h"
#include <QWidget>
#include <QGraphicsScene>
#include <retroshare/rsidentity.h>
#include <retroshare/rspeers.h>
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

View File

@ -2,6 +2,14 @@
<ui version="4.0">
<class>IdentityWidget</class>
<widget class="QWidget" name="IdentityWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>102</width>
<height>153</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
@ -56,6 +64,9 @@
<property name="text">
<string>Name</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
@ -63,6 +74,12 @@
</item>
<item>
<widget class="QLabel" name="labelKeyId">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>KeyId</string>
</property>

View File

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>913</width>
<width>727</width>
<height>524</height>
</rect>
</property>
@ -19,105 +19,146 @@
<property name="windowTitle">
<string/>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="titleBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="margin">
<number>2</number>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Suggestions&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QFrame" name="titleBarFrame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<property name="margin">
<number>2</number>
</property>
<item>
<widget class="QLabel" name="titleBarPixmap_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<item>
<widget class="QLabel" name="titleBarPixmap_3">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/identity/identities_32.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="titleBarLabel_3">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;People&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="titleBarSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/identity/identities_32.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
<widget class="FlowLayoutWidget" name="id">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>891</width>
<height>373</height>
</rect>
</widget>
</item>
<item>
<widget class="QLabel" name="titleBarLabel_3">
<property name="font">
<font>
<pointsize>10</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;People&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="titleBarSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QScrollArea" name="scrollArea">
<property name="minimumSize">
<size>
<width>0</width>
<height>250</height>
</size>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="FlowLayoutWidget" name="id">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>707</width>
<height>248</height>
</rect>
</property>
<layout class="QVBoxLayout"/>
</widget>
</widget>
<widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="text">
<string>Drag people to your Circles</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
<layout class="QVBoxLayout"/>
</widget>
</widget>
<widget class="PictureFlow" name="pictureFlowWidget" native="true">
<property name="widgetResizable" stdset="0">
<bool>true</bool>
</property>
</widget>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="PictureFlow" name="pictureFlowWidget" native="true">
<property name="widgetResizable" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>