diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/main.cpp | 2 | ||||
| -rw-r--r-- | src/main/oshelper.cpp | 13 | ||||
| -rw-r--r-- | src/main/oshelper.h | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/src/main/main.cpp b/src/main/main.cpp index c6c0ea52..c564c59f 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -61,6 +61,7 @@ #include "wallet/api/wallet2_api.h" #include "Logger.h" #include "MainApp.h" +#include "qt/downloader.h" #include "qt/ipc.h" #include "qt/network.h" #include "qt/utils.h" @@ -295,6 +296,7 @@ int main(int argc, char *argv[]) // registering types for QML qmlRegisterType<clipboardAdapter>("moneroComponents.Clipboard", 1, 0, "Clipboard"); + qmlRegisterType<Downloader>("moneroComponents.Downloader", 1, 0, "Downloader"); // Temporary Qt.labs.settings replacement qmlRegisterType<MoneroSettings>("moneroComponents.Settings", 1, 0, "MoneroSettings"); diff --git a/src/main/oshelper.cpp b/src/main/oshelper.cpp index 4402db6d..75c668f5 100644 --- a/src/main/oshelper.cpp +++ b/src/main/oshelper.cpp @@ -27,6 +27,8 @@ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "oshelper.h" +#include <QFileDialog> +#include <QStandardPaths> #include <QTemporaryFile> #include <QDir> #include <QDebug> @@ -82,6 +84,11 @@ OSHelper::OSHelper(QObject *parent) : QObject(parent) } +QString OSHelper::downloadLocation() const +{ + return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); +} + bool OSHelper::openContainingFolder(const QString &filePath) const { #if defined(Q_OS_WIN) @@ -105,6 +112,12 @@ bool OSHelper::openContainingFolder(const QString &filePath) const return QDesktopServices::openUrl(url); } +QString OSHelper::openSaveFileDialog(const QString &title, const QString &folder, const QString &filename) const +{ + const QString hint = (folder.isEmpty() ? "" : folder + QDir::separator()) + filename; + return QFileDialog::getSaveFileName(nullptr, title, hint); +} + QString OSHelper::temporaryFilename() const { QString tempFileName; diff --git a/src/main/oshelper.h b/src/main/oshelper.h index 72f284af..ba498554 100644 --- a/src/main/oshelper.h +++ b/src/main/oshelper.h @@ -39,7 +39,9 @@ class OSHelper : public QObject public: explicit OSHelper(QObject *parent = 0); + Q_INVOKABLE QString downloadLocation() const; Q_INVOKABLE bool openContainingFolder(const QString &filePath) const; + Q_INVOKABLE QString openSaveFileDialog(const QString &title, const QString &folder, const QString &filename) const; Q_INVOKABLE QString temporaryFilename() const; Q_INVOKABLE QString temporaryPath() const; Q_INVOKABLE bool removeTemporaryWallet(const QString &walletName) const; |
