From 171a5bef0dd93f68c882510701d668cf0ac060ed Mon Sep 17 00:00:00 2001 From: defnax Date: Fri, 30 Jan 2009 23:51:59 +0000 Subject: [PATCH] * 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 --- retroshare-gui/src/gui/MessengerWindow.cpp | 73 +++++----- retroshare-gui/src/gui/MessengerWindow.h | 5 +- retroshare-gui/src/gui/MessengerWindow.ui | 131 ++++++++---------- .../src/gui/chat/PopupChatDialog.cpp | 2 +- 4 files changed, 102 insertions(+), 109 deletions(-) diff --git a/retroshare-gui/src/gui/MessengerWindow.cpp b/retroshare-gui/src/gui/MessengerWindow.cpp index 78a0e5e0c..0520b1cad 100644 --- a/retroshare-gui/src/gui/MessengerWindow.cpp +++ b/retroshare-gui/src/gui/MessengerWindow.cpp @@ -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 #include - #include #include #include @@ -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() ) ); @@ -119,18 +118,9 @@ MessengerWindow::MessengerWindow(QWidget* parent, Qt::WFlags flags) ui.statuscomboBox->setMinimumWidth(20); ui.messagecomboBox->setMinimumWidth(20); ui.searchlineEdit->setMinimumWidth(20); - - /* The background palette breaks MessengerWindow in Linux... - * so it is disabled until a solution is found. - */ -#if 0 - QPixmap Backpixmap((QString)":/images/backgroundimage.png"); + updateAvatar(); - //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() ; } } diff --git a/retroshare-gui/src/gui/MessengerWindow.h b/retroshare-gui/src/gui/MessengerWindow.h index a38c5c6c3..0cbb48d30 100644 --- a/retroshare-gui/src/gui/MessengerWindow.h +++ b/retroshare-gui/src/gui/MessengerWindow.h @@ -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(); diff --git a/retroshare-gui/src/gui/MessengerWindow.ui b/retroshare-gui/src/gui/MessengerWindow.ui index 7bf9064da..4b331366a 100644 --- a/retroshare-gui/src/gui/MessengerWindow.ui +++ b/retroshare-gui/src/gui/MessengerWindow.ui @@ -13,26 +13,23 @@ RetroShare Messenger - :/images/rstray3.png + + :/images/rstray3.png:/images/rstray3.png + + + 0 + 30 + 270 + 481 + + - + 0 - - 0 - - - 0 - - - 0 - - - 0 - - + 0 @@ -56,34 +53,41 @@ 2 - - 0 - - + 0 - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"> -<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</p></body></html> - - - border-image: url(:/images/mystatus_bg.png); - - - :/images/retrosharelogo1.png - - + 70 70 + + + 70 + 70 + + + + Click to Change your Avatar + + + border-image: url(:/images/mystatus_bg.png); + + + + :/images/user/personal64.png:/images/user/personal64.png + + + + 50 + 50 + + true @@ -91,22 +95,10 @@ p, li { white-space: pre-wrap; } - + 4 - - 4 - - - 4 - - - 4 - - - 6 - - + 6 @@ -135,7 +127,8 @@ p, li { white-space: pre-wrap; } Online - :/images/donline.png + + :/images/donline.png:/images/donline.png @@ -143,7 +136,8 @@ p, li { white-space: pre-wrap; } Busy - :/images/dbusy.png + + :/images/dbusy.png:/images/dbusy.png @@ -151,7 +145,8 @@ p, li { white-space: pre-wrap; } Be right Back - :/images/dbrb.png + + :/images/dbrb.png:/images/dbrb.png @@ -159,7 +154,8 @@ p, li { white-space: pre-wrap; } Away - :/images/daway.png + + :/images/daway.png:/images/daway.png @@ -167,7 +163,8 @@ p, li { white-space: pre-wrap; } In a Call - :/images/dphone.png + + :/images/dphone.png:/images/dphone.png @@ -175,7 +172,8 @@ p, li { white-space: pre-wrap; } Out of lunch - :/images/dlunch.png + + :/images/dlunch.png:/images/dlunch.png @@ -183,7 +181,8 @@ p, li { white-space: pre-wrap; } Apear Offline - :/images/dhidden.png + + :/images/dhidden.png:/images/dhidden.png @@ -211,13 +210,14 @@ p, li { white-space: pre-wrap; } Share Files for your Friends - + ... - :/images/friendsfolder24.png + + :/images/friendsfolder24.png:/images/friendsfolder24.png @@ -235,7 +235,7 @@ p, li { white-space: pre-wrap; } Qt::Horizontal - + 221 20 @@ -248,22 +248,10 @@ p, li { white-space: pre-wrap; } - + 9 - - 9 - - - 9 - - - 9 - - - 6 - - + 6 @@ -297,7 +285,8 @@ p, li { white-space: pre-wrap; } - :/images/user/add_user24.png + + :/images/user/add_user24.png:/images/user/add_user24.png diff --git a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp index 38ed00ade..891d3a38f 100644 --- a/retroshare-gui/src/gui/chat/PopupChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupChatDialog.cpp @@ -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 ;