mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
small refinement
* Use ViewWindow's status widget to show message; * Add markdown guide; * Add shortcut for StayOnTop;
This commit is contained in:
parent
4496c441fe
commit
5d9103b933
@ -16,6 +16,7 @@ namespace vnotex
|
|||||||
enum Shortcut
|
enum Shortcut
|
||||||
{
|
{
|
||||||
FullScreen,
|
FullScreen,
|
||||||
|
StayOnTop,
|
||||||
ExpandContentArea,
|
ExpandContentArea,
|
||||||
Settings,
|
Settings,
|
||||||
NewNote,
|
NewNote,
|
||||||
|
@ -20,13 +20,13 @@ namespace vnotex
|
|||||||
|
|
||||||
m_styles.clear();
|
m_styles.clear();
|
||||||
auto stylesArray = p_obj[QStringLiteral("styles")].toArray();
|
auto stylesArray = p_obj[QStringLiteral("styles")].toArray();
|
||||||
for (size_t i = 0; i < stylesArray.size(); ++i) {
|
for (int i = 0; i < stylesArray.size(); ++i) {
|
||||||
m_styles << stylesArray[i].toString();
|
m_styles << stylesArray[i].toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scripts.clear();
|
m_scripts.clear();
|
||||||
auto scriptsArray = p_obj[QStringLiteral("scripts")].toArray();
|
auto scriptsArray = p_obj[QStringLiteral("scripts")].toArray();
|
||||||
for (size_t i = 0; i < scriptsArray.size(); ++i) {
|
for (int i = 0; i < scriptsArray.size(); ++i) {
|
||||||
m_scripts << scriptsArray[i].toString();
|
m_scripts << scriptsArray[i].toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
"locale" : "",
|
"locale" : "",
|
||||||
"shortcuts" : {
|
"shortcuts" : {
|
||||||
"FullScreen" : "F11",
|
"FullScreen" : "F11",
|
||||||
|
"StayOnTop" : "F10",
|
||||||
"ExpandContentArea" : "Ctrl+G, E",
|
"ExpandContentArea" : "Ctrl+G, E",
|
||||||
"Settings" : "Ctrl+Alt+P",
|
"Settings" : "Ctrl+Alt+P",
|
||||||
"NewNote" : "Ctrl+Alt+N",
|
"NewNote" : "Ctrl+Alt+N",
|
||||||
|
250
src/data/extra/docs/en/markdown_guide.md
Normal file
250
src/data/extra/docs/en/markdown_guide.md
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
# Markdown Guide
|
||||||
|
This is a quick guide [^1] for Markdown, a lightweight and easy-to-use syntax for writing.
|
||||||
|
|
||||||
|
## What is Markdown?
|
||||||
|
Markdown is a way to style text via a few simple markers. You could write the document in plain text and then read it with a beautiful typesetting.
|
||||||
|
|
||||||
|
There is no standard Markdown syntax and many editors will support its own additional syntax. VNote supports only the widely-used basic syntax.
|
||||||
|
|
||||||
|
## How to Use Markdown?
|
||||||
|
If you are new to Markdown, it is better to learn the syntax elements step by step. Knowing headers and emphasis is enough to survive. You could learn another new syntax and practise it every one or two days.
|
||||||
|
|
||||||
|
## Syntax Guide
|
||||||
|
Here is an overview of Markdown syntax supported by VNote.
|
||||||
|
|
||||||
|
### Headers
|
||||||
|
```md
|
||||||
|
# This is a <h1> tag
|
||||||
|
## This is a <h2> tag
|
||||||
|
###### This is a <h6> tag
|
||||||
|
```
|
||||||
|
|
||||||
|
**Notes**:
|
||||||
|
|
||||||
|
* At least one space is needed after the `#`;
|
||||||
|
* A header should occupy one entire line;
|
||||||
|
|
||||||
|
### Emphasis
|
||||||
|
```md
|
||||||
|
*This text will be italic*
|
||||||
|
_This text will be italic_
|
||||||
|
|
||||||
|
**This text will be bold**
|
||||||
|
__This text will be bold__
|
||||||
|
```
|
||||||
|
|
||||||
|
**Notes**:
|
||||||
|
|
||||||
|
* `*` is recommended in VNote;
|
||||||
|
* If the render failed, try to add an additional space before the first `*` and after the last `*`. The space is necessary if the surrounded text begins or ends with full width punctuation;
|
||||||
|
|
||||||
|
### Lists
|
||||||
|
#### Unordered
|
||||||
|
```md
|
||||||
|
* Item 1
|
||||||
|
This is a text under Item 1. Notice that there are two spaces at the end above.
|
||||||
|
* Item 2
|
||||||
|
* Item 2a
|
||||||
|
* Item 2b
|
||||||
|
* Item 3
|
||||||
|
|
||||||
|
To end a list, there should be one empty line above.
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Ordered
|
||||||
|
```md
|
||||||
|
1. Item 1
|
||||||
|
1. Item 2
|
||||||
|
Notice that the sequence number is irrelevant. Markdown will change the sequence automatically when renderring.
|
||||||
|
3. Item 3
|
||||||
|
1. Item 3a
|
||||||
|
2. Item 3b
|
||||||
|
4. Item 4
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tables
|
||||||
|
```md
|
||||||
|
| col 1 | col 2 | col 3 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| cell1 | cell2 | cell3 |
|
||||||
|
| cell4 | cell5 | cell6 |
|
||||||
|
```
|
||||||
|
|
||||||
|
### Images and Links
|
||||||
|
```md
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[Link Text](/url/of/the/link)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Notes**:
|
||||||
|
|
||||||
|
* It is not recommended to use image links in reference format. VNote will not preview those images.
|
||||||
|
|
||||||
|
### Blockquotes
|
||||||
|
```md
|
||||||
|
As VNote suggests:
|
||||||
|
|
||||||
|
> VNote is the best Markdown note-taking application
|
||||||
|
> ever.
|
||||||
|
>
|
||||||
|
> THere is two spaces after `ever.` above to insert a
|
||||||
|
> new line.
|
||||||
|
|
||||||
|
It also suggests:
|
||||||
|
|
||||||
|
> VNote is good.
|
||||||
|
Here is another sentence within the quote.
|
||||||
|
```
|
||||||
|
|
||||||
|
**Notes**:
|
||||||
|
|
||||||
|
* Space is needed after the marker `>`;
|
||||||
|
* You could just add only one `>` at the first line;
|
||||||
|
|
||||||
|
### Fenced Code Block
|
||||||
|
```lang
|
||||||
|
This is a fenced code block.
|
||||||
|
```
|
||||||
|
|
||||||
|
~~~cpp
|
||||||
|
This is another fenced code block.
|
||||||
|
~~~
|
||||||
|
|
||||||
|
**Notes**:
|
||||||
|
|
||||||
|
* `lang` is optional to specify the language of the code; if not specified, VNote won't highlight the code;
|
||||||
|
* It is always a good practice to add one empty line before the whole fenced code block.
|
||||||
|
|
||||||
|
### Diagrams
|
||||||
|
VNote supports the following engines to draw diagrams. You should specify particular language of the fenced code block and write the definition of your diagram within it.
|
||||||
|
|
||||||
|
* [Flowchart.js](http://flowchart.js.org/) for *flowchart* with language `flow` or `flowchart`;
|
||||||
|
* [Mermaid](https://mermaidjs.github.io/) with language `mermaid`;
|
||||||
|
* [WaveDrom](https://wavedrom.com/) for *digital timing diagram* with language `wavedrom`;
|
||||||
|
|
||||||
|
For example,
|
||||||
|
|
||||||
|
```flowchart
|
||||||
|
st=>start: Start:>http://www.google.com[blank]
|
||||||
|
e=>end:>http://www.google.com
|
||||||
|
op1=>operation: My Operation
|
||||||
|
sub1=>subroutine: My Subroutine
|
||||||
|
cond=>condition: Yes
|
||||||
|
or No?:>http://www.google.com
|
||||||
|
io=>inputoutput: catch something...
|
||||||
|
|
||||||
|
st->op1->cond
|
||||||
|
cond(yes)->io->e
|
||||||
|
cond(no)->sub1(right)->op1
|
||||||
|
```
|
||||||
|
|
||||||
|
#### UML
|
||||||
|
VNote supports [PlantUML](http://plantuml.com/) to draw UML diagrams. You should use `puml` specified as the language of the fenced code block and write the definition of your diagram within it.
|
||||||
|
|
||||||
|
```puml
|
||||||
|
@startuml
|
||||||
|
Bob -> Alice : hello
|
||||||
|
@enduml
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Graphviz
|
||||||
|
VNote supports [Graphviz](http://www.graphviz.org/) to draw diagrams. You should use `dot` specified as the language of the fenced code block and write the definition of your diagram within it.
|
||||||
|
|
||||||
|
### Math Formulas
|
||||||
|
VNote supports math formulas via [MathJax](https://www.mathjax.org/). The default math delimiters are `$$...$$` for **displayed mathematics**, and `$...$` for **inline mathematics**.
|
||||||
|
|
||||||
|
* Inline mathematics should not cross multiple lines;
|
||||||
|
* Forms like `3$abc$`, `$abc$4`, `$ abc$`, and `$abc $` will not be treated as mathematics;
|
||||||
|
* Use `\` to escape `$`;
|
||||||
|
* There should be only space chars before opening `$$` and after closing `$$`;
|
||||||
|
* Use `\\` to new a line within a displayed mathematics;
|
||||||
|
|
||||||
|
VNote also supports displayed mathematics via fenced code block with language `mathjax` specified.
|
||||||
|
|
||||||
|
```mathjax
|
||||||
|
$$
|
||||||
|
J(\theta) = \frac 1 2 \sum_{i=1}^m (h_\theta(x^{(i)})-y^{(i)})^2
|
||||||
|
$$
|
||||||
|
```
|
||||||
|
|
||||||
|
Equation number of displayed mathematics is supported:
|
||||||
|
|
||||||
|
$$vnote x markdown = awesome$$ (1.2.1)
|
||||||
|
|
||||||
|
### Inline Code
|
||||||
|
```md
|
||||||
|
Here is a `inline code`.
|
||||||
|
```
|
||||||
|
|
||||||
|
To insert one `` ` ``, you need to use two `` ` `` to enclose it, such as ``` `` ` `` ```. To insert two `` ` ``, you need to use three `` ` ``.
|
||||||
|
|
||||||
|
### Strikethrough
|
||||||
|
```md
|
||||||
|
Here is a ~~text~~ with strikethrough.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Task Lists
|
||||||
|
```md
|
||||||
|
* [x] this is a complete item.
|
||||||
|
* [ ] this is an incomplete item.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Footnote
|
||||||
|
```md
|
||||||
|
This is a footnote [^1].
|
||||||
|
|
||||||
|
[^1]: Here is the detail of the footnote.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Superscript and Subscript
|
||||||
|
```md
|
||||||
|
This is the 1^st^ superscript.
|
||||||
|
|
||||||
|
This is the H~2~O subscript.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Alert
|
||||||
|
```md
|
||||||
|
::: alert-info
|
||||||
|
|
||||||
|
This is an info text.
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
::: alert-danger
|
||||||
|
|
||||||
|
This is a danger text.
|
||||||
|
|
||||||
|
:::
|
||||||
|
```
|
||||||
|
|
||||||
|
Available variants:
|
||||||
|
|
||||||
|
```
|
||||||
|
alert-primary
|
||||||
|
alert-secondary
|
||||||
|
alert-success
|
||||||
|
alert-info
|
||||||
|
alert-warning
|
||||||
|
alert-danger
|
||||||
|
alert-light
|
||||||
|
alert-dark
|
||||||
|
```
|
||||||
|
|
||||||
|
### New Line and Paragraph
|
||||||
|
If you want to enter a new line, you should add two spaces after current line and then continue your input. VNote provides `Shift+Enter` to help.
|
||||||
|
|
||||||
|
If you want to enter a new paragraph, you should add an empty line and then continue entering the new paragraph.
|
||||||
|
|
||||||
|
Generally, you need to add an empty line after a block element (such as code block, lists, blockquote) to explicitly end it.
|
||||||
|
|
||||||
|
[^1]: This guide references [Mastering Markdown](https://guides.github.com/features/mastering-markdown/).
|
@ -8,6 +8,7 @@
|
|||||||
<file>docs/en/get_started.txt</file>
|
<file>docs/en/get_started.txt</file>
|
||||||
<file>docs/en/about_vnotex.txt</file>
|
<file>docs/en/about_vnotex.txt</file>
|
||||||
<file>docs/en/shortcuts.md</file>
|
<file>docs/en/shortcuts.md</file>
|
||||||
|
<file>docs/en/markdown_guide.md</file>
|
||||||
<file>web/markdownviewertemplate.html</file>
|
<file>web/markdownviewertemplate.html</file>
|
||||||
<file>web/css/globalstyles.css</file>
|
<file>web/css/globalstyles.css</file>
|
||||||
<file>web/css/markdownit.css</file>
|
<file>web/css/markdownit.css</file>
|
||||||
|
44
src/widgets/editors/statuswidget.cpp
Normal file
44
src/widgets/editors/statuswidget.cpp
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include "statuswidget.h"
|
||||||
|
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
|
||||||
|
using namespace vnotex;
|
||||||
|
|
||||||
|
StatusWidget::StatusWidget(QWidget *p_parent)
|
||||||
|
: QWidget(p_parent)
|
||||||
|
{
|
||||||
|
auto layout = new QHBoxLayout(this);
|
||||||
|
layout->setContentsMargins(0, 0, 0, 0);
|
||||||
|
layout->setSpacing(0);
|
||||||
|
|
||||||
|
m_messageLabel = new QLabel(this);
|
||||||
|
m_messageLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
|
||||||
|
layout->addWidget(m_messageLabel);
|
||||||
|
|
||||||
|
m_messageTimer = new QTimer(this);
|
||||||
|
m_messageTimer->setSingleShot(true);
|
||||||
|
connect(m_messageTimer, &QTimer::timeout,
|
||||||
|
m_messageLabel, &QLabel::clear);
|
||||||
|
}
|
||||||
|
|
||||||
|
StatusWidget::~StatusWidget()
|
||||||
|
{
|
||||||
|
if (m_editorWidget) {
|
||||||
|
m_editorWidget->setParent(nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatusWidget::showMessage(const QString &p_msg, int p_milliseconds)
|
||||||
|
{
|
||||||
|
m_messageLabel->setText(p_msg);
|
||||||
|
m_messageTimer->start(p_milliseconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
void StatusWidget::setEditorStatusWidget(const QSharedPointer<QWidget> &p_editorWidget)
|
||||||
|
{
|
||||||
|
Q_ASSERT(!m_editorWidget);
|
||||||
|
m_editorWidget = p_editorWidget;
|
||||||
|
layout()->addWidget(m_editorWidget.data());
|
||||||
|
}
|
36
src/widgets/editors/statuswidget.h
Normal file
36
src/widgets/editors/statuswidget.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#ifndef STATUSWIDGET_H
|
||||||
|
#define STATUSWIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
class QLabel;
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
|
namespace vnotex
|
||||||
|
{
|
||||||
|
// A status widget wrapper for ViewWindow.
|
||||||
|
class StatusWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit StatusWidget(QWidget *p_parent = nullptr);
|
||||||
|
|
||||||
|
~StatusWidget();
|
||||||
|
|
||||||
|
void showMessage(const QString &p_msg, int p_milliseconds = 3000);
|
||||||
|
|
||||||
|
void setEditorStatusWidget(const QSharedPointer<QWidget> &p_editorWidget);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QLabel *m_messageLabel = nullptr;
|
||||||
|
|
||||||
|
QTimer *m_messageTimer = nullptr;
|
||||||
|
|
||||||
|
// Use shared pointer here to hold the widget.
|
||||||
|
// Should detach the widget in destructor.
|
||||||
|
QSharedPointer<QWidget> m_editorWidget;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // STATUSWIDGET_H
|
@ -28,6 +28,7 @@
|
|||||||
#include "outlineprovider.h"
|
#include "outlineprovider.h"
|
||||||
#include "toolbarhelper.h"
|
#include "toolbarhelper.h"
|
||||||
#include "findandreplacewidget.h"
|
#include "findandreplacewidget.h"
|
||||||
|
#include "editors/statuswidget.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -58,6 +59,8 @@ MarkdownViewWindow::~MarkdownViewWindow()
|
|||||||
getMainStatusWidget()->removeWidget(m_viewerStatusWidget.get());
|
getMainStatusWidget()->removeWidget(m_viewerStatusWidget.get());
|
||||||
m_viewerStatusWidget->setParent(nullptr);
|
m_viewerStatusWidget->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_mainStatusWidget->setParent(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkdownViewWindow::setupUI()
|
void MarkdownViewWindow::setupUI()
|
||||||
@ -72,9 +75,13 @@ void MarkdownViewWindow::setupUI()
|
|||||||
|
|
||||||
// Status widget.
|
// Status widget.
|
||||||
// We use a QTabWidget as status widget since we have two widgets for different modes.
|
// We use a QTabWidget as status widget since we have two widgets for different modes.
|
||||||
auto stackedWidget = QSharedPointer<QStackedWidget>::create(this);
|
{
|
||||||
stackedWidget->setContentsMargins(0, 0, 0, 0);
|
auto statusWidget = QSharedPointer<StatusWidget>::create(this);
|
||||||
setStatusWidget(stackedWidget);
|
m_mainStatusWidget = QSharedPointer<QStackedWidget>::create(this);
|
||||||
|
m_mainStatusWidget->setContentsMargins(0, 0, 0, 0);
|
||||||
|
statusWidget->setEditorStatusWidget(m_mainStatusWidget);
|
||||||
|
setStatusWidget(statusWidget);
|
||||||
|
}
|
||||||
|
|
||||||
setupToolBar();
|
setupToolBar();
|
||||||
}
|
}
|
||||||
@ -339,7 +346,7 @@ void MarkdownViewWindow::setupTextEditor()
|
|||||||
|
|
||||||
QStackedWidget *MarkdownViewWindow::getMainStatusWidget() const
|
QStackedWidget *MarkdownViewWindow::getMainStatusWidget() const
|
||||||
{
|
{
|
||||||
return static_cast<QStackedWidget *>(m_statusWidget.get());
|
return m_mainStatusWidget.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MarkdownViewWindow::eventFilter(QObject *p_obj, QEvent *p_event)
|
bool MarkdownViewWindow::eventFilter(QObject *p_obj, QEvent *p_event)
|
||||||
@ -422,7 +429,9 @@ void MarkdownViewWindow::setupViewer()
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(adapter, &MarkdownViewerAdapter::findTextReady,
|
connect(adapter, &MarkdownViewerAdapter::findTextReady,
|
||||||
this, &ViewWindow::showFindResult);
|
this, [this](const QString &p_text, int p_totalMatches, int p_currentMatchIndex) {
|
||||||
|
this->showFindResult(p_text, p_totalMatches, p_currentMatchIndex);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarkdownViewWindow::syncTextEditorFromBuffer(bool p_syncPositionFromReadMode)
|
void MarkdownViewWindow::syncTextEditorFromBuffer(bool p_syncPositionFromReadMode)
|
||||||
|
@ -145,6 +145,8 @@ namespace vnotex
|
|||||||
|
|
||||||
QSharedPointer<QWidget> m_viewerStatusWidget;
|
QSharedPointer<QWidget> m_viewerStatusWidget;
|
||||||
|
|
||||||
|
QSharedPointer<QStackedWidget> m_mainStatusWidget;
|
||||||
|
|
||||||
// Managed by QObject.
|
// Managed by QObject.
|
||||||
PreviewHelper *m_previewHelper = nullptr;
|
PreviewHelper *m_previewHelper = nullptr;
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include "editors/texteditor.h"
|
#include "editors/texteditor.h"
|
||||||
#include <core/vnotex.h>
|
#include <core/vnotex.h>
|
||||||
#include <core/thememgr.h>
|
#include <core/thememgr.h>
|
||||||
|
#include "editors/statuswidget.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -45,7 +46,11 @@ void TextViewWindow::setupUI()
|
|||||||
TextViewWindowHelper::connectEditor(this);
|
TextViewWindowHelper::connectEditor(this);
|
||||||
|
|
||||||
// Status widget.
|
// Status widget.
|
||||||
setStatusWidget(m_editor->statusWidget());
|
{
|
||||||
|
auto statusWidget = QSharedPointer<StatusWidget>::create();
|
||||||
|
statusWidget->setEditorStatusWidget(m_editor->statusWidget());
|
||||||
|
setStatusWidget(statusWidget);
|
||||||
|
}
|
||||||
|
|
||||||
setupToolBar();
|
setupToolBar();
|
||||||
}
|
}
|
||||||
|
@ -224,6 +224,8 @@ QToolBar *ToolBarHelper::setupSettingsToolBar(MainWindow *p_win, QToolBar *p_too
|
|||||||
auto stayOnTopAct = menu->addAction(generateIcon("stay_on_top.svg"), MainWindow::tr("Stay On Top"),
|
auto stayOnTopAct = menu->addAction(generateIcon("stay_on_top.svg"), MainWindow::tr("Stay On Top"),
|
||||||
p_win, &MainWindow::setStayOnTop);
|
p_win, &MainWindow::setStayOnTop);
|
||||||
stayOnTopAct->setCheckable(true);
|
stayOnTopAct->setCheckable(true);
|
||||||
|
WidgetUtils::addActionShortcut(stayOnTopAct,
|
||||||
|
coreConfig.getShortcut(CoreConfig::Shortcut::StayOnTop));
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
@ -337,6 +339,17 @@ QToolBar *ToolBarHelper::setupSettingsToolBar(MainWindow *p_win, QToolBar *p_too
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
menu->addAction(MainWindow::tr("Markdown Guide"),
|
||||||
|
menu,
|
||||||
|
[]() {
|
||||||
|
const auto file = DocsUtils::getDocFile(QStringLiteral("markdown_guide.md"));
|
||||||
|
if (!file.isEmpty()) {
|
||||||
|
auto paras = QSharedPointer<FileOpenParameters>::create();
|
||||||
|
paras->m_readOnly = true;
|
||||||
|
emit VNoteX::getInst().openFileRequested(file, paras);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
|
||||||
menu->addAction(MainWindow::tr("View Logs"),
|
menu->addAction(MainWindow::tr("View Logs"),
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "attachmentdragdropareaindicator.h"
|
#include "attachmentdragdropareaindicator.h"
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "findandreplacewidget.h"
|
#include "findandreplacewidget.h"
|
||||||
|
#include "editors/statuswidget.h"
|
||||||
|
|
||||||
using namespace vnotex;
|
using namespace vnotex;
|
||||||
|
|
||||||
@ -231,7 +232,7 @@ void ViewWindow::addBottomWidget(QWidget *p_widget)
|
|||||||
m_bottomLayout->addWidget(p_widget);
|
m_bottomLayout->addWidget(p_widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewWindow::setStatusWidget(const QSharedPointer<QWidget> &p_widget)
|
void ViewWindow::setStatusWidget(const QSharedPointer<StatusWidget> &p_widget)
|
||||||
{
|
{
|
||||||
m_statusWidget = p_widget;
|
m_statusWidget = p_widget;
|
||||||
m_bottomLayout->insertWidget(0, p_widget.data());
|
m_bottomLayout->insertWidget(0, p_widget.data());
|
||||||
@ -863,12 +864,12 @@ void ViewWindow::wheelEvent(QWheelEvent *p_event)
|
|||||||
|
|
||||||
void ViewWindow::showZoomFactor(qreal p_factor)
|
void ViewWindow::showZoomFactor(qreal p_factor)
|
||||||
{
|
{
|
||||||
VNoteX::getInst().showStatusMessageShort(tr("Zoomed: %1%").arg(p_factor * 100));
|
showMessage(tr("Zoomed: %1%").arg(p_factor * 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewWindow::showZoomDelta(int p_delta)
|
void ViewWindow::showZoomDelta(int p_delta)
|
||||||
{
|
{
|
||||||
VNoteX::getInst().showStatusMessageShort(tr("Zoomed: %1%2").arg(p_delta > 0 ? "+" : "").arg(p_delta));
|
showMessage(tr("Zoomed: %1%2").arg(p_delta > 0 ? "+" : "").arg(p_delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewWindow::showFindAndReplaceWidget()
|
void ViewWindow::showFindAndReplaceWidget()
|
||||||
@ -1003,19 +1004,26 @@ void ViewWindow::replaceAll(const QString &p_text, FindOptions p_options, const
|
|||||||
void ViewWindow::showFindResult(const QString &p_text, int p_totalMatches, int p_currentMatchIndex)
|
void ViewWindow::showFindResult(const QString &p_text, int p_totalMatches, int p_currentMatchIndex)
|
||||||
{
|
{
|
||||||
if (p_totalMatches == 0) {
|
if (p_totalMatches == 0) {
|
||||||
VNoteX::getInst().showStatusMessageShort(tr("Pattern not found: %1").arg(p_text));
|
showMessage(tr("Pattern not found: %1").arg(p_text));
|
||||||
} else {
|
} else {
|
||||||
VNoteX::getInst().showStatusMessageShort(tr("Match found: %1/%2").arg(p_currentMatchIndex + 1).arg(p_totalMatches));
|
showMessage(tr("Match found: %1/%2").arg(p_currentMatchIndex + 1).arg(p_totalMatches));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewWindow::showReplaceResult(const QString &p_text, int p_totalReplaces)
|
void ViewWindow::showReplaceResult(const QString &p_text, int p_totalReplaces)
|
||||||
{
|
{
|
||||||
if (p_totalReplaces == 0) {
|
if (p_totalReplaces == 0) {
|
||||||
VNoteX::getInst().showStatusMessageShort(tr("Pattern not found: %1").arg(p_text));
|
showMessage(tr("Pattern not found: %1").arg(p_text));
|
||||||
} else {
|
} else {
|
||||||
VNoteX::getInst().showStatusMessageShort(tr("Replaced %n match(es)", "", p_totalReplaces));
|
showMessage(tr("Replaced %n match(es)", "", p_totalReplaces));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ViewWindow::showMessage(const QString p_msg)
|
||||||
|
{
|
||||||
|
if (m_statusWidget) {
|
||||||
|
m_statusWidget->showMessage(p_msg);
|
||||||
|
} else {
|
||||||
|
VNoteX::getInst().showStatusMessageShort(p_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@ namespace vnotex
|
|||||||
class OutlineProvider;
|
class OutlineProvider;
|
||||||
class EditReadDiscardAction;
|
class EditReadDiscardAction;
|
||||||
class FindAndReplaceWidget;
|
class FindAndReplaceWidget;
|
||||||
|
class StatusWidget;
|
||||||
|
|
||||||
class ViewWindow : public QFrame
|
class ViewWindow : public QFrame
|
||||||
{
|
{
|
||||||
@ -148,6 +149,9 @@ namespace vnotex
|
|||||||
|
|
||||||
virtual void handleFindAndReplaceWidgetOpened();
|
virtual void handleFindAndReplaceWidgetOpened();
|
||||||
|
|
||||||
|
// Show message in status widget if exists. Otherwise, show it in the mainwindow's status widget.
|
||||||
|
void showMessage(const QString p_msg);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setCentralWidget(QWidget *p_widget);
|
void setCentralWidget(QWidget *p_widget);
|
||||||
|
|
||||||
@ -157,7 +161,7 @@ namespace vnotex
|
|||||||
|
|
||||||
void addBottomWidget(QWidget *p_widget);
|
void addBottomWidget(QWidget *p_widget);
|
||||||
|
|
||||||
void setStatusWidget(const QSharedPointer<QWidget> &p_widget);
|
void setStatusWidget(const QSharedPointer<StatusWidget> &p_widget);
|
||||||
|
|
||||||
bool eventFilter(QObject *p_obj, QEvent *p_event) Q_DECL_OVERRIDE;
|
bool eventFilter(QObject *p_obj, QEvent *p_event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
@ -202,14 +206,12 @@ namespace vnotex
|
|||||||
bool findAndReplaceWidgetVisible() const;
|
bool findAndReplaceWidgetVisible() const;
|
||||||
|
|
||||||
// @p_currentMatchIndex: 0-based.
|
// @p_currentMatchIndex: 0-based.
|
||||||
static void showFindResult(const QString &p_text, int p_totalMatches, int p_currentMatchIndex);
|
void showFindResult(const QString &p_text, int p_totalMatches, int p_currentMatchIndex);
|
||||||
|
|
||||||
static void showReplaceResult(const QString &p_text, int p_totalReplaces);
|
void showReplaceResult(const QString &p_text, int p_totalReplaces);
|
||||||
|
|
||||||
static ViewWindow::Mode modeFromOpenParameters(const FileOpenParameters &p_paras);
|
static ViewWindow::Mode modeFromOpenParameters(const FileOpenParameters &p_paras);
|
||||||
|
|
||||||
QSharedPointer<QWidget> m_statusWidget;
|
|
||||||
|
|
||||||
// The revision of the buffer of the last sync content.
|
// The revision of the buffer of the last sync content.
|
||||||
int m_bufferRevision = 0;
|
int m_bufferRevision = 0;
|
||||||
|
|
||||||
@ -306,6 +308,8 @@ namespace vnotex
|
|||||||
// Last find info.
|
// Last find info.
|
||||||
FindInfo m_findInfo;
|
FindInfo m_findInfo;
|
||||||
|
|
||||||
|
QSharedPointer<StatusWidget> m_statusWidget;
|
||||||
|
|
||||||
static QIcon s_savedIcon;
|
static QIcon s_savedIcon;
|
||||||
static QIcon s_modifiedIcon;
|
static QIcon s_modifiedIcon;
|
||||||
};
|
};
|
||||||
|
@ -26,6 +26,7 @@ SOURCES += \
|
|||||||
$$PWD/editors/markdownviewer.cpp \
|
$$PWD/editors/markdownviewer.cpp \
|
||||||
$$PWD/editors/markdownvieweradapter.cpp \
|
$$PWD/editors/markdownvieweradapter.cpp \
|
||||||
$$PWD/editors/previewhelper.cpp \
|
$$PWD/editors/previewhelper.cpp \
|
||||||
|
$$PWD/editors/statuswidget.cpp \
|
||||||
$$PWD/editors/texteditor.cpp \
|
$$PWD/editors/texteditor.cpp \
|
||||||
$$PWD/editreaddiscardaction.cpp \
|
$$PWD/editreaddiscardaction.cpp \
|
||||||
$$PWD/filesystemviewer.cpp \
|
$$PWD/filesystemviewer.cpp \
|
||||||
@ -103,6 +104,7 @@ HEADERS += \
|
|||||||
$$PWD/editors/markdownviewer.h \
|
$$PWD/editors/markdownviewer.h \
|
||||||
$$PWD/editors/markdownvieweradapter.h \
|
$$PWD/editors/markdownvieweradapter.h \
|
||||||
$$PWD/editors/previewhelper.h \
|
$$PWD/editors/previewhelper.h \
|
||||||
|
$$PWD/editors/statuswidget.h \
|
||||||
$$PWD/editors/texteditor.h \
|
$$PWD/editors/texteditor.h \
|
||||||
$$PWD/editreaddiscardaction.h \
|
$$PWD/editreaddiscardaction.h \
|
||||||
$$PWD/filesystemviewer.h \
|
$$PWD/filesystemviewer.h \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user