Commit b2817adf authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Ensure correct setup of UI for default protocol

Decouple the update of the UI after a change of the protocol from
setting the protocol. This way we can initialize the protocol already
in-class and still setup the UI depending on the protocol without having
to rely on the uninitialized mCurrentProto being different from
GpgME::UnknownProtocol.

The initialization of mCurrentProto in-class also ensures that other
setup code uses the correct value.

GnuPG-bug-id: 5535
parent 06b03e9b
......@@ -214,7 +214,7 @@ SignEncryptWidget::SignEncryptWidget(QWidget *parent, bool sigEncExclusive)
lay->addWidget(encBox);
loadKeys();
setProtocol(GpgME::UnknownProtocol);
onProtocolChanged();
addRecipientWidget();
updateOp();
}
......@@ -607,19 +607,24 @@ void SignEncryptWidget::setProtocol(GpgME::Protocol proto)
return;
}
mCurrentProto = proto;
mSigSelect->setKeyFilter(std::shared_ptr<KeyFilter>(new SignCertificateFilter(proto)));
mSelfSelect->setKeyFilter(std::shared_ptr<KeyFilter>(new EncryptSelfCertificateFilter(proto)));
const auto encFilter = std::shared_ptr<KeyFilter>(new EncryptCertificateFilter(proto));
onProtocolChanged();
}
void Kleo::SignEncryptWidget::onProtocolChanged()
{
mSigSelect->setKeyFilter(std::shared_ptr<KeyFilter>(new SignCertificateFilter(mCurrentProto)));
mSelfSelect->setKeyFilter(std::shared_ptr<KeyFilter>(new EncryptSelfCertificateFilter(mCurrentProto)));
const auto encFilter = std::shared_ptr<KeyFilter>(new EncryptCertificateFilter(mCurrentProto));
for (CertificateLineEdit *edit : std::as_const(mRecpWidgets)) {
edit->setKeyFilter(encFilter);
}
if (mIsExclusive) {
mSymmetric->setDisabled(proto == GpgME::CMS);
if (mSymmetric->isChecked() && proto == GpgME::CMS) {
mSymmetric->setDisabled(mCurrentProto == GpgME::CMS);
if (mSymmetric->isChecked() && mCurrentProto == GpgME::CMS) {
mSymmetric->setChecked(false);
}
if (mSigChk->isChecked() && proto == GpgME::CMS &&
if (mSigChk->isChecked() && mCurrentProto == GpgME::CMS &&
(mEncSelfChk->isChecked() || mEncOtherChk->isChecked())) {
mSigChk->setChecked(false);
}
......
......@@ -116,6 +116,7 @@ Q_SIGNALS:
private:
CertificateLineEdit* addRecipientWidget();
void onProtocolChanged();
private:
KeySelectionCombo *mSigSelect = nullptr;
......@@ -132,7 +133,7 @@ private:
QCheckBox *mEncOtherChk = nullptr;
QCheckBox *mEncSelfChk = nullptr;
int mRecpRowCount = 2;
GpgME::Protocol mCurrentProto;
GpgME::Protocol mCurrentProto = GpgME::UnknownProtocol;
const bool mIsExclusive;
};
} // namespace Kleo
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment