diff --git a/retroshare-gui/src/gui/FriendsDialog.cpp b/retroshare-gui/src/gui/FriendsDialog.cpp index 36469f0b5..f3db08f9e 100644 --- a/retroshare-gui/src/gui/FriendsDialog.cpp +++ b/retroshare-gui/src/gui/FriendsDialog.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include "retroshare/rspeers.h" #include @@ -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)), this, SLOT(fileHashingFinished(QList))); @@ -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 hashedFiles) { std::cerr << "FriendsDialog::fileHashingFinished() started." << std::endl; diff --git a/retroshare-gui/src/gui/FriendsDialog.h b/retroshare-gui/src/gui/FriendsDialog.h index 73e237f96..9da3bb78f 100644 --- a/retroshare-gui/src/gui/FriendsDialog.h +++ b/retroshare-gui/src/gui/FriendsDialog.h @@ -118,6 +118,8 @@ private slots: void addExtraFile(); + void addExtraPicture(); + bool fileSave(); bool fileSaveAs(); diff --git a/retroshare-gui/src/gui/FriendsDialog.ui b/retroshare-gui/src/gui/FriendsDialog.ui index 0eab518a7..8698289b6 100644 --- a/retroshare-gui/src/gui/FriendsDialog.ui +++ b/retroshare-gui/src/gui/FriendsDialog.ui @@ -550,41 +550,35 @@ - - - - 0 - 0 - - + - 24 - 24 + 28 + 28 - 24 - 24 + 28 + 28 Qt::NoFocus + + Attach a Picture + - :/images/configure.png:/images/configure.png + :/images/add_image24.png:/images/add_image24.png - 22 - 22 + 24 + 24 - - QToolButton::InstantPopup - true @@ -631,6 +625,47 @@ + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + Qt::NoFocus + + + + :/images/configure.png:/images/configure.png + + + + 22 + 22 + + + + QToolButton::InstantPopup + + + true + + +