mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 22:09:52 +08:00
add config enable_smart_table to control whether format tables automatically
This commit is contained in:
parent
8319a7a029
commit
e06ce87710
@ -324,6 +324,9 @@ auto_scroll_cursor_line=1
|
|||||||
; Editor font family to override the value set by the style
|
; Editor font family to override the value set by the style
|
||||||
editor_font_family=
|
editor_font_family=
|
||||||
|
|
||||||
|
; Whether enable smart table
|
||||||
|
enable_smart_table=true
|
||||||
|
|
||||||
[export]
|
[export]
|
||||||
; Path of the wkhtmltopdf tool
|
; Path of the wkhtmltopdf tool
|
||||||
wkhtmltopdf=wkhtmltopdf
|
wkhtmltopdf=wkhtmltopdf
|
||||||
|
@ -371,6 +371,8 @@ void VConfigManager::initEditorConfigs()
|
|||||||
m_autoScrollCursorLine = getConfigFromSettings(section, "auto_scroll_cursor_line").toInt();
|
m_autoScrollCursorLine = getConfigFromSettings(section, "auto_scroll_cursor_line").toInt();
|
||||||
|
|
||||||
m_editorFontFamily = getConfigFromSettings(section, "editor_font_family").toString();
|
m_editorFontFamily = getConfigFromSettings(section, "editor_font_family").toString();
|
||||||
|
|
||||||
|
m_enableSmartTable = getConfigFromSettings(section, "enable_smart_table").toBool();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VConfigManager::initMarkdownConfigs()
|
void VConfigManager::initMarkdownConfigs()
|
||||||
|
@ -628,6 +628,9 @@ public:
|
|||||||
bool getPrependDotInRelativePath() const;
|
bool getPrependDotInRelativePath() const;
|
||||||
void setPrependDotInRelativePath(bool p_enabled);
|
void setPrependDotInRelativePath(bool p_enabled);
|
||||||
|
|
||||||
|
bool getEnableSmartTable() const;
|
||||||
|
void setEnableSmartTable(bool p_enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initEditorConfigs();
|
void initEditorConfigs();
|
||||||
|
|
||||||
@ -1112,6 +1115,9 @@ private:
|
|||||||
// Whether prepend a dot in the relative path of images and attachments.
|
// Whether prepend a dot in the relative path of images and attachments.
|
||||||
bool m_prependDotInRelativePath;
|
bool m_prependDotInRelativePath;
|
||||||
|
|
||||||
|
// Whether enable smart table.
|
||||||
|
bool m_enableSmartTable;
|
||||||
|
|
||||||
// The name of the config file in each directory.
|
// The name of the config file in each directory.
|
||||||
static const QString c_dirConfigFile;
|
static const QString c_dirConfigFile;
|
||||||
|
|
||||||
@ -2898,4 +2904,19 @@ inline void VConfigManager::setPrependDotInRelativePath(bool p_enabled)
|
|||||||
m_prependDotInRelativePath = p_enabled;
|
m_prependDotInRelativePath = p_enabled;
|
||||||
setConfigToSettings("markdown", "prepend_dot_in_relative_path", m_prependDotInRelativePath);
|
setConfigToSettings("markdown", "prepend_dot_in_relative_path", m_prependDotInRelativePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool VConfigManager::getEnableSmartTable() const
|
||||||
|
{
|
||||||
|
return m_enableSmartTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void VConfigManager::setEnableSmartTable(bool p_enabled)
|
||||||
|
{
|
||||||
|
if (m_enableSmartTable == p_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_enableSmartTable = p_enabled;
|
||||||
|
setConfigToSettings("editor", "enable_smart_table", m_enableSmartTable);
|
||||||
|
}
|
||||||
#endif // VCONFIGMANAGER_H
|
#endif // VCONFIGMANAGER_H
|
||||||
|
@ -1322,6 +1322,17 @@ void VMainWindow::initEditMenu()
|
|||||||
tabAct->setChecked(g_config->getEnableTabHighlight());
|
tabAct->setChecked(g_config->getEnableTabHighlight());
|
||||||
|
|
||||||
initAutoScrollCursorLineMenu(editMenu);
|
initAutoScrollCursorLineMenu(editMenu);
|
||||||
|
|
||||||
|
// Smart table.
|
||||||
|
QAction *smartTableAct = new QAction(tr("Smart Table"), this);
|
||||||
|
smartTableAct->setToolTip(tr("Format table automatically"));
|
||||||
|
smartTableAct->setCheckable(true);
|
||||||
|
connect(smartTableAct, &QAction::triggered,
|
||||||
|
this, [](bool p_checked) {
|
||||||
|
g_config->setEnableSmartTable(p_checked);
|
||||||
|
});
|
||||||
|
editMenu->addAction(smartTableAct);
|
||||||
|
smartTableAct->setChecked(g_config->getEnableSmartTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMainWindow::initDockWindows()
|
void VMainWindow::initDockWindows()
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#include "vtablehelper.h"
|
#include "vtablehelper.h"
|
||||||
|
|
||||||
#include "veditor.h"
|
#include "veditor.h"
|
||||||
|
#include "vconfigmanager.h"
|
||||||
|
|
||||||
|
extern VConfigManager *g_config;
|
||||||
|
|
||||||
VTableHelper::VTableHelper(VEditor *p_editor, QObject *p_parent)
|
VTableHelper::VTableHelper(VEditor *p_editor, QObject *p_parent)
|
||||||
: QObject(p_parent),
|
: QObject(p_parent),
|
||||||
@ -10,7 +13,9 @@ VTableHelper::VTableHelper(VEditor *p_editor, QObject *p_parent)
|
|||||||
|
|
||||||
void VTableHelper::updateTableBlocks(const QVector<VTableBlock> &p_blocks)
|
void VTableHelper::updateTableBlocks(const QVector<VTableBlock> &p_blocks)
|
||||||
{
|
{
|
||||||
if (m_editor->isReadOnlyW() || !m_editor->isModified()) {
|
if (m_editor->isReadOnlyW() ||
|
||||||
|
!m_editor->isModified() ||
|
||||||
|
!g_config->getEnableSmartTable()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user