mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-12 00:00:44 -04:00
Added copy and save of image to AspectRatioPixmapLabel
This commit is contained in:
parent
e829292eaf
commit
8422d3fc8c
4 changed files with 95 additions and 8 deletions
|
@ -115,13 +115,7 @@ void ImageUtil::extractImage(QWidget *window, QTextCursor cursor, QString file)
|
|||
if(!image.isNull())
|
||||
{
|
||||
success = true;
|
||||
if(!file.isEmpty() || misc::getSaveFileName(window, RshareSettings::LASTDIR_IMAGES, "Save Picture File", "Pictures (*.png *.xpm *.jpg)", file))
|
||||
{
|
||||
if(!image.save(file, nullptr, 100))
|
||||
if(!image.save(file + ".png", nullptr, 100))
|
||||
QMessageBox::warning(window, QApplication::translate("ImageUtil", "Save image"), QApplication::translate("ImageUtil", "Cannot save the image, invalid filename")
|
||||
+ "\n" + file);
|
||||
}
|
||||
saveImage(window, image, file);
|
||||
}
|
||||
}
|
||||
if(!success)
|
||||
|
@ -130,6 +124,26 @@ void ImageUtil::extractImage(QWidget *window, QTextCursor cursor, QString file)
|
|||
}
|
||||
}
|
||||
|
||||
bool ImageUtil::saveImage(QWidget *window, const QImage &image, QString file)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if (!file.isEmpty() || misc::getSaveFileName(window, RshareSettings::LASTDIR_IMAGES, QApplication::translate("ImageUtil", "Save Picture File"), QApplication::translate("ImageUtil", "Pictures (*.png *.xpm *.jpg)"), file)) {
|
||||
if (image.save(file, nullptr, 100)) {
|
||||
result = true;
|
||||
} else {
|
||||
if (image.save(file + ".png", nullptr, 100)) {
|
||||
result = true;
|
||||
} else {
|
||||
QMessageBox::warning(window, QApplication::translate("ImageUtil", "Save image"), QApplication::translate("ImageUtil", "Cannot save the image, invalid filename")
|
||||
+ "\n" + file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void ImageUtil::copyImage(QWidget *window, QTextCursor cursor)
|
||||
{
|
||||
cursor.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue