I have a UI for some decryption software that gets invoked from the mail client on an encrypted attachment.
My decryption object emits a signal on successful completion of the decryption :
emit decryptedChanged();
which I pass through my controller object (attached as _encryptedattachmentencryptedattachment to the QML UI:
connect(m_decryptor, SIGNAL(decryptedChanged()), this, SIGNAL(decryptedChanged()));
I have a Sheet which is shown on invocation on an encrypted file: when the UI is initialised:
onCreationCompleted: {
splashscreen.open();
}
(at the end of my TabbedPane, before the attachedObjects where the Sheet is.)
I am trying to get the Sheet to close based on the signal.
Sheet {
id: splashscreen
peekEnabled: false
Page {
Container {
layout: DockLayout {
}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
Label {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Center
text: "Decrypting..."
multiline: true
}
}
}
onCreationCompleted: {
_encryptedattachment.decryptedChanged.connect(splashscreen.onDecryptedChanged());
}
function onDecryptedChanged () {
splashscreen.close();
}
}
The splashscreen will not close. I know the object can be seen by the UI, as I use other properties etc. Am I missing a QPROPERTY or something?
Update:
This is my signal definition:
Q_INVOKABLE void decryptedChanged();
Update again:
I have added some console.logs to the QML:
onCreationCompleted: {
_encryptedattachment.decryptedChanged.connect( splashscreen.onDecryptedChanged() );
console.log("connected");
}
function onDecryptedChanged() {
console.log("closing");
splashscreen.close();
}
This gives me the following ouptut:
closing
connected
which is backwards, and the splashscreen does not close.
The problem is in this line:
_encryptedattachment.decryptedChanged.connect( splashscreen.onDecryptedChanged() );
the parentheses after the onDecryptedChanged mean that that function is called, not connected to.
_encryptedattachment.decryptedChanged.connect( splashscreen.onDecryptedChanged );
works fine.