mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
MagicWord: add %att% as the relative path of the attachment folder
This commit is contained in:
parent
c4c7f99ca7
commit
377c00c25d
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user