Allow to import stickers from chat window

This commit is contained in:
hunbernd 2019-10-05 23:18:41 +02:00
parent 641964fff9
commit e52f1282ec
7 changed files with 46 additions and 12 deletions

View file

@ -32,6 +32,7 @@
#include <QTextStream>
#include <QTimer>
#include <QToolTip>
#include <QInputDialog>
#include "ChatWidget.h"
#include "ui_ChatWidget.h"
@ -162,6 +163,7 @@ ChatWidget::ChatWidget(QWidget *parent)
connect(ui->actionQuote, SIGNAL(triggered()), this, SLOT(quote()));
connect(ui->actionDropPlacemark, SIGNAL(triggered()), this, SLOT(dropPlacemark()));
connect(ui->actionSave_image, SIGNAL(triggered()), this, SLOT(saveImage()));
connect(ui->actionImport_sticker, SIGNAL(triggered()), this, SLOT(saveSticker()));
connect(ui->actionShow_Hidden_Images, SIGNAL(triggered()), ui->textBrowser, SLOT(showImages()));
ui->actionShow_Hidden_Images->setIcon(ui->textBrowser->getBlockedImage());
@ -1127,7 +1129,9 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
contextMnu->addAction(ui->actionShow_Hidden_Images);
ui->actionSave_image->setData(point);
ui->actionImport_sticker->setData(point);
contextMnu->addAction(ui->actionSave_image);
contextMnu->addAction(ui->actionImport_sticker);
}
QString anchor = ui->textBrowser->anchorForPosition(point);
@ -1909,3 +1913,13 @@ void ChatWidget::saveImage()
QTextCursor cursor = ui->textBrowser->cursorForPosition(point);
ImageUtil::extractImage(window(), cursor);
}
void ChatWidget::saveSticker()
{
QPoint point = ui->actionImport_sticker->data().toPoint();
QTextCursor cursor = ui->textBrowser->cursorForPosition(point);
QString filename = QInputDialog::getText(window(), "Import sticker", "Sticker name");
if(filename.isEmpty()) return;
filename = Emoticons::importedStickerPath() + "/" + filename + ".png";
ImageUtil::extractImage(window(), cursor, filename);
}