Added connect the Thumbnail Button for select Images/Pictures to use it as Thumbnail for your Channel Item

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2073 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
defnax 2010-01-18 22:30:21 +00:00
parent eab78c5c03
commit 20646fb349
3 changed files with 34 additions and 5 deletions

View file

@ -45,6 +45,7 @@ CreateChannelMsg::CreateChannelMsg(std::string cId)
connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(addFileButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile())); connect(addfilepushButton, SIGNAL(clicked() ), this , SLOT(addExtraFile()));
connect(addThumbnailButton, SIGNAL(clicked() ), this , SLOT(addThumbnail()));
setAcceptDrops(true); setAcceptDrops(true);
@ -456,8 +457,31 @@ void CreateChannelMsg::sendMessage(std::wstring subject, std::wstring msg, std::
} }
void CreateChannelMsg::addThumbnail()
{
QString fileName = QFileDialog::getOpenFileName(this, "Load File", QDir::homePath(), "Pictures (*.png *.xpm *.jpg)");
if(!fileName.isEmpty())
{
picture = QPixmap(fileName).scaled(156,107, Qt::IgnoreAspectRatio);
// to show the selected
thumbnail_label->setPixmap(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, "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.
//updateThumbnail() ;
}
}

View file

@ -43,6 +43,8 @@ public:
void newChannelMsg(); void newChannelMsg();
QPixmap picture;
protected: protected:
virtual void dragEnterEvent(QDragEnterEvent *event); virtual void dragEnterEvent(QDragEnterEvent *event);
virtual void dropEvent(QDropEvent *event); virtual void dropEvent(QDropEvent *event);
@ -54,6 +56,8 @@ private slots:
void cancelMsg(); void cancelMsg();
void sendMsg(); void sendMsg();
void addThumbnail();
private: private:
void parseRsFileListAttachments(std::string attachList); void parseRsFileListAttachments(std::string attachList);

View file

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>505</width> <width>509</width>
<height>464</height> <height>464</height>
</rect> </rect>
</property> </property>
@ -159,7 +159,7 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="addThumbnailButton">
<property name="text"> <property name="text">
<string>Add Channel Thumbnail</string> <string>Add Channel Thumbnail</string>
</property> </property>
@ -172,7 +172,7 @@ p, li { white-space: pre-wrap; }
</layout> </layout>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
<widget class="QLabel" name="label"> <widget class="QLabel" name="thumbnail_label">
<property name="maximumSize"> <property name="maximumSize">
<size> <size>
<width>156</width> <width>156</width>
@ -352,7 +352,7 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>460</width> <width>464</width>
<height>282</height> <height>282</height>
</rect> </rect>
</property> </property>
@ -427,6 +427,7 @@ background: white;}</string>
<resources> <resources>
<include location="../images.qrc"/> <include location="../images.qrc"/>
<include location="../images.qrc"/> <include location="../images.qrc"/>
<include location="../images.qrc"/>
</resources> </resources>
<connections/> <connections/>
</ui> </ui>