diff --git a/fileitemaction/denote_fileitemaction.cpp b/fileitemaction/denote_fileitemaction.cpp index a2a8732..b5f9561 100644 --- a/fileitemaction/denote_fileitemaction.cpp +++ b/fileitemaction/denote_fileitemaction.cpp @@ -68,7 +68,7 @@ void DenoteFileItemAction::renameWithDenote(const KFileItemList &items, QWidget defaultTitle.replace(QLatin1Char('_'), QLatin1Char(' ')); // Try to extract title from frontmatter if applicable - const QString ext = QStringLiteral(".") + fi.suffix(); + const QString ext = QStringLiteral(".") + fi.completeSuffix(); Denote::FileType fileType = Denote::fileTypeFromExtension(ext); if (fileType != Denote::FileType::Unknown) { QFile file(path); diff --git a/lib/denote_frontmatter.cpp b/lib/denote_frontmatter.cpp index db60c73..a3eac83 100644 --- a/lib/denote_frontmatter.cpp +++ b/lib/denote_frontmatter.cpp @@ -8,12 +8,21 @@ namespace Denote { FileType fileTypeFromExtension(const QString &ext) { const QString lower = ext.toLower(); + // Check the full extension first, then the inner extension for compound types + // e.g. ".md.gpg" -> check ".md.gpg", then ".md" if (lower == QStringLiteral(".md") || lower == QStringLiteral(".markdown")) return FileType::MdYaml; if (lower == QStringLiteral(".org")) return FileType::Org; if (lower == QStringLiteral(".txt")) return FileType::Txt; + + // For compound extensions, check if the inner part is supported + int dot = lower.indexOf(QLatin1Char('.'), 1); + if (dot > 0) { + return fileTypeFromExtension(lower.left(dot)); + } + return FileType::Unknown; }