diff --git a/kerfuffle/archive_kerfuffle.cpp b/kerfuffle/archive_kerfuffle.cpp --- a/kerfuffle/archive_kerfuffle.cpp +++ b/kerfuffle/archive_kerfuffle.cpp @@ -306,9 +306,14 @@ return Q_NULLPTR; } - qCDebug(ARK) << "Going to add files" << files << "with options" << options; + CompressionOptions newOptions = options; + if (encryptionType() != Unencrypted) { + newOptions[QStringLiteral("PasswordProtectedHint")] = true; + } + + qCDebug(ARK) << "Going to add files" << files << "with options" << newOptions; Q_ASSERT(!m_iface->isReadOnly()); - AddJob *newJob = new AddJob(files, options, static_cast(m_iface), this); + AddJob *newJob = new AddJob(files, newOptions, static_cast(m_iface), this); connect(newJob, &AddJob::result, this, &Archive::onAddFinished); return newJob; } diff --git a/kerfuffle/cliinterface.cpp b/kerfuffle/cliinterface.cpp --- a/kerfuffle/cliinterface.cpp +++ b/kerfuffle/cliinterface.cpp @@ -176,6 +176,17 @@ m_operationMode = Add; + const QStringList addArgs = m_param.value(AddArgs).toStringList(); + + if (addArgs.contains(QStringLiteral("$PasswordSwitch")) && + options.value(QStringLiteral("PasswordProtectedHint")).toBool() && + password().isEmpty()) { + qCDebug(ARK) << "Password hint enabled, querying user"; + if (!passwordQuery()) { + return false; + } + } + int compLevel = options.value(QStringLiteral("CompressionLevel"), -1).toInt(); const auto args = substituteAddVariables(m_param.value(AddArgs).toStringList(), diff --git a/kerfuffle/queries.cpp b/kerfuffle/queries.cpp --- a/kerfuffle/queries.cpp +++ b/kerfuffle/queries.cpp @@ -176,7 +176,7 @@ QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); QPointer dlg = new KPasswordDialog; - dlg.data()->setPrompt(xi18nc("@info", "The archive %1 is password protected. Please enter the password to extract the file.", + dlg.data()->setPrompt(xi18nc("@info", "The archive %1 is password protected. Please enter the password.", m_data.value(QStringLiteral("archiveFilename")).toString())); if (m_data.value(QStringLiteral("incorrectTryAgain")).toBool()) {