mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
MarkdownEditor: support disabling in-place preview temporarily
This commit is contained in:
parent
cf988e6fa6
commit
f92e1a9791
@ -1 +1 @@
|
||||
Subproject commit 47902164b0e11f5debfb40deb649d451d650660f
|
||||
Subproject commit 922084a388e1f135e25297ba84a9d0ca0078ed06
|
@ -21,6 +21,7 @@
|
||||
<file>icons/menu.svg</file>
|
||||
<file>icons/settings.svg</file>
|
||||
<file>icons/view.svg</file>
|
||||
<file>icons/inplace_preview_editor.svg</file>
|
||||
<file>icons/settings_menu.svg</file>
|
||||
<file>icons/whatsthis.svg</file>
|
||||
<file>icons/help_menu.svg</file>
|
||||
|
15
src/data/core/icons/inplace_preview_editor.svg
Normal file
15
src/data/core/icons/inplace_preview_editor.svg
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 16.2.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="512px" height="512px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
|
||||
<g>
|
||||
<path fill="#000000" d="M256,128c-81.9,0-145.7,48.8-224,128c67.4,67.7,124,128,224,128c99.9,0,173.4-76.4,224-126.6
|
||||
C428.2,198.6,354.8,128,256,128z M256,347.3c-49.4,0-89.6-41-89.6-91.3c0-50.4,40.2-91.3,89.6-91.3s89.6,41,89.6,91.3
|
||||
C345.6,306.4,305.4,347.3,256,347.3z"/>
|
||||
<g>
|
||||
<path fill="#000000" d="M256,224c0-7.9,2.9-15.1,7.6-20.7c-2.5-0.4-5-0.6-7.6-0.6c-28.8,0-52.3,23.9-52.3,53.3c0,29.4,23.5,53.3,52.3,53.3
|
||||
s52.3-23.9,52.3-53.3c0-2.3-0.2-4.6-0.4-6.9c-5.5,4.3-12.3,6.9-19.8,6.9C270.3,256,256,241.7,256,224z"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1018 B |
@ -6,6 +6,7 @@
|
||||
|
||||
#include <utils/widgetutils.h>
|
||||
#include <utils/pathutils.h>
|
||||
#include <utils/utils.h>
|
||||
#include <core/vnotex.h>
|
||||
#include <core/exception.h>
|
||||
#include <core/configmgr.h>
|
||||
@ -215,9 +216,12 @@ void HistoryPanel::addItem(const HistoryItemFull &p_hisItem)
|
||||
item->setText(PathUtils::fileNameCheap(p_hisItem.m_item.m_path));
|
||||
item->setData(Qt::UserRole, p_hisItem.m_item.m_path);
|
||||
if (p_hisItem.m_notebookName.isEmpty()) {
|
||||
item->setToolTip(p_hisItem.m_item.m_path);
|
||||
item->setToolTip(tr("%1\n%2").arg(p_hisItem.m_item.m_path,
|
||||
Utils::dateTimeString(p_hisItem.m_item.m_lastAccessedTimeUtc.toLocalTime())));
|
||||
} else {
|
||||
item->setToolTip(tr("[%1] %2").arg(p_hisItem.m_notebookName, p_hisItem.m_item.m_path));
|
||||
item->setToolTip(tr("[%1] %2\n%3").arg(p_hisItem.m_notebookName,
|
||||
p_hisItem.m_item.m_path,
|
||||
Utils::dateTimeString(p_hisItem.m_item.m_lastAccessedTimeUtc.toLocalTime())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -250,6 +250,8 @@ void MarkdownViewWindow::setupToolBar()
|
||||
auto toolBar = createToolBar(this);
|
||||
|
||||
const auto &editorConfig = ConfigMgr::getInst().getEditorConfig();
|
||||
const auto &markdownEditorConfig = editorConfig.getMarkdownEditorConfig();
|
||||
|
||||
const int iconSize = editorConfig.getToolBarIconSize();
|
||||
toolBar->setIconSize(QSize(iconSize, iconSize));
|
||||
|
||||
@ -266,6 +268,16 @@ void MarkdownViewWindow::setupToolBar()
|
||||
|
||||
addAction(toolBar, ViewWindowToolBarHelper::SectionNumber);
|
||||
|
||||
{
|
||||
auto act = addAction(toolBar, ViewWindowToolBarHelper::InplacePreview);
|
||||
connect(act, &QAction::triggered,
|
||||
this, [this, act](bool p_checked) {
|
||||
if (!isReadMode()) {
|
||||
m_editor->setInplacePreviewEnabled(p_checked);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
addAction(toolBar, ViewWindowToolBarHelper::TypeHeading);
|
||||
addAction(toolBar, ViewWindowToolBarHelper::TypeBold);
|
||||
addAction(toolBar, ViewWindowToolBarHelper::TypeItalic);
|
||||
|
@ -441,6 +441,16 @@ QAction *ViewWindow::addAction(QToolBar *p_toolBar, ViewWindowToolBarHelper::Act
|
||||
break;
|
||||
}
|
||||
|
||||
case ViewWindowToolBarHelper::InplacePreview:
|
||||
{
|
||||
act = ViewWindowToolBarHelper::addAction(p_toolBar, p_action);
|
||||
connect(this, &ViewWindow::modeChanged,
|
||||
this, [this, act]() {
|
||||
act->setEnabled(inModeCanInsert() && getBuffer());
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
|
@ -351,6 +351,15 @@ QAction *ViewWindowToolBarHelper::addAction(QToolBar *p_tb, Action p_action)
|
||||
break;
|
||||
}
|
||||
|
||||
case Action::InplacePreview:
|
||||
{
|
||||
act = p_tb->addAction(ToolBarHelper::generateIcon("inplace_preview_editor.svg"),
|
||||
ViewWindow::tr("Toggle In-Place Preview"));
|
||||
act->setCheckable(true);
|
||||
act->setChecked(true);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
|
@ -43,7 +43,8 @@ namespace vnotex
|
||||
Attachment,
|
||||
Outline,
|
||||
FindAndReplace,
|
||||
SectionNumber
|
||||
SectionNumber,
|
||||
InplacePreview
|
||||
};
|
||||
|
||||
static QAction *addAction(QToolBar *p_tb, Action p_action);
|
||||
|
Loading…
x
Reference in New Issue
Block a user