Persistent storage for common settings. closes #10

This commit is contained in:
Ilya Kitaev 2016-06-15 13:25:45 +03:00
parent 1eac46ae73
commit 2151f1395c
4 changed files with 41 additions and 4 deletions

View File

@ -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);

View File

@ -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"

View File

@ -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;
}

View File

@ -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