fix image provider, couple other things

This commit is contained in:
David Kelly 2017-08-30 15:23:54 -07:00
parent b8da08ca42
commit 988ee8c8d1
6 changed files with 50 additions and 10 deletions

View file

@ -54,6 +54,7 @@ Item {
text: "Testing: Reset Wallet!";
onClicked: {
commerce.reset();
sendSignalToWallet({method: 'walletReset'});
}
}

View file

@ -107,7 +107,7 @@ Rectangle {
anchors.centerIn: walletSetupLightboxContainer;
width: walletSetupLightboxContainer.width - 50;
height: walletSetupLightboxContainer.height - 50;
Connections {
onSendSignalToWallet: {
if (msg.method === 'walletSetup_raiseKeyboard') {
@ -127,7 +127,7 @@ Rectangle {
anchors.centerIn: walletSetupLightboxContainer;
width: walletSetupLightboxContainer.width - 50;
height: walletSetupLightboxContainer.height - 50;
Connections {
onSendSignalToWallet: {
sendToScript(msg);
@ -196,7 +196,7 @@ Rectangle {
commerce.getLoginStatus();
}
}
NeedsLogIn {
id: needsLogIn;
visible: root.activeView === "needsLogIn";
@ -225,7 +225,7 @@ Rectangle {
anchors.bottom: tabButtonsContainer.top;
anchors.left: parent.left;
anchors.right: parent.right;
Connections {
onSendSignalToWallet: {
if (msg.method === 'setUpClicked') {
@ -295,6 +295,14 @@ Rectangle {
anchors.leftMargin: 16;
anchors.right: parent.right;
anchors.rightMargin: 16;
Connections {
onSendSignalToWallet: {
if (msg.method === 'walletReset') {
sendToScript(msg);
}
}
}
}
@ -509,7 +517,7 @@ Rectangle {
}
//
// TAB BUTTONS END
//
//
Item {
id: keyboardContainer;

View file

@ -14,6 +14,7 @@
#include "Wallet.h"
#include "Application.h"
#include "ui/ImageProvider.h"
#include "scripting/HMDScriptingInterface.h"
#include <PathUtils.h>
#include <OffscreenUi.h>
@ -493,10 +494,21 @@ void Wallet::sendKeyFilePathIfExists() {
void Wallet::reset() {
_publicKeys.clear();
delete _securityImage;
_securityImage = nullptr;
// tell the provider we got nothing
updateImageProvider();
delete _passphrase;
// for now we need to maintain the hard-coded passphrase.
// FIXME: remove this line as part of wiring up the passphrase
// and probably set it to nullptr
_passphrase = new QString("pwd");
QFile keyFile(keyFilePath());
QFile imageFile(imageFilePath());
keyFile.remove();
imageFile.remove();
}
}

View file

@ -18,10 +18,25 @@ const QString ImageProvider::PROVIDER_NAME = "security";
QReadWriteLock ImageProvider::_rwLock;
QPixmap* ImageProvider::_securityImage = nullptr;
void ImageProvider::setSecurityImage(QPixmap* pixmap) {
ImageProvider::~ImageProvider() {
QWriteLocker lock(&_rwLock);
if (_securityImage) {
delete _securityImage;
_securityImage = nullptr;
}
}
void ImageProvider::setSecurityImage(const QPixmap* pixmap) {
// no need to delete old one, that is managed by the wallet
QWriteLocker lock(&_rwLock);
_securityImage = pixmap;
if (_securityImage) {
delete _securityImage;
}
if (pixmap) {
_securityImage = new QPixmap(*pixmap);
} else {
_securityImage = nullptr;
}
}
QPixmap ImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) {

View file

@ -20,10 +20,10 @@ public:
static const QString PROVIDER_NAME;
ImageProvider() : QQuickImageProvider(QQuickImageProvider::Pixmap) {}
virtual ~ImageProvider();
QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requestedSize) override;
void setSecurityImage(QPixmap* pixmap);
void setSecurityImage(const QPixmap* pixmap);
protected:
static QReadWriteLock _rwLock;
static QPixmap* _securityImage;

View file

@ -70,6 +70,10 @@
case 'maybeEnableHmdPreview':
Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled);
break;
case 'walletReset':
onButtonClicked();
onButtonClicked();
break;
default:
print('Unrecognized message from QML:', JSON.stringify(message));
}