File tree Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Expand file tree Collapse file tree 2 files changed +80
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2023 The Bitcoin Core developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ #include < qml/androidcustomdatadir.h>
6
+
7
+ #include < common/args.h>
8
+ #include < qml/util.h>
9
+ #include < qml/guiconstants.h>
10
+ #include < qt/guiutil.h>
11
+
12
+ #include < QDebug>
13
+ #include < QFile>
14
+ #include < QStandardPaths>
15
+ #include < QDir>
16
+
17
+ AndroidCustomDataDir::AndroidCustomDataDir (QObject * parent)
18
+ : QObject(parent)
19
+ {
20
+ m_default_data_dir = QStandardPaths::writableLocation (QStandardPaths::AppDataLocation);
21
+ }
22
+
23
+ void AndroidCustomDataDir::setDataDir (const QString & new_data_dir)
24
+ {
25
+ if (m_data_dir == new_data_dir) {
26
+ return ;
27
+ }
28
+
29
+ m_data_dir = new_data_dir;
30
+ gArgs .SoftSetArg (" -datadir" , fs::PathToString (GUIUtil::QStringToPath (m_data_dir)));
31
+ gArgs .ClearPathCache ();
32
+ Q_EMIT dataDirChanged ();
33
+ }
34
+
35
+ QString AndroidCustomDataDir::readCustomDataDir ()
36
+ {
37
+ QFile file (m_default_data_dir + " /filepath.txt" );
38
+ QString storedPath;
39
+
40
+ if (file.open (QIODevice::ReadOnly)) {
41
+ QTextStream in (&file);
42
+ storedPath = in.readAll ().trimmed ();
43
+ file.close ();
44
+ // Process the retrieved path
45
+ qDebug () << " Retrieved path: " << storedPath;
46
+ }
47
+ return storedPath;
48
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2024 The Bitcoin Core developers
2
+ // Distributed under the MIT software license, see the accompanying
3
+ // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
+
5
+ #ifndef BITCOIN_QML_ANDROIDCUSTOMDATADIR_H
6
+ #define BITCOIN_QML_ANDROIDCUSTOMDATADIR_H
7
+
8
+ #include < QFile>
9
+ #include < QStandardPaths>
10
+ #include < QDir>
11
+
12
+ class AndroidCustomDataDir : public QObject
13
+ {
14
+ Q_OBJECT
15
+ Q_PROPERTY (QString dataDir READ dataDir WRITE setDataDir NOTIFY dataDirChanged)
16
+
17
+ public:
18
+ explicit AndroidCustomDataDir (QObject * parent = nullptr );
19
+
20
+ QString dataDir () const { return m_data_dir; }
21
+ void setDataDir (const QString & new_data_dir);
22
+ QString readCustomDataDir ();
23
+
24
+ Q_SIGNALS:
25
+ void dataDirChanged ();
26
+
27
+ private:
28
+ QString m_data_dir;
29
+ QString m_default_data_dir;
30
+ };
31
+
32
+ #endif // BITCOIN_QML_ANDROIDCUSTOMDATADIR_H
You can’t perform that action at this time.
0 commit comments