mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added Avatar Dialog at the moment for own peerid, soon for gxs avatars change.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7905 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
64f8b4c539
commit
96bf79daae
118
retroshare-gui/src/gui/common/AvatarDialog.cpp
Normal file
118
retroshare-gui/src/gui/common/AvatarDialog.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Avatar Dialog
|
||||
*
|
||||
* Copyright 2015 by RetroShare Team
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QBuffer>
|
||||
|
||||
#include "gui/common/AvatarDialog.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsmsgs.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
/** Constructor */
|
||||
AvatarDialog::AvatarDialog(QWidget *parent)
|
||||
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/no_avatar_70.png"));
|
||||
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.buttonBox, SIGNAL(accepted()), this, SLOT(saveAvatar()));
|
||||
|
||||
loadOwnAvatar();
|
||||
|
||||
}
|
||||
|
||||
AvatarDialog::~AvatarDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void AvatarDialog::changeAvatar()
|
||||
{
|
||||
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Load Avatar"), 128, 128);
|
||||
|
||||
if (img.isNull())
|
||||
return;
|
||||
|
||||
ui.avatarLabel->setPixmap(img) ;
|
||||
|
||||
}
|
||||
|
||||
void AvatarDialog::loadOwnAvatar()
|
||||
{
|
||||
RsPeerDetails pd ;
|
||||
if (rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) {
|
||||
QPixmap avatar;
|
||||
AvatarDefs::getOwnAvatar(avatar);
|
||||
ui.avatarLabel->setPixmap(avatar);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void AvatarDialog::removeAvatar()
|
||||
{
|
||||
ui.avatarLabel->setPixmap(NULL);
|
||||
}
|
||||
|
||||
void AvatarDialog::saveAvatar()
|
||||
{
|
||||
const QPixmap *pixmap = ui.avatarLabel->pixmap();
|
||||
|
||||
if (!pixmap->isNull())
|
||||
{
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
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)
|
||||
{
|
||||
|
||||
}
|
65
retroshare-gui/src/gui/common/AvatarDialog.h
Normal file
65
retroshare-gui/src/gui/common/AvatarDialog.h
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Avatar Dialog.
|
||||
*
|
||||
* Copyright 2012-2012 by Robert Fernie.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License Version 2.1 as published by the Free Software Foundation.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
||||
* USA.
|
||||
*
|
||||
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _AVATARDIALOG_H
|
||||
#define _AVATARDIALOG_H
|
||||
|
||||
#include "ui_AvatarDialog.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "util/TokenQueue.h"
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rsgxsifacetypes.h>
|
||||
#include <retroshare/rsgxscommon.h>
|
||||
#include <QString>
|
||||
|
||||
namespace Ui {
|
||||
class AvatarDialog;
|
||||
}
|
||||
|
||||
|
||||
class AvatarDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AvatarDialog(QWidget *parent = 0);
|
||||
~AvatarDialog();
|
||||
|
||||
void setAvatar(const RsGxsImage &avatar);
|
||||
void getAvatar(RsGxsImage &avatar);
|
||||
|
||||
private slots:
|
||||
|
||||
void changeAvatar();
|
||||
void removeAvatar();
|
||||
void saveAvatar();
|
||||
void loadOwnAvatar();
|
||||
|
||||
private:
|
||||
Ui::AvatarDialog ui;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
210
retroshare-gui/src/gui/common/AvatarDialog.ui
Normal file
210
retroshare-gui/src/gui/common/AvatarDialog.ui
Normal file
@ -0,0 +1,210 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AvatarDialog</class>
|
||||
<widget class="QDialog" name="AvatarDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>374</width>
|
||||
<height>252</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Change Avatar</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="HeaderFrame" name="headerFrame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="avatarLabel">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>128</width>
|
||||
<height>128</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Your Avatar Picture</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="avatarButton">
|
||||
<property name="text">
|
||||
<string>Add Avatar</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="removeButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>98</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>218</width>
|
||||
<height>88</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>98</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>frame</zorder>
|
||||
<zorder>headerFrame</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>HeaderFrame</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>gui/common/HeaderFrame.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../images.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>AvatarDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>AvatarDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
@ -26,6 +26,8 @@
|
||||
|
||||
#include "gui/notifyqt.h"
|
||||
#include "gui/common/AvatarDefs.h"
|
||||
#include "gui/common/AvatarDialog.h"
|
||||
|
||||
#include "util/misc.h"
|
||||
|
||||
#include "AvatarWidget.h"
|
||||
@ -83,10 +85,8 @@ QString AvatarWidget::frameState()
|
||||
void AvatarWidget::mouseReleaseEvent(QMouseEvent */*event*/)
|
||||
{
|
||||
if (mFlag.isOwnId) {
|
||||
QByteArray ba;
|
||||
if (misc::getOpenAvatarPicture(this, ba)) {
|
||||
rsMsgs->setOwnAvatarData((unsigned char*)(ba.data()), ba.size()); // last char 0 included.
|
||||
}
|
||||
AvatarDialog *dialog = new AvatarDialog();
|
||||
dialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,6 +331,7 @@ HEADERS += rshare.h \
|
||||
gui/SoundManager.h \
|
||||
gui/HelpDialog.h \
|
||||
gui/LogoBar.h \
|
||||
gui/common/AvatarDialog.h \
|
||||
gui/FileTransfer/xprogressbar.h \
|
||||
gui/FileTransfer/DetailsDialog.h \
|
||||
gui/FileTransfer/FileTransferInfoWidget.h \
|
||||
@ -545,6 +546,7 @@ FORMS += gui/StartDialog.ui \
|
||||
gui/AboutDialog.ui \
|
||||
gui/QuickStartWizard.ui \
|
||||
gui/NetworkDialog.ui \
|
||||
gui/common/AvatarDialog.ui \
|
||||
gui/FileTransfer/TransfersDialog.ui \
|
||||
gui/FileTransfer/DetailsDialog.ui \
|
||||
gui/MainWindow.ui \
|
||||
@ -740,6 +742,7 @@ SOURCES += main.cpp \
|
||||
gui/common/rwindow.cpp \
|
||||
gui/common/html.cpp \
|
||||
gui/common/AvatarDefs.cpp \
|
||||
gui/common/AvatarDialog.cpp \
|
||||
gui/common/GroupFlagsWidget.cpp \
|
||||
gui/common/GroupSelectionBox.cpp \
|
||||
gui/common/StatusDefs.cpp \
|
||||
|
Loading…
Reference in New Issue
Block a user