From f36ffbe2c7470a95ab4ef5cf3181a0e886f6b998 Mon Sep 17 00:00:00 2001 From: Nikhil Tanwar <2002nikhiltanwar@gmail.com> Date: Thu, 3 Aug 2023 11:35:57 +0530 Subject: [PATCH] Remove moveToTrash feature for QT versions pre 5.15 The settings entry is hidden when the QT version is not supported The file is always permanently deleted - dialog box indicates this. --- src/contentmanager.cpp | 9 ++++++++- src/settingsview.cpp | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/contentmanager.cpp b/src/contentmanager.cpp index 409bad19c..81f7c37bf 100644 --- a/src/contentmanager.cpp +++ b/src/contentmanager.cpp @@ -461,10 +461,14 @@ void ContentManager::eraseBookFilesFromComputer(const QString dirPath, const QSt } QDir dir(dirPath, fileName); for(const QString& file: dir.entryList()) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) if (moveToTrash) QFile::moveToTrash(dir.filePath(file)); else dir.remove(file); +#else + dir.remove(file); // moveToTrash will always be false here, no check required. +#endif } } @@ -479,7 +483,10 @@ QString formatText(QString text) void ContentManager::eraseBook(const QString& id) { auto text = gt("delete-book-text"); - const auto moveToTrash = KiwixApp::instance()->getSettingsManager()->getMoveToTrash(); + auto moveToTrash = KiwixApp::instance()->getSettingsManager()->getMoveToTrash(); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + moveToTrash = false; // we do not support move to trash functionality for qt versions below 5.15 +#endif if (moveToTrash) { text += formatText(gt("move-files-to-trash-text")); } else { diff --git a/src/settingsview.cpp b/src/settingsview.cpp index 973c17fff..30f608b0b 100644 --- a/src/settingsview.cpp +++ b/src/settingsview.cpp @@ -34,6 +34,11 @@ SettingsView::SettingsView(QWidget *parent) ui->monitorHelp->setText("?"); ui->monitorHelp->setToolTip(gt("monitor-directory-tooltip")); ui->moveToTrashLabel->setText(gt("move-files-to-trash")); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + ui->moveToTrashLabel->hide(); + ui->moveToTrashToggle->hide(); +#endif + } void SettingsView::init(int zoomPercent, const QString &downloadDir, const QString &monitorDir, const bool moveToTrash)