Skip to content

Commit

Permalink
Remove moveToTrash feature for QT versions pre 5.15
Browse files Browse the repository at this point in the history
The settings entry is hidden when the QT version is not supported
The file is always permanently deleted - dialog box indicates this.
  • Loading branch information
juuz0 committed Aug 3, 2023
1 parent 40a2547 commit f36ffbe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/contentmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions src/settingsview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ SettingsView::SettingsView(QWidget *parent)
ui->monitorHelp->setText("<b>?</b>");
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

Check notice on line 41 in src/settingsview.cpp

View check run for this annotation

codefactor.io / CodeFactor

src/settingsview.cpp#L41

Redundant blank line at the end of a code block should be deleted. (whitespace/blank_line)
}

void SettingsView::init(int zoomPercent, const QString &downloadDir, const QString &monitorDir, const bool moveToTrash)
Expand Down

0 comments on commit f36ffbe

Please sign in to comment.