Verified Commit c19d2736 authored by Ingo Klöcker's avatar Ingo Klöcker Committed by Ingo Klöcker
Browse files

Remove word puzzles

Use an enum for the current sign and/or encrypt operation and use
individually translated UI texts.

GnuPG-bug-id: 6188
parent 7df275a7
Pipeline #228875 passed with stage
in 2 minutes and 55 seconds
......@@ -438,11 +438,25 @@ public:
}
private Q_SLOTS:
void updateCommitButton(const QString &label)
void updateCommitButton(const SignEncryptWidget::Operation op)
{
if (mParent->currentPage() != this) {
return;
}
QString label;
switch (op) {
case SignEncryptWidget::Sign:
label = i18nc("@action:button", "Sign");
break;
case SignEncryptWidget::Encrypt:
label = i18nc("@action:button", "Encrypt");
break;
case SignEncryptWidget::SignAndEncrypt:
label = i18nc("@action:button", "Sign / Encrypt");
break;
default:
;
};
auto btn = qobject_cast<QPushButton*>(mParent->button(QWizard::CommitButton));
if (!label.isEmpty()) {
mParent->setButtonText(QWizard::CommitButton, label);
......
......@@ -483,22 +483,20 @@ void SignEncryptWidget::updateOp()
const Key sigKey = signKey();
const std::vector<Key> recp = recipients();
QString newOp;
if (!sigKey.isNull() && (!recp.empty() || encryptSymmetric())) {
newOp = i18nc("@action", "Sign / Encrypt");
mOp = SignAndEncrypt;
} else if (!recp.empty() || encryptSymmetric()) {
newOp = i18nc("@action", "Encrypt");
mOp = Encrypt;
} else if (!sigKey.isNull()) {
newOp = i18nc("@action", "Sign");
mOp = Sign;
} else {
newOp = QString();
mOp = NoOperation;
}
mOp = newOp;
Q_EMIT operationChanged(mOp);
Q_EMIT keysChanged();
}
QString SignEncryptWidget::currentOp() const
SignEncryptWidget::Operation SignEncryptWidget::currentOp() const
{
return mOp;
}
......@@ -645,7 +643,7 @@ void Kleo::SignEncryptWidget::onProtocolChanged()
bool SignEncryptWidget::isComplete() const
{
return !currentOp().isEmpty()
return currentOp() != NoOperation
&& std::all_of(std::cbegin(mRecpWidgets), std::cend(mRecpWidgets),
[](auto w) { return !w->isEnabled() || w->hasAcceptableInput(); });
}
......
......@@ -29,6 +29,13 @@ class SignEncryptWidget: public QWidget
{
Q_OBJECT
public:
enum Operation {
NoOperation,
Sign,
Encrypt,
SignAndEncrypt
};
/** If cmsSigEncExclusive is true CMS operations can be
* done only either as sign or as encrypt */
explicit SignEncryptWidget(QWidget *parent = nullptr, bool cmsSigEncExclusive = false);
......@@ -52,9 +59,8 @@ public:
* encrypt to self is disabled. */
GpgME::Key selfKey() const;
/** Returns the operation based on the current selection or
* a null string if nothing would happen. */
QString currentOp() const;
/** Returns the operation based on the current selection. */
Operation currentOp() const;
/** Whether or not symmetric encryption should also be used. */
bool encryptSymmetric() const;
......@@ -115,7 +121,7 @@ Q_SIGNALS:
/* Emitted when the certificate selection changed the operation
* with that selection. e.g. "Sign" or "Sign/Encrypt".
* If no crypto operation is selected this returns a null string. */
void operationChanged(const QString &op);
void operationChanged(Operation op);
/* Emitted when the certificate selection might be changed. */
void keysChanged();
......@@ -136,7 +142,7 @@ private:
QVector<GpgME::Key> mAddedKeys;
QVector<KeyGroup> mAddedGroups;
QVBoxLayout *mRecpLayout = nullptr;
QString mOp;
Operation mOp;
AbstractKeyListModel *mModel = nullptr;
QCheckBox *mSymmetric = nullptr;
QCheckBox *mSigChk = nullptr;
......
......@@ -208,7 +208,7 @@ public:
doEncryptSign();
});
connect(mSigEncWidget, &SignEncryptWidget::operationChanged, q, [this] (const QString &) {
connect(mSigEncWidget, &SignEncryptWidget::operationChanged, q, [this]() {
updateButtons();
});
......@@ -397,7 +397,19 @@ public:
}
doCryptoCommon();
mProgressLabel->setText(mSigEncWidget->currentOp() + QStringLiteral("..."));
switch (mSigEncWidget->currentOp()) {
case SignEncryptWidget::Sign:
mProgressLabel->setText(i18nc("@info:progress", "Signing notepad..."));
break;
case SignEncryptWidget::Encrypt:
mProgressLabel->setText(i18nc("@info:progress", "Encrypting notepad..."));
break;
case SignEncryptWidget::SignAndEncrypt:
mProgressLabel->setText(i18nc("@info:progress", "Signing and encrypting notepad..."));
break;
default:
;
};
auto input = Input::createFromByteArray(&mInputData, i18n("Notepad"));
auto output = Output::createFromByteArray(&mOutputData, i18n("Notepad"));
......@@ -476,15 +488,18 @@ public:
checkImportProtocol();
mImportBtn->setEnabled(mImportProto != GpgME::UnknownProtocol);
if (!mSigEncWidget->currentOp().isEmpty()) {
mCryptBtn->setEnabled(true);
mCryptBtn->setText(i18nc("1 is an operation to apply to the notepad. "
"Like Sign/Encrypt or just Encrypt.", "%1 Notepad",
mSigEncWidget->currentOp()));
} else {
mCryptBtn->setText(i18n("Sign / Encrypt Notepad"));
mCryptBtn->setEnabled(false);
}
mCryptBtn->setEnabled(mSigEncWidget->currentOp() != SignEncryptWidget::NoOperation);
switch (mSigEncWidget->currentOp()) {
case SignEncryptWidget::Sign:
mCryptBtn->setText(i18nc("@action:button", "Sign Notepad"));
break;
case SignEncryptWidget::Encrypt:
mCryptBtn->setText(i18nc("@action:button", "Encrypt Notepad"));
break;
case SignEncryptWidget::SignAndEncrypt:
default:
mCryptBtn->setText(i18nc("@action:button", "Sign / Encrypt Notepad"));
};
if (DeVSCompliance::isActive()) {
const bool de_vs = DeVSCompliance::isCompliant() && mSigEncWidget->isDeVsAndValid();
......
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