mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 16:15:23 -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
|
@ -1810,39 +1810,17 @@ void FriendsDialog::updateAvatar()
|
|||
|
||||
void FriendsDialog::getAvatar()
|
||||
{
|
||||
QString fileName;
|
||||
if (misc::getOpenFileName(this, RshareSettings::LASTDIR_IMAGES, tr("Load File"), tr("Pictures (*.png *.xpm *.jpg *.tiff *.gif)"), fileName))
|
||||
QByteArray ba;
|
||||
if (misc::getOpenAvatarPicture(this, ba))
|
||||
{
|
||||
QPixmap picture;
|
||||
picture = QPixmap(fileName).scaled(96,96, Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
|
||||
#ifdef FRIENDS_DEBUG
|
||||
std::cerr << "Sending avatar image down the pipe" << std::endl ;
|
||||
std::cerr << "Avatar image size = " << ba.size() << std::endl ;
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
||||
#ifdef FRIENDS_DEBUG
|
||||
std::cerr << "Image size = " << ba.size() << std::endl ;
|
||||
#endif
|
||||
|
||||
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()),ba.size()) ; // last char 0 included.
|
||||
|
||||
// I suppressed this because it gets called already by rsMsgs->setOwnAvatarData() through a Qt notification signal
|
||||
//updateAvatar() ;
|
||||
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()), ba.size()) ; // last char 0 included.
|
||||
}
|
||||
}
|
||||
|
||||
void FriendsDialog::changeAvatarClicked()
|
||||
{
|
||||
|
||||
updateAvatar();
|
||||
}
|
||||
|
||||
void FriendsDialog::on_actionCreate_New_Forum_activated()
|
||||
{
|
||||
MainWindow::activatePage (MainWindow::Forums);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue