mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add config to enable code block copy button in settings dialog
This commit is contained in:
parent
28d62d2400
commit
f06e2b168c
@ -1274,6 +1274,10 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
|
|||||||
QLabel *colorColumnLabel = new QLabel(tr("Color column:"));
|
QLabel *colorColumnLabel = new QLabel(tr("Color column:"));
|
||||||
colorColumnLabel->setToolTip(m_colorColumnEdit->toolTip());
|
colorColumnLabel->setToolTip(m_colorColumnEdit->toolTip());
|
||||||
|
|
||||||
|
// Code block copy button.
|
||||||
|
m_codeBlockCopyButtonCB = new QCheckBox(tr("Code block copy button"));
|
||||||
|
m_codeBlockCopyButtonCB->setToolTip(tr("Display a copy button at the top right corner of each code block to copy the content in read mode"));
|
||||||
|
|
||||||
// MathJax.
|
// MathJax.
|
||||||
m_mathjaxConfigEdit = new VLineEdit();
|
m_mathjaxConfigEdit = new VLineEdit();
|
||||||
m_mathjaxConfigEdit->setToolTip(tr("Location of MathJax JavaScript and its configuration "
|
m_mathjaxConfigEdit->setToolTip(tr("Location of MathJax JavaScript and its configuration "
|
||||||
@ -1371,6 +1375,7 @@ VMarkdownTab::VMarkdownTab(QWidget *p_parent)
|
|||||||
mainLayout->addRow(tr("Open mode:"), m_openModeCombo);
|
mainLayout->addRow(tr("Open mode:"), m_openModeCombo);
|
||||||
mainLayout->addRow(tr("Heading sequence:"), headingSequenceLayout);
|
mainLayout->addRow(tr("Heading sequence:"), headingSequenceLayout);
|
||||||
mainLayout->addRow(colorColumnLabel, m_colorColumnEdit);
|
mainLayout->addRow(colorColumnLabel, m_colorColumnEdit);
|
||||||
|
mainLayout->addRow(m_codeBlockCopyButtonCB);
|
||||||
mainLayout->addRow(tr("MathJax configuration:"), m_mathjaxConfigEdit);
|
mainLayout->addRow(tr("MathJax configuration:"), m_mathjaxConfigEdit);
|
||||||
mainLayout->addRow(tr("PlantUML:"), m_plantUMLModeCombo);
|
mainLayout->addRow(tr("PlantUML:"), m_plantUMLModeCombo);
|
||||||
mainLayout->addRow(tr("PlantUML server:"), m_plantUMLServerEdit);
|
mainLayout->addRow(tr("PlantUML server:"), m_plantUMLServerEdit);
|
||||||
@ -1395,6 +1400,10 @@ bool VMarkdownTab::loadConfiguration()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!loadCodeBlockCopyButton()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!loadMathJax()) {
|
if (!loadMathJax()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1424,6 +1433,10 @@ bool VMarkdownTab::saveConfiguration()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!saveCodeBlockCopyButton()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!saveMathJax()) {
|
if (!saveMathJax()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1507,6 +1520,18 @@ bool VMarkdownTab::saveColorColumn()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool VMarkdownTab::loadCodeBlockCopyButton()
|
||||||
|
{
|
||||||
|
m_codeBlockCopyButtonCB->setChecked(g_config->getEnableCodeBlockCopyButton());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VMarkdownTab::saveCodeBlockCopyButton()
|
||||||
|
{
|
||||||
|
g_config->setEnableCodeBlockCopyButton(m_codeBlockCopyButtonCB->isChecked());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool VMarkdownTab::loadMathJax()
|
bool VMarkdownTab::loadMathJax()
|
||||||
{
|
{
|
||||||
m_mathjaxConfigEdit->setText(g_config->getMathjaxJavascript());
|
m_mathjaxConfigEdit->setText(g_config->getMathjaxJavascript());
|
||||||
|
@ -223,6 +223,9 @@ private:
|
|||||||
bool loadColorColumn();
|
bool loadColorColumn();
|
||||||
bool saveColorColumn();
|
bool saveColorColumn();
|
||||||
|
|
||||||
|
bool loadCodeBlockCopyButton();
|
||||||
|
bool saveCodeBlockCopyButton();
|
||||||
|
|
||||||
bool loadMathJax();
|
bool loadMathJax();
|
||||||
bool saveMathJax();
|
bool saveMathJax();
|
||||||
|
|
||||||
@ -242,6 +245,9 @@ private:
|
|||||||
// Color column in code block.
|
// Color column in code block.
|
||||||
VLineEdit *m_colorColumnEdit;
|
VLineEdit *m_colorColumnEdit;
|
||||||
|
|
||||||
|
// Copy button in code block.
|
||||||
|
QCheckBox *m_codeBlockCopyButtonCB;
|
||||||
|
|
||||||
// MathJax.
|
// MathJax.
|
||||||
VLineEdit *m_mathjaxConfigEdit;
|
VLineEdit *m_mathjaxConfigEdit;
|
||||||
|
|
||||||
|
@ -647,6 +647,7 @@ public:
|
|||||||
int getTableFormatInterval() const;
|
int getTableFormatInterval() const;
|
||||||
|
|
||||||
bool getEnableCodeBlockCopyButton() const;
|
bool getEnableCodeBlockCopyButton() const;
|
||||||
|
void setEnableCodeBlockCopyButton(bool p_enabled);
|
||||||
|
|
||||||
// Github image hosting setting.
|
// Github image hosting setting.
|
||||||
const QString &getGithubPersonalAccessToken() const;
|
const QString &getGithubPersonalAccessToken() const;
|
||||||
@ -3081,6 +3082,16 @@ inline bool VConfigManager::getEnableCodeBlockCopyButton() const
|
|||||||
return m_enableCodeBlockCopyButton;
|
return m_enableCodeBlockCopyButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void VConfigManager::setEnableCodeBlockCopyButton(bool p_enabled)
|
||||||
|
{
|
||||||
|
if (m_enableCodeBlockCopyButton == p_enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_enableCodeBlockCopyButton = p_enabled;
|
||||||
|
setConfigToSettings("web", "enable_code_block_copy_button", p_enabled);
|
||||||
|
}
|
||||||
|
|
||||||
inline const QString &VConfigManager::getGithubPersonalAccessToken() const
|
inline const QString &VConfigManager::getGithubPersonalAccessToken() const
|
||||||
{
|
{
|
||||||
return m_githubPersonalAccessToken;
|
return m_githubPersonalAccessToken;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user