mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
Used AvatarDialog to choose an avatar for an identity.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7913 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
b0a8eba546
commit
5dd26de35b
@ -344,18 +344,18 @@
|
|||||||
<height>128</height>
|
<height>128</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::Box</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string extracomment="Click here to change your avatar">Your Avatar</string>
|
<string extracomment="Click here to change your avatar">Your Avatar</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -23,8 +23,10 @@
|
|||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
#include "gui/Identity/IdEditDialog.h"
|
#include "IdEditDialog.h"
|
||||||
|
#include "ui_IdEditDialog.h"
|
||||||
#include "gui/common/UIStateHelper.h"
|
#include "gui/common/UIStateHelper.h"
|
||||||
|
#include "gui/common/AvatarDialog.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
#include "gui/gxs/GxsIdDetails.h"
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
@ -37,67 +39,56 @@
|
|||||||
#define IDEDITDIALOG_LOADID 1
|
#define IDEDITDIALOG_LOADID 1
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
IdEditDialog::IdEditDialog(QWidget *parent)
|
IdEditDialog::IdEditDialog(QWidget *parent) :
|
||||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
|
||||||
|
ui(new(Ui::IdEditDialog))
|
||||||
{
|
{
|
||||||
mIsNew = true;
|
mIsNew = true;
|
||||||
mLastIdName="";
|
mLastIdName="";
|
||||||
|
|
||||||
ui.setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_create_64.png"));
|
ui->headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_create_64.png"));
|
||||||
ui.headerFrame->setHeaderText(tr("Create New Identity"));
|
ui->headerFrame->setHeaderText(tr("Create New Identity"));
|
||||||
|
|
||||||
/* Setup UI helper */
|
/* Setup UI helper */
|
||||||
mStateHelper = new UIStateHelper(this);
|
mStateHelper = new UIStateHelper(this);
|
||||||
|
|
||||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_Nickname);
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui->lineEdit_Nickname);
|
||||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_KeyId);
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui->lineEdit_KeyId);
|
||||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgHash);
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui->lineEdit_GpgHash);
|
||||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgId);
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui->lineEdit_GpgId);
|
||||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui->lineEdit_GpgName);
|
||||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.radioButton_GpgId);
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui->radioButton_GpgId);
|
||||||
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui.radioButton_Pseudo);
|
mStateHelper->addWidget(IDEDITDIALOG_LOADID, ui->radioButton_Pseudo);
|
||||||
|
|
||||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_Nickname);
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui->lineEdit_Nickname);
|
||||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui->lineEdit_GpgName);
|
||||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_KeyId);
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui->lineEdit_KeyId);
|
||||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgHash);
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui->lineEdit_GpgHash);
|
||||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgId);
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui->lineEdit_GpgId);
|
||||||
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui.lineEdit_GpgName);
|
mStateHelper->addLoadPlaceholder(IDEDITDIALOG_LOADID, ui->lineEdit_GpgName);
|
||||||
|
|
||||||
/* Initialize recogn tags */
|
/* Initialize recogn tags */
|
||||||
loadRecognTags();
|
loadRecognTags();
|
||||||
|
|
||||||
/* Connect signals */
|
/* Connect signals */
|
||||||
connect(ui.radioButton_GpgId, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
connect(ui->radioButton_GpgId, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
||||||
connect(ui.radioButton_Pseudo, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
connect(ui->radioButton_Pseudo, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
|
||||||
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(submit()));
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(submit()));
|
||||||
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||||
|
|
||||||
connect(ui.plainTextEdit_Tag, SIGNAL(textChanged()), this, SLOT(checkNewTag()));
|
|
||||||
connect(ui.pushButton_Tag, SIGNAL(clicked(bool)), this, SLOT(addRecognTag()));
|
|
||||||
connect(ui.toolButton_Tag1, SIGNAL(clicked(bool)), this, SLOT(rmTag1()));
|
|
||||||
connect(ui.toolButton_Tag2, SIGNAL(clicked(bool)), this, SLOT(rmTag2()));
|
|
||||||
connect(ui.toolButton_Tag3, SIGNAL(clicked(bool)), this, SLOT(rmTag3()));
|
|
||||||
connect(ui.toolButton_Tag4, SIGNAL(clicked(bool)), this, SLOT(rmTag4()));
|
|
||||||
connect(ui.toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
|
|
||||||
connect(ui.avatarButton, SIGNAL(clicked(bool)), this, SLOT(changeAvatar()));
|
|
||||||
connect(ui.removeButton, SIGNAL(clicked(bool)), this, SLOT(removeAvatar()));
|
|
||||||
|
|
||||||
|
connect(ui->plainTextEdit_Tag, SIGNAL(textChanged()), this, SLOT(checkNewTag()));
|
||||||
|
connect(ui->pushButton_Tag, SIGNAL(clicked(bool)), this, SLOT(addRecognTag()));
|
||||||
|
connect(ui->toolButton_Tag1, SIGNAL(clicked(bool)), this, SLOT(rmTag1()));
|
||||||
|
connect(ui->toolButton_Tag2, SIGNAL(clicked(bool)), this, SLOT(rmTag2()));
|
||||||
|
connect(ui->toolButton_Tag3, SIGNAL(clicked(bool)), this, SLOT(rmTag3()));
|
||||||
|
connect(ui->toolButton_Tag4, SIGNAL(clicked(bool)), this, SLOT(rmTag4()));
|
||||||
|
connect(ui->toolButton_Tag5, SIGNAL(clicked(bool)), this, SLOT(rmTag5()));
|
||||||
|
connect(ui->avatarButton, SIGNAL(clicked(bool)), this, SLOT(changeAvatar()));
|
||||||
|
|
||||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||||
ui.pushButton_Tag->setEnabled(false);
|
ui->pushButton_Tag->setEnabled(false);
|
||||||
}
|
|
||||||
|
|
||||||
void IdEditDialog::changeAvatar()
|
|
||||||
{
|
|
||||||
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Avatar"), 128, 128);
|
|
||||||
|
|
||||||
if (img.isNull())
|
|
||||||
return;
|
|
||||||
|
|
||||||
ui.avatarLabel->setPixmap(img) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IdEditDialog::~IdEditDialog()
|
IdEditDialog::~IdEditDialog()
|
||||||
@ -105,39 +96,54 @@ IdEditDialog::~IdEditDialog()
|
|||||||
delete(mIdQueue);
|
delete(mIdQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IdEditDialog::changeAvatar()
|
||||||
|
{
|
||||||
|
AvatarDialog dialog(this);
|
||||||
|
|
||||||
|
dialog.setAvatar(mAvatar);
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
QPixmap newAvatar;
|
||||||
|
dialog.getAvatar(newAvatar);
|
||||||
|
|
||||||
|
setAvatar(newAvatar);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void IdEditDialog::setupNewId(bool pseudo)
|
void IdEditDialog::setupNewId(bool pseudo)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("New identity"));
|
setWindowTitle(tr("New identity"));
|
||||||
|
|
||||||
mIsNew = true;
|
mIsNew = true;
|
||||||
|
|
||||||
ui.lineEdit_KeyId->setText(tr("To be generated"));
|
ui->lineEdit_KeyId->setText(tr("To be generated"));
|
||||||
ui.lineEdit_Nickname->setText("");
|
ui->lineEdit_Nickname->setText("");
|
||||||
ui.radioButton_GpgId->setEnabled(true);
|
ui->radioButton_GpgId->setEnabled(true);
|
||||||
ui.radioButton_Pseudo->setEnabled(true);
|
ui->radioButton_Pseudo->setEnabled(true);
|
||||||
|
|
||||||
if (pseudo)
|
if (pseudo)
|
||||||
{
|
{
|
||||||
ui.radioButton_Pseudo->setChecked(true);
|
ui->radioButton_Pseudo->setChecked(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.radioButton_GpgId->setChecked(true);
|
ui->radioButton_GpgId->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// force - incase it wasn't triggered.
|
// force - incase it wasn't triggered.
|
||||||
idTypeToggled(true);
|
idTypeToggled(true);
|
||||||
|
|
||||||
ui.frame_Tags->setHidden(true);
|
ui->frame_Tags->setHidden(true);
|
||||||
ui.radioButton_GpgId->setEnabled(true);
|
ui->radioButton_GpgId->setEnabled(true);
|
||||||
ui.radioButton_Pseudo->setEnabled(true);
|
ui->radioButton_Pseudo->setEnabled(true);
|
||||||
|
|
||||||
|
setAvatar(QPixmap());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdEditDialog::idTypeToggled(bool checked)
|
void IdEditDialog::idTypeToggled(bool checked)
|
||||||
{
|
{
|
||||||
if (checked)
|
if (checked)
|
||||||
{
|
{
|
||||||
bool pseudo = ui.radioButton_Pseudo->isChecked();
|
bool pseudo = ui->radioButton_Pseudo->isChecked();
|
||||||
updateIdType(pseudo);
|
updateIdType(pseudo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,9 +152,9 @@ void IdEditDialog::updateIdType(bool pseudo)
|
|||||||
{
|
{
|
||||||
if (pseudo)
|
if (pseudo)
|
||||||
{
|
{
|
||||||
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
ui->lineEdit_GpgHash->setText(tr("N/A"));
|
||||||
ui.lineEdit_GpgId->setText(tr("N/A"));
|
ui->lineEdit_GpgId->setText(tr("N/A"));
|
||||||
ui.lineEdit_GpgName->setText(tr("N/A"));
|
ui->lineEdit_GpgName->setText(tr("N/A"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -157,17 +163,29 @@ void IdEditDialog::updateIdType(bool pseudo)
|
|||||||
RsPeerDetails details;
|
RsPeerDetails details;
|
||||||
rsPeers->getGPGDetails(gpgid, details);
|
rsPeers->getGPGDetails(gpgid, details);
|
||||||
|
|
||||||
ui.lineEdit_GpgId->setText(QString::fromStdString(gpgid.toStdString()));
|
ui->lineEdit_GpgId->setText(QString::fromStdString(gpgid.toStdString()));
|
||||||
ui.lineEdit_GpgHash->setText(tr("To be generated"));
|
ui->lineEdit_GpgHash->setText(tr("To be generated"));
|
||||||
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
ui->lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IdEditDialog::setAvatar(const QPixmap &avatar)
|
||||||
|
{
|
||||||
|
mAvatar = avatar;
|
||||||
|
|
||||||
|
if (!mAvatar.isNull()) {
|
||||||
|
ui->avatarLabel->setPixmap(mAvatar);
|
||||||
|
} else {
|
||||||
|
// we need to use the default pixmap here, generated from the ID
|
||||||
|
ui->avatarLabel->setPixmap(QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(mEditGroup.mMeta.mGroupId))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdEditDialog::setupExistingId(std::string keyId)
|
void IdEditDialog::setupExistingId(std::string keyId)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Edit identity"));
|
setWindowTitle(tr("Edit identity"));
|
||||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_edit_64.png"));
|
ui->headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_edit_64.png"));
|
||||||
ui.headerFrame->setHeaderText(tr("Edit identity"));
|
ui->headerFrame->setHeaderText(tr("Edit identity"));
|
||||||
|
|
||||||
mIsNew = false;
|
mIsNew = false;
|
||||||
|
|
||||||
@ -191,81 +209,81 @@ void IdEditDialog::loadExistingId(uint32_t token)
|
|||||||
std::vector<RsGxsIdGroup> datavector;
|
std::vector<RsGxsIdGroup> datavector;
|
||||||
if (!rsIdentity->getGroupData(token, datavector))
|
if (!rsIdentity->getGroupData(token, datavector))
|
||||||
{
|
{
|
||||||
ui.lineEdit_KeyId->setText(tr("Error getting key!"));
|
ui->lineEdit_KeyId->setText(tr("Error getting key!"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mEditGroup = datavector[0];
|
|
||||||
QPixmap pixmap;
|
|
||||||
|
|
||||||
|
|
||||||
if(mEditGroup.mImage.mSize > 0 && pixmap.loadFromData(mEditGroup.mImage.mData, mEditGroup.mImage.mSize, "PNG"))
|
|
||||||
ui.avatarLabel->setPixmap(pixmap);
|
|
||||||
else
|
|
||||||
pixmap = QPixmap::fromImage(GxsIdDetails::makeDefaultIcon(RsGxsId(mEditGroup.mMeta.mGroupId))) ;
|
|
||||||
ui.avatarLabel->setPixmap(pixmap); // we need to use the default pixmap here, generated from the ID
|
|
||||||
|
|
||||||
if (datavector.size() != 1)
|
if (datavector.size() != 1)
|
||||||
{
|
{
|
||||||
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
ui.lineEdit_KeyId->setText(tr("Error KeyID invalid"));
|
ui->lineEdit_KeyId->setText(tr("Error KeyID invalid"));
|
||||||
ui.lineEdit_Nickname->setText("");
|
ui->lineEdit_Nickname->setText("");
|
||||||
|
|
||||||
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
ui->lineEdit_GpgHash->setText(tr("N/A"));
|
||||||
ui.lineEdit_GpgId->setText(tr("N/A"));
|
ui->lineEdit_GpgId->setText(tr("N/A"));
|
||||||
ui.lineEdit_GpgName->setText(tr("N/A"));
|
ui->lineEdit_GpgName->setText(tr("N/A"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mEditGroup = datavector[0];
|
||||||
|
QPixmap avatar;
|
||||||
|
|
||||||
|
if (mEditGroup.mImage.mSize > 0) {
|
||||||
|
avatar.loadFromData(mEditGroup.mImage.mData, mEditGroup.mImage.mSize, "PNG");
|
||||||
|
}
|
||||||
|
|
||||||
|
setAvatar(avatar);
|
||||||
|
|
||||||
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
bool realid = (mEditGroup.mMeta.mGroupFlags & RSGXSID_GROUPFLAG_REALID);
|
||||||
|
|
||||||
if (realid)
|
if (realid)
|
||||||
{
|
{
|
||||||
ui.radioButton_GpgId->setChecked(true);
|
ui->radioButton_GpgId->setChecked(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.radioButton_Pseudo->setChecked(true);
|
ui->radioButton_Pseudo->setChecked(true);
|
||||||
}
|
}
|
||||||
// these are not editable for existing Id.
|
// these are not editable for existing Id.
|
||||||
ui.radioButton_GpgId->setEnabled(false);
|
ui->radioButton_GpgId->setEnabled(false);
|
||||||
ui.radioButton_Pseudo->setEnabled(false);
|
ui->radioButton_Pseudo->setEnabled(false);
|
||||||
|
|
||||||
// DOES THIS TRIGGER ALREADY???
|
// DOES THIS TRIGGER ALREADY???
|
||||||
// force - incase it wasn't triggered.
|
// force - incase it wasn't triggered.
|
||||||
idTypeToggled(true);
|
idTypeToggled(true);
|
||||||
|
|
||||||
ui.lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str()));
|
ui->lineEdit_Nickname->setText(QString::fromUtf8(mEditGroup.mMeta.mGroupName.c_str()));
|
||||||
ui.lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId.toStdString()));
|
ui->lineEdit_KeyId->setText(QString::fromStdString(mEditGroup.mMeta.mGroupId.toStdString()));
|
||||||
|
|
||||||
if (realid)
|
if (realid)
|
||||||
{
|
{
|
||||||
ui.lineEdit_GpgHash->setText(QString::fromStdString(mEditGroup.mPgpIdHash.toStdString()));
|
ui->lineEdit_GpgHash->setText(QString::fromStdString(mEditGroup.mPgpIdHash.toStdString()));
|
||||||
|
|
||||||
if (mEditGroup.mPgpKnown)
|
if (mEditGroup.mPgpKnown)
|
||||||
{
|
{
|
||||||
RsPeerDetails details;
|
RsPeerDetails details;
|
||||||
rsPeers->getGPGDetails(mEditGroup.mPgpId, details);
|
rsPeers->getGPGDetails(mEditGroup.mPgpId, details);
|
||||||
ui.lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
ui->lineEdit_GpgName->setText(QString::fromUtf8(details.name.c_str()));
|
||||||
|
|
||||||
ui.lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId.toStdString()));
|
ui->lineEdit_GpgId->setText(QString::fromStdString(mEditGroup.mPgpId.toStdString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.lineEdit_GpgId->setText(tr("Unknown GpgId"));
|
ui->lineEdit_GpgId->setText(tr("Unknown GpgId"));
|
||||||
ui.lineEdit_GpgName->setText(tr("Unknown real name"));
|
ui->lineEdit_GpgName->setText(tr("Unknown real name"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ui.lineEdit_GpgHash->setText(tr("N/A"));
|
ui->lineEdit_GpgHash->setText(tr("N/A"));
|
||||||
ui.lineEdit_GpgId->setText(tr("N/A"));
|
ui->lineEdit_GpgId->setText(tr("N/A"));
|
||||||
ui.lineEdit_GpgName->setText(tr("N/A"));
|
ui->lineEdit_GpgName->setText(tr("N/A"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// RecognTags.
|
// RecognTags.
|
||||||
ui.frame_Tags->setHidden(false);
|
ui->frame_Tags->setHidden(false);
|
||||||
|
|
||||||
loadRecognTags();
|
loadRecognTags();
|
||||||
}
|
}
|
||||||
@ -274,13 +292,13 @@ void IdEditDialog::loadExistingId(uint32_t token)
|
|||||||
|
|
||||||
void IdEditDialog::checkNewTag()
|
void IdEditDialog::checkNewTag()
|
||||||
{
|
{
|
||||||
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
|
std::string tag = ui->plainTextEdit_Tag->toPlainText().toStdString();
|
||||||
RsGxsId id ( ui.lineEdit_KeyId->text().toStdString());
|
RsGxsId id ( ui->lineEdit_KeyId->text().toStdString());
|
||||||
std::string name = ui.lineEdit_Nickname->text().toUtf8().data();
|
std::string name = ui->lineEdit_Nickname->text().toUtf8().data();
|
||||||
|
|
||||||
QString desc;
|
QString desc;
|
||||||
bool ok = tagDetails(id, name, tag, desc);
|
bool ok = tagDetails(id, name, tag, desc);
|
||||||
ui.label_TagCheck->setText(desc);
|
ui->label_TagCheck->setText(desc);
|
||||||
|
|
||||||
// hack to allow add invalid tags (for testing).
|
// hack to allow add invalid tags (for testing).
|
||||||
if (!tag.empty())
|
if (!tag.empty())
|
||||||
@ -293,12 +311,12 @@ void IdEditDialog::checkNewTag()
|
|||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.pushButton_Tag->setEnabled(ok);
|
ui->pushButton_Tag->setEnabled(ok);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdEditDialog::addRecognTag()
|
void IdEditDialog::addRecognTag()
|
||||||
{
|
{
|
||||||
std::string tag = ui.plainTextEdit_Tag->toPlainText().toStdString();
|
std::string tag = ui->plainTextEdit_Tag->toPlainText().toStdString();
|
||||||
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
|
if (mEditGroup.mRecognTags.size() >= MAX_RECOGN_TAGS)
|
||||||
{
|
{
|
||||||
std::cerr << "IdEditDialog::addRecognTag() Too many Tags, delete one first";
|
std::cerr << "IdEditDialog::addRecognTag() Too many Tags, delete one first";
|
||||||
@ -394,17 +412,17 @@ void IdEditDialog::loadRecognTags()
|
|||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
// delete existing items.
|
// delete existing items.
|
||||||
ui.label_Tag1->setHidden(true);
|
ui->label_Tag1->setHidden(true);
|
||||||
ui.label_Tag2->setHidden(true);
|
ui->label_Tag2->setHidden(true);
|
||||||
ui.label_Tag3->setHidden(true);
|
ui->label_Tag3->setHidden(true);
|
||||||
ui.label_Tag4->setHidden(true);
|
ui->label_Tag4->setHidden(true);
|
||||||
ui.label_Tag5->setHidden(true);
|
ui->label_Tag5->setHidden(true);
|
||||||
ui.toolButton_Tag1->setHidden(true);
|
ui->toolButton_Tag1->setHidden(true);
|
||||||
ui.toolButton_Tag2->setHidden(true);
|
ui->toolButton_Tag2->setHidden(true);
|
||||||
ui.toolButton_Tag3->setHidden(true);
|
ui->toolButton_Tag3->setHidden(true);
|
||||||
ui.toolButton_Tag4->setHidden(true);
|
ui->toolButton_Tag4->setHidden(true);
|
||||||
ui.toolButton_Tag5->setHidden(true);
|
ui->toolButton_Tag5->setHidden(true);
|
||||||
ui.plainTextEdit_Tag->setPlainText("");
|
ui->plainTextEdit_Tag->setPlainText("");
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
std::list<std::string>::const_iterator it;
|
std::list<std::string>::const_iterator it;
|
||||||
@ -417,29 +435,29 @@ void IdEditDialog::loadRecognTags()
|
|||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
ui.label_Tag1->setText(recognTag);
|
ui->label_Tag1->setText(recognTag);
|
||||||
ui.label_Tag1->setHidden(false);
|
ui->label_Tag1->setHidden(false);
|
||||||
ui.toolButton_Tag1->setHidden(false);
|
ui->toolButton_Tag1->setHidden(false);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ui.label_Tag2->setText(recognTag);
|
ui->label_Tag2->setText(recognTag);
|
||||||
ui.label_Tag2->setHidden(false);
|
ui->label_Tag2->setHidden(false);
|
||||||
ui.toolButton_Tag2->setHidden(false);
|
ui->toolButton_Tag2->setHidden(false);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ui.label_Tag3->setText(recognTag);
|
ui->label_Tag3->setText(recognTag);
|
||||||
ui.label_Tag3->setHidden(false);
|
ui->label_Tag3->setHidden(false);
|
||||||
ui.toolButton_Tag3->setHidden(false);
|
ui->toolButton_Tag3->setHidden(false);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ui.label_Tag4->setText(recognTag);
|
ui->label_Tag4->setText(recognTag);
|
||||||
ui.label_Tag4->setHidden(false);
|
ui->label_Tag4->setHidden(false);
|
||||||
ui.toolButton_Tag4->setHidden(false);
|
ui->toolButton_Tag4->setHidden(false);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
ui.label_Tag5->setText(recognTag);
|
ui->label_Tag5->setText(recognTag);
|
||||||
ui.label_Tag5->setHidden(false);
|
ui->label_Tag5->setHidden(false);
|
||||||
ui.toolButton_Tag5->setHidden(false);
|
ui->toolButton_Tag5->setHidden(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -459,7 +477,7 @@ void IdEditDialog::submit()
|
|||||||
|
|
||||||
void IdEditDialog::createId()
|
void IdEditDialog::createId()
|
||||||
{
|
{
|
||||||
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
|
std::string groupname = ui->lineEdit_Nickname->text().toUtf8().constData();
|
||||||
|
|
||||||
if (groupname.size() < 2)
|
if (groupname.size() < 2)
|
||||||
{
|
{
|
||||||
@ -470,17 +488,15 @@ void IdEditDialog::createId()
|
|||||||
|
|
||||||
RsIdentityParameters params;
|
RsIdentityParameters params;
|
||||||
params.nickname = groupname;
|
params.nickname = groupname;
|
||||||
params.isPgpLinked = (ui.radioButton_GpgId->isChecked());
|
params.isPgpLinked = (ui->radioButton_GpgId->isChecked());
|
||||||
|
|
||||||
const QPixmap *pixmap = ui.avatarLabel->pixmap();
|
if (!mAvatar.isNull())
|
||||||
|
|
||||||
if (pixmap && !pixmap->isNull())
|
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QBuffer buffer(&ba);
|
QBuffer buffer(&ba);
|
||||||
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
|
mAvatar.save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||||
|
|
||||||
params.mImage.copy((uint8_t *) ba.data(), ba.size());
|
params.mImage.copy((uint8_t *) ba.data(), ba.size());
|
||||||
}
|
}
|
||||||
@ -497,7 +513,7 @@ void IdEditDialog::createId()
|
|||||||
void IdEditDialog::updateId()
|
void IdEditDialog::updateId()
|
||||||
{
|
{
|
||||||
/* submit updated details */
|
/* submit updated details */
|
||||||
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
|
std::string groupname = ui->lineEdit_Nickname->text().toUtf8().constData();
|
||||||
|
|
||||||
if (groupname.size() < 2)
|
if (groupname.size() < 2)
|
||||||
{
|
{
|
||||||
@ -508,15 +524,13 @@ void IdEditDialog::updateId()
|
|||||||
|
|
||||||
mEditGroup.mMeta.mGroupName = groupname;
|
mEditGroup.mMeta.mGroupName = groupname;
|
||||||
|
|
||||||
const QPixmap *pixmap = ui.avatarLabel->pixmap();
|
if (!mAvatar.isNull())
|
||||||
|
|
||||||
if (pixmap && !pixmap->isNull())
|
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
QBuffer buffer(&ba);
|
QBuffer buffer(&ba);
|
||||||
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
|
mAvatar.save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||||
|
|
||||||
mEditGroup.mImage.copy((uint8_t *) ba.data(), ba.size());
|
mEditGroup.mImage.copy((uint8_t *) ba.data(), ba.size());
|
||||||
}
|
}
|
||||||
@ -526,7 +540,6 @@ void IdEditDialog::updateId()
|
|||||||
uint32_t dummyToken = 0;
|
uint32_t dummyToken = 0;
|
||||||
rsIdentity->updateIdentity(dummyToken, mEditGroup);
|
rsIdentity->updateIdentity(dummyToken, mEditGroup);
|
||||||
|
|
||||||
|
|
||||||
mLastIdName = groupname;
|
mLastIdName = groupname;
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
@ -539,16 +552,3 @@ void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &
|
|||||||
// only one here!
|
// only one here!
|
||||||
loadExistingId(req.mToken);
|
loadExistingId(req.mToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdEditDialog::removeAvatar()
|
|
||||||
{
|
|
||||||
/* submit updated details */
|
|
||||||
std::string groupname = ui.lineEdit_Nickname->text().toUtf8().constData();
|
|
||||||
|
|
||||||
mEditGroup.mMeta.mGroupName = groupname;
|
|
||||||
mEditGroup.mImage.clear();
|
|
||||||
ui.avatarLabel->setPixmap(QPixmap());
|
|
||||||
|
|
||||||
uint32_t dummyToken = 0;
|
|
||||||
rsIdentity->updateIdentity(dummyToken, mEditGroup);
|
|
||||||
}
|
|
||||||
|
@ -24,17 +24,19 @@
|
|||||||
#ifndef IDEDITDIALOG_H
|
#ifndef IDEDITDIALOG_H
|
||||||
#define IDEDITDIALOG_H
|
#define IDEDITDIALOG_H
|
||||||
|
|
||||||
#include "ui_IdEditDialog.h"
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "util/TokenQueue.h"
|
#include "util/TokenQueue.h"
|
||||||
#include <retroshare/rsidentity.h>
|
#include <retroshare/rsidentity.h>
|
||||||
#include <retroshare/rsgxsifacetypes.h>
|
#include <retroshare/rsgxsifacetypes.h>
|
||||||
#include <QString>
|
#include <QDialog>
|
||||||
|
|
||||||
class UIStateHelper;
|
class UIStateHelper;
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class IdEditDialog;
|
||||||
|
}
|
||||||
|
|
||||||
class IdEditDialog : public QDialog, public TokenResponse
|
class IdEditDialog : public QDialog, public TokenResponse
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -55,7 +57,6 @@ private slots:
|
|||||||
void submit();
|
void submit();
|
||||||
|
|
||||||
void changeAvatar();
|
void changeAvatar();
|
||||||
void removeAvatar();
|
|
||||||
|
|
||||||
void addRecognTag();
|
void addRecognTag();
|
||||||
void checkNewTag();
|
void checkNewTag();
|
||||||
@ -70,6 +71,7 @@ private:
|
|||||||
void updateId();
|
void updateId();
|
||||||
void updateIdType(bool pseudo);
|
void updateIdType(bool pseudo);
|
||||||
void loadExistingId(uint32_t token);
|
void loadExistingId(uint32_t token);
|
||||||
|
void setAvatar(const QPixmap &avatar);
|
||||||
|
|
||||||
void loadRecognTags();
|
void loadRecognTags();
|
||||||
// extract details.
|
// extract details.
|
||||||
@ -77,7 +79,7 @@ private:
|
|||||||
void rmTag(int idx);
|
void rmTag(int idx);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Ui::IdEditDialog ui;
|
Ui::IdEditDialog *ui;
|
||||||
bool mIsNew;
|
bool mIsNew;
|
||||||
UIStateHelper *mStateHelper;
|
UIStateHelper *mStateHelper;
|
||||||
|
|
||||||
@ -85,6 +87,8 @@ protected:
|
|||||||
|
|
||||||
TokenQueue *mIdQueue;
|
TokenQueue *mIdQueue;
|
||||||
std::string mLastIdName;
|
std::string mLastIdName;
|
||||||
|
|
||||||
|
QPixmap mAvatar; // Avatar from identity (not calculated)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -218,18 +218,18 @@
|
|||||||
<height>128</height>
|
<height>128</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::Box</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string extracomment="Click here to change your avatar">Your Avatar</string>
|
<string extracomment="Click here to change your avatar">Your Avatar</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
@ -239,16 +239,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="removeButton">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Remove Avatar</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_3">
|
<spacer name="verticalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -23,42 +23,34 @@
|
|||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
|
||||||
#include "gui/common/AvatarDialog.h"
|
#include "AvatarDialog.h"
|
||||||
#include "gui/common/AvatarDefs.h"
|
#include "ui_AvatarDialog.h"
|
||||||
|
#include "AvatarDefs.h"
|
||||||
#include "gui/gxs/GxsIdDetails.h"
|
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include "util/misc.h"
|
#include "util/misc.h"
|
||||||
|
|
||||||
#include <retroshare/rsidentity.h>
|
|
||||||
#include <retroshare/rspeers.h>
|
|
||||||
#include <retroshare/rsmsgs.h>
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
AvatarDialog::AvatarDialog(QWidget *parent)
|
AvatarDialog::AvatarDialog(QWidget *parent) :
|
||||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
|
||||||
|
ui(new(Ui::AvatarDialog))
|
||||||
{
|
{
|
||||||
/* Invoke Qt Designer generated QObject setup routine */
|
/* Invoke Qt Designer generated QObject setup routine */
|
||||||
ui.setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/no_avatar_70.png"));
|
ui->headerFrame->setHeaderImage(QPixmap(":/images/no_avatar_70.png"));
|
||||||
ui.headerFrame->setHeaderText(tr("Set your Avatar picture"));
|
ui->headerFrame->setHeaderText(tr("Set your Avatar picture"));
|
||||||
|
|
||||||
|
connect(ui->avatarButton, SIGNAL(clicked(bool)), this, SLOT(changeAvatar()));
|
||||||
|
connect(ui->removeButton, SIGNAL(clicked(bool)), this, SLOT(removeAvatar()));
|
||||||
|
|
||||||
connect(ui.avatarButton, SIGNAL(clicked(bool)), this, SLOT(changeAvatar()));
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||||
connect(ui.removeButton, SIGNAL(clicked(bool)), this, SLOT(removeAvatar()));
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||||
|
|
||||||
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(saveAvatar()));
|
|
||||||
|
|
||||||
loadOwnAvatar();
|
|
||||||
|
|
||||||
|
updateInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
AvatarDialog::~AvatarDialog()
|
AvatarDialog::~AvatarDialog()
|
||||||
{
|
{
|
||||||
|
delete(ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarDialog::changeAvatar()
|
void AvatarDialog::changeAvatar()
|
||||||
@ -68,51 +60,53 @@ void AvatarDialog::changeAvatar()
|
|||||||
if (img.isNull())
|
if (img.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ui.avatarLabel->setPixmap(img) ;
|
ui->avatarLabel->setPixmap(img);
|
||||||
|
updateInterface();
|
||||||
}
|
|
||||||
|
|
||||||
void AvatarDialog::loadOwnAvatar()
|
|
||||||
{
|
|
||||||
RsPeerDetails pd ;
|
|
||||||
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
|
|
||||||
QPixmap avatar;
|
|
||||||
AvatarDefs::getOwnAvatar(avatar);
|
|
||||||
ui.avatarLabel->setPixmap(avatar);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarDialog::removeAvatar()
|
void AvatarDialog::removeAvatar()
|
||||||
{
|
{
|
||||||
ui.avatarLabel->setPixmap(NULL);
|
ui->avatarLabel->setPixmap(QPixmap());
|
||||||
|
updateInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AvatarDialog::saveAvatar()
|
void AvatarDialog::updateInterface()
|
||||||
{
|
{
|
||||||
const QPixmap *pixmap = ui.avatarLabel->pixmap();
|
const QPixmap *pixmap = ui->avatarLabel->pixmap();
|
||||||
|
if (pixmap && !pixmap->isNull()) {
|
||||||
|
ui->removeButton->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
ui->removeButton->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!pixmap->isNull())
|
void AvatarDialog::setAvatar(const QPixmap &avatar)
|
||||||
{
|
{
|
||||||
QByteArray ba;
|
ui->avatarLabel->setPixmap(avatar);
|
||||||
QBuffer buffer(&ba);
|
updateInterface();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::getAvatar(QPixmap &avatar)
|
||||||
|
{
|
||||||
|
const QPixmap *pixmap = ui->avatarLabel->pixmap();
|
||||||
|
if (!pixmap) {
|
||||||
|
avatar = QPixmap();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
avatar = *pixmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AvatarDialog::getAvatar(QByteArray &avatar)
|
||||||
|
{
|
||||||
|
const QPixmap *pixmap = ui->avatarLabel->pixmap();
|
||||||
|
if (!pixmap) {
|
||||||
|
avatar.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QBuffer buffer(&avatar);
|
||||||
|
|
||||||
buffer.open(QIODevice::WriteOnly);
|
buffer.open(QIODevice::WriteOnly);
|
||||||
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
|
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||||
|
|
||||||
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()), ba.size()) ; // last char 0 included.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AvatarDialog::setAvatar(const RsGxsImage &avatar)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void AvatarDialog::getAvatar(RsGxsImage &avatar)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,21 +24,15 @@
|
|||||||
#ifndef _AVATARDIALOG_H
|
#ifndef _AVATARDIALOG_H
|
||||||
#define _AVATARDIALOG_H
|
#define _AVATARDIALOG_H
|
||||||
|
|
||||||
#include "ui_AvatarDialog.h"
|
#include <QDialog>
|
||||||
|
|
||||||
#include <inttypes.h>
|
class QPixmap;
|
||||||
|
class QByteArray;
|
||||||
#include "util/TokenQueue.h"
|
|
||||||
#include <retroshare/rsidentity.h>
|
|
||||||
#include <retroshare/rsgxsifacetypes.h>
|
|
||||||
#include <retroshare/rsgxscommon.h>
|
|
||||||
#include <QString>
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class AvatarDialog;
|
class AvatarDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class AvatarDialog : public QDialog
|
class AvatarDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -47,19 +41,20 @@ public:
|
|||||||
AvatarDialog(QWidget *parent = 0);
|
AvatarDialog(QWidget *parent = 0);
|
||||||
~AvatarDialog();
|
~AvatarDialog();
|
||||||
|
|
||||||
void setAvatar(const RsGxsImage &avatar);
|
void setAvatar(const QPixmap &avatar);
|
||||||
void getAvatar(RsGxsImage &avatar);
|
|
||||||
|
void getAvatar(QPixmap &avatar);
|
||||||
|
void getAvatar(QByteArray &avatar);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void changeAvatar();
|
void changeAvatar();
|
||||||
void removeAvatar();
|
void removeAvatar();
|
||||||
void saveAvatar();
|
|
||||||
void loadOwnAvatar();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::AvatarDialog ui;
|
void updateInterface();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::AvatarDialog *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -55,6 +55,12 @@
|
|||||||
<height>128</height>
|
<height>128</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::Box</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Your Avatar Picture</string>
|
<string>Your Avatar Picture</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -28,8 +28,6 @@
|
|||||||
#include "gui/common/AvatarDefs.h"
|
#include "gui/common/AvatarDefs.h"
|
||||||
#include "gui/common/AvatarDialog.h"
|
#include "gui/common/AvatarDialog.h"
|
||||||
|
|
||||||
#include "util/misc.h"
|
|
||||||
|
|
||||||
#include "AvatarWidget.h"
|
#include "AvatarWidget.h"
|
||||||
#include "ui_AvatarWidget.h"
|
#include "ui_AvatarWidget.h"
|
||||||
|
|
||||||
@ -84,9 +82,21 @@ QString AvatarWidget::frameState()
|
|||||||
|
|
||||||
void AvatarWidget::mouseReleaseEvent(QMouseEvent */*event*/)
|
void AvatarWidget::mouseReleaseEvent(QMouseEvent */*event*/)
|
||||||
{
|
{
|
||||||
if (mFlag.isOwnId) {
|
if (!mFlag.isOwnId) {
|
||||||
AvatarDialog *dialog = new AvatarDialog();
|
return;
|
||||||
dialog->show();
|
}
|
||||||
|
|
||||||
|
AvatarDialog dialog(this);
|
||||||
|
|
||||||
|
QPixmap avatar;
|
||||||
|
AvatarDefs::getOwnAvatar(avatar, "");
|
||||||
|
|
||||||
|
dialog.setAvatar(avatar);
|
||||||
|
if (dialog.exec() == QDialog::Accepted) {
|
||||||
|
QByteArray newAvatar;
|
||||||
|
dialog.getAvatar(newAvatar);
|
||||||
|
|
||||||
|
rsMsgs->setOwnAvatarData((unsigned char *)(newAvatar.data()), newAvatar.size()) ; // last char 0 included.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user