Fix imageclipboard saveImage().
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
#include "imageclipboard.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QGuiApplication>
|
||||
#include <QUrl>
|
||||
#include <QtDebug>
|
||||
|
||||
ImageClipboard::ImageClipboard(QObject* parent)
|
||||
: QObject(parent), m_clipboard(QGuiApplication::clipboard()) {
|
||||
@@ -17,10 +20,21 @@ QImage ImageClipboard::image() {
|
||||
return m_clipboard->image();
|
||||
}
|
||||
|
||||
void ImageClipboard::saveImage(const QUrl& localPath) {
|
||||
auto i = image();
|
||||
bool ImageClipboard::saveImage(const QUrl& localPath) {
|
||||
if (!localPath.isLocalFile())
|
||||
return false;
|
||||
|
||||
if (i.isNull()) return;
|
||||
auto i = image();
|
||||
|
||||
i.save(localPath.toString());
|
||||
if (i.isNull())
|
||||
return false;
|
||||
|
||||
QString path = QFileInfo(localPath.toString()).absolutePath();
|
||||
QDir dir;
|
||||
if (!dir.exists(path))
|
||||
dir.mkpath(path);
|
||||
|
||||
i.save(localPath.toLocalFile());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user