MagicWord: add %att% as the relative path of the attachment folder

This commit is contained in:
Le Tan 2018-09-06 21:12:06 +08:00
parent c4c7f99ca7
commit 377c00c25d

View File

@ -8,6 +8,8 @@
#include "vconfigmanager.h"
#include "vmainwindow.h"
#include "vnotefile.h"
#include "vnotebook.h"
extern VConfigManager *g_config;
@ -280,6 +282,25 @@ void VMetaWordManager::init()
return QString();
});
// %att%.
addMetaWord(MetaWordType::FunctionBased,
"att",
tr("relative path of current note's attachment folder"),
[](const VMetaWord *) {
const VFile *file = g_mainWin->getCurrentFile();
if (file && file->getType() == FileType::Note) {
const VNoteFile *nfile = static_cast<const VNoteFile *>(file);
const QString &folder = nfile->getAttachmentFolder();
if (!folder.isEmpty()) {
return nfile->getNotebook()->getAttachmentFolder()
+ "/"
+ folder;
}
}
return QString();
});
// Custom meta words.
initCustomMetaWords();