new wallet wizard: wallet created in temporary directory and moved to

the destination at the final step
This commit is contained in:
Ilya Kitaev 2016-06-10 16:41:13 +03:00
parent 5c10be3251
commit fd50e6f9a3
13 changed files with 105 additions and 29 deletions

View file

@ -13,6 +13,9 @@ BITMONERO_DIR=$ROOT_DIR/bitmonero
if [ ! -d $BITMONERO_DIR ]; then
git clone --depth=1 $BITMONERO_URL $BITMONERO_DIR
else
cd $BITMONERO_DIR;
git pull;
fi
rm -fr $BITMONERO_DIR/build

View file

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<languages>
<language name="US English" locale="en_US" flag="/lang/flags/usa.png" qs="none"/>
<language name="UK English" locale="en_GB" flag="/lang/flags/uk.png" qs="none"/>
<language name="Russia" locale="ru_RU" flag="/lang/flags/russia.png" qs="none"/>
<language name="RPA" locale="TODO" flag="/lang/flags/rpa.png" qs="none"/>
<language name="Palestine" locale="TODO" flag="/lang/flags/palestine.png" qs="none"/>
<language name="India" locale="hi_IN" flag="/lang/flags/india.png" qs="none"/>
<language name="German" locale="de_DE" flag="/lang/flags/german.png" qs="none"/>
<language name="China" locale="zh_CN" flag="/lang/flags/china.png" qs="none"/>
<language name="Brazil" locale="pt_BR" flag="/lang/flags/brazil.png" qs="none"/>
<language name="Bangladesh" locale="TODO" flag="/lang/flags/bangladesh.png" qs="none"/>
<language display_name="US English" locale="en_US" wallet_name="English" flag="/lang/flags/usa.png" qs="none"/>
<language display_name="UK English" locale="en_GB" wallet_name="English" flag="/lang/flags/uk.png" qs="none"/>
<language display_name="Russia" locale="ru_RU" wallet_name="English" flag="/lang/flags/russia.png" qs="none"/>
<language display_name="RPA" locale="TODO" wallet_name="English" flag="/lang/flags/rpa.png" qs="none"/>
<language display_name="Palestine" locale="TODO" wallet_name="English" flag="/lang/flags/palestine.png" qs="none"/>
<language display_name="India" locale="hi_IN" wallet_name="English" flag="/lang/flags/india.png" qs="none"/>
<language display_name="German" locale="de_DE" wallet_name="English" flag="/lang/flags/german.png" qs="none"/>
<language display_name="China" locale="zh_CN" wallet_name="English" flag="/lang/flags/china.png" qs="none"/>
<language display_name="Brazil" locale="pt_BR" wallet_name="English" flag="/lang/flags/brazil.png" qs="none"/>
<language display_name="Bangladesh" locale="TODO" wallet_name="English" flag="/lang/flags/bangladesh.png" qs="none"/>
</languages>

View file

@ -33,10 +33,13 @@
#include "clipboardAdapter.h"
#include "filter.h"
#include "oscursor.h"
#include "oshelper.h"
#include "WalletManager.h"
#include "Wallet.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
@ -51,6 +54,9 @@ int main(int argc, char *argv[])
OSCursor cursor;
engine.rootContext()->setContextProperty("globalCursor", &cursor);
OSHelper osHelper;
engine.rootContext()->setContextProperty("oshelper", &osHelper);
engine.rootContext()->setContextProperty("walletManager", WalletManager::instance());
// export to QML monero accounts root directory

View file

@ -18,7 +18,8 @@ HEADERS += \
src/libwalletqt/Wallet.h \
src/libwalletqt/PendingTransaction.h \
src/libwalletqt/TransactionHistory.h \
src/libwalletqt/TransactionInfo.h
src/libwalletqt/TransactionInfo.h \
oshelper.h
SOURCES += main.cpp \
@ -29,7 +30,8 @@ SOURCES += main.cpp \
src/libwalletqt/Wallet.cpp \
src/libwalletqt/PendingTransaction.cpp \
src/libwalletqt/TransactionHistory.cpp \
src/libwalletqt/TransactionInfo.cpp
src/libwalletqt/TransactionInfo.cpp \
oshelper.cpp
lupdate_only {
SOURCES = *.qml \

24
oshelper.cpp Normal file
View file

@ -0,0 +1,24 @@
#include "oshelper.h"
#include <QTemporaryFile>
#include <QDir>
OSHelper::OSHelper(QObject *parent) : QObject(parent)
{
}
QString OSHelper::temporaryFilename() const
{
QString tempFileName;
{
QTemporaryFile f;
f.open();
tempFileName = f.fileName();
}
return tempFileName;
}
QString OSHelper::temporaryPath() const
{
return QDir::tempPath();
}

22
oshelper.h Normal file
View file

@ -0,0 +1,22 @@
#ifndef OSHELPER_H
#define OSHELPER_H
#include <QObject>
/**
* @brief The OSHelper class - exports to QML some OS-related functions
*/
class OSHelper : public QObject
{
Q_OBJECT
public:
explicit OSHelper(QObject *parent = 0);
Q_INVOKABLE QString temporaryFilename() const;
Q_INVOKABLE QString temporaryPath() const;
signals:
public slots:
};
#endif // OSHELPER_H

View file

@ -40,18 +40,23 @@ Item {
onOpacityChanged: visible = opacity !== 0
function saveSettings(settingsObject) {
//! function called each time we display this page
function onPageClosed(settingsObject) {
settingsObject['account_name'] = uiItem.accountNameText
settingsObject['words'] = uiItem.wordsTexttext
settingsObject['wallet_path'] = uiItem.walletPath
// put wallet files to the subdirectory with the same name as
// wallet name
var new_wallet_filename = settingsObject.wallet_path + "/"
+ settingsObject.account_name + "/"
+ settingsObject.account_name;
// moving wallet files to the new destination, if user changed it
if (new_wallet_filename !== settingsObject.wallet_filename) {
// using previously saved wallet;
settingsObject.wallet.rename(new_wallet_filename);
settingsObject.wallet.store(new_wallet_filename);
//walletManager.moveWallet(settingsObject.wallet_filename, new_wallet_filename);
}
@ -59,10 +64,18 @@ Item {
settingsObject['wallet_filename'] = new_wallet_filename;
}
//! function called each time we hide this page
//
function createWallet(settingsObject) {
var wallet_filename = uiItem.walletPath + "/" + uiItem.accountNameText
// TODO: create wallet in temporary filename and a) move it to the path specified by user after the final
// page submitted or b) delete it when program closed before reaching final page
var wallet_filename = oshelper.temporaryFilename();
if (typeof settingsObject.wallet === 'undefined') {
var wallet = walletManager.createWallet(wallet_filename, "", settingsObject.locale)
//var wallet = walletManager.createWallet(wallet_filename, "", settingsObject.language)
var wallet = walletManager.createWallet(wallet_filename, "", settingsObject.wallet_language)
uiItem.wordsTextItem.memoText = wallet.seed
// saving wallet in "global" settings object
// TODO: wallet should have a property pointing to the file where it stored or loaded from
@ -70,10 +83,12 @@ Item {
} else {
print("wallet already created. we just stepping back");
}
settingsObject.wallet_filename = wallet_filename
}
WizardManageWalletUI {
id: uiItem
titleText: qsTr("A new wallet has been created for you")

View file

@ -38,7 +38,7 @@ Item {
onOpacityChanged: visible = opacity !== 0
function saveSettings(settingsObject) {
function onPageClosed(settingsObject) {
settingsObject['auto_donations_enabled'] = enableAutoDonationCheckBox.checked;
settingsObject['auto_donations_amount'] = autoDonationAmountText.text;
settingsObject['allow_background_mining'] = allowBackgroundMiningCheckBox.checked;

View file

@ -49,8 +49,8 @@ Rectangle {
function switchPage(next) {
// save settings for current page;
if (typeof pages[currentPage].saveSettings !== 'undefined') {
pages[currentPage].saveSettings(settings);
if (typeof pages[currentPage].onPageClosed !== 'undefined') {
pages[currentPage].onPageClosed(settings);
}
print ("switchpage: start: currentPage: ", currentPage);
@ -61,7 +61,6 @@ Rectangle {
pages[currentPage].opacity = 1;
handlePageChanged();
}
}
function handlePageChanged() {
@ -91,9 +90,9 @@ Rectangle {
nextButton.enabled = true
}
}
function openCreateWalletPage() {
print ("show create wallet page");
pages[currentPage].opacity = 0;

View file

@ -206,7 +206,7 @@ Item {
verticalAlignment: Text.AlignVCenter
selectByMouse: true
text: moneroAccountsDir + "/My Wallet"
text: moneroAccountsDir + "/"
onFocusChanged: {
if(focus) {
fileDialog.folder = text

View file

@ -43,7 +43,7 @@ Item {
onOpacityChanged: visible = opacity !== 0
function saveSettings(settingsObject) {
function onPageClosed(settingsObject) {
settingsObject.wallet.setPassword(passwordItem.password)
}

View file

@ -40,7 +40,7 @@ Item {
onOpacityChanged: visible = opacity !== 0
function saveSettings(settingsObject) {
function onPageClosed(settingsObject) {
settingsObject['account_name'] = uiItem.accountNameText
settingsObject['words'] = uiItem.wordsTexttext
settingsObject['wallet_path'] = uiItem.walletPath

View file

@ -36,8 +36,11 @@ Item {
onOpacityChanged: visible = opacity !== 0
function saveSettings(settingsObject) {
settingsObject['language'] = languagesModel.get(gridView.currentIndex).name
function onPageClosed(settingsObject) {
var lang = languagesModel.get(gridView.currentIndex);
settingsObject['language'] = lang.display_name;
settingsObject['wallet_language'] = lang.wallet_name;
settingsObject['locale'] = lang.locale;
}
Column {
@ -78,7 +81,9 @@ Item {
source: "/lang/languages.xml"
query: "/languages/language"
XmlRole { name: "name"; query: "@name/string()" }
XmlRole { name: "display_name"; query: "@display_name/string()" }
XmlRole { name: "locale"; query: "@locale/string()" }
XmlRole { name: "wallet_name"; query: "@wallet_name/string()" }
XmlRole { name: "flag"; query: "@flag/string()" }
// TODO: XmlListModel is read only, we should store current language somewhere else
// and set current language accordingly
@ -126,7 +131,7 @@ Item {
font.bold: gridView.currentIndex === index
elide: Text.ElideRight
color: "#3F3F3F"
text: name
text: display_name
}
MouseArea {
id: delegateArea