Ask for password in wallet is password protected. closes #26

This commit is contained in:
Ilya Kitaev 2016-08-17 15:14:43 +03:00
parent 6f1343aaa0
commit c1269301f7
7 changed files with 138 additions and 29 deletions

View File

@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.0
import QtGraphicalEffects 1.0
import "components"
import "pages"
@ -167,5 +168,12 @@ Rectangle {
}
}
// indicate disabled state
Desaturate {
anchors.fill: parent
source: parent
desaturation: root.enabled ? 0.0 : 1.0
}
}

View File

@ -27,6 +27,7 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.2
import QtGraphicalEffects 1.0
import "components"
Rectangle {
@ -355,4 +356,12 @@ Rectangle {
connected: false
}
}
// indicate disabled state
Desaturate {
anchors.fill: parent
source: parent
desaturation: panel.enabled ? 0.0 : 1.0
}
}

View File

@ -27,8 +27,10 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import QtQuick 2.2
import QtGraphicalEffects 1.0
Rectangle {
id: root
color: "#F0EEEE"
signal paymentClicked(string address, string paymentId, double amount, int mixinCount, int priority)
signal generatePaymentIdInvoked()
@ -116,4 +118,11 @@ Rectangle {
height: 1
color: "#DBDBDB"
}
// indicate disabled state
Desaturate {
anchors.fill: parent
source: parent
desaturation: root.enabled ? 0.0 : 1.0
}
}

View File

@ -29,10 +29,13 @@
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
import QtGraphicalEffects 1.0
import "tabs"
import "components"
Rectangle {
id: root
width: 330
color: "#FFFFFF"
@ -145,4 +148,11 @@ Rectangle {
width: 1
color: "#DBDBDB"
}
// indicate disabled state
Desaturate {
anchors.fill: parent
source: parent
desaturation: root.enabled ? 0.0 : 1.0
}
}

View File

@ -1,5 +1,40 @@
import QtQuick 2.0
import QtQuick.Controls 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.4
Item {
// import "../components"
Dialog {
id: root
readonly property alias password: passwordInput.text
standardButtons: StandardButton.Ok + StandardButton.Cancel
ColumnLayout {
id: column
height: 40
anchors.fill: parent
Label {
text: qsTr("Please enter wallet password")
Layout.columnSpan: 2
Layout.fillWidth: true
font.family: "Arial"
font.pixelSize: 32
}
TextField {
id : passwordInput
echoMode: TextInput.Password
focus: true
Layout.fillWidth: true
font.family: "Arial"
font.pixelSize: 24
style: TextFieldStyle {
passwordCharacter: "•"
}
}
}
}

View File

@ -41,7 +41,8 @@ import "wizard"
ApplicationWindow {
id: appWindow
objectName: "appWindow"
property var currentItem
property bool whatIsEnable: false
property bool ctrlPressed: false
@ -50,6 +51,8 @@ ApplicationWindow {
property alias persistentSettings : persistentSettings
property var wallet;
property var transaction;
property alias password : passwordDialog.password
function altKeyReleased() { ctrlPressed = false; }
@ -98,24 +101,24 @@ ApplicationWindow {
}
function mousePressed(obj, mouseX, mouseY) {
if(obj.objectName === "appWindow")
obj = rootItem
// if(obj.objectName === "appWindow")
// obj = rootItem
var tmp = rootItem.mapFromItem(obj, mouseX, mouseY)
if(tmp !== undefined) {
mouseX = tmp.x
mouseY = tmp.y
}
// var tmp = rootItem.mapFromItem(obj, mouseX, mouseY)
// if(tmp !== undefined) {
// mouseX = tmp.x
// mouseY = tmp.y
// }
if(currentItem !== undefined) {
var tmp_x = rootItem.mapToItem(currentItem, mouseX, mouseY).x
var tmp_y = rootItem.mapToItem(currentItem, mouseX, mouseY).y
// if(currentItem !== undefined) {
// var tmp_x = rootItem.mapToItem(currentItem, mouseX, mouseY).x
// var tmp_y = rootItem.mapToItem(currentItem, mouseX, mouseY).y
if(!currentItem.containsPoint(tmp_x, tmp_y)) {
currentItem.hide()
currentItem = undefined
}
}
// if(!currentItem.containsPoint(tmp_x, tmp_y)) {
// currentItem.hide()
// currentItem = undefined
// }
// }
}
function mouseReleased(obj, mouseX, mouseY) {
@ -142,17 +145,18 @@ ApplicationWindow {
var wallet_path = walletPath();
console.log("opening wallet at: ", wallet_path);
// TODO: wallet password dialog
wallet = walletManager.openWallet(wallet_path, "", persistentSettings.testnet);
wallet = walletManager.openWallet(wallet_path, appWindow.password,
persistentSettings.testnet);
if (wallet.status !== Wallet.Status_Ok) {
console.error("Error opening wallet with empty password: ", wallet.errorString);
console.log("closing wallet...")
walletManager.closeWallet(wallet)
console.log("wallet closed")
// try to open wallet with password;
passwordDialog.open();
return;
}
console.log("Wallet opened successfully: ", wallet.errorString);
}
// subscribing for wallet updates
@ -195,6 +199,8 @@ ApplicationWindow {
}
// called on "transfer"
function handlePayment(address, paymentId, amount, mixinCount, priority) {
console.log("Creating transaction: ")
@ -213,6 +219,7 @@ ApplicationWindow {
informationPopup.title = qsTr("Error") + translationManager.emptyString;
informationPopup.text = qsTr("Can't create transaction: ") + transaction.errorString
informationPopup.icon = StandardIcon.Critical
informationPopup.onCloseCallback = null
informationPopup.open();
// deleting transaction object, we don't want memleaks
wallet.disposeTransaction(transaction);
@ -248,13 +255,22 @@ ApplicationWindow {
informationPopup.text = qsTr("Money sent successfully") + translationManager.emptyString
informationPopup.icon = StandardIcon.Information
}
informationPopup.onCloseCallback = null
informationPopup.open()
wallet.refresh()
wallet.disposeTransaction(transaction)
}
// blocks UI if wallet can't be opened or no connection to the daemon
function enableUI(enable) {
middlePanel.enabled = enable;
leftPanel.enabled = enable;
rightPanel.enabled = enable;
basicPanel.enabled = enable;
}
objectName: "appWindow"
visible: true
width: rightPanelExpanded ? 1269 : 1269 - 300
height: 800
@ -262,6 +278,7 @@ ApplicationWindow {
flags: Qt.FramelessWindowHint | Qt.WindowSystemMenuHint | Qt.Window | Qt.WindowMinimizeButtonHint
onWidthChanged: x -= 0
Component.onCompleted: {
x = (Screen.width - width) / 2
y = (Screen.height - height) / 2
@ -278,6 +295,7 @@ ApplicationWindow {
}
}
Settings {
id: persistentSettings
property string language
@ -296,9 +314,15 @@ ApplicationWindow {
// Information dialog
MessageDialog {
// dynamically change onclose handler
property var onCloseCallback
id: informationPopup
standardButtons: StandardButton.Ok
onAccepted: {
if (onCloseCallback) {
onCloseCallback()
}
}
}
// Confrirmation aka question dialog
@ -317,6 +341,7 @@ ApplicationWindow {
var wallet_path = walletPath();
console.log("opening wallet with password: ", wallet_path);
wallet = walletManager.openWallet(wallet_path, password, persistentSettings.testnet);
if (wallet.status !== Wallet.Status_Ok) {
console.error("Error opening wallet with password: ", wallet.errorString);
@ -324,9 +349,16 @@ ApplicationWindow {
informationPopup.text = qsTr("Couldn't open wallet: ") + wallet.errorString;
informationPopup.icon = StandardIcon.Critical
informationPopup.open()
informationPopup.onCloseCallback = appWindow.initialize
walletManager.closeWallet(wallet);
}
}
onRejected: {
appWindow.enableUI(false)
}
onDiscard: {
appWindow.enableUI(false)
}
}
Window {
@ -339,7 +371,6 @@ ApplicationWindow {
anchors.fill: parent
text: qsTr("Initializing Wallet...");
}
}

View File

@ -146,6 +146,8 @@ isEmpty(QMAKE_LRELEASE) {
langupd.command = \
$$LANGUPD $$LANGUPD_OPTIONS $$shell_path($$_PRO_FILE) -ts $$_PRO_FILE_PWD/$$TRANSLATIONS
langrel.depends = langupd
langrel.input = TRANSLATIONS
langrel.output = $$TRANSLATION_TARGET_DIR/${QMAKE_FILE_BASE}.qm
@ -157,7 +159,12 @@ QMAKE_EXTRA_TARGETS += langupd deploy deploy_win
QMAKE_EXTRA_COMPILERS += langrel
PRE_TARGETDEPS += langupd compiler_langrel_make_all
# temporary: do not update/release translations for "Debug" build,
# as we have an issue with linking
CONFIG(release, debug|release) {
PRE_TARGETDEPS += langupd compiler_langrel_make_all
}
RESOURCES += qml.qrc
@ -182,8 +189,8 @@ OTHER_FILES += \
$$TRANSLATIONS
DISTFILES += \
notes.txt \
components/PasswordDialog.qml
notes.txt
# windows application icon
RC_FILE = monero-core.rc