Commit 07269ec7 authored by Ragnar Thomsen's avatar Ragnar Thomsen

Implement a custom AddDialog

This diff implements an AddDialog class that is used instead of
QFileDialogs for adding files/folders to an archive. Now both folders
and files are added to an archive with a single action in Part, instead
of two separate actions (Add File/Add Folder).

AddDialog has a button which opens a new dialog that allows setting
advanced compression settings (currently only compression level). Since
compression options are used both when creating a new archive and adding
files to an existing archive, a new class called
CompressionOptionsWidget was created which is used by both AddDialog and
CreateDialog.

Differential Revision: D2120
GUI:
parent bce36ee9
......@@ -16,6 +16,11 @@ ecm_add_tests(
LINK_LIBRARIES kerfuffle Qt5::Test
NAME_PREFIX kerfuffle-)
ecm_add_test(
adddialogtest.cpp
LINK_LIBRARIES kerfuffle Qt5::Test KF5::KIOFileWidgets
NAME_PREFIX kerfuffle-)
ecm_add_tests(
jobstest.cpp
LINK_LIBRARIES jsoninterface Qt5::Test
......
/*
* Copyright (c) 2016 Ragnar Thomsen <rthomsen6@gmail.com>
*
* 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 "adddialog.h"
#include "archiveformat.h"
#include "pluginmanager.h"
#include <KCollapsibleGroupBox>
#include <QCheckBox>
#include <QComboBox>
#include <QLineEdit>
#include <QMimeDatabase>
#include <QTest>
using namespace Kerfuffle;
class AddDialogTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testBasicWidgets_data();
void testBasicWidgets();
private:
PluginManager m_pluginManager;
};
void AddDialogTest::testBasicWidgets_data()
{
QTest::addColumn<QString>("mimeType");
QTest::addColumn<bool>("supportsCompLevel");
QTest::addColumn<int>("initialCompLevel");
QTest::addColumn<int>("changeToCompLevel");
QTest::newRow("tar") << QStringLiteral("application/x-tar") << false << -1 << -1;
QTest::newRow("targzip") << QStringLiteral("application/x-compressed-tar") << true << 3 << 7;
QTest::newRow("tarbzip") << QStringLiteral("application/x-bzip-compressed-tar") << true << 3 << 7;
QTest::newRow("tarZ") << QStringLiteral("application/x-tarz") << false << -1 << -1;
QTest::newRow("tarxz") << QStringLiteral("application/x-xz-compressed-tar") << true << 3 << 7;
QTest::newRow("tarlzma") << QStringLiteral("application/x-lzma-compressed-tar") << true << 3 << 7;
QTest::newRow("tarlzop") << QStringLiteral("application/x-tzo") << true << 3 << 7;
QTest::newRow("tarlzip") << QStringLiteral("application/x-lzip-compressed-tar") << true << 3 << 7;
const auto writeMimeTypes = m_pluginManager.supportedWriteMimeTypes();
if (writeMimeTypes.contains(QStringLiteral("application/zip"))) {
QTest::newRow("zip") << QStringLiteral("application/zip") << true << 3 << 7;
} else {
qDebug() << "zip format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-7z-compressed"))) {
QTest::newRow("7z") << QStringLiteral("application/x-7z-compressed") << true << 3 << 7;
} else {
qDebug() << "7z format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-rar"))) {
QTest::newRow("rar") << QStringLiteral("application/x-rar") << true << 2 << 5;
} else {
qDebug() << "rar format not available, skipping test.";
}
if (writeMimeTypes.contains(QStringLiteral("application/x-lrzip-compressed-tar"))) {
QTest::newRow("tarlrzip") << QStringLiteral("application/x-lrzip-compressed-tar") << true << 3 << 7;
} else {
qDebug() << "tar.lrzip format not available, skipping test.";
}
}
void AddDialogTest::testBasicWidgets()
{
QFETCH(QString, mimeType);
const QMimeType mime = QMimeDatabase().mimeTypeForName(mimeType);
QFETCH(bool, supportsCompLevel);
QFETCH(int, initialCompLevel);
QFETCH(int, changeToCompLevel);
AddDialog *dialog = new AddDialog(Q_NULLPTR, QString(), QUrl(), mime);
dialog->slotOpenOptions();
auto collapsibleCompression = dialog->optionsDialog->findChild<KCollapsibleGroupBox*>(QStringLiteral("collapsibleCompression"));
QVERIFY(collapsibleCompression);
if (supportsCompLevel) {
// Test that collapsiblegroupbox is enabled for mimetypes that support compression levels.
QVERIFY(collapsibleCompression->isEnabled());
auto compLevelSlider = dialog->optionsDialog->findChild<QSlider*>(QStringLiteral("compLevelSlider"));
QVERIFY(compLevelSlider);
const KPluginMetaData metadata = PluginManager().preferredPluginFor(mime)->metaData();
const ArchiveFormat archiveFormat = ArchiveFormat::fromMetadata(mime, metadata);
QVERIFY(archiveFormat.isValid());
// Test that min/max of slider are correct.
QCOMPARE(compLevelSlider->minimum(), archiveFormat.minCompressionLevel());
QCOMPARE(compLevelSlider->maximum(), archiveFormat.maxCompressionLevel());
// Test that the slider is set to default compression level.
QCOMPARE(compLevelSlider->value(), archiveFormat.defaultCompressionLevel());
// Set the compression level slider.
compLevelSlider->setValue(changeToCompLevel);
} else {
// Test that collapsiblegroupbox is disabled for mimetypes that don't support compression levels.
QVERIFY(!collapsibleCompression->isEnabled());
}
dialog->optionsDialog->accept();
dialog->accept();
if (supportsCompLevel) {
// Test that the value set by slider is exported from AddDialog.
QCOMPARE(dialog->compressionOptions()[QStringLiteral("CompressionLevel")].toInt(), changeToCompLevel);
}
// Test that passing a compression level in ctor works.
CompressionOptions opts;
opts[QStringLiteral("CompressionLevel")] = initialCompLevel;
dialog = new AddDialog(Q_NULLPTR, QString(), QUrl(), mime, opts);
dialog->slotOpenOptions();
if (supportsCompLevel) {
auto compLevelSlider = dialog->optionsDialog->findChild<QSlider*>(QStringLiteral("compLevelSlider"));
QVERIFY(compLevelSlider);
// Test that slider is set to the compression level supplied in ctor.
QCOMPARE(compLevelSlider->value(), initialCompLevel);
}
dialog->optionsDialog->accept();
dialog->accept();
}
QTEST_MAIN(AddDialogTest)
#include "adddialogtest.moc"
......@@ -8,6 +8,8 @@ set(kerfuffle_SRCS
previewsettingspage.cpp
settingspage.cpp
jobs.cpp
adddialog.cpp
compressionoptionswidget.cpp
createdialog.cpp
extractiondialog.cpp
propertiesdialog.cpp
......@@ -27,6 +29,7 @@ ki18n_wrap_ui(kerfuffle_SRCS
extractionsettings.ui
previewsettings.ui
propertiesdialog.ui
compressionoptionswidget.ui
)
ecm_qt_declare_logging_category(kerfuffle_SRCS
......
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2016 Ragnar Thomsen <rthomsen6@gmail.com>
*
* 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 "adddialog.h"
#include "ark_debug.h"
#include "archiveformat.h"
#include "compressionoptionswidget.h"
#include "mimetypes.h"
#include <QDialogButtonBox>
#include <QPointer>
#include <QPushButton>
#include <QUrl>
#include <QVBoxLayout>
namespace Kerfuffle
{
AddDialog::AddDialog(QWidget *parent,
const QString &title,
const QUrl &startDir,
const QMimeType &mimeType,
const CompressionOptions &opts)
: QDialog(parent, Qt::Dialog)
, m_mimeType(mimeType)
, m_compOptions(opts)
{
qCDebug(ARK) << "AddDialog loaded with options:" << m_compOptions;
setWindowTitle(title);
QVBoxLayout *vlayout = new QVBoxLayout(this);
m_fileWidget = new KFileWidget(startDir, this);
vlayout->addWidget(m_fileWidget);
QPushButton *optionsButton = new QPushButton(QIcon::fromTheme(QStringLiteral("settings-configure")),
i18n("Advanced Options"));
optionsButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_fileWidget->setCustomWidget(optionsButton);
connect(optionsButton, &QPushButton::clicked, this, &AddDialog::slotOpenOptions);
m_fileWidget->setMode(KFile::Files | KFile::Directory | KFile::LocalOnly | KFile::ExistingOnly);
m_fileWidget->setOperationMode(KFileWidget::Opening);
m_fileWidget->okButton()->setText(i18nc("@action:button", "Add"));
m_fileWidget->okButton()->show();
connect(m_fileWidget->okButton(), &QPushButton::clicked, m_fileWidget, &KFileWidget::slotOk);
connect(m_fileWidget, &KFileWidget::accepted, m_fileWidget, &KFileWidget::accept);
connect(m_fileWidget, &KFileWidget::accepted, this, &QDialog::accept);
m_fileWidget->cancelButton()->show();
connect(m_fileWidget->cancelButton(), &QPushButton::clicked, this, &QDialog::reject);
}
AddDialog::~AddDialog()
{
}
QStringList AddDialog::selectedFiles() const
{
return m_fileWidget->selectedFiles();
}
CompressionOptions AddDialog::compressionOptions() const
{
return m_compOptions;
}
void AddDialog::slotOpenOptions()
{
optionsDialog = new QDialog(this);
QVBoxLayout *vlayout = new QVBoxLayout(optionsDialog);
optionsDialog->setWindowTitle(i18n("Advanced Options"));
CompressionOptionsWidget *optionsWidget = new CompressionOptionsWidget(optionsDialog, m_compOptions);
optionsWidget->setMimeType(m_mimeType);
optionsWidget->setEncryptionVisible(false);
optionsWidget->collapsibleCompression->expand();
vlayout->addWidget(optionsWidget);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, optionsDialog);
vlayout->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, optionsDialog, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, optionsDialog, &QDialog::reject);
optionsDialog->layout()->setSizeConstraint(QLayout::SetFixedSize);
connect(optionsDialog, &QDialog::finished, this, [this, optionsWidget](int result) {
if (result == QDialog::Accepted) {
m_compOptions = optionsWidget->commpressionOptions();
}
optionsDialog->deleteLater();
});
optionsDialog->open();
}
}
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2016 Ragnar Thomsen <rthomsen6@gmail.com>
*
* 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 ADDDIALOG_H
#define ADDDIALOG_H
#include "kerfuffle_export.h"
#include "archive_kerfuffle.h"
#include "compressionoptionswidget.h"
#include <KFileWidget>
#include <QDialog>
#include <QMimeType>
class QUrl;
namespace Kerfuffle
{
class KERFUFFLE_EXPORT AddDialog : public QDialog
{
Q_OBJECT
public:
explicit AddDialog(QWidget *parent,
const QString &title,
const QUrl &startDir,
const QMimeType &mimeType,
const CompressionOptions &opts = QHash<QString, QVariant>());
virtual ~AddDialog();
QStringList selectedFiles() const;
CompressionOptions compressionOptions() const;
QDialog *optionsDialog;
private:
KFileWidget *m_fileWidget;
QMimeType m_mimeType;
CompressionOptions m_compOptions;
public slots:
void slotOpenOptions();
};
}
#endif
......@@ -470,4 +470,14 @@ void Archive::onUserQuery(Query* query)
query->execute();
}
void Archive::setCompressionOptions(const CompressionOptions &opts)
{
m_compOptions = opts;
}
CompressionOptions Archive::compressionOptions() const
{
return m_compOptions;
}
} // namespace Kerfuffle
......@@ -180,6 +180,8 @@ public:
qulonglong unpackedSize();
qulonglong packedSize() const;
QString subfolderName();
void setCompressionOptions(const CompressionOptions &opts);
CompressionOptions compressionOptions() const;
static Archive *create(const QString &fileName, QObject *parent = 0);
static Archive *create(const QString &fileName, const QString &fixedMimeType, QObject *parent = 0);
......@@ -256,6 +258,7 @@ private:
EncryptionType m_encryptionType;
qulonglong m_numberOfFiles;
qulonglong m_numberOfFolders;
CompressionOptions m_compOptions;
QMimeType m_mimeType;
};
......
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2016 Ragnar Thomsen <rthomsen6@gmail.com>
*
* 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 "compressionoptionswidget.h"
#include "ark_debug.h"
#include "archiveformat.h"
#include "pluginmanager.h"
#include <KColorScheme>
#include <KPluginMetaData>
#include <QMimeDatabase>
namespace Kerfuffle
{
CompressionOptionsWidget::CompressionOptionsWidget(QWidget *parent,
const CompressionOptions &opts)
: QWidget(parent)
, m_opts(opts)
{
setupUi(this);
KColorScheme colorScheme(QPalette::Active, KColorScheme::View);
pwdWidget->setBackgroundWarningColor(colorScheme.background(KColorScheme::NegativeBackground).color());
pwdWidget->setPasswordStrengthMeterVisible(false);
}
CompressionOptions CompressionOptionsWidget::commpressionOptions() const
{
CompressionOptions opts;
opts[QStringLiteral("CompressionLevel")] = compLevelSlider->value();
return opts;
}
int CompressionOptionsWidget::compressionLevel() const
{
return compLevelSlider->value();
}
void CompressionOptionsWidget::setEncryptionVisible(bool visible)
{
collapsibleEncryption->setVisible(visible);
}
QString CompressionOptionsWidget::password() const
{
return pwdWidget->password();
}
void CompressionOptionsWidget::updateWidgets()
{
const KPluginMetaData metadata = PluginManager().preferredPluginFor(m_mimetype)->metaData();
const ArchiveFormat archiveFormat = ArchiveFormat::fromMetadata(m_mimetype, metadata);
Q_ASSERT(archiveFormat.isValid());
if (archiveFormat.encryptionType() != Archive::Unencrypted) {
collapsibleEncryption->setEnabled(true);
collapsibleEncryption->setToolTip(QString());
pwdWidget->setEnabled(true);
if (archiveFormat.encryptionType() == Archive::HeaderEncrypted) {
encryptHeaderCheckBox->setEnabled(true);
encryptHeaderCheckBox->setToolTip(QString());
} else {
encryptHeaderCheckBox->setEnabled(false);
// Show the tooltip only if the encryption is still enabled.
// This is needed because if the new filter is e.g. tar, the whole encryption group gets disabled.
if (collapsibleEncryption->isEnabled() && collapsibleEncryption->isExpanded()) {
encryptHeaderCheckBox->setToolTip(i18n("Protection of the list of files is not possible with the %1 format.",
m_mimetype.comment()));
} else {
encryptHeaderCheckBox->setToolTip(QString());
}
}
} else {
collapsibleEncryption->setEnabled(false);
collapsibleEncryption->setToolTip(i18n("Protection of the archive with password is not possible with the %1 format.",
m_mimetype.comment()));
pwdWidget->setEnabled(false);
encryptHeaderCheckBox->setToolTip(QString());
}
if (archiveFormat.maxCompressionLevel() == 0) {
collapsibleCompression->setEnabled(false);
collapsibleCompression->setToolTip(i18n("It is not possible to set compression level for the %1 format.",
m_mimetype.comment()));
} else {
collapsibleCompression->setEnabled(true);
collapsibleCompression->setToolTip(QString());
compLevelSlider->setMinimum(archiveFormat.minCompressionLevel());
compLevelSlider->setMaximum(archiveFormat.maxCompressionLevel());
if (m_opts.contains(QStringLiteral("CompressionLevel"))) {
compLevelSlider->setValue(m_opts.value(QStringLiteral("CompressionLevel")).toInt());
} else {
compLevelSlider->setValue(archiveFormat.defaultCompressionLevel());
}
}
}
void CompressionOptionsWidget::setMimeType(const QMimeType &mimeType)
{
m_mimetype = mimeType;
updateWidgets();
}
bool CompressionOptionsWidget::isEncryptionAvailable() const
{
return collapsibleEncryption->isEnabled();
}
bool CompressionOptionsWidget::isEncryptionEnabled() const
{
return isEncryptionAvailable() && collapsibleEncryption->isExpanded();
}
bool CompressionOptionsWidget::isHeaderEncryptionAvailable() const
{
return isEncryptionEnabled() && encryptHeaderCheckBox->isEnabled();
}
bool CompressionOptionsWidget::isHeaderEncryptionEnabled() const
{
return isHeaderEncryptionAvailable() && encryptHeaderCheckBox->isChecked();
}
KNewPasswordWidget::PasswordStatus CompressionOptionsWidget::passwordStatus() const
{
return pwdWidget->passwordStatus();
}
}
/*
* ark -- archiver for the KDE project
*
* Copyright (C) 2016 Ragnar Thomsen <rthomsen6@gmail.com>
*
* 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 COMPRESSIONOPTIONSWIDGET_H
#define COMPRESSIONOPTIONSWIDGET_H
#include "kerfuffle_export.h"
#include "archive_kerfuffle.h"
#include "ui_compressionoptionswidget.h"
#include <QMimeType>
#include <QWidget>
namespace Kerfuffle
{
class KERFUFFLE_EXPORT CompressionOptionsWidget : public QWidget, public Ui::CompressionOptionsWidget
{
Q_OBJECT
public:
explicit CompressionOptionsWidget(QWidget *parent = Q_NULLPTR,
const CompressionOptions &opts = QHash<QString, QVariant>());
int compressionLevel() const;
QString password() const;
CompressionOptions commpressionOptions() const;
bool isEncryptionAvailable() const;
bool isEncryptionEnabled() const;
bool isHeaderEncryptionAvailable() const;
bool isHeaderEncryptionEnabled() const;
KNewPasswordWidget::PasswordStatus passwordStatus() const;
void setEncryptionVisible(bool visible);
void setMimeType(const QMimeType &mimeType);
private: