MoneroSettings: portable mode, CWD relative 'monero-storage' dir

This commit is contained in:
xiphon
2020-07-28 17:29:13 +00:00
parent c137a6ea36
commit 1aa98c3cfd
2 changed files with 104 additions and 3 deletions

View File

@@ -36,6 +36,8 @@
#ifndef MONEROSETTINGS_H
#define MONEROSETTINGS_H
#include <memory>
#include <QtQml/qqmlparserstatus.h>
#include <QGuiApplication>
#include <QClipboard>
@@ -50,15 +52,23 @@ class MoneroSettings : public QObject, public QQmlParserStatus
Q_OBJECT
Q_INTERFACES(QQmlParserStatus)
Q_PROPERTY(QString fileName READ fileName WRITE setFileName FINAL)
Q_PROPERTY(bool portable READ portable NOTIFY portableChanged)
Q_PROPERTY(QString portableFolderName READ portableFolderName CONSTANT)
public:
explicit MoneroSettings(QObject *parent = nullptr);
QString fileName() const;
void setFileName(const QString &fileName);
Q_INVOKABLE bool setPortable(bool enabled);
Q_INVOKABLE void setWritable(bool enabled);
public slots:
void _q_propertyChanged();
signals:
void portableChanged() const;
protected:
void timerEvent(QTimerEvent *event) override;
void classBegin() override;
@@ -71,10 +81,19 @@ private:
void load();
void store();
bool portable() const;
bool portableConfigExists() const;
QString portableFilePath() const;
QString portableFolderName() const;
std::unique_ptr<QSettings> portableSettings() const;
std::unique_ptr<QSettings> unportableSettings() const;
void swap(std::unique_ptr<QSettings> newSettings);
QHash<const char *, QVariant> m_changedProperties;
QSettings *m_settings = NULL;
std::unique_ptr<QSettings> m_settings;
QString m_fileName = QString("");
bool m_initialized = false;
bool m_writable = true;
int m_timerId = 0;
};