use signals

This commit is contained in:
Liv Erickson 2018-01-25 15:04:12 -08:00
parent 7ee5608992
commit 7e5684c439
2 changed files with 14 additions and 18 deletions

View file

@ -267,13 +267,6 @@ void ContextOverlayInterface::contextOverlays_hoverLeaveEntity(const EntityItemI
}
}
bool ContextOverlayInterface::getLastInspectedEntityWasValid() {
if (!_lastInspectedEntity.isNull() && !_lastInspectedValidEntity.isNull()) {
return _lastInspectedEntity == _lastInspectedValidEntity;
}
return false;
}
void ContextOverlayInterface::requestEntityOwnershipVerification(const QUuid& entityItemID) {
EntityItemProperties entityProperties = _entityScriptingInterface->getEntityProperties(entityItemID, _entityPropertyFlags);
_entityMarketplaceID = entityProperties.getMarketplaceID();
@ -368,6 +361,7 @@ void ContextOverlayInterface::requestOwnershipVerification() {
auto ledger = DependencyManager::get<Ledger>();
_challengeOwnershipTimeoutTimer.stop();
emit ledger->updateCertificateStatus(entityProperties.getCertificateID(), (uint)(ledger->CERTIFICATE_STATUS_STATIC_VERIFICATION_FAILED));
emit ownershipVerificationFailed(_lastInspectedEntity);
qCDebug(context_overlay) << "Entity" << _lastInspectedEntity << "failed static certificate verification!";
}
}
@ -424,6 +418,7 @@ void ContextOverlayInterface::startChallengeOwnershipTimer() {
connect(&_challengeOwnershipTimeoutTimer, &QTimer::timeout, this, [=]() {
qCDebug(entities) << "Ownership challenge timed out for" << _lastInspectedEntity;
emit ledger->updateCertificateStatus(entityProperties.getCertificateID(), (uint)(ledger->CERTIFICATE_STATUS_VERIFICATION_TIMEOUT));
emit ownershipVerificationFailed(_lastInspectedEntity);
});
_challengeOwnershipTimeoutTimer.start(5000);
@ -448,8 +443,9 @@ void ContextOverlayInterface::handleChallengeOwnershipReplyPacket(QSharedPointer
if (verificationSuccess) {
emit ledger->updateCertificateStatus(certID, (uint)(ledger->CERTIFICATE_STATUS_VERIFICATION_SUCCESS));
_lastInspectedValidEntity = _lastInspectedEntity;
emit ownershipVerificationSuccess(_lastInspectedEntity);
} else {
emit ledger->updateCertificateStatus(certID, (uint)(ledger->CERTIFICATE_STATUS_OWNER_VERIFICATION_FAILED));
emit ownershipVerificationFailed(_lastInspectedEntity);
}
}

View file

@ -36,21 +36,20 @@
class ContextOverlayInterface : public QObject, public Dependency {
Q_OBJECT
Q_PROPERTY(QUuid entityWithContextOverlay READ getCurrentEntityWithContextOverlay WRITE setCurrentEntityWithContextOverlay)
Q_PROPERTY(bool enabled READ getEnabled WRITE setEnabled)
Q_PROPERTY(bool isInMarketplaceInspectionMode READ getIsInMarketplaceInspectionMode WRITE setIsInMarketplaceInspectionMode)
Q_PROPERTY(QUuid entityWithContextOverlay READ getCurrentEntityWithContextOverlay WRITE setCurrentEntityWithContextOverlay)
Q_PROPERTY(bool enabled READ getEnabled WRITE setEnabled)
Q_PROPERTY(bool isInMarketplaceInspectionMode READ getIsInMarketplaceInspectionMode WRITE setIsInMarketplaceInspectionMode)
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
QSharedPointer<EntityScriptingInterface> _entityScriptingInterface;
EntityPropertyFlags _entityPropertyFlags;
QSharedPointer<HMDScriptingInterface> _hmdScriptingInterface;
QSharedPointer<TabletScriptingInterface> _tabletScriptingInterface;
QSharedPointer<SelectionScriptingInterface> _selectionScriptingInterface;
OverlayID _contextOverlayID{ UNKNOWN_OVERLAY_ID };
std::shared_ptr<Image3DOverlay> _contextOverlay{ nullptr };
OverlayID _contextOverlayID { UNKNOWN_OVERLAY_ID };
std::shared_ptr<Image3DOverlay> _contextOverlay { nullptr };
public:
ContextOverlayInterface();
Q_INVOKABLE QUuid getCurrentEntityWithContextOverlay() { return _currentEntityWithContextOverlay; }
Q_INVOKABLE bool getLastInspectedEntityWasValid();
Q_INVOKABLE void requestEntityOwnershipVerification(const QUuid& entityID);
void setCurrentEntityWithContextOverlay(const QUuid& entityID) { _currentEntityWithContextOverlay = entityID; }
void setLastInspectedEntity(const QUuid& entityID) { _challengeOwnershipTimeoutTimer.stop(); _lastInspectedEntity = entityID; }
@ -61,8 +60,10 @@ public:
signals:
void contextOverlayClicked(const QUuid& currentEntityWithContextOverlay);
void ownershipVerificationSuccess(const QUuid& entityID);
void ownershipVerificationFailed(const QUuid& entityID);
public slots:
public slots:
bool createOrDestroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
bool destroyContextOverlay(const EntityItemID& entityItemID, const PointerEvent& event);
bool destroyContextOverlay(const EntityItemID& entityItemID);
@ -73,7 +74,7 @@ signals:
void contextOverlays_hoverLeaveEntity(const EntityItemID& entityID, const PointerEvent& event);
bool contextOverlayFilterPassed(const EntityItemID& entityItemID);
private slots:
private slots:
void handleChallengeOwnershipReplyPacket(QSharedPointer<ReceivedMessage> packet, SharedNodePointer sendingNode);
private:
@ -85,7 +86,6 @@ private:
bool _enabled{ true };
EntityItemID _currentEntityWithContextOverlay{};
EntityItemID _lastInspectedEntity{};
EntityItemID _lastInspectedValidEntity{};
QString _entityMarketplaceID;
bool _contextOverlayJustClicked { false };