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

Disable Decrypt/Verify button if required files do not exist

If the signed file or the detached signature is empty or does not exist,
then do not allow the user to proceed. Otherwise, the missing files
cause weird error messages.

GnuPG-bug-id: 6062
parent 1161f2ad
Pipeline #200820 passed with stage
in 3 minutes and 32 seconds
......@@ -85,7 +85,19 @@ public:
bool isComplete() const override
{
return true;
return std::all_of(m_widgets.cbegin(), m_widgets.cend(), [](const auto &w) {
switch (w->mode()) {
case DecryptVerifyOperationWidget::VerifyDetachedWithSignature:
case DecryptVerifyOperationWidget::VerifyDetachedWithSignedData: {
const QString sigFileName = w->inputFileName();
const QString dataFileName = w->signedDataFileName();
return !sigFileName.isEmpty() && !dataFileName.isEmpty() && QFile::exists(sigFileName) && QFile::exists(dataFileName);
}
case DecryptVerifyOperationWidget::DecryptVerifyOpaque:
;
}
return true;
});
}
private:
std::vector<DecryptVerifyOperationWidget *> m_widgets;
......@@ -246,6 +258,7 @@ void OperationsWidget::ensureIndexAvailable(unsigned int idx)
auto w = new DecryptVerifyOperationWidget(m_ui.scrollArea.widget());
blay.insertWidget(blay.count() - 1, w);
w->show();
connect(w, &DecryptVerifyOperationWidget::changed, this, &WizardPage::completeChanged);
m_widgets.push_back(w);
}
}
......
......@@ -122,6 +122,10 @@ DecryptVerifyOperationWidget::Private::UI::UI(DecryptVerifyOperationWidget *q)
connect(&verifyDetachedCB, &QCheckBox::toggled, &signedDataFileNameRQ, &FileNameRequester::setEnabled);
connect(&verifyDetachedCB, SIGNAL(toggled(bool)), q, SLOT(enableDisableWidgets()));
connect(&archiveCB, SIGNAL(toggled(bool)), q, SLOT(enableDisableWidgets()));
connect(&verifyDetachedCB, &QCheckBox::toggled, q, &DecryptVerifyOperationWidget::changed);
connect(&inputFileNameRQ, &FileNameRequester::fileNameChanged, q, &DecryptVerifyOperationWidget::changed);
connect(&signedDataFileNameRQ, &FileNameRequester::fileNameChanged, q, &DecryptVerifyOperationWidget::changed);
}
DecryptVerifyOperationWidget::Private::Private(DecryptVerifyOperationWidget *qq)
......@@ -175,11 +179,13 @@ void DecryptVerifyOperationWidget::setMode(Mode mode, const std::shared_ptr<Arch
d->ui.signedDataLB.setBuddy(signedDataWidget);
d->ui.archiveCB.setChecked(ad.get() != nullptr);
for (int i = 0, end = d->ui.archivesCB.count(); i != end; ++i)
for (int i = 0, end = d->ui.archivesCB.count(); i != end; ++i) {
if (ad == d->ui.archivesCB.itemData(i).value< std::shared_ptr<ArchiveDefinition> >()) {
d->ui.archivesCB.setCurrentIndex(i);
return;
}
}
Q_EMIT changed();
}
DecryptVerifyOperationWidget::Mode DecryptVerifyOperationWidget::mode() const
......
......@@ -57,6 +57,9 @@ public:
void setArchiveDefinitions(const std::vector< std::shared_ptr<ArchiveDefinition> > &ads);
std::shared_ptr<ArchiveDefinition> selectedArchiveDefinition() const;
Q_SIGNALS:
void changed();
private:
class Private;
kdtools::pimpl_ptr<Private> d;
......
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