diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp index aace423f8..ec41434c1 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.cpp @@ -19,6 +19,7 @@ *******************************************************************************/ #include +#include #include #include #include @@ -59,6 +60,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createPost())); connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture())); + connect(ui->pasteButton, SIGNAL(clicked() ), this , SLOT(pastePicture())); connect(ui->RichTextEditWidget, SIGNAL(textSizeOk(bool)),ui->postButton, SLOT(setEnabled(bool))); ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png")); @@ -256,6 +258,35 @@ void PostedCreatePostDialog::addPicture() } +void PostedCreatePostDialog::pastePicture() +{ + imagefilename = ""; + imagebytes.clear(); + QPixmap empty; + ui->imageLabel->setPixmap(empty); + + // paste picture from clipboard + const QClipboard *clipboard = QApplication::clipboard(); + const QMimeData *mimeData = clipboard->mimeData(); + + QImage image; + if (mimeData->hasImage()) { + image = (qvariant_cast(mimeData->imageData())); + + QImage opt; + if(ImageUtil::optimizeSizeBytes(imagebytes, image, opt,"JPG", 640*480, MAXMESSAGESIZE - 2000)) { //Leave space for other stuff + ui->imageLabel->setPixmap(QPixmap::fromImage(opt)); + ui->stackedWidgetPicture->setCurrentIndex(IMG_PICTURE); + ui->removeButton->show(); + } + } else { + QMessageBox::information(nullptr,tr("No clipboard image found."),tr("There is no image data in the clipboard to paste")); + imagefilename = ""; + imagebytes.clear(); + return; + } +} + int PostedCreatePostDialog::viewMode() { if (ui->viewPostButton->isChecked()) { diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h index 48ae3cbd4..8576c5ea9 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.h @@ -50,6 +50,7 @@ private: private slots: void createPost(); void addPicture(); + void pastePicture(); void on_removeButton_clicked(); void fileHashingFinished(QList hashedFiles); void reject() override; //QDialog diff --git a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui index a44f226b1..8af895d9c 100644 --- a/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui +++ b/retroshare-gui/src/gui/Posted/PostedCreatePostDialog.ui @@ -7,7 +7,7 @@ 0 0 575 - 518 + 549 @@ -152,8 +152,8 @@ 9 - - + + Qt::Horizontal @@ -182,15 +182,8 @@ - - - - Post size is limited to 32 KB, pictures will be downscaled. - - - - - + + Qt::Horizontal @@ -203,6 +196,13 @@ + + + Post size is limited to 32 KB, pictures will be downscaled. + + + + Qt::Vertical @@ -215,6 +215,16 @@ + + + + Paste image from clipboard + + + Paste Picture + + +