mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-12 11:02:30 -04:00
Applied patch from AsamK and fixed german translation.
Reduced code duplication with avatar picture loading, by creating two new functions that handle image choosing and thumbnail creation. two new functions: bool misc::getOpenAvatarPicture(QWidget *parent, QByteArray &image_data) QPixmap misc::getOpenThumbnailedPicture(QWidget *parent, const QString &caption, int width, int height) getOpenThumbnailedPicture opens a QFileDialog to let the user choose a picture file. This picture is converted to a thumbnail and returned as a QPixmap. getOpenAvatarPicture calls getOpenThumbnailedPicture and converts the result to a PNG byte array. All three avatar loading functions now call getOpenAvatarPicture Furthermore Channel Logo and Channel Msg thumbnail functions now use getOpenThumbnailedPicture git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4561 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
43c0594d18
commit
0fbada0eba
12 changed files with 666 additions and 212 deletions
|
@ -23,7 +23,6 @@
|
|||
#include <QFileInfo>
|
||||
#include <QWidgetAction>
|
||||
#include <QTimer>
|
||||
#include <QBuffer>
|
||||
|
||||
#include "common/vmessagebox.h"
|
||||
#include "common/StatusDefs.h"
|
||||
|
@ -51,6 +50,7 @@
|
|||
#include "util/PixmapMerging.h"
|
||||
#include "LogoBar.h"
|
||||
#include "util/Widget.h"
|
||||
#include "util/misc.h"
|
||||
#include "settings/rsharesettings.h"
|
||||
#include "common/RSTreeWidgetItem.h"
|
||||
|
||||
|
@ -1085,11 +1085,6 @@ void MessengerWindow::sendMessage()
|
|||
MessageComposer::msgFriend(id, false);
|
||||
}
|
||||
|
||||
void MessengerWindow::changeAvatarClicked()
|
||||
{
|
||||
updateAvatar();
|
||||
}
|
||||
|
||||
void MessengerWindow::updateAvatar()
|
||||
{
|
||||
unsigned char *data = NULL;
|
||||
|
@ -1112,24 +1107,13 @@ void MessengerWindow::updateAvatar()
|
|||
|
||||
void MessengerWindow::getAvatar()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
|
||||
if(!fileName.isEmpty())
|
||||
QByteArray ba;
|
||||
if (misc::getOpenAvatarPicture(this, ba))
|
||||
{
|
||||
picture = QPixmap(fileName).scaled(96,96, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
|
||||
std::cerr << "Sending avatar image down the pipe" << std::endl ;
|
||||
|
||||
// send avatar down the pipe for other peers to get it.
|
||||
QByteArray ba;
|
||||
QBuffer buffer(&ba);
|
||||
buffer.open(QIODevice::WriteOnly);
|
||||
picture.save(&buffer, "PNG"); // writes image into ba in PNG format
|
||||
|
||||
std::cerr << "Image size = " << ba.size() << std::endl ;
|
||||
|
||||
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()),ba.size()) ; // last char 0 included.
|
||||
|
||||
updateAvatar() ;
|
||||
#ifdef MSG_DEBUG
|
||||
std::cerr << "Avatar image size = " << ba.size() << std::endl ;
|
||||
#endif
|
||||
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()), ba.size()) ; // last char 0 included.
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue