added attach picture system to broadcast (Patch from Phenom)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6611 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2013-08-25 20:41:50 +00:00
parent 2d3cb91cd8
commit d1d2fbb869
3 changed files with 74 additions and 17 deletions

View File

@ -30,6 +30,7 @@
#include <QTextCodec>
#include <QTimer>
#include <QMessageBox>
#include <QTextDocumentFragment>
#include "retroshare/rspeers.h"
#include <retroshare/rshistory.h>
@ -131,6 +132,7 @@ FriendsDialog::FriendsDialog(QWidget *parent)
connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(chooseFont()));
connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(chooseColor()));
connect(ui.attachPictureButton, SIGNAL(clicked()), this, SLOT(addExtraPicture()));
connect(ui.actionSave_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
@ -232,6 +234,11 @@ FriendsDialog::FriendsDialog(QWidget *parent)
#ifdef Q_WS_WIN
#endif
#if QT_VERSION < 0x040700
// embedded images are not supported before QT 4.7.0
ui->attachPictureButton->setVisible(false);
#endif
}
FriendsDialog::~FriendsDialog ()
@ -800,6 +807,19 @@ void FriendsDialog::addExtraFile()
}
}
void FriendsDialog::addExtraPicture()
{
// select a picture file
QString file;
if (misc::getOpenFileName(window(), RshareSettings::LASTDIR_IMAGES, tr("Load Picture File"), "Pictures (*.png *.xpm *.jpg)", file)) {
QString encodedImage;
if (RsHtml::makeEmbeddedImage(file, encodedImage, 640*480)) {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(encodedImage);
ui.lineEdit->textCursor().insertFragment(fragment);
}
}
}
void FriendsDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
{
std::cerr << "FriendsDialog::fileHashingFinished() started." << std::endl;

View File

@ -118,6 +118,8 @@ private slots:
void addExtraFile();
void addExtraPicture();
bool fileSave();
bool fileSaveAs();

View File

@ -550,41 +550,35 @@
</widget>
</item>
<item>
<widget class="QToolButton" name="menuButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QToolButton" name="attachPictureButton">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
<width>28</width>
<height>28</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Attach a Picture</string>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/configure.png</normaloff>:/images/configure.png</iconset>
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
@ -631,6 +625,47 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="menuButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="icon">
<iconset resource="images.qrc">
<normaloff>:/images/configure.png</normaloff>:/images/configure.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation">