diff --git a/autotests/kerfuffle/adddialogtest.cpp b/autotests/kerfuffle/adddialogtest.cpp --- a/autotests/kerfuffle/adddialogtest.cpp +++ b/autotests/kerfuffle/adddialogtest.cpp @@ -144,12 +144,12 @@ if (supportsCompLevel) { // Test that the value set by slider is exported from AddDialog. - QCOMPARE(dialog->compressionOptions()[QStringLiteral("CompressionLevel")].toInt(), changeToCompLevel); + QCOMPARE(dialog->compressionOptions().compressionLevel(), changeToCompLevel); } // Test that passing a compression level in ctor works. CompressionOptions opts; - opts[QStringLiteral("CompressionLevel")] = initialCompLevel; + opts.setCompressionLevel(initialCompLevel); dialog = new AddDialog(Q_NULLPTR, QString(), QUrl(), mime, opts); dialog->slotOpenOptions(); diff --git a/autotests/kerfuffle/addtest.cpp b/autotests/kerfuffle/addtest.cpp --- a/autotests/kerfuffle/addtest.cpp +++ b/autotests/kerfuffle/addtest.cpp @@ -124,8 +124,8 @@ QVector oldEntries = TestHelper::getEntryList(archive); - CompressionOptions options = CompressionOptions(); - options.insert(QStringLiteral("GlobalWorkDir"), QFINDTESTDATA("data")); + CompressionOptions options; + options.setGlobalWorkDir(QFINDTESTDATA("data")); AddJob *addJob = archive->addFiles(files, destination, options); TestHelper::startAndWaitForResult(addJob); diff --git a/autotests/kerfuffle/copytest.cpp b/autotests/kerfuffle/copytest.cpp --- a/autotests/kerfuffle/copytest.cpp +++ b/autotests/kerfuffle/copytest.cpp @@ -193,8 +193,8 @@ const QVector oldEntries = TestHelper::getEntryList(archive); - CompressionOptions options = CompressionOptions(); - options.insert(QStringLiteral("GlobalWorkDir"), QFINDTESTDATA("data")); + CompressionOptions options; + options.setGlobalWorkDir(QFINDTESTDATA("data")); CopyJob *copyJob = archive->copyFiles(files, destination, options); TestHelper::startAndWaitForResult(copyJob); diff --git a/autotests/kerfuffle/extracttest.cpp b/autotests/kerfuffle/extracttest.cpp --- a/autotests/kerfuffle/extracttest.cpp +++ b/autotests/kerfuffle/extracttest.cpp @@ -249,11 +249,12 @@ QTest::addColumn("expectedExtractedEntriesCount"); ExtractionOptions optionsPreservePaths; - optionsPreservePaths[QStringLiteral("PreservePaths")] = true; - ExtractionOptions dragAndDropOptions = optionsPreservePaths; - dragAndDropOptions[QStringLiteral("DragAndDrop")] = true; - dragAndDropOptions[QStringLiteral("RemoveRootNode")] = true; + ExtractionOptions optionsNoPaths; + optionsNoPaths.setPreservePaths(false); + + ExtractionOptions dragAndDropOptions; + dragAndDropOptions.setDragAndDropEnabled(true); QString archivePath = QFINDTESTDATA("data/simplearchive.tar.gz"); QTest::newRow("extract the whole simplearchive.tar.gz") @@ -269,7 +270,7 @@ new Archive::Entry(this, QStringLiteral("aDir/b.txt"), QStringLiteral("aDir")), new Archive::Entry(this, QStringLiteral("c.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.gz"); @@ -306,7 +307,7 @@ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")), new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/one_toplevel_folder.zip"); @@ -345,7 +346,7 @@ new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")), new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/one_toplevel_folder.7z"); @@ -386,7 +387,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.bz2"); @@ -403,7 +404,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.xz"); @@ -420,7 +421,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.lzma"); @@ -437,7 +438,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.Z"); @@ -454,7 +455,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.lz"); @@ -471,7 +472,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.lzo"); @@ -490,7 +491,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.lrz"); @@ -512,7 +513,7 @@ new Archive::Entry(this, QStringLiteral("file3.txt"), QString()), new Archive::Entry(this, QStringLiteral("dir2/file22.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.tar.lz4"); @@ -532,7 +533,7 @@ new Archive::Entry(this, QStringLiteral("dir1/file11.txt"), QString()), new Archive::Entry(this, QStringLiteral("file4.txt"), QString()) } - << ExtractionOptions() + << optionsNoPaths << 2; archivePath = QFINDTESTDATA("data/simplearchive.xar"); diff --git a/autotests/kerfuffle/jobstest.cpp b/autotests/kerfuffle/jobstest.cpp --- a/autotests/kerfuffle/jobstest.cpp +++ b/autotests/kerfuffle/jobstest.cpp @@ -219,34 +219,29 @@ { JSONArchiveInterface *iface = createArchiveInterface(QFINDTESTDATA("data/archive001.json")); ExtractJob *job = new ExtractJob(QVector(), QStringLiteral("/tmp/some-dir"), ExtractionOptions(), iface); - ExtractionOptions defaultOptions; - defaultOptions[QStringLiteral("PreservePaths")] = false; QCOMPARE(job->destinationDirectory(), QLatin1String("/tmp/some-dir")); - QCOMPARE(job->extractionOptions(), defaultOptions); + QVERIFY(job->extractionOptions().preservePaths()); job->setAutoDelete(false); startAndWaitForResult(job); QCOMPARE(job->destinationDirectory(), QLatin1String("/tmp/some-dir")); - QCOMPARE(job->extractionOptions(), defaultOptions); delete job; ExtractionOptions options; - options[QStringLiteral("PreservePaths")] = true; - options[QStringLiteral("foo")] = QLatin1String("bar"); - options[QStringLiteral("pi")] = 3.14f; + options.setPreservePaths(false); job = new ExtractJob(QVector(), QStringLiteral("/root"), options, iface); QCOMPARE(job->destinationDirectory(), QLatin1String("/root")); - QCOMPARE(job->extractionOptions(), options); + QVERIFY(!job->extractionOptions().preservePaths()); job->setAutoDelete(false); startAndWaitForResult(job); QCOMPARE(job->destinationDirectory(), QLatin1String("/root")); - QCOMPARE(job->extractionOptions(), options); + QVERIFY(!job->extractionOptions().preservePaths()); delete job; } @@ -258,13 +253,13 @@ const QString tempDirPath = job->tempDir()->path(); QVERIFY(QFileInfo::exists(tempDirPath)); QVERIFY(job->validatedFilePath().endsWith(QLatin1String("anotherDir/file.txt"))); - QVERIFY(job->extractionOptions()[QStringLiteral("PreservePaths")].toBool()); + QVERIFY(job->extractionOptions().preservePaths()); job->setAutoDelete(false); startAndWaitForResult(job); QVERIFY(job->validatedFilePath().endsWith(QLatin1String("anotherDir/file.txt"))); - QVERIFY(job->extractionOptions()[QStringLiteral("PreservePaths")].toBool()); + QVERIFY(job->extractionOptions().preservePaths()); delete job->tempDir(); QVERIFY(!QFileInfo::exists(tempDirPath)); diff --git a/autotests/kerfuffle/jsonarchiveinterface.cpp b/autotests/kerfuffle/jsonarchiveinterface.cpp --- a/autotests/kerfuffle/jsonarchiveinterface.cpp +++ b/autotests/kerfuffle/jsonarchiveinterface.cpp @@ -83,7 +83,7 @@ return true; } -bool JSONArchiveInterface::moveFiles(const QVector& files, Kerfuffle::Archive::Entry *destination, const Kerfuffle::ExtractionOptions& options) +bool JSONArchiveInterface::moveFiles(const QVector& files, Kerfuffle::Archive::Entry *destination, const Kerfuffle::CompressionOptions& options) { Q_UNUSED(files) Q_UNUSED(destination) diff --git a/autotests/kerfuffle/movetest.cpp b/autotests/kerfuffle/movetest.cpp --- a/autotests/kerfuffle/movetest.cpp +++ b/autotests/kerfuffle/movetest.cpp @@ -170,7 +170,7 @@ QVector oldEntries = TestHelper::getEntryList(archive); CompressionOptions options = CompressionOptions(); - options.insert(QStringLiteral("GlobalWorkDir"), QFINDTESTDATA("data")); + options.setGlobalWorkDir(QFINDTESTDATA("data")); MoveJob *moveJob = archive->moveFiles(files, destination, options); TestHelper::startAndWaitForResult(moveJob); diff --git a/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp b/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp --- a/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp +++ b/autotests/plugins/cliunarchiverplugin/cliunarchivertest.cpp @@ -230,37 +230,37 @@ QTest::addColumn("extractionOptions"); QTest::addColumn("expectedExtractedEntriesCount"); - ExtractionOptions options; - options[QStringLiteral("AlwaysUseTmpDir")] = true; + ExtractionOptions defaultOptions; + defaultOptions.setAlwaysUseTempDir(true); - ExtractionOptions optionsPreservePaths = options; - optionsPreservePaths[QStringLiteral("PreservePaths")] = true; + ExtractionOptions optionsNoPaths = defaultOptions; + optionsNoPaths.setPreservePaths(false); - ExtractionOptions dragAndDropOptions = optionsPreservePaths; - dragAndDropOptions[QStringLiteral("DragAndDrop")] = true; + ExtractionOptions dragAndDropOptions = defaultOptions; + dragAndDropOptions.setDragAndDropEnabled(true); QTest::newRow("extract the whole multiple_toplevel_entries.rar") << QFINDTESTDATA("data/multiple_toplevel_entries.rar") << QVector() - << optionsPreservePaths + << defaultOptions << 12; QTest::newRow("extract selected entries from a rar, without paths") << QFINDTESTDATA("data/one_toplevel_folder.rar") << QVector { new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")), new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")) } - << options + << optionsNoPaths << 2; QTest::newRow("extract selected entries from a rar, preserve paths") << QFINDTESTDATA("data/one_toplevel_folder.rar") << QVector { new Archive::Entry(this, QStringLiteral("A/test2.txt"), QStringLiteral("A")), new Archive::Entry(this, QStringLiteral("A/B/test1.txt"), QStringLiteral("A/B")) } - << optionsPreservePaths + << defaultOptions << 4; QTest::newRow("extract selected entries from a rar, drag-and-drop") @@ -277,13 +277,13 @@ QTest::newRow("rar with empty folders") << QFINDTESTDATA("data/empty_folders.rar") << QVector() - << optionsPreservePaths + << defaultOptions << 5; QTest::newRow("rar with hidden folder and files") << QFINDTESTDATA("data/hidden_files.rar") << QVector() - << optionsPreservePaths + << defaultOptions << 4; } diff --git a/kerfuffle/CMakeLists.txt b/kerfuffle/CMakeLists.txt --- a/kerfuffle/CMakeLists.txt +++ b/kerfuffle/CMakeLists.txt @@ -20,6 +20,7 @@ plugin.cpp pluginmanager.cpp archiveentry.cpp + options.cpp ) kconfig_add_kcfg_files(kerfuffle_SRCS settings.kcfgc) diff --git a/kerfuffle/adddialog.h b/kerfuffle/adddialog.h --- a/kerfuffle/adddialog.h +++ b/kerfuffle/adddialog.h @@ -49,7 +49,7 @@ const QString &title, const QUrl &startDir, const QMimeType &mimeType, - const CompressionOptions &opts = QHash()); + const CompressionOptions &opts = {}); virtual ~AddDialog(); QStringList selectedFiles() const; CompressionOptions compressionOptions() const; diff --git a/kerfuffle/addtoarchive.cpp b/kerfuffle/addtoarchive.cpp --- a/kerfuffle/addtoarchive.cpp +++ b/kerfuffle/addtoarchive.cpp @@ -186,8 +186,8 @@ entry->setFullPath(stripDir.absoluteFilePath(entry->fullPath())); } - options[QStringLiteral( "GlobalWorkDir" )] = stripDir.path(); qCDebug(ARK) << "Setting GlobalWorkDir to " << stripDir.path(); + options.setGlobalWorkDir(stripDir.path()); } auto createJob = Archive::create(m_filename, m_mimeType, m_entries, options, this); diff --git a/kerfuffle/archive_kerfuffle.h b/kerfuffle/archive_kerfuffle.h --- a/kerfuffle/archive_kerfuffle.h +++ b/kerfuffle/archive_kerfuffle.h @@ -29,6 +29,7 @@ #define ARCHIVE_H #include "kerfuffle_export.h" +#include "options.h" #include #include @@ -62,14 +63,6 @@ FailedPlugin }; -/** -These are the extra options for doing the compression. Naming convention -is CamelCase with either Global, or the compression type (such as Zip, -Rar, etc), followed by the property name used - */ -typedef QHash CompressionOptions; -typedef QHash ExtractionOptions; - class KERFUFFLE_EXPORT Archive : public QObject { Q_OBJECT @@ -125,8 +118,6 @@ qulonglong unpackedSize() const; qulonglong packedSize() const; QString subfolderName() const; - void setCompressionOptions(const CompressionOptions &opts); - CompressionOptions compressionOptions() const; QString multiVolumeName() const; ReadOnlyArchiveInterface *interface(); @@ -248,7 +239,6 @@ EncryptionType m_encryptionType; qulonglong m_numberOfFiles; qulonglong m_numberOfFolders; - CompressionOptions m_compOptions; QMimeType m_mimeType; QStringList m_compressionMethods; }; diff --git a/kerfuffle/archive_kerfuffle.cpp b/kerfuffle/archive_kerfuffle.cpp --- a/kerfuffle/archive_kerfuffle.cpp +++ b/kerfuffle/archive_kerfuffle.cpp @@ -400,7 +400,7 @@ CompressionOptions newOptions = options; if (encryptionType() != Unencrypted) { - newOptions[QStringLiteral("PasswordProtectedHint")] = true; + newOptions.setEncryptedArchiveHint(true); } qCDebug(ARK) << "Going to add files" << files << "with options" << newOptions; @@ -419,7 +419,7 @@ CompressionOptions newOptions = options; if (encryptionType() != Unencrypted) { - newOptions[QStringLiteral("PasswordProtectedHint")] = true; + newOptions.setEncryptedArchiveHint(true); } qCDebug(ARK) << "Going to move files" << files << "with options" << newOptions; @@ -437,7 +437,7 @@ CompressionOptions newOptions = options; if (encryptionType() != Unencrypted) { - newOptions[QStringLiteral("PasswordProtectedHint")] = true; + newOptions.setEncryptedArchiveHint(true); } qCDebug(ARK) << "Going to copy files" << files << "with options" << newOptions; @@ -455,7 +455,7 @@ ExtractionOptions newOptions = options; if (encryptionType() != Unencrypted) { - newOptions[QStringLiteral( "PasswordProtectedHint" )] = true; + newOptions.setEncryptedArchiveHint(true); } ExtractJob *newJob = new ExtractJob(files, destinationDir, newOptions, m_iface); @@ -521,16 +521,6 @@ query->execute(); } -void Archive::setCompressionOptions(const CompressionOptions &opts) -{ - m_compOptions = opts; -} - -CompressionOptions Archive::compressionOptions() const -{ - return m_compOptions; -} - QString Archive::multiVolumeName() const { return m_iface->multiVolumeName(); diff --git a/kerfuffle/cliinterface.h b/kerfuffle/cliinterface.h --- a/kerfuffle/cliinterface.h +++ b/kerfuffle/cliinterface.h @@ -503,7 +503,7 @@ bool m_listEmptyLines; QString m_storedFileName; - CompressionOptions m_compressionOptions; + ExtractionOptions m_extractionOptions; QString m_extractDestDir; QTemporaryDir *m_extractTempDir; QTemporaryFile *m_commentTempFile; diff --git a/kerfuffle/cliinterface.cpp b/kerfuffle/cliinterface.cpp --- a/kerfuffle/cliinterface.cpp +++ b/kerfuffle/cliinterface.cpp @@ -122,14 +122,12 @@ cacheParameterList(); m_operationMode = Extract; - m_compressionOptions = options; + m_extractionOptions = options; m_extractedFiles = files; m_extractDestDir = destinationDirectory; const QStringList extractArgs = m_param.value(ExtractArgs).toStringList(); - if (extractArgs.contains(QStringLiteral("$PasswordSwitch")) && - options.value(QStringLiteral("PasswordProtectedHint")).toBool() && - password().isEmpty()) { + if (extractArgs.contains(QStringLiteral("$PasswordSwitch")) && options.encryptedArchiveHint() && password().isEmpty()) { qCDebug(ARK) << "Password hint enabled, querying user"; if (!passwordQuery()) { return false; @@ -139,14 +137,13 @@ // Populate the argument list. const QStringList args = substituteExtractVariables(extractArgs, files, - options.value(QStringLiteral("PreservePaths")).toBool(), + options.preservePaths(), password()); QUrl destDir = QUrl(destinationDirectory); QDir::setCurrent(destDir.adjusted(QUrl::RemoveScheme).url()); - bool useTmpExtractDir = options.value(QStringLiteral("DragAndDrop")).toBool() || - options.value(QStringLiteral("AlwaysUseTmpDir")).toBool(); + const bool useTmpExtractDir = options.isDragAndDropEnabled() || options.alwaysUseTempDir(); if (useTmpExtractDir) { @@ -220,26 +217,20 @@ filesToPass = files; } - if (addArgs.contains(QStringLiteral("$PasswordSwitch")) && - options.value(QStringLiteral("PasswordProtectedHint")).toBool() && - password().isEmpty()) { + if (addArgs.contains(QStringLiteral("$PasswordSwitch")) && options.encryptedArchiveHint() && password().isEmpty()) { qCDebug(ARK) << "Password hint enabled, querying user"; if (!passwordQuery()) { return false; } } - int compLevel = options.value(QStringLiteral("CompressionLevel"), -1).toInt(); - ulong volumeSize = options.value(QStringLiteral("VolumeSize"), 0).toULongLong(); - QString compMethod = options.value(QStringLiteral("CompressionMethod")).toString(); - const auto args = substituteAddVariables(m_param.value(AddArgs).toStringList(), filesToPass, password(), isHeaderEncryptionEnabled(), - compLevel, - volumeSize, - compMethod); + options.compressionLevel(), + options.volumeSize(), + options.compressionMethod()); return runProcess(m_param.value(AddProgram).toStringList(), args); } @@ -271,12 +262,11 @@ m_passedFiles = files; m_passedDestination = destination; m_passedOptions = options; - m_passedOptions[QStringLiteral("PreservePaths")] = true; m_subOperation = Extract; connect(this, &CliInterface::finished, this, &CliInterface::continueCopying); - return extractFiles(files, QDir::currentPath(), m_passedOptions); + return extractFiles(files, QDir::currentPath(), ExtractionOptions()); } bool CliInterface::deleteFiles(const QVector &files) @@ -423,7 +413,7 @@ m_process = Q_NULLPTR; } - if (m_compressionOptions.value(QStringLiteral("AlwaysUseTmpDir")).toBool()) { + if (m_extractionOptions.alwaysUseTempDir()) { // unar exits with code 1 if extraction fails. // This happens at least with wrong passwords or not enough space in the destination folder. if (m_exitCode == 1) { @@ -440,8 +430,8 @@ return; } - if (!m_compressionOptions.value(QStringLiteral("DragAndDrop")).toBool()) { - if (!moveToDestination(QDir::current(), QDir(m_extractDestDir), m_compressionOptions[QStringLiteral("PreservePaths")].toBool())) { + if (!m_extractionOptions.isDragAndDropEnabled()) { + if (!moveToDestination(QDir::current(), QDir(m_extractDestDir), m_extractionOptions.preservePaths())) { emit error(i18ncp("@info", "Could not move the extracted file to the destination directory.", "Could not move the extracted files to the destination directory.", @@ -455,7 +445,7 @@ } } - if (m_compressionOptions.value(QStringLiteral("DragAndDrop")).toBool()) { + if (m_extractionOptions.isDragAndDropEnabled()) { if (!moveDroppedFilesToDest(m_extractedFiles, m_extractDestDir)) { emit error(i18ncp("@info", "Could not move the extracted file to the destination directory.", diff --git a/kerfuffle/compressionoptionswidget.h b/kerfuffle/compressionoptionswidget.h --- a/kerfuffle/compressionoptionswidget.h +++ b/kerfuffle/compressionoptionswidget.h @@ -43,7 +43,7 @@ public: explicit CompressionOptionsWidget(QWidget *parent = Q_NULLPTR, - const CompressionOptions &opts = QHash()); + const CompressionOptions &opts = {}); int compressionLevel() const; QString compressionMethod() const; ulong volumeSize() const; diff --git a/kerfuffle/compressionoptionswidget.cpp b/kerfuffle/compressionoptionswidget.cpp --- a/kerfuffle/compressionoptionswidget.cpp +++ b/kerfuffle/compressionoptionswidget.cpp @@ -50,23 +50,22 @@ connect(multiVolumeCheckbox, &QCheckBox::stateChanged, this, &CompressionOptionsWidget::slotMultiVolumeChecked); - if (m_opts.contains(QStringLiteral("VolumeSize"))) { + if (m_opts.volumeSize() > 0) { multiVolumeCheckbox->setChecked(true); // Convert from kilobytes. - volumeSizeSpinbox->setValue(m_opts.value(QStringLiteral("VolumeSize")).toDouble() / 1024); + volumeSizeSpinbox->setValue(static_cast(m_opts.volumeSize()) / 1024); } } CompressionOptions CompressionOptionsWidget::commpressionOptions() const { CompressionOptions opts; - opts[QStringLiteral("CompressionLevel")] = compLevelSlider->value(); + opts.setCompressionLevel(compLevelSlider->value()); if (multiVolumeCheckbox->isChecked()) { - // Convert to kilobytes. - opts[QStringLiteral("VolumeSize")] = QString::number(volumeSize()); + opts.setVolumeSize(volumeSize()); } if (!compMethodComboBox->currentText().isEmpty()) { - opts[QStringLiteral("CompressionMethod")] = compMethodComboBox->currentText(); + opts.setCompressionMethod(compMethodComboBox->currentText()); } return opts; @@ -156,8 +155,8 @@ compLevelSlider->setToolTip(QString()); compLevelSlider->setMinimum(archiveFormat.minCompressionLevel()); compLevelSlider->setMaximum(archiveFormat.maxCompressionLevel()); - if (m_opts.contains(QStringLiteral("CompressionLevel"))) { - compLevelSlider->setValue(m_opts.value(QStringLiteral("CompressionLevel")).toInt()); + if (m_opts.isCompressionLevelSet()) { + compLevelSlider->setValue(m_opts.compressionLevel()); } else { compLevelSlider->setValue(archiveFormat.defaultCompressionLevel()); } @@ -175,9 +174,9 @@ compMethodComboBox->setToolTip(QString()); compMethodComboBox->clear(); compMethodComboBox->insertItems(0, archiveFormat.compressionMethods()); - if (m_opts.contains(QStringLiteral("CompressionMethod")) && - compMethodComboBox->findText(m_opts.value(QStringLiteral("CompressionMethod")).toString()) > -1) { - compMethodComboBox->setCurrentText(m_opts.value(QStringLiteral("CompressionMethod")).toString()); + if (!m_opts.compressionMethod().isEmpty() && + compMethodComboBox->findText(m_opts.compressionMethod()) > -1) { + compMethodComboBox->setCurrentText(m_opts.compressionMethod()); } else { compMethodComboBox->setCurrentText(archiveFormat.defaultCompressionMethod()); } diff --git a/kerfuffle/jobs.h b/kerfuffle/jobs.h --- a/kerfuffle/jobs.h +++ b/kerfuffle/jobs.h @@ -221,8 +221,6 @@ virtual void doWork() Q_DECL_OVERRIDE; private: - // TODO: Maybe this should be a method if ExtractionOptions were a class? - void setDefaultOptions(); QVector m_entries; QString m_destinationDir; diff --git a/kerfuffle/jobs.cpp b/kerfuffle/jobs.cpp --- a/kerfuffle/jobs.cpp +++ b/kerfuffle/jobs.cpp @@ -362,7 +362,7 @@ setupDestination(); Kerfuffle::ExtractionOptions options; - options[QStringLiteral("PreservePaths")] = m_preservePaths; + options.setPreservePaths(m_preservePaths); auto extractJob = archive()->extractFiles({}, m_destination, options); if (extractJob) { @@ -437,7 +437,6 @@ , m_options(options) { qCDebug(ARK) << "ExtractJob created"; - setDefaultOptions(); } void ExtractJob::doWork() @@ -471,20 +470,6 @@ } } -void ExtractJob::setDefaultOptions() -{ - ExtractionOptions defaultOptions; - - defaultOptions[QStringLiteral("PreservePaths")] = false; - - ExtractionOptions::const_iterator it = defaultOptions.constBegin(); - for (; it != defaultOptions.constEnd(); ++it) { - if (!m_options.contains(it.key())) { - m_options[it.key()] = it.value(); - } - } -} - QString ExtractJob::destinationDirectory() const { return m_destinationDir; @@ -518,10 +503,9 @@ ExtractionOptions TempExtractJob::extractionOptions() const { ExtractionOptions options; - options[QStringLiteral("PreservePaths")] = true; if (m_passwordProtectedHint) { - options[QStringLiteral("PasswordProtectedHint")] = true; + options.setEncryptedArchiveHint(true); } return options; @@ -582,7 +566,7 @@ void AddJob::doWork() { // Set current dir. - const QString globalWorkDir = m_options.value(QStringLiteral("GlobalWorkDir")).toString(); + const QString globalWorkDir = m_options.globalWorkDir(); const QDir workDir = globalWorkDir.isEmpty() ? QDir::current() : QDir(globalWorkDir); if (!globalWorkDir.isEmpty()) { qCDebug(ARK) << "GlobalWorkDir is set, changing dir to " << globalWorkDir; @@ -604,11 +588,8 @@ } } } - qCDebug(ARK) << "Counted" << totalCount << "entries in" << timer.elapsed() << "ms"; - - m_options[QStringLiteral("NumberOfEntries")] = totalCount; - qCDebug(ARK) << "AddJob: going to add" << totalCount << "entries"; + qCDebug(ARK) << "AddJob: going to add" << totalCount << "entries, counted in" << timer.elapsed() << "ms"; QString desc = i18np("Adding a file", "Adding %1 files", totalCount); emit description(this, desc, qMakePair(i18n("Archive"), archiveInterface()->filename())); diff --git a/kerfuffle/options.h b/kerfuffle/options.h new file mode 100644 --- /dev/null +++ b/kerfuffle/options.h @@ -0,0 +1,110 @@ +/* + * ark -- archiver for the KDE project + * + * Copyright (C) 2016 Elvis Angelaccio + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef OPTIONS_H +#define OPTIONS_H + +#include "kerfuffle_export.h" + +#include + +namespace Kerfuffle +{ + +class KERFUFFLE_EXPORT Options +{ +public: + + bool encryptedArchiveHint() const; + void setEncryptedArchiveHint(bool encrypted); + +private: + + bool m_encryptedArchiveHint = false; +}; + +class KERFUFFLE_EXPORT CompressionOptions : public Options +{ +public: + + /** + * @return Whether a custom compression level has been set in the options. + * If false, the default level from the ArchiveFormat should be used instead. + * @see compressionLevel() + */ + bool isCompressionLevelSet() const; + + /** + * @return Whether a custom volume size has been set in the options. + * If false, the default size from the ArchiveFormat should be used instead. + * @see compressionLevel() + */ + bool isVolumeSizeSet() const; + + int compressionLevel() const; + void setCompressionLevel(int level); + int volumeSize() const; + void setVolumeSize(int size); + QString compressionMethod() const; + void setCompressionMethod(const QString &method); + QString globalWorkDir() const; + void setGlobalWorkDir(const QString &workDir); + +private: + int m_compressionLevel = -1; + int m_volumeSize = 0; + QString m_compressionMethod; + QString m_globalWorkDir; +}; + +class KERFUFFLE_EXPORT ExtractionOptions : public Options +{ +public: + + bool preservePaths() const; + void setPreservePaths(bool preservePaths); + bool isDragAndDropEnabled() const; + void setDragAndDropEnabled(bool enabled); + bool alwaysUseTempDir() const; + void setAlwaysUseTempDir(bool alwaysUseTempDir); + +private: + + bool m_preservePaths = true; + bool m_dragAndDrop = false; + bool m_alwaysUseTempDir = false; +}; + +QDebug KERFUFFLE_EXPORT operator<<(QDebug d, const CompressionOptions &options); +QDebug KERFUFFLE_EXPORT operator<<(QDebug d, const ExtractionOptions &options); + +} + +Q_DECLARE_METATYPE(Kerfuffle::CompressionOptions) +Q_DECLARE_METATYPE(Kerfuffle::ExtractionOptions) + +#endif diff --git a/kerfuffle/options.cpp b/kerfuffle/options.cpp new file mode 100644 --- /dev/null +++ b/kerfuffle/options.cpp @@ -0,0 +1,148 @@ +/* + * ark -- archiver for the KDE project + * + * Copyright (C) 2016 Elvis Angelaccio + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ( INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "options.h" + +namespace Kerfuffle +{ + +bool Options::encryptedArchiveHint() const +{ + return m_encryptedArchiveHint; +} + +void Options::setEncryptedArchiveHint(bool encrypted) +{ + m_encryptedArchiveHint = encrypted; +} + +bool ExtractionOptions::preservePaths() const +{ + return m_preservePaths; +} + +void ExtractionOptions::setPreservePaths(bool preservePaths) +{ + m_preservePaths = preservePaths; +} + +bool ExtractionOptions::isDragAndDropEnabled() const +{ + return m_dragAndDrop; +} + +void ExtractionOptions::setDragAndDropEnabled(bool enabled) +{ + m_dragAndDrop = enabled; +} + +bool ExtractionOptions::alwaysUseTempDir() const +{ + return m_alwaysUseTempDir; +} + +void ExtractionOptions::setAlwaysUseTempDir(bool alwaysUseTempDir) +{ + m_alwaysUseTempDir = alwaysUseTempDir; +} + +bool CompressionOptions::isCompressionLevelSet() const +{ + return compressionLevel() != -1; +} + +bool CompressionOptions::isVolumeSizeSet() const +{ + return volumeSize() > 0; +} + +int CompressionOptions::compressionLevel() const +{ + return m_compressionLevel; +} + +void CompressionOptions::setCompressionLevel(int level) +{ + m_compressionLevel = level; +} + +int CompressionOptions::volumeSize() const +{ + return m_volumeSize; +} + +void CompressionOptions::setVolumeSize(int size) +{ + m_volumeSize = size; +} + +QString CompressionOptions::compressionMethod() const +{ + return m_compressionMethod; +} + +void CompressionOptions::setCompressionMethod(const QString &method) +{ + m_compressionMethod = method; +} + +QString CompressionOptions::globalWorkDir() const +{ + return m_globalWorkDir; +} + +void CompressionOptions::setGlobalWorkDir(const QString &workDir) +{ + m_globalWorkDir = workDir; +} + +QDebug operator<<(QDebug d, const CompressionOptions &options) +{ + d.nospace() << "(encryption hint: " << options.encryptedArchiveHint(); + if (!options.compressionMethod().isEmpty()) { + d.nospace() << ", compression method: " << options.compressionMethod(); + } + if (!options.globalWorkDir().isEmpty()) { + d.nospace() << ", global work dir: " << options.globalWorkDir(); + } + d.nospace() << ", compression level: " << options.compressionLevel(); + d.nospace() << ", volume size: " << options.volumeSize(); + d.nospace() << ")"; + return d.space(); +} + +QDebug operator<<(QDebug d, const ExtractionOptions &options) +{ + d.nospace() << "(encryption hint: " << options.encryptedArchiveHint(); + d.nospace() << ", preserve paths: " << options.preservePaths(); + d.nospace() << ", drag and drop: " << options.isDragAndDropEnabled(); + d.nospace() << ", always temp dir: " << options.alwaysUseTempDir(); + d.nospace() << ")"; + return d.space(); +} + +} diff --git a/part/archivemodel.h b/part/archivemodel.h --- a/part/archivemodel.h +++ b/part/archivemodel.h @@ -123,7 +123,7 @@ void loadingFinished(KJob *); void extractionFinished(bool success); void error(const QString& error, const QString& details); - void droppedFiles(const QStringList& files, const Archive::Entry*, const QString&); + void droppedFiles(const QStringList& files, const Archive::Entry*, const QString&, const Kerfuffle::CompressionOptions&); void messageWidget(KMessageWidget::MessageType type, const QString& msg); private slots: diff --git a/part/archivemodel.cpp b/part/archivemodel.cpp --- a/part/archivemodel.cpp +++ b/part/archivemodel.cpp @@ -475,7 +475,7 @@ } } - emit droppedFiles(paths, entry, QString()); + emit droppedFiles(paths, entry, QString(), CompressionOptions()); return true; } diff --git a/part/part.h b/part/part.h --- a/part/part.h +++ b/part/part.h @@ -115,8 +115,10 @@ * or drag'n'drop event, for adding a watched file it has empty. * @param relPath Relative path of watched entry inside the archive. Is used only for adding temporarily extracted * watched file. + * @param options Compression options. */ - void slotAddFiles(const QStringList &files, const Kerfuffle::Archive::Entry *destination, const QString &relPath); + // TODO: compression options are set only when this slot is called by slotAddFiles(). Set them also in the other cases. + void slotAddFiles(const QStringList &files, const Kerfuffle::Archive::Entry *destination, const QString &relPath, const Kerfuffle::CompressionOptions &options); /** * Creates and starts MoveJob or CopyJob. diff --git a/part/part.cpp b/part/part.cpp --- a/part/part.cpp +++ b/part/part.cpp @@ -172,7 +172,7 @@ connect(m_model, &ArchiveModel::loadingFinished, this, &Part::slotLoadingFinished); connect(m_model, &ArchiveModel::droppedFiles, - this, static_cast(&Part::slotAddFiles)); + this, static_cast(&Part::slotAddFiles)); connect(m_model, &ArchiveModel::error, this, &Part::slotError); connect(m_model, &ArchiveModel::messageWidget, @@ -273,9 +273,7 @@ qCDebug(ARK) << "Extract to" << destination; Kerfuffle::ExtractionOptions options; - options[QStringLiteral("PreservePaths")] = true; - options[QStringLiteral("RemoveRootNode")] = true; - options[QStringLiteral("DragAndDrop")] = true; + options.setDragAndDropEnabled(true); // Create and start the ExtractJob. ExtractJob *job = m_model->extractFiles(filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())), destination, options); @@ -693,9 +691,7 @@ qCDebug(ARK) << "Extracting to:" << finalDestinationDirectory; - Kerfuffle::ExtractionOptions options; - options[QStringLiteral("PreservePaths")] = true; - ExtractJob *job = m_model->extractFiles(filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())), finalDestinationDirectory, options); + ExtractJob *job = m_model->extractFiles(filesAndRootNodesForIndexes(addChildren(m_view->selectionModel()->selectedRows())), finalDestinationDirectory, ExtractionOptions()); registerJob(job); connect(job, &KJob::result, @@ -1043,7 +1039,7 @@ QStringList list = QStringList() << file; qCDebug(ARK) << "Updating file" << file << "with path" << relPath; - slotAddFiles(list, Q_NULLPTR, relPath); + slotAddFiles(list, Q_NULLPTR, relPath, CompressionOptions()); } // This is needed because some apps, such as Kate, delete and recreate // files when saving. @@ -1120,11 +1116,7 @@ qCDebug(ARK) << "Selected " << files; Kerfuffle::ExtractionOptions options; - - if (dialog.data()->preservePaths()) { - options[QStringLiteral("PreservePaths")] = true; - } - options[QStringLiteral("FollowExtractionDialogSettings")] = true; + options.setPreservePaths(dialog->preservePaths()); const QString destinationDirectory = dialog.data()->destinationDirectory().toLocalFile(); ExtractJob *job = m_model->extractFiles(files, destinationDirectory, options); @@ -1217,12 +1209,6 @@ ExtractJob *extractJob = qobject_cast(job); Q_ASSERT(extractJob); - const bool followExtractionDialogSettings = - extractJob->extractionOptions().value(QStringLiteral("FollowExtractionDialogSettings"), false).toBool(); - if (!followExtractionDialogSettings) { - return; - } - if (ArkSettings::openDestinationFolderAfterExtraction()) { qCDebug(ARK) << "Shall open" << extractJob->destinationDirectory(); QUrl destinationDirectory = QUrl::fromLocalFile(extractJob->destinationDirectory()).adjusted(QUrl::NormalizePathSegments); @@ -1242,7 +1228,7 @@ m_view->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); } -void Part::slotAddFiles(const QStringList& filesToAdd, const Archive::Entry *destination, const QString &relPath) +void Part::slotAddFiles(const QStringList& filesToAdd, const Archive::Entry *destination, const QString &relPath, const CompressionOptions &options) { if (!m_model->archive() || filesToAdd.isEmpty()) { return; @@ -1304,15 +1290,15 @@ globalWorkDir.chop(1); } - CompressionOptions options(m_model->archive()->compressionOptions()); + CompressionOptions compOptions = options; // Now take the absolute path of the parent directory. globalWorkDir = QFileInfo(globalWorkDir).dir().absolutePath(); qCDebug(ARK) << "Detected GlobalWorkDir to be " << globalWorkDir; - options[QStringLiteral("GlobalWorkDir")] = globalWorkDir; + compOptions.setGlobalWorkDir(globalWorkDir); - AddJob *job = m_model->addFiles(m_jobTempEntries, destination, options); + AddJob *job = m_model->addFiles(m_jobTempEntries, destination, compOptions); if (!job) { qDeleteAll(m_jobTempEntries); m_jobTempEntries.clear(); @@ -1329,23 +1315,14 @@ { // If compression options are already set, we don't use the values from CreateDialog. CompressionOptions opts; - if (m_model->archive()->compressionOptions().isEmpty()) { - if (arguments().metaData().contains(QStringLiteral("compressionLevel"))) { - opts[QStringLiteral("CompressionLevel")] = arguments().metaData()[QStringLiteral("compressionLevel")]; - } - if (arguments().metaData().contains(QStringLiteral("compressionMethod"))) { - opts[QStringLiteral("CompressionMethod")] = arguments().metaData()[QStringLiteral("compressionMethod")]; - } - if (arguments().metaData().contains(QStringLiteral("volumeSize"))) { - opts[QStringLiteral("VolumeSize")] = arguments().metaData()[QStringLiteral("volumeSize")]; - } - m_model->archive()->setCompressionOptions(opts); - } else { - opts = m_model->archive()->compressionOptions(); + if (arguments().metaData().contains(QStringLiteral("compressionLevel"))) { + opts.setCompressionLevel(arguments().metaData()[QStringLiteral("compressionLevel")].toInt()); } - - if (m_model->archive()->property("compressionMethods").toStringList().size() == 1) { - opts[QStringLiteral("CompressionMethod")] = m_model->archive()->property("compressionMethods").toStringList().first(); + if (arguments().metaData().contains(QStringLiteral("compressionMethod"))) { + opts.setCompressionMethod(arguments().metaData()[QStringLiteral("compressionMethod")]); + } + if (arguments().metaData().contains(QStringLiteral("volumeSize"))) { + opts.setVolumeSize(arguments().metaData()[QStringLiteral("volumeSize")].toInt()); } QString dialogTitle = i18nc("@title:window", "Add Files"); @@ -1380,8 +1357,7 @@ if (dlg->exec() == QDialog::Accepted) { qCDebug(ARK) << "Selected files:" << dlg->selectedFiles(); qCDebug(ARK) << "Options:" << dlg->compressionOptions(); - m_model->archive()->setCompressionOptions(dlg->compressionOptions()); - slotAddFiles(dlg->selectedFiles(), destination, QString()); + slotAddFiles(dlg->selectedFiles(), destination, QString(), dlg->compressionOptions()); } delete dlg; } @@ -1533,13 +1509,11 @@ qCDebug(ARK) << "Copying " << files << "to" << destination; } - CompressionOptions options(m_model->archive()->compressionOptions()); - KJob *job; if (entriesWithoutChildren != 0) { - job = m_model->moveFiles(files, destination, options); + job = m_model->moveFiles(files, destination, CompressionOptions()); } else { - job = m_model->copyFiles(files, destination, options); + job = m_model->copyFiles(files, destination, CompressionOptions()); } if (job) { diff --git a/plugins/cliunarchiverplugin/cliplugin.cpp b/plugins/cliunarchiverplugin/cliplugin.cpp --- a/plugins/cliunarchiverplugin/cliplugin.cpp +++ b/plugins/cliunarchiverplugin/cliplugin.cpp @@ -66,7 +66,7 @@ // and then we move the files to the intended destination. qCDebug(ARK) << "Enabling extraction to temporary directory."; - newOptions[QStringLiteral("AlwaysUseTmpDir")] = true; + newOptions.setAlwaysUseTempDir(true); return CliInterface::extractFiles(files, destinationDirectory, newOptions); } diff --git a/plugins/clizipplugin/cliplugin.cpp b/plugins/clizipplugin/cliplugin.cpp --- a/plugins/clizipplugin/cliplugin.cpp +++ b/plugins/clizipplugin/cliplugin.cpp @@ -213,7 +213,7 @@ m_subOperation = Extract; connect(this, &CliPlugin::finished, this, &CliPlugin::continueMoving); - return extractFiles(files, QDir::currentPath(), options); + return extractFiles(files, QDir::currentPath(), ExtractionOptions()); } int CliPlugin::moveRequiredSignals() const { diff --git a/plugins/libarchive/libarchiveplugin.cpp b/plugins/libarchive/libarchiveplugin.cpp --- a/plugins/libarchive/libarchiveplugin.cpp +++ b/plugins/libarchive/libarchiveplugin.cpp @@ -150,8 +150,8 @@ QDir::setCurrent(destinationDirectory); const bool extractAll = files.isEmpty(); - const bool preservePaths = options.value(QStringLiteral( "PreservePaths" )).toBool(); - bool removeRootNode = options.value(QStringLiteral("RemoveRootNode"), QVariant()).toBool(); + const bool preservePaths = options.preservePaths(); + const bool removeRootNode = options.isDragAndDropEnabled(); // To avoid traversing the entire archive when extracting a limited set of // entries, we maintain a list of remaining entries and stop when it's diff --git a/plugins/libarchive/readwritelibarchiveplugin.cpp b/plugins/libarchive/readwritelibarchiveplugin.cpp --- a/plugins/libarchive/readwritelibarchiveplugin.cpp +++ b/plugins/libarchive/readwritelibarchiveplugin.cpp @@ -363,9 +363,9 @@ } // Set compression level if passed in CompressionOptions. - if (options.contains(QStringLiteral("CompressionLevel"))) { - qCDebug(ARK) << "Using compression level:" << options.value(QStringLiteral("CompressionLevel")).toString(); - ret = archive_write_set_filter_option(m_archiveWriter.data(), NULL, "compression-level", options.value(QStringLiteral("CompressionLevel")).toString().toUtf8()); + if (options.isCompressionLevelSet()) { + qCDebug(ARK) << "Using compression level:" << options.compressionLevel(); + ret = archive_write_set_filter_option(m_archiveWriter.data(), NULL, "compression-level", QString::number(options.compressionLevel()).toUtf8()); if (ret != ARCHIVE_OK) { qCWarning(ARK) << "Failed to set compression level"; emit error(xi18nc("@info", "Setting the compression level failed with the following error:%1",