* 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/rsiface.h"
#include "rsiface/rspeers.h" #include "rsiface/rspeers.h"
#include "rsiface/rsmsgs.h"
#include "rshare.h" #include "rshare.h"
#include "MessengerWindow.h" #include "MessengerWindow.h"
//#include "MainWindow.h"
#include "chat/PopupChatDialog.h" #include "chat/PopupChatDialog.h"
#include "msgs/ChanMsgDialog.h" #include "msgs/ChanMsgDialog.h"
@ -45,7 +45,6 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include <QMenu> #include <QMenu>
#include <QCursor> #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.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.shareButton, SIGNAL(clicked()), SLOT(openShareManager()));
connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend2() ) ); connect( ui.addIMAccountButton, SIGNAL(clicked( bool ) ), this , SLOT( addFriend2() ) );
@ -119,18 +118,9 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags)
ui.statuscomboBox->setMinimumWidth(20); ui.statuscomboBox->setMinimumWidth(20);
ui.messagecomboBox->setMinimumWidth(20); ui.messagecomboBox->setMinimumWidth(20);
ui.searchlineEdit->setMinimumWidth(20); ui.searchlineEdit->setMinimumWidth(20);
/* The background palette breaks MessengerWindow in Linux...
* so it is disabled until a solution is found.
*/
#if 0 updateAvatar();
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 */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -395,9 +385,6 @@ void MessengerWindow::setChatDialog(PeersDialog *cd)
chatDialog = cd; chatDialog = cd;
} }
void MessengerWindow::chatfriend2() void MessengerWindow::chatfriend2()
{ {
bool isOnline; bool isOnline;
@ -462,7 +449,6 @@ void MessengerWindow::sendMessage()
nMsgDialog->show(); nMsgDialog->show();
} }
QTreeWidgetItem *MessengerWindow::getCurrentPeer(bool &isOnline) QTreeWidgetItem *MessengerWindow::getCurrentPeer(bool &isOnline)
{ {
/* get the current, and extract the Id */ /* get the current, and extract the Id */
@ -546,28 +532,49 @@ void MessengerWindow::addFriend2()
#endif #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 { LogoBar & MessengerWindow::getLogoBar() const {
return *_rsLogoBarmessenger; return *_rsLogoBarmessenger;
} }
void MessengerWindow::getPicture() void MessengerWindow::updateAvatar()
{ {
QString fileName = QFileDialog::getOpenFileName(this, "Load File", unsigned char *data = NULL;
QDir::homePath(), int size = 0 ;
"Pictures (*.png *.xpm *.jpg)");
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()) if(!fileName.isEmpty())
{ {
picture = QPixmap(fileName).scaled(53,53, Qt::IgnoreAspectRatio); picture = QPixmap(fileName).scaled(82,82, Qt::IgnoreAspectRatio);
ui.avatarButton->setIcon(picture);
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 addFriend2();
void getPicture(); void getAvatar();
void openShareManager(); void openShareManager();
void showMessagesPopup(); void showMessagesPopup();
//void showMessages(MainWindow::Page page = MainWindow::Messages); //void showMessages(MainWindow::Page page = MainWindow::Messages);
/** RsServer Friend Calls */ /** RsServer Friend Calls */
void allowfriend2(); void allowfriend2();
void connectfriend2(); void connectfriend2();

View File

@ -13,26 +13,23 @@
<string>RetroShare Messenger</string> <string>RetroShare Messenger</string>
</property> </property>
<property name="windowIcon" > <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> </property>
<widget class="QWidget" name="centralwidget" > <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" > <layout class="QGridLayout" >
<property name="leftMargin" > <property name="margin" >
<number>0</number> <number>0</number>
</property> </property>
<property name="topMargin" > <property name="spacing" >
<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" >
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0" > <item row="0" column="0" >
@ -56,34 +53,41 @@
<property name="bottomMargin" > <property name="bottomMargin" >
<number>2</number> <number>2</number>
</property> </property>
<property name="horizontalSpacing" > <property name="spacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<number>0</number> <number>0</number>
</property> </property>
<item row="0" column="0" colspan="2" > <item row="0" column="0" colspan="2" >
<layout class="QGridLayout" > <layout class="QGridLayout" >
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QToolButton" name="avatarButton" > <widget class="QToolButton" name="avatarButton" >
<property name="toolTip" > <property name="minimumSize" >
<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" >
<size> <size>
<width>70</width> <width>70</width>
<height>70</height> <height>70</height>
</size> </size>
</property> </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" > <property name="autoRaise" >
<bool>true</bool> <bool>true</bool>
</property> </property>
@ -91,22 +95,10 @@ p, li { white-space: pre-wrap; }&#xd;
</item> </item>
<item row="0" column="1" > <item row="0" column="1" >
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="leftMargin" > <property name="margin" >
<number>4</number> <number>4</number>
</property> </property>
<property name="topMargin" > <property name="spacing" >
<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" >
<number>6</number> <number>6</number>
</property> </property>
<item row="0" column="0" > <item row="0" column="0" >
@ -135,7 +127,8 @@ p, li { white-space: pre-wrap; }
<string>Online</string> <string>Online</string>
</property> </property>
<property name="icon" > <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> </property>
</item> </item>
<item> <item>
@ -143,7 +136,8 @@ p, li { white-space: pre-wrap; }
<string>Busy</string> <string>Busy</string>
</property> </property>
<property name="icon" > <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> </property>
</item> </item>
<item> <item>
@ -151,7 +145,8 @@ p, li { white-space: pre-wrap; }
<string>Be right Back</string> <string>Be right Back</string>
</property> </property>
<property name="icon" > <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> </property>
</item> </item>
<item> <item>
@ -159,7 +154,8 @@ p, li { white-space: pre-wrap; }
<string>Away</string> <string>Away</string>
</property> </property>
<property name="icon" > <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> </property>
</item> </item>
<item> <item>
@ -167,7 +163,8 @@ p, li { white-space: pre-wrap; }
<string>In a Call</string> <string>In a Call</string>
</property> </property>
<property name="icon" > <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> </property>
</item> </item>
<item> <item>
@ -175,7 +172,8 @@ p, li { white-space: pre-wrap; }
<string>Out of lunch</string> <string>Out of lunch</string>
</property> </property>
<property name="icon" > <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> </property>
</item> </item>
<item> <item>
@ -183,7 +181,8 @@ p, li { white-space: pre-wrap; }
<string>Apear Offline</string> <string>Apear Offline</string>
</property> </property>
<property name="icon" > <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> </property>
</item> </item>
</widget> </widget>
@ -211,13 +210,14 @@ p, li { white-space: pre-wrap; }
<string>Share Files for your Friends</string> <string>Share Files for your Friends</string>
</property> </property>
<property name="styleSheet" > <property name="styleSheet" >
<string/> <string notr="true" />
</property> </property>
<property name="text" > <property name="text" >
<string>...</string> <string>...</string>
</property> </property>
<property name="icon" > <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>
<property name="iconSize" > <property name="iconSize" >
<size> <size>
@ -235,7 +235,7 @@ p, li { white-space: pre-wrap; }
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="sizeHint" > <property name="sizeHint" stdset="0" >
<size> <size>
<width>221</width> <width>221</width>
<height>20</height> <height>20</height>
@ -248,22 +248,10 @@ p, li { white-space: pre-wrap; }
</item> </item>
<item row="1" column="0" > <item row="1" column="0" >
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="leftMargin" > <property name="margin" >
<number>9</number> <number>9</number>
</property> </property>
<property name="topMargin" > <property name="spacing" >
<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" >
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="0" colspan="2" > <item row="1" column="0" colspan="2" >
@ -297,7 +285,8 @@ p, li { white-space: pre-wrap; }
<string/> <string/>
</property> </property>
<property name="icon" > <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>
<property name="iconSize" > <property name="iconSize" >
<size> <size>

View File

@ -608,7 +608,7 @@ void PopupChatDialog::getAvatar()
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)"); QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
if(!fileName.isEmpty()) 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 ; std::cerr << "Sending avatar image down the pipe" << std::endl ;