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 <QTextCodec>
#include <QTimer> #include <QTimer>
#include <QMessageBox> #include <QMessageBox>
#include <QTextDocumentFragment>
#include "retroshare/rspeers.h" #include "retroshare/rspeers.h"
#include <retroshare/rshistory.h> #include <retroshare/rshistory.h>
@ -131,6 +132,7 @@ FriendsDialog::FriendsDialog(QWidget *parent)
connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(ui.textitalicChatButton, SIGNAL(clicked()), this, SLOT(setFont()));
connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(chooseFont())); connect(ui.fontsButton, SIGNAL(clicked()), this, SLOT(chooseFont()));
connect(ui.colorChatButton, SIGNAL(clicked()), this, SLOT(chooseColor())); 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.actionSave_History, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>))); connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
@ -232,6 +234,11 @@ FriendsDialog::FriendsDialog(QWidget *parent)
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
#endif #endif
#if QT_VERSION < 0x040700
// embedded images are not supported before QT 4.7.0
ui->attachPictureButton->setVisible(false);
#endif
} }
FriendsDialog::~FriendsDialog () 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) void FriendsDialog::fileHashingFinished(QList<HashedFile> hashedFiles)
{ {
std::cerr << "FriendsDialog::fileHashingFinished() started." << std::endl; std::cerr << "FriendsDialog::fileHashingFinished() started." << std::endl;

View File

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

View File

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