From 508610d3041258500cea43eb65abd8a849a32cef Mon Sep 17 00:00:00 2001 From: Le Tan Date: Wed, 13 Jan 2021 21:46:47 +0800 Subject: [PATCH] small fix --- src/core/notebook/filenode.cpp | 5 +++++ src/data/core/vnotex.json | 6 +++--- src/widgets/editors/markdowneditor.cpp | 2 +- src/widgets/editors/markdowntablehelper.cpp | 8 ++++++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/core/notebook/filenode.cpp b/src/core/notebook/filenode.cpp index c2f4a620..d4644c0b 100644 --- a/src/core/notebook/filenode.cpp +++ b/src/core/notebook/filenode.cpp @@ -81,6 +81,11 @@ QStringList FileNode::addAttachment(const QString &p_destFolderPath, const QStri { QStringList addedFiles; for (const auto &file : p_files) { + if (PathUtils::isDir(file)) { + qWarning() << "skip adding folder as attachment" << file; + continue; + } + auto destFilePath = m_backend->renameIfExistsCaseInsensitive( PathUtils::concatenateFilePath(p_destFolderPath, PathUtils::fileName(file))); m_backend->copyFile(file, destFilePath); diff --git a/src/data/core/vnotex.json b/src/data/core/vnotex.json index 182be339..888a2d6d 100644 --- a/src/data/core/vnotex.json +++ b/src/data/core/vnotex.json @@ -252,10 +252,10 @@ "linkify" : true, "//comment" : "Whether add indentation to the first line of paragraph", "indent_first_line" : false, - "//comment" : "Whether enable smart table (formation)", + "//comment" : "Whether enable smart table (formatting)", "smart_table" : true, - "//comment" : "Time interval (milliseconds) to do smart table formation", - "smart_table_interval" : 2000 + "//comment" : "Time interval (milliseconds) to do smart table formatting", + "smart_table_interval" : 1000 } }, "widget" : { diff --git a/src/widgets/editors/markdowneditor.cpp b/src/widgets/editors/markdowneditor.cpp index f8f5722c..c4045d83 100644 --- a/src/widgets/editors/markdowneditor.cpp +++ b/src/widgets/editors/markdowneditor.cpp @@ -591,7 +591,7 @@ bool MarkdownEditor::processUrlFromMimeData(const QMimeData *p_source) if (!localFile.isEmpty()) { dialog.addSelection(tr("Insert As Relative Link"), 3); - if (m_buffer->isAttachmentSupported() && !m_buffer->isAttachment(localFile)) { + if (m_buffer->isAttachmentSupported() && !m_buffer->isAttachment(localFile) && !PathUtils::isDir(localFile)) { dialog.addSelection(tr("Attach And Insert Link"), 6); } } diff --git a/src/widgets/editors/markdowntablehelper.cpp b/src/widgets/editors/markdowntablehelper.cpp index ab1980af..5a0ea421 100644 --- a/src/widgets/editors/markdowntablehelper.cpp +++ b/src/widgets/editors/markdowntablehelper.cpp @@ -32,6 +32,14 @@ QTimer *MarkdownTableHelper::getTimer() m_timer->setInterval(ConfigMgr::getInst().getEditorConfig().getMarkdownEditorConfig().getSmartTableInterval()); connect(m_timer, &QTimer::timeout, this, &MarkdownTableHelper::formatTable); + + connect(m_editor->getTextEdit(), &QTextEdit::cursorPositionChanged, + this, [this]() { + if (m_timer->isActive()) { + // Defer the formatting. + m_timer->start(); + } + }); } return m_timer;