Commit 20c6faa5 authored by Elvis Angelaccio's avatar Elvis Angelaccio
Browse files

Stop ignoring compression options when dropping files

Compression options set by CreateDialog were only taken into account
when adding files through the AddDialog, but not when adding files by
dropping them from Dolphin.

We fix this issue by moving the init of compression options in a new
dedicated function, which we can call also when dropping files.

While at it, this change allows us to simplify the `droppedFiles()`
signal emitted by ArchiveModel.

BUG: 396579
FIXED-IN: 18.07.80
parent 38945f83
......@@ -320,7 +320,7 @@ bool ArchiveModel::dropMimeData(const QMimeData *data, Qt::DropAction action, in
}
}
emit droppedFiles(paths, entry, QString());
emit droppedFiles(paths, entry);
return true;
}
......
......@@ -143,7 +143,7 @@ signals:
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*);
void messageWidget(KMessageWidget::MessageType type, const QString& msg);
private slots:
......
......@@ -202,7 +202,7 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList& args)
connect(m_model, &ArchiveModel::loadingFinished,
this, &Part::slotLoadingFinished);
connect(m_model, &ArchiveModel::droppedFiles,
this, QOverload<const QStringList&, const Archive::Entry*, const QString&>::of(&Part::slotAddFiles));
this, &Part::slotDroppedFiles);
connect(m_model, &ArchiveModel::error,
this, &Part::slotError);
connect(m_model, &ArchiveModel::messageWidget,
......@@ -741,6 +741,29 @@ QModelIndexList Part::getSelectedIndexes()
return list;
}
void Part::readCompressionOptions()
{
// Store options from CreateDialog if they are set.
if (!m_compressionOptions.isCompressionLevelSet() && arguments().metaData().contains(QStringLiteral("compressionLevel"))) {
m_compressionOptions.setCompressionLevel(arguments().metaData()[QStringLiteral("compressionLevel")].toInt());
}
if (m_compressionOptions.compressionMethod().isEmpty() && arguments().metaData().contains(QStringLiteral("compressionMethod"))) {
m_compressionOptions.setCompressionMethod(arguments().metaData()[QStringLiteral("compressionMethod")]);
}
if (m_compressionOptions.encryptionMethod().isEmpty() && arguments().metaData().contains(QStringLiteral("encryptionMethod"))) {
m_compressionOptions.setEncryptionMethod(arguments().metaData()[QStringLiteral("encryptionMethod")]);
}
if (!m_compressionOptions.isVolumeSizeSet() && arguments().metaData().contains(QStringLiteral("volumeSize"))) {
m_compressionOptions.setVolumeSize(arguments().metaData()[QStringLiteral("volumeSize")].toULong());
}
const auto compressionMethods = m_model->archive()->property("compressionMethods").toStringList();
qCDebug(ARK) << "compmethods:" << compressionMethods;
if (compressionMethods.size() == 1) {
m_compressionOptions.setCompressionMethod(compressionMethods.first());
}
}
bool Part::openFile()
{
qCDebug(ARK) << "Attempting to open archive" << localFilePath();
......@@ -1335,27 +1358,15 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const Archive::Entry *des
job->start();
}
void Part::slotAddFiles()
void Part::slotDroppedFiles(const QStringList &files, const Archive::Entry *destination)
{
// Store options from CreateDialog if they are set.
if (!m_compressionOptions.isCompressionLevelSet() && arguments().metaData().contains(QStringLiteral("compressionLevel"))) {
m_compressionOptions.setCompressionLevel(arguments().metaData()[QStringLiteral("compressionLevel")].toInt());
}
if (m_compressionOptions.compressionMethod().isEmpty() && arguments().metaData().contains(QStringLiteral("compressionMethod"))) {
m_compressionOptions.setCompressionMethod(arguments().metaData()[QStringLiteral("compressionMethod")]);
}
if (m_compressionOptions.encryptionMethod().isEmpty() && arguments().metaData().contains(QStringLiteral("encryptionMethod"))) {
m_compressionOptions.setEncryptionMethod(arguments().metaData()[QStringLiteral("encryptionMethod")]);
}
if (!m_compressionOptions.isVolumeSizeSet() && arguments().metaData().contains(QStringLiteral("volumeSize"))) {
m_compressionOptions.setVolumeSize(arguments().metaData()[QStringLiteral("volumeSize")].toULong());
}
readCompressionOptions();
slotAddFiles(files, destination, QString());
}
const auto compressionMethods = m_model->archive()->property("compressionMethods").toStringList();
qCDebug(ARK) << "compmethods:" << compressionMethods;
if (compressionMethods.size() == 1) {
m_compressionOptions.setCompressionMethod(compressionMethods.first());
}
void Part::slotAddFiles()
{
readCompressionOptions();
QString dialogTitle = i18nc("@title:window", "Add Files");
const Archive::Entry *destination = nullptr;
......
......@@ -123,6 +123,7 @@ private slots:
* watched file.
*/
void slotAddFiles(const QStringList &files, const Kerfuffle::Archive::Entry *destination, const QString &relPath);
void slotDroppedFiles(const QStringList &files, const Kerfuffle::Archive::Entry *destination);
/**
* Creates and starts MoveJob or CopyJob.
......@@ -191,6 +192,7 @@ private:
QModelIndexList addChildren(const QModelIndexList &list) const;
void registerJob(KJob *job);
QModelIndexList getSelectedIndexes();
void readCompressionOptions();
ArchiveModel *m_model;
ArchiveView *m_view;
......
Markdown is supported
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