Commit ac60f6b4 authored by Jan Paul Batrina's avatar Jan Paul Batrina Committed by Elvis Angelaccio
Browse files

Do not show overwrite confirmation dialog for modified files

Since a confirmation dialog for modified files is shown anyway,
we do not need to show the overwrite confirmation dialog.
parent 9074c103
......@@ -1138,7 +1138,7 @@ void Part::slotWatchedFileModified(const QString& file)
QStringList list = QStringList() << file;
qCDebug(ARK) << "Updating file" << file << "with path" << relPath;
slotAddFiles(list, nullptr, relPath);
slotAddFiles(list, nullptr, relPath, DoNotShowOverwriteDialog);
}
// This is needed because some apps, such as Kate, delete and recreate
// files when saving.
......@@ -1320,7 +1320,7 @@ void Part::slotExtractionDone(KJob* job)
}
}
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, OverwriteBehaviour onOverwrite)
{
if (!m_model->archive() || filesToAdd.isEmpty()) {
return;
......@@ -1348,7 +1348,7 @@ void Part::slotAddFiles(const QStringList& filesToAdd, const Archive::Entry *des
QList<const Archive::Entry*> conflictingEntries;
bool error = m_model->conflictingEntries(conflictingEntries, withChildPaths, true);
if (conflictingEntries.count() > 0) {
if (onOverwrite == ShowOverwriteDialog && conflictingEntries.count() > 0) {
QPointer<OverwriteDialog> overwriteDialog = new OverwriteDialog(widget(), conflictingEntries, error);
int ret = overwriteDialog->exec();
delete overwriteDialog;
......
......@@ -68,6 +68,12 @@ public:
OpenFileWith
};
enum OverwriteBehaviour {
ShowOverwriteDialog,
DoNotShowOverwriteDialog
};
Part(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &);
~Part() override;
......@@ -125,8 +131,9 @@ private Q_SLOTS:
* 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 onOverwrite Whether to show a confirmation dialog when files will be overwritten
*/
void slotAddFiles(const QStringList &files, const Kerfuffle::Archive::Entry *destination, const QString &relPath);
void slotAddFiles(const QStringList &files, const Kerfuffle::Archive::Entry *destination, const QString &relPath, OverwriteBehaviour onOverwrite = ShowOverwriteDialog);
void slotDroppedFiles(const QStringList &files, const Kerfuffle::Archive::Entry *destination);
/**
......
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