Commit 361af734 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

New function script.selectFileName() in QML API.

parent 76daf6f9
......@@ -4062,6 +4062,8 @@ script.saveImage(img, filePath, [format]): Speichere Bild in Datei, true wenn OK
script.imageProperties(img): Eigenschaften eines Bildes, enthält
"width", "height", "depth" und "colorCount", leer wenn Bild ungültig
script.scaleImage(img, width, [height]): Liefert skaliertes Bild
script.selectFileName(caption, dir, filter, saveFile): Öffnet Dateidialog, um
eine Datei auszuwählen
</programlisting>
</sect2>
......
......@@ -3891,6 +3891,8 @@ script.saveImage(img, filePath, [format]): Save an image to a file, true if OK
script.imageProperties(img): Get properties of an image, map containing
"width", "height", "depth" and "colorCount", empty if invalid image
script.scaleImage(img, width, [height]): Scale an image, returns scaled image
script.selectFileName(caption, dir, filter, saveFile): Open file dialog to
select a file
</programlisting>
</sect2>
......
......@@ -31,6 +31,7 @@
#include <QDir>
#include <QProcess>
#include <QImage>
#include <QFileDialog>
#include <QBuffer>
#include <QCryptographicHash>
#include "pictureframe.h"
......@@ -487,3 +488,18 @@ QVariant ScriptUtils::scaleImage(const QVariant& var, int width, int height)
}
return QVariant();
}
/**
* @brief Open a file select dialog to get a file name.
* @param caption dialog caption
* @param dir working directory
* @param filter file type filter
* @param saveFile true to open a save file dialog
* @return selected file, empty if canceled.
*/
QString ScriptUtils::selectFileName(const QString& caption, const QString& dir,
const QString& filter, bool saveFile)
{
return saveFile ? QFileDialog::getSaveFileName(0, caption, dir, filter)
: QFileDialog::getOpenFileName(0, caption, dir, filter);
}
......@@ -295,6 +295,18 @@ public:
*/
Q_INVOKABLE static QVariant scaleImage(const QVariant& var,
int width, int height = -1);
/**
* @brief Open a file select dialog to get a file name.
* @param caption dialog caption
* @param dir working directory
* @param filter file type filter
* @param saveFile true to open a save file dialog
* @return selected file, empty if canceled.
*/
Q_INVOKABLE static QString selectFileName(
const QString& caption = QString(), const QString& dir = QString(),
const QString& filter = QString(), bool saveFile = false);
};
#endif // SCRIPTUTILS_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment