mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add config table_format_interval for smart table
This commit is contained in:
parent
84edcbd26e
commit
13d0c60e59
@ -333,6 +333,9 @@ editor_font_family=
|
||||
; Whether enable smart table
|
||||
enable_smart_table=true
|
||||
|
||||
; Interval (milliseconds) to format table
|
||||
table_format_interval=3000
|
||||
|
||||
[export]
|
||||
; Path of the wkhtmltopdf tool
|
||||
wkhtmltopdf=wkhtmltopdf
|
||||
|
@ -377,6 +377,8 @@ void VConfigManager::initEditorConfigs()
|
||||
m_editorFontFamily = getConfigFromSettings(section, "editor_font_family").toString();
|
||||
|
||||
m_enableSmartTable = getConfigFromSettings(section, "enable_smart_table").toBool();
|
||||
|
||||
m_tableFormatIntervalMS = getConfigFromSettings(section, "table_format_interval").toInt();
|
||||
}
|
||||
|
||||
void VConfigManager::initMarkdownConfigs()
|
||||
|
@ -643,6 +643,8 @@ public:
|
||||
QDateTime getLastStartDateTime() const;
|
||||
void updateLastStartDateTime();
|
||||
|
||||
int getTableFormatInterval() const;
|
||||
|
||||
private:
|
||||
void initEditorConfigs();
|
||||
|
||||
@ -1133,6 +1135,9 @@ private:
|
||||
// Whether auto locate to current tab in note list.
|
||||
bool m_syncNoteListToCurrentTab;
|
||||
|
||||
// Interval (milliseconds) to format table.
|
||||
int m_tableFormatIntervalMS;
|
||||
|
||||
// The name of the config file in each directory.
|
||||
static const QString c_dirConfigFile;
|
||||
|
||||
@ -2959,4 +2964,9 @@ inline void VConfigManager::setSyncNoteListToTab(bool p_enabled)
|
||||
m_syncNoteListToCurrentTab = p_enabled;
|
||||
setConfigToSettings("global", "sync_note_list_to_current_tab", m_syncNoteListToCurrentTab);
|
||||
}
|
||||
|
||||
inline int VConfigManager::getTableFormatInterval() const
|
||||
{
|
||||
return m_tableFormatIntervalMS;
|
||||
}
|
||||
#endif // VCONFIGMANAGER_H
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <QPrintDialog>
|
||||
#include <QPainter>
|
||||
#include <QWebEnginePage>
|
||||
#include <QRandomGenerator>
|
||||
|
||||
#include "vmainwindow.h"
|
||||
#include "vdirectorytree.h"
|
||||
@ -3472,7 +3473,8 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
|
||||
}
|
||||
|
||||
if (g_config->getAllowUserTrack()) {
|
||||
QTimer::singleShot(30 * 1000, this, SLOT(collectUserStat()));
|
||||
int interval = (30 + QRandomGenerator::global()->generate() % 60) * 1000;
|
||||
QTimer::singleShot(interval, this, SLOT(collectUserStat()));
|
||||
}
|
||||
|
||||
m_syncNoteListToCurrentTab = true;
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "vtablehelper.h"
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
#include "veditor.h"
|
||||
#include "vconfigmanager.h"
|
||||
|
||||
@ -9,10 +11,17 @@ VTableHelper::VTableHelper(VEditor *p_editor, QObject *p_parent)
|
||||
: QObject(p_parent),
|
||||
m_editor(p_editor)
|
||||
{
|
||||
m_timer = new QTimer(this);
|
||||
m_timer->setSingleShot(true);
|
||||
m_timer->setInterval(g_config->getTableFormatInterval());
|
||||
connect(m_timer, &QTimer::timeout,
|
||||
this, &VTableHelper::formatTables);
|
||||
}
|
||||
|
||||
void VTableHelper::updateTableBlocks(const QVector<VTableBlock> &p_blocks)
|
||||
{
|
||||
m_timer->stop();
|
||||
|
||||
if (m_editor->isReadOnlyW() ||
|
||||
!m_editor->isModified() ||
|
||||
!g_config->getEnableSmartTable()) {
|
||||
@ -24,14 +33,8 @@ void VTableHelper::updateTableBlocks(const QVector<VTableBlock> &p_blocks)
|
||||
return;
|
||||
}
|
||||
|
||||
VTable table(m_editor, p_blocks[idx]);
|
||||
if (!table.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.format();
|
||||
|
||||
table.write();
|
||||
m_block = p_blocks[idx];
|
||||
m_timer->start();
|
||||
}
|
||||
|
||||
int VTableHelper::currentCursorTableBlock(const QVector<VTableBlock> &p_blocks) const
|
||||
@ -66,3 +69,19 @@ void VTableHelper::insertTable(int p_nrRow, int p_nrCol, VTable::Alignment p_ali
|
||||
|
||||
table.write();
|
||||
}
|
||||
|
||||
void VTableHelper::formatTables()
|
||||
{
|
||||
if (!m_block.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
VTable table(m_editor, m_block);
|
||||
if (!table.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
table.format();
|
||||
|
||||
table.write();
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define VTABLEHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
#include "markdownhighlighterdata.h"
|
||||
#include "vtable.h"
|
||||
@ -24,7 +25,13 @@ private:
|
||||
// Return the block index which contains the cursor.
|
||||
int currentCursorTableBlock(const QVector<VTableBlock> &p_blocks) const;
|
||||
|
||||
void formatTables();
|
||||
|
||||
VEditor *m_editor;
|
||||
|
||||
QTimer *m_timer;
|
||||
|
||||
VTableBlock m_block;
|
||||
};
|
||||
|
||||
#endif // VTABLEHELPER_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user