From f3d251fc93fda956cb8cc14b5717c2485db84781 Mon Sep 17 00:00:00 2001 From: D33r-Gee Date: Wed, 27 Mar 2024 11:32:43 -0700 Subject: [PATCH] qml: UI only. added setcustomdatadir() method into the options_model files --- src/qml/models/options_model.cpp | 32 ++++++++++++++++++++++++++++++++ src/qml/models/options_model.h | 16 ++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/src/qml/models/options_model.cpp b/src/qml/models/options_model.cpp index 61459dbf6c..082ed06513 100644 --- a/src/qml/models/options_model.cpp +++ b/src/qml/models/options_model.cpp @@ -9,13 +9,20 @@ #include #include #include +#include #include #include #include +#include +#include #include #include +#include +#include +#include + OptionsQmlModel::OptionsQmlModel(interfaces::Node& node) : m_node{node} { @@ -105,3 +112,28 @@ common::SettingsValue OptionsQmlModel::pruneSetting() const assert(!m_prune || m_prune_size_gb >= 1); return m_prune ? PruneGBtoMiB(m_prune_size_gb) : 0; } + +QString PathToQString(const fs::path &path) +{ + return QString::fromStdString(path.u8string()); +} + +QString OptionsQmlModel::getDefaultDataDirString() +{ + return PathToQString(GetDefaultDataDir()); +} + + +QUrl OptionsQmlModel::getDefaultDataDirectory() +{ + QString path = getDefaultDataDirString(); + return QUrl::fromLocalFile(path); +} + +void OptionsQmlModel::setCustomDataDirArgs(QString path) +{ + if (!path.isEmpty()) { + // TODO: add actual custom data wiring + qDebug() << "PlaceHolder: Created data directory: " << path; + } +} \ No newline at end of file diff --git a/src/qml/models/options_model.h b/src/qml/models/options_model.h index b67aa8c76c..86bdacd8f8 100644 --- a/src/qml/models/options_model.h +++ b/src/qml/models/options_model.h @@ -11,6 +11,8 @@ #include #include +#include +#include namespace interfaces { class Node; @@ -32,6 +34,8 @@ class OptionsQmlModel : public QObject Q_PROPERTY(int scriptThreads READ scriptThreads WRITE setScriptThreads NOTIFY scriptThreadsChanged) Q_PROPERTY(bool server READ server WRITE setServer NOTIFY serverChanged) Q_PROPERTY(bool upnp READ upnp WRITE setUpnp NOTIFY upnpChanged) + Q_PROPERTY(QString getDefaultDataDirString READ getDefaultDataDirString CONSTANT) + Q_PROPERTY(QUrl getDefaultDataDirectory READ getDefaultDataDirectory CONSTANT) public: explicit OptionsQmlModel(interfaces::Node& node); @@ -56,6 +60,15 @@ class OptionsQmlModel : public QObject void setServer(bool new_server); bool upnp() const { return m_upnp; } void setUpnp(bool new_upnp); + QString getDefaultDataDirString(); + QUrl getDefaultDataDirectory(); + Q_INVOKABLE void setCustomDataDirArgs(QString path); + +public Q_SLOTS: + void setCustomDataDirString(const QString &new_custom_datadir_string) { + m_custom_datadir_string = new_custom_datadir_string; + m_signalReceived = true; + } Q_SIGNALS: void dbcacheSizeMiBChanged(int new_dbcache_size_mib); @@ -66,6 +79,7 @@ class OptionsQmlModel : public QObject void scriptThreadsChanged(int new_script_threads); void serverChanged(bool new_server); void upnpChanged(bool new_upnp); + void customDataDirStringChanged(QString new_custom_datadir_string); private: interfaces::Node& m_node; @@ -83,6 +97,8 @@ class OptionsQmlModel : public QObject int m_script_threads; bool m_server; bool m_upnp; + QString m_custom_datadir_string; + bool m_signalReceived = false; common::SettingsValue pruneSetting() const; };