diff options
| author | Mike Skec <skec@protonmail.ch> | 2020-12-30 16:38:06 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2020-12-30 11:10:54 +0100 |
| commit | e5814f2bae65e9b757a26e8b263d5e868dbb2f41 (patch) | |
| tree | 0d6963b254b7ad8bd2bf4f1e5210104d0fb92dfc /src/protocols | |
| parent | 3854701237560d1655bcf713bdd5a3f91f3a075b (diff) | |
| download | kristall-e5814f2bae65e9b757a26e8b263d5e868dbb2f41.tar.gz | |
Add preference to show hidden files in directory listings
also improved listing code so that files and dirs with spaces now display and function properly
Diffstat (limited to 'src/protocols')
| -rw-r--r-- | src/protocols/filehandler.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/protocols/filehandler.cpp b/src/protocols/filehandler.cpp index e31f354..c53b3e1 100644 --- a/src/protocols/filehandler.cpp +++ b/src/protocols/filehandler.cpp @@ -1,5 +1,7 @@ #include "filehandler.hpp" +#include "../kristall.hpp" + #include <QMimeDatabase> #include <QUrl> #include <QFile> @@ -49,14 +51,17 @@ bool FileHandler::startRequest(const QUrl &url, RequestOptions options) QString page; page += QString("# Index of %1\n").arg(url.path()); + auto filters = QDir::Dirs | QDir::Files | QDir::NoDot; + if (kristall::options.show_hidden_files_in_dirs) filters |= QDir::Hidden; + dir.setFilter(filters); + // Iterate over files in the directory, and add links to each. for (unsigned i = 0; i < dir.count(); ++i) { - // Skip '.' directory. - if (dir[i] == ".") continue; - // Add link to page. - page += QString("=> file://%1 %2\n").arg(dir.filePath(dir[i]), dir[i]); + page += QString("=> file://%1 %2\n") + .arg(QUrl(dir.filePath(dir[i])).toString(QUrl::FullyEncoded), + dir[i]); } emit this->requestComplete(page.toUtf8(), "text/gemini"); |
