mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge pull request #2700 from defnax/pastepicture-boards
Added paste picture from clipboard feature for picture posts
This commit is contained in:
commit
29c66b91e1
@ -19,6 +19,7 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
#include <QClipboard>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -59,6 +60,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou
|
|||||||
|
|
||||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createPost()));
|
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createPost()));
|
||||||
connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture()));
|
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)));
|
connect(ui->RichTextEditWidget, SIGNAL(textSizeOk(bool)),ui->postButton, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png"));
|
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<QImage>(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()
|
int PostedCreatePostDialog::viewMode()
|
||||||
{
|
{
|
||||||
if (ui->viewPostButton->isChecked()) {
|
if (ui->viewPostButton->isChecked()) {
|
||||||
|
@ -50,6 +50,7 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
void createPost();
|
void createPost();
|
||||||
void addPicture();
|
void addPicture();
|
||||||
|
void pastePicture();
|
||||||
void on_removeButton_clicked();
|
void on_removeButton_clicked();
|
||||||
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
void fileHashingFinished(QList<HashedFile> hashedFiles);
|
||||||
void reject() override; //QDialog
|
void reject() override; //QDialog
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>575</width>
|
<width>575</width>
|
||||||
<height>518</height>
|
<height>549</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -152,8 +152,8 @@
|
|||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>9</number>
|
<number>9</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="0">
|
<item row="1" column="2">
|
||||||
<spacer name="addPicLeft_HSpacer">
|
<spacer name="addPicRight_HSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -182,15 +182,8 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="sizeWarningLabel">
|
<spacer name="addPicLeft_HSpacer">
|
||||||
<property name="text">
|
|
||||||
<string>Post size is limited to 32 KB, pictures will be downscaled.</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
|
||||||
<spacer name="addPicRight_HSpacer">
|
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -203,6 +196,13 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="3">
|
<item row="3" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="sizeWarningLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>Post size is limited to 32 KB, pictures will be downscaled.</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="3">
|
||||||
<spacer name="addPic_VSpacer">
|
<spacer name="addPic_VSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@ -215,6 +215,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QPushButton" name="pasteButton">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Paste image from clipboard</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Paste Picture</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
|
Loading…
Reference in New Issue
Block a user