From 2151f1395c28027f867d8e640b0c0be4cd4e0a23 Mon Sep 17 00:00:00 2001 From: Ilya Kitaev Date: Wed, 15 Jun 2016 13:25:45 +0300 Subject: [PATCH] Persistent storage for common settings. closes #10 --- main.cpp | 5 +++++ main.qml | 2 ++ wizard/WizardDonation.qml | 12 ++++++++---- wizard/WizardMain.qml | 26 ++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index a4a79947..7331a4e4 100644 --- a/main.cpp +++ b/main.cpp @@ -43,6 +43,11 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); + + app.setApplicationName("monero-core"); + app.setOrganizationDomain("getmonero.org"); + app.setOrganizationName("The Monero Project"); + filter *eventFilter = new filter; app.installEventFilter(eventFilter); diff --git a/main.qml b/main.qml index a36a3755..0eb87b2e 100644 --- a/main.qml +++ b/main.qml @@ -30,6 +30,8 @@ import QtQuick 2.2 import QtQuick.Window 2.0 import QtQuick.Controls 1.1 import QtQuick.Controls.Styles 1.1 + + import "components" import "wizard" diff --git a/wizard/WizardDonation.qml b/wizard/WizardDonation.qml index e0b73df8..80ebd78b 100644 --- a/wizard/WizardDonation.qml +++ b/wizard/WizardDonation.qml @@ -38,13 +38,17 @@ Item { onOpacityChanged: visible = opacity !== 0 + function onPageOpened(settingsObject) { + enableAutoDonationCheckBox.checked = settingsObject.auto_donations_enabled + autoDonationAmountText.text = settingsObject.auto_donations_amount + allowBackgroundMiningCheckBox.checked = settingsObject.allow_background_mining + + } + function onPageClosed(settingsObject) { settingsObject['auto_donations_enabled'] = enableAutoDonationCheckBox.checked; - settingsObject['auto_donations_amount'] = autoDonationAmountText.text; + settingsObject['auto_donations_amount'] = parseInt(autoDonationAmountText.text); settingsObject['allow_background_mining'] = allowBackgroundMiningCheckBox.checked; - - - return true; } diff --git a/wizard/WizardMain.qml b/wizard/WizardMain.qml index da3a9824..940243cb 100644 --- a/wizard/WizardMain.qml +++ b/wizard/WizardMain.qml @@ -27,6 +27,8 @@ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import QtQuick 2.2 +import Qt.labs.settings 1.0 + import "../components" Rectangle { @@ -142,10 +144,34 @@ Rectangle { // saving wallet_filename; settings['wallet_filename'] = new_wallet_filename; + + // persist settings + persistentSettings.language = settings.language + persistentSettings.account_name = settings.account_name + persistentSettings.wallet_path = settings.wallet_path + persistentSettings.allow_background_mining = settings.allow_background_mining + persistentSettings.auto_donations_enabled = settings.auto_donations_enabled + persistentSettings.auto_donations_amount = settings.auto_donations_amount + } + + // reading settings from persistent storage + Component.onCompleted: { + settings['allow_background_mining'] = persistentSettings.allow_background_mining + settings['auto_donations_enabled'] = persistentSettings.auto_donations_enabled + settings['auto_donations_amount'] = persistentSettings.auto_donations_amount } + Settings { + id: persistentSettings + property string language + property string account_name + property string wallet_path + property bool auto_donations_enabled : true + property int auto_donations_amount : 50 + property bool allow_background_mining : true + } Rectangle { id: nextButton