* set Qt::IgnoreAspectRatio for pictures

* added for MessengerWindow the new getAvatar and updateAvatar function


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@961 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2009-01-30 23:51:59 +00:00
parent 2212393b9e
commit 171a5bef0d
4 changed files with 102 additions and 109 deletions

View File

@ -25,10 +25,10 @@
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsmsgs.h"
#include "rshare.h"
#include "MessengerWindow.h"
//#include "MainWindow.h"
#include "chat/PopupChatDialog.h"
#include "msgs/ChanMsgDialog.h"
@ -45,7 +45,6 @@
#include <iostream>
#include <sstream>
#include <QContextMenuEvent>
#include <QMenu>
#include <QCursor>
@ -84,7 +83,7 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
connect( ui.messengertreeWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( messengertreeWidgetCostumPopupMenu( QPoint ) ) );
connect( ui.avatarButton, SIGNAL(clicked()), SLOT(getPicture()));
connect( ui.avatarButton, SIGNAL(clicked()), SLOT(getAvatar()));
connect( ui.shareButton, SIGNAL(clicked()), SLOT(openShareManager()));
connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend2() ) );
@ -120,17 +119,8 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
ui.messagecomboBox->setMinimumWidth(20);
ui.searchlineEdit->setMinimumWidth(20);
/* The background palette breaks MessengerWindow in Linux...
* so it is disabled until a solution is found.
*/
updateAvatar();
#if 0
QPixmap Backpixmap((QString)":/images/backgroundimage.png");
//QBrush BackBrush(Backpixmap);
QPalette BackPalette(BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush, BackBrush);
this->setPalette(BackPalette); //Set Background
#endif
/* Hide platform specific features */
#ifdef Q_WS_WIN
@ -395,9 +385,6 @@ void MessengerWindow::setChatDialog(PeersDialog *cd)
chatDialog = cd;
}
void MessengerWindow::chatfriend2()
{
bool isOnline;
@ -462,7 +449,6 @@ void MessengerWindow::sendMessage()
nMsgDialog->show();
}
QTreeWidgetItem *MessengerWindow::getCurrentPeer(bool &isOnline)
{
/* get the current, and extract the Id */
@ -546,28 +532,49 @@ void MessengerWindow::addFriend2()
#endif
}
void MessengerWindow::updateAvatar()
{
std::string backgroundPixmapFilename = ":/images/retrosharelogo1.png";
std::string foregroundPixmapData = ":/images/nopic.png";
//std::string foregroundPixmapData = _cUserProfile->getUserProfile().getIcon().getData();
ui.avatarButton->setIcon(PixmapMerging::merge(foregroundPixmapData, backgroundPixmapFilename));
}
LogoBar & MessengerWindow::getLogoBar() const {
return *_rsLogoBarmessenger;
}
void MessengerWindow::getPicture()
void MessengerWindow::updateAvatar()
{
QString fileName = QFileDialog::getOpenFileName(this, "Load File",
QDir::homePath(),
"Pictures (*.png *.xpm *.jpg)");
unsigned char *data = NULL;
int size = 0 ;
rsMsgs->getOwnAvatarData(data,size);
std::cerr << "Image size = " << size << std::endl ;
if(size == 0)
std::cerr << "Got no image" << std::endl ;
// set the image
QPixmap pix ;
pix.loadFromData(data,size,"JPG") ;
ui.avatarButton->setIcon(pix); // writes image into ba in JPG format
delete[] data ;
}
void MessengerWindow::getAvatar()
{
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
if(!fileName.isEmpty())
{
picture = QPixmap(fileName).scaled(53,53, Qt::IgnoreAspectRatio);
ui.avatarButton->setIcon(picture);
picture = QPixmap(fileName).scaled(82,82, Qt::IgnoreAspectRatio);
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, "JPG"); // writes image into ba in JPG format
std::cerr << "Image size = " << ba.size() << std::endl ;
rsMsgs->setOwnAvatarData((unsigned char *)(ba.data()),ba.size()) ; // last char 0 included.
updateAvatar() ;
}
}

View File

@ -78,17 +78,14 @@ private slots:
void addFriend2();
void getPicture();
void getAvatar();
void openShareManager();
void showMessagesPopup();
//void showMessages(MainWindow::Page page = MainWindow::Messages);
/** RsServer Friend Calls */
void allowfriend2();
void connectfriend2();

View File

@ -13,26 +13,23 @@
<string>RetroShare Messenger</string>
</property>
<property name="windowIcon" >
<iconset resource="images.qrc" >:/images/rstray3.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<widget class="QWidget" name="centralwidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>30</y>
<width>270</width>
<height>481</height>
</rect>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<property name="margin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<property name="spacing" >
<number>0</number>
</property>
<item row="0" column="0" >
@ -56,34 +53,41 @@
<property name="bottomMargin" >
<number>2</number>
</property>
<property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<property name="spacing" >
<number>0</number>
</property>
<item row="0" column="0" colspan="2" >
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QToolButton" name="avatarButton" >
<property name="toolTip" >
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">&#xd;
p, li { white-space: pre-wrap; }&#xd;
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;">&#xd;
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Click to change your avatar&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="styleSheet" >
<string>border-image: url(:/images/mystatus_bg.png);</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/retrosharelogo1.png</iconset>
</property>
<property name="iconSize" >
<property name="minimumSize" >
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>70</width>
<height>70</height>
</size>
</property>
<property name="toolTip" >
<string>Click to Change your Avatar</string>
</property>
<property name="styleSheet" >
<string notr="true" >border-image: url(:/images/mystatus_bg.png);</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >
<normaloff>:/images/user/personal64.png</normaloff>:/images/user/personal64.png</iconset>
</property>
<property name="iconSize" >
<size>
<width>50</width>
<height>50</height>
</size>
</property>
<property name="autoRaise" >
<bool>true</bool>
</property>
@ -91,22 +95,10 @@ p, li { white-space: pre-wrap; }&#xd;
</item>
<item row="0" column="1" >
<layout class="QGridLayout" >
<property name="leftMargin" >
<property name="margin" >
<number>4</number>
</property>
<property name="topMargin" >
<number>4</number>
</property>
<property name="rightMargin" >
<number>4</number>
</property>
<property name="bottomMargin" >
<number>4</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="0" >
@ -135,7 +127,8 @@ p, li { white-space: pre-wrap; }
<string>Online</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/donline.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/donline.png</normaloff>:/images/donline.png</iconset>
</property>
</item>
<item>
@ -143,7 +136,8 @@ p, li { white-space: pre-wrap; }
<string>Busy</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/dbusy.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/dbusy.png</normaloff>:/images/dbusy.png</iconset>
</property>
</item>
<item>
@ -151,7 +145,8 @@ p, li { white-space: pre-wrap; }
<string>Be right Back</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/dbrb.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/dbrb.png</normaloff>:/images/dbrb.png</iconset>
</property>
</item>
<item>
@ -159,7 +154,8 @@ p, li { white-space: pre-wrap; }
<string>Away</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/daway.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/daway.png</normaloff>:/images/daway.png</iconset>
</property>
</item>
<item>
@ -167,7 +163,8 @@ p, li { white-space: pre-wrap; }
<string>In a Call</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/dphone.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/dphone.png</normaloff>:/images/dphone.png</iconset>
</property>
</item>
<item>
@ -175,7 +172,8 @@ p, li { white-space: pre-wrap; }
<string>Out of lunch</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/dlunch.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/dlunch.png</normaloff>:/images/dlunch.png</iconset>
</property>
</item>
<item>
@ -183,7 +181,8 @@ p, li { white-space: pre-wrap; }
<string>Apear Offline</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/dhidden.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/dhidden.png</normaloff>:/images/dhidden.png</iconset>
</property>
</item>
</widget>
@ -211,13 +210,14 @@ p, li { white-space: pre-wrap; }
<string>Share Files for your Friends</string>
</property>
<property name="styleSheet" >
<string/>
<string notr="true" />
</property>
<property name="text" >
<string>...</string>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/friendsfolder24.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/friendsfolder24.png</normaloff>:/images/friendsfolder24.png</iconset>
</property>
<property name="iconSize" >
<size>
@ -235,7 +235,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<property name="sizeHint" stdset="0" >
<size>
<width>221</width>
<height>20</height>
@ -248,22 +248,10 @@ p, li { white-space: pre-wrap; }
</item>
<item row="1" column="0" >
<layout class="QGridLayout" >
<property name="leftMargin" >
<property name="margin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" colspan="2" >
@ -297,7 +285,8 @@ p, li { white-space: pre-wrap; }
<string/>
</property>
<property name="icon" >
<iconset resource="images.qrc" >:/images/user/add_user24.png</iconset>
<iconset resource="images.qrc" >
<normaloff>:/images/user/add_user24.png</normaloff>:/images/user/add_user24.png</iconset>
</property>
<property name="iconSize" >
<size>

View File

@ -608,7 +608,7 @@ void PopupChatDialog::getAvatar()
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
if(!fileName.isEmpty())
{
picture = QPixmap(fileName).scaled(82,82, Qt::KeepAspectRatio);
picture = QPixmap(fileName).scaled(82,82, Qt::IgnoreAspectRatio);
std::cerr << "Sending avatar image down the pipe" << std::endl ;