Print wallet filename in password dialog where approrpiate

pull/2/head
moneromooo.monero 8 years ago
parent 26abdee5c4
commit b5a993bd8a

@ -40,19 +40,28 @@ Window {
modality: Qt.ApplicationModal modality: Qt.ApplicationModal
flags: Qt.Window | Qt.FramelessWindowHint flags: Qt.Window | Qt.FramelessWindowHint
property alias password: passwordInput.text property alias password: passwordInput.text
property string walletName
// same signals as Dialog has // same signals as Dialog has
signal accepted() signal accepted()
signal rejected() signal rejected()
function open() { function open(walletName) {
root.walletName = walletName ? walletName : ""
show() show()
} }
function usefulName(path) {
// arbitrary "short enough" limit
if (path.length < 32)
return path
return path.replace(/.*[\/\\]/, '').replace(/\.keys$/, '')
}
// TODO: implement without hardcoding sizes // TODO: implement without hardcoding sizes
width: 480 width: 480
height: 200 height: walletName ? 240 : 200
ColumnLayout { ColumnLayout {
id: mainLayout id: mainLayout
@ -65,7 +74,7 @@ Window {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Label { Label {
text: qsTr("Please enter wallet password") text: root.walletName.length > 0 ? qsTr("Please enter wallet password for:<br>") + usefulName(root.walletName) : qsTr("Please enter wallet password")
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.columnSpan: 2 Layout.columnSpan: 2
Layout.fillWidth: true Layout.fillWidth: true

@ -240,7 +240,7 @@ ApplicationWindow {
console.log("closing wallet async : " + wallet.address) console.log("closing wallet async : " + wallet.address)
walletManager.closeWalletAsync(wallet) walletManager.closeWalletAsync(wallet)
// try to open wallet with password; // try to open wallet with password;
passwordDialog.open(); passwordDialog.open(wallet.path);
} else { } else {
// opening with password but password doesn't match // opening with password but password doesn't match
console.error("Error opening wallet with password: ", wallet.errorString); console.error("Error opening wallet with password: ", wallet.errorString);
@ -252,7 +252,7 @@ ApplicationWindow {
walletManager.closeWalletAsync(wallet); walletManager.closeWalletAsync(wallet);
informationPopup.open() informationPopup.open()
informationPopup.onCloseCallback = function() { informationPopup.onCloseCallback = function() {
passwordDialog.open() passwordDialog.open(wallet.path)
} }
} }
return; return;

@ -112,6 +112,11 @@ QString Wallet::address() const
return QString::fromStdString(m_walletImpl->address()); return QString::fromStdString(m_walletImpl->address());
} }
QString Wallet::path() const
{
return QString::fromStdString(m_walletImpl->path());
}
bool Wallet::store(const QString &path) bool Wallet::store(const QString &path)
{ {
return m_walletImpl->store(path.toStdString()); return m_walletImpl->store(path.toStdString());

@ -31,6 +31,7 @@ class Wallet : public QObject
Q_PROPERTY(TransactionHistory * history READ history) Q_PROPERTY(TransactionHistory * history READ history)
Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId) Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId)
Q_PROPERTY(TransactionHistorySortFilterModel * historyModel READ historyModel NOTIFY historyModelChanged) Q_PROPERTY(TransactionHistorySortFilterModel * historyModel READ historyModel NOTIFY historyModelChanged)
Q_PROPERTY(QString path READ path)
public: public:
@ -78,6 +79,9 @@ public:
//! returns wallet's public address //! returns wallet's public address
QString address() const; QString address() const;
//! returns wallet file's path
QString path() const;
//! saves wallet to the file by given path //! saves wallet to the file by given path
//! empty path stores in current location //! empty path stores in current location
Q_INVOKABLE bool store(const QString &path = ""); Q_INVOKABLE bool store(const QString &path = "");