Skip to content

Commit ffd5201

Browse files
committed
qml: UI only. added setcustomdatadir() method into the options_model files
1 parent 0b59fee commit ffd5201

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/qml/models/options_model.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@
99
#include <common/system.h>
1010
#include <interfaces/node.h>
1111
#include <qt/guiconstants.h>
12+
#include <qt/guiutil.h>
1213
#include <qt/optionsmodel.h>
1314
#include <txdb.h>
1415
#include <univalue.h>
16+
#include <util/fs.h>
17+
#include <util/fs_helpers.h>
1518
#include <validation.h>
1619

1720
#include <cassert>
1821

22+
#include <QDebug>
23+
#include <QDir>
24+
#include <QSettings>
25+
1926
OptionsQmlModel::OptionsQmlModel(interfaces::Node& node)
2027
: m_node{node}
2128
{
@@ -105,3 +112,28 @@ common::SettingsValue OptionsQmlModel::pruneSetting() const
105112
assert(!m_prune || m_prune_size_gb >= 1);
106113
return m_prune ? PruneGBtoMiB(m_prune_size_gb) : 0;
107114
}
115+
116+
QString PathToQString(const fs::path &path)
117+
{
118+
return QString::fromStdString(path.u8string());
119+
}
120+
121+
QString OptionsQmlModel::getDefaultDataDirString()
122+
{
123+
return PathToQString(GetDefaultDataDir());
124+
}
125+
126+
127+
QUrl OptionsQmlModel::getDefaultDataDirectory()
128+
{
129+
QString path = getDefaultDataDirString();
130+
return QUrl::fromLocalFile(path);
131+
}
132+
133+
void OptionsQmlModel::setCustomDataDirArgs(QString path)
134+
{
135+
if (!path.isEmpty()) {
136+
// TODO: add actual custom data wiring
137+
qDebug() << "PlaceHolder: Created data directory: " << path;
138+
}
139+
}

src/qml/models/options_model.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#include <validation.h>
1212

1313
#include <QObject>
14+
#include <QString>
15+
#include <QUrl>
1416

1517
namespace interfaces {
1618
class Node;
@@ -32,6 +34,8 @@ class OptionsQmlModel : public QObject
3234
Q_PROPERTY(int scriptThreads READ scriptThreads WRITE setScriptThreads NOTIFY scriptThreadsChanged)
3335
Q_PROPERTY(bool server READ server WRITE setServer NOTIFY serverChanged)
3436
Q_PROPERTY(bool upnp READ upnp WRITE setUpnp NOTIFY upnpChanged)
37+
Q_PROPERTY(QString getDefaultDataDirString READ getDefaultDataDirString CONSTANT)
38+
Q_PROPERTY(QUrl getDefaultDataDirectory READ getDefaultDataDirectory CONSTANT)
3539

3640
public:
3741
explicit OptionsQmlModel(interfaces::Node& node);
@@ -56,6 +60,15 @@ class OptionsQmlModel : public QObject
5660
void setServer(bool new_server);
5761
bool upnp() const { return m_upnp; }
5862
void setUpnp(bool new_upnp);
63+
QString getDefaultDataDirString();
64+
QUrl getDefaultDataDirectory();
65+
Q_INVOKABLE void setCustomDataDirArgs(QString path);
66+
67+
public Q_SLOTS:
68+
void setCustomDataDirString(const QString &new_custom_datadir_string) {
69+
m_custom_datadir_string = new_custom_datadir_string;
70+
m_signalReceived = true;
71+
}
5972

6073
Q_SIGNALS:
6174
void dbcacheSizeMiBChanged(int new_dbcache_size_mib);
@@ -66,6 +79,7 @@ class OptionsQmlModel : public QObject
6679
void scriptThreadsChanged(int new_script_threads);
6780
void serverChanged(bool new_server);
6881
void upnpChanged(bool new_upnp);
82+
void customDataDirStringChanged(QString new_custom_datadir_string);
6983

7084
private:
7185
interfaces::Node& m_node;
@@ -83,6 +97,8 @@ class OptionsQmlModel : public QObject
8397
int m_script_threads;
8498
bool m_server;
8599
bool m_upnp;
100+
QString m_custom_datadir_string;
101+
bool m_signalReceived = false;
86102

87103
common::SettingsValue pruneSetting() const;
88104
};

0 commit comments

Comments
 (0)