mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-03 17:39:54 +00:00
new wallet wizard: wallet created in temporary directory and moved to
the destination at the final step
This commit is contained in:
parent
5c10be3251
commit
fd50e6f9a3
13 changed files with 105 additions and 29 deletions
|
@ -13,6 +13,9 @@ BITMONERO_DIR=$ROOT_DIR/bitmonero
|
||||||
|
|
||||||
if [ ! -d $BITMONERO_DIR ]; then
|
if [ ! -d $BITMONERO_DIR ]; then
|
||||||
git clone --depth=1 $BITMONERO_URL $BITMONERO_DIR
|
git clone --depth=1 $BITMONERO_URL $BITMONERO_DIR
|
||||||
|
else
|
||||||
|
cd $BITMONERO_DIR;
|
||||||
|
git pull;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -fr $BITMONERO_DIR/build
|
rm -fr $BITMONERO_DIR/build
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<languages>
|
<languages>
|
||||||
<language name="US English" locale="en_US" flag="/lang/flags/usa.png" qs="none"/>
|
<language display_name="US English" locale="en_US" wallet_name="English" flag="/lang/flags/usa.png" qs="none"/>
|
||||||
<language name="UK English" locale="en_GB" flag="/lang/flags/uk.png" qs="none"/>
|
<language display_name="UK English" locale="en_GB" wallet_name="English" flag="/lang/flags/uk.png" qs="none"/>
|
||||||
<language name="Russia" locale="ru_RU" flag="/lang/flags/russia.png" qs="none"/>
|
<language display_name="Russia" locale="ru_RU" wallet_name="English" flag="/lang/flags/russia.png" qs="none"/>
|
||||||
<language name="RPA" locale="TODO" flag="/lang/flags/rpa.png" qs="none"/>
|
<language display_name="RPA" locale="TODO" wallet_name="English" flag="/lang/flags/rpa.png" qs="none"/>
|
||||||
<language name="Palestine" locale="TODO" flag="/lang/flags/palestine.png" qs="none"/>
|
<language display_name="Palestine" locale="TODO" wallet_name="English" flag="/lang/flags/palestine.png" qs="none"/>
|
||||||
<language name="India" locale="hi_IN" flag="/lang/flags/india.png" qs="none"/>
|
<language display_name="India" locale="hi_IN" wallet_name="English" flag="/lang/flags/india.png" qs="none"/>
|
||||||
<language name="German" locale="de_DE" flag="/lang/flags/german.png" qs="none"/>
|
<language display_name="German" locale="de_DE" wallet_name="English" flag="/lang/flags/german.png" qs="none"/>
|
||||||
<language name="China" locale="zh_CN" flag="/lang/flags/china.png" qs="none"/>
|
<language display_name="China" locale="zh_CN" wallet_name="English" flag="/lang/flags/china.png" qs="none"/>
|
||||||
<language name="Brazil" locale="pt_BR" flag="/lang/flags/brazil.png" qs="none"/>
|
<language display_name="Brazil" locale="pt_BR" wallet_name="English" flag="/lang/flags/brazil.png" qs="none"/>
|
||||||
<language name="Bangladesh" locale="TODO" flag="/lang/flags/bangladesh.png" qs="none"/>
|
<language display_name="Bangladesh" locale="TODO" wallet_name="English" flag="/lang/flags/bangladesh.png" qs="none"/>
|
||||||
</languages>
|
</languages>
|
||||||
|
|
6
main.cpp
6
main.cpp
|
@ -33,10 +33,13 @@
|
||||||
#include "clipboardAdapter.h"
|
#include "clipboardAdapter.h"
|
||||||
#include "filter.h"
|
#include "filter.h"
|
||||||
#include "oscursor.h"
|
#include "oscursor.h"
|
||||||
|
#include "oshelper.h"
|
||||||
#include "WalletManager.h"
|
#include "WalletManager.h"
|
||||||
#include "Wallet.h"
|
#include "Wallet.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
@ -51,6 +54,9 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
OSCursor cursor;
|
OSCursor cursor;
|
||||||
engine.rootContext()->setContextProperty("globalCursor", &cursor);
|
engine.rootContext()->setContextProperty("globalCursor", &cursor);
|
||||||
|
OSHelper osHelper;
|
||||||
|
engine.rootContext()->setContextProperty("oshelper", &osHelper);
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("walletManager", WalletManager::instance());
|
engine.rootContext()->setContextProperty("walletManager", WalletManager::instance());
|
||||||
|
|
||||||
// export to QML monero accounts root directory
|
// export to QML monero accounts root directory
|
||||||
|
|
|
@ -18,7 +18,8 @@ HEADERS += \
|
||||||
src/libwalletqt/Wallet.h \
|
src/libwalletqt/Wallet.h \
|
||||||
src/libwalletqt/PendingTransaction.h \
|
src/libwalletqt/PendingTransaction.h \
|
||||||
src/libwalletqt/TransactionHistory.h \
|
src/libwalletqt/TransactionHistory.h \
|
||||||
src/libwalletqt/TransactionInfo.h
|
src/libwalletqt/TransactionInfo.h \
|
||||||
|
oshelper.h
|
||||||
|
|
||||||
|
|
||||||
SOURCES += main.cpp \
|
SOURCES += main.cpp \
|
||||||
|
@ -29,7 +30,8 @@ SOURCES += main.cpp \
|
||||||
src/libwalletqt/Wallet.cpp \
|
src/libwalletqt/Wallet.cpp \
|
||||||
src/libwalletqt/PendingTransaction.cpp \
|
src/libwalletqt/PendingTransaction.cpp \
|
||||||
src/libwalletqt/TransactionHistory.cpp \
|
src/libwalletqt/TransactionHistory.cpp \
|
||||||
src/libwalletqt/TransactionInfo.cpp
|
src/libwalletqt/TransactionInfo.cpp \
|
||||||
|
oshelper.cpp
|
||||||
|
|
||||||
lupdate_only {
|
lupdate_only {
|
||||||
SOURCES = *.qml \
|
SOURCES = *.qml \
|
||||||
|
|
24
oshelper.cpp
Normal file
24
oshelper.cpp
Normal 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
22
oshelper.h
Normal 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
|
|
@ -40,18 +40,23 @@ Item {
|
||||||
|
|
||||||
onOpacityChanged: visible = opacity !== 0
|
onOpacityChanged: visible = opacity !== 0
|
||||||
|
|
||||||
function saveSettings(settingsObject) {
|
//! function called each time we display this page
|
||||||
|
|
||||||
|
function onPageClosed(settingsObject) {
|
||||||
settingsObject['account_name'] = uiItem.accountNameText
|
settingsObject['account_name'] = uiItem.accountNameText
|
||||||
settingsObject['words'] = uiItem.wordsTexttext
|
settingsObject['words'] = uiItem.wordsTexttext
|
||||||
settingsObject['wallet_path'] = uiItem.walletPath
|
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 + "/"
|
var new_wallet_filename = settingsObject.wallet_path + "/"
|
||||||
|
+ settingsObject.account_name + "/"
|
||||||
+ settingsObject.account_name;
|
+ settingsObject.account_name;
|
||||||
|
|
||||||
// moving wallet files to the new destination, if user changed it
|
// moving wallet files to the new destination, if user changed it
|
||||||
if (new_wallet_filename !== settingsObject.wallet_filename) {
|
if (new_wallet_filename !== settingsObject.wallet_filename) {
|
||||||
// using previously saved wallet;
|
// using previously saved wallet;
|
||||||
settingsObject.wallet.rename(new_wallet_filename);
|
settingsObject.wallet.store(new_wallet_filename);
|
||||||
//walletManager.moveWallet(settingsObject.wallet_filename, new_wallet_filename);
|
//walletManager.moveWallet(settingsObject.wallet_filename, new_wallet_filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +64,18 @@ Item {
|
||||||
settingsObject['wallet_filename'] = new_wallet_filename;
|
settingsObject['wallet_filename'] = new_wallet_filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! function called each time we hide this page
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
function createWallet(settingsObject) {
|
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') {
|
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
|
uiItem.wordsTextItem.memoText = wallet.seed
|
||||||
// saving wallet in "global" settings object
|
// saving wallet in "global" settings object
|
||||||
// TODO: wallet should have a property pointing to the file where it stored or loaded from
|
// TODO: wallet should have a property pointing to the file where it stored or loaded from
|
||||||
|
@ -70,10 +83,12 @@ Item {
|
||||||
} else {
|
} else {
|
||||||
print("wallet already created. we just stepping back");
|
print("wallet already created. we just stepping back");
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsObject.wallet_filename = wallet_filename
|
settingsObject.wallet_filename = wallet_filename
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
WizardManageWalletUI {
|
WizardManageWalletUI {
|
||||||
id: uiItem
|
id: uiItem
|
||||||
titleText: qsTr("A new wallet has been created for you")
|
titleText: qsTr("A new wallet has been created for you")
|
||||||
|
|
|
@ -38,7 +38,7 @@ Item {
|
||||||
|
|
||||||
onOpacityChanged: visible = opacity !== 0
|
onOpacityChanged: visible = opacity !== 0
|
||||||
|
|
||||||
function saveSettings(settingsObject) {
|
function onPageClosed(settingsObject) {
|
||||||
settingsObject['auto_donations_enabled'] = enableAutoDonationCheckBox.checked;
|
settingsObject['auto_donations_enabled'] = enableAutoDonationCheckBox.checked;
|
||||||
settingsObject['auto_donations_amount'] = autoDonationAmountText.text;
|
settingsObject['auto_donations_amount'] = autoDonationAmountText.text;
|
||||||
settingsObject['allow_background_mining'] = allowBackgroundMiningCheckBox.checked;
|
settingsObject['allow_background_mining'] = allowBackgroundMiningCheckBox.checked;
|
||||||
|
|
|
@ -49,8 +49,8 @@ Rectangle {
|
||||||
|
|
||||||
function switchPage(next) {
|
function switchPage(next) {
|
||||||
// save settings for current page;
|
// save settings for current page;
|
||||||
if (typeof pages[currentPage].saveSettings !== 'undefined') {
|
if (typeof pages[currentPage].onPageClosed !== 'undefined') {
|
||||||
pages[currentPage].saveSettings(settings);
|
pages[currentPage].onPageClosed(settings);
|
||||||
}
|
}
|
||||||
print ("switchpage: start: currentPage: ", currentPage);
|
print ("switchpage: start: currentPage: ", currentPage);
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@ Rectangle {
|
||||||
pages[currentPage].opacity = 1;
|
pages[currentPage].opacity = 1;
|
||||||
handlePageChanged();
|
handlePageChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePageChanged() {
|
function handlePageChanged() {
|
||||||
|
@ -91,9 +90,9 @@ Rectangle {
|
||||||
nextButton.enabled = true
|
nextButton.enabled = true
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function openCreateWalletPage() {
|
function openCreateWalletPage() {
|
||||||
print ("show create wallet page");
|
print ("show create wallet page");
|
||||||
pages[currentPage].opacity = 0;
|
pages[currentPage].opacity = 0;
|
||||||
|
|
|
@ -206,7 +206,7 @@ Item {
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
selectByMouse: true
|
selectByMouse: true
|
||||||
|
|
||||||
text: moneroAccountsDir + "/My Wallet"
|
text: moneroAccountsDir + "/"
|
||||||
onFocusChanged: {
|
onFocusChanged: {
|
||||||
if(focus) {
|
if(focus) {
|
||||||
fileDialog.folder = text
|
fileDialog.folder = text
|
||||||
|
|
|
@ -43,7 +43,7 @@ Item {
|
||||||
|
|
||||||
onOpacityChanged: visible = opacity !== 0
|
onOpacityChanged: visible = opacity !== 0
|
||||||
|
|
||||||
function saveSettings(settingsObject) {
|
function onPageClosed(settingsObject) {
|
||||||
settingsObject.wallet.setPassword(passwordItem.password)
|
settingsObject.wallet.setPassword(passwordItem.password)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ Item {
|
||||||
|
|
||||||
onOpacityChanged: visible = opacity !== 0
|
onOpacityChanged: visible = opacity !== 0
|
||||||
|
|
||||||
function saveSettings(settingsObject) {
|
function onPageClosed(settingsObject) {
|
||||||
settingsObject['account_name'] = uiItem.accountNameText
|
settingsObject['account_name'] = uiItem.accountNameText
|
||||||
settingsObject['words'] = uiItem.wordsTexttext
|
settingsObject['words'] = uiItem.wordsTexttext
|
||||||
settingsObject['wallet_path'] = uiItem.walletPath
|
settingsObject['wallet_path'] = uiItem.walletPath
|
||||||
|
|
|
@ -36,8 +36,11 @@ Item {
|
||||||
|
|
||||||
onOpacityChanged: visible = opacity !== 0
|
onOpacityChanged: visible = opacity !== 0
|
||||||
|
|
||||||
function saveSettings(settingsObject) {
|
function onPageClosed(settingsObject) {
|
||||||
settingsObject['language'] = languagesModel.get(gridView.currentIndex).name
|
var lang = languagesModel.get(gridView.currentIndex);
|
||||||
|
settingsObject['language'] = lang.display_name;
|
||||||
|
settingsObject['wallet_language'] = lang.wallet_name;
|
||||||
|
settingsObject['locale'] = lang.locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
@ -78,7 +81,9 @@ Item {
|
||||||
source: "/lang/languages.xml"
|
source: "/lang/languages.xml"
|
||||||
query: "/languages/language"
|
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()" }
|
XmlRole { name: "flag"; query: "@flag/string()" }
|
||||||
// TODO: XmlListModel is read only, we should store current language somewhere else
|
// TODO: XmlListModel is read only, we should store current language somewhere else
|
||||||
// and set current language accordingly
|
// and set current language accordingly
|
||||||
|
@ -126,7 +131,7 @@ Item {
|
||||||
font.bold: gridView.currentIndex === index
|
font.bold: gridView.currentIndex === index
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
color: "#3F3F3F"
|
color: "#3F3F3F"
|
||||||
text: name
|
text: display_name
|
||||||
}
|
}
|
||||||
MouseArea {
|
MouseArea {
|
||||||
id: delegateArea
|
id: delegateArea
|
||||||
|
|
Loading…
Reference in a new issue