mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-25 09:11:06 -04:00
Show save image option only when it is needed
This commit is contained in:
parent
bbebd6a5d7
commit
bc4691ceb4
4 changed files with 21 additions and 4 deletions
|
@ -979,8 +979,12 @@ void ChatWidget::contextMenuTextBrowser(QPoint point)
|
||||||
contextMnu->addAction(ui->actionClearChatHistory);
|
contextMnu->addAction(ui->actionClearChatHistory);
|
||||||
contextMnu->addAction(ui->actionQuote);
|
contextMnu->addAction(ui->actionQuote);
|
||||||
|
|
||||||
ui->actionSave_image->setData(point);
|
QTextCursor cursor = ui->textBrowser->cursorForPosition(point);
|
||||||
contextMnu->addAction(ui->actionSave_image);
|
if(ImageUtil::checkImage(cursor))
|
||||||
|
{
|
||||||
|
ui->actionSave_image->setData(point);
|
||||||
|
contextMnu->addAction(ui->actionSave_image);
|
||||||
|
}
|
||||||
|
|
||||||
contextMnu->exec(ui->textBrowser->viewport()->mapToGlobal(point));
|
contextMnu->exec(ui->textBrowser->viewport()->mapToGlobal(point));
|
||||||
delete(contextMnu);
|
delete(contextMnu);
|
||||||
|
|
|
@ -514,8 +514,12 @@ void GxsForumThreadWidget::contextMenuTextBrowser(QPoint point)
|
||||||
|
|
||||||
contextMnu->addSeparator();
|
contextMnu->addSeparator();
|
||||||
|
|
||||||
ui->actionSave_image->setData(point);
|
QTextCursor cursor = ui->postText->cursorForPosition(point);
|
||||||
contextMnu->addAction(ui->actionSave_image);
|
if(ImageUtil::checkImage(cursor))
|
||||||
|
{
|
||||||
|
ui->actionSave_image->setData(point);
|
||||||
|
contextMnu->addAction(ui->actionSave_image);
|
||||||
|
}
|
||||||
|
|
||||||
contextMnu->exec(ui->postText->viewport()->mapToGlobal(point));
|
contextMnu->exec(ui->postText->viewport()->mapToGlobal(point));
|
||||||
delete(contextMnu);
|
delete(contextMnu);
|
||||||
|
|
|
@ -41,3 +41,11 @@ void ImageUtil::extractImage(QWidget *window, QTextCursor cursor)
|
||||||
QMessageBox::warning(window, QApplication::translate("ImageUtil", "Save image"), QApplication::translate("ImageUtil", "Not an image"));
|
QMessageBox::warning(window, QApplication::translate("ImageUtil", "Save image"), QApplication::translate("ImageUtil", "Not an image"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ImageUtil::checkImage(QTextCursor cursor)
|
||||||
|
{
|
||||||
|
cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1);
|
||||||
|
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, 2);
|
||||||
|
QString imagestr = cursor.selection().toHtml();
|
||||||
|
return imagestr.indexOf("base64,") != -1;
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ public:
|
||||||
ImageUtil();
|
ImageUtil();
|
||||||
|
|
||||||
static void extractImage(QWidget *window, QTextCursor cursor);
|
static void extractImage(QWidget *window, QTextCursor cursor);
|
||||||
|
static bool checkImage(QTextCursor cursor);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IMAGEUTIL_H
|
#endif // IMAGEUTIL_H
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue