bug-fix: some minor bug fixes

1. Refine VUpdater to compare versions with different sections, such as
1.2.3 or 1.2;
2. Update shortcuts help;
3. Fix bug with autoindent and autolist.
This commit is contained in:
Le Tan 2017-06-26 18:45:24 +08:00
parent cf70786448
commit 003ba7a1f2
5 changed files with 24 additions and 18 deletions

View File

@ -99,27 +99,34 @@ void VUpdater::checkUpdates()
} }
// Return if @p_latestVersion is newer than p_curVersion. // Return if @p_latestVersion is newer than p_curVersion.
// They are both in format xx.xx // They are both in format xx.xx.xx.xx
bool isNewerVersion(const QString &p_curVersion, const QString &p_latestVersion) bool isNewerVersion(const QString &p_curVersion, const QString &p_latestVersion)
{ {
QStringList curList = p_curVersion.split('.', QString::SkipEmptyParts); QStringList curList = p_curVersion.split('.', QString::SkipEmptyParts);
QStringList latestList = p_latestVersion.split('.', QString::SkipEmptyParts); QStringList latestList = p_latestVersion.split('.', QString::SkipEmptyParts);
if (curList.size() != 2 || latestList.size() != 2) { int i = 0;
return false; for (; i < curList.size() && i < latestList.size(); ++i) {
int a = curList[i].toInt();
int b = latestList[i].toInt();
if (a > b) {
return false;
} else if (a < b) {
return true;
}
} }
int a = curList[0].toInt();
int b = curList[1].toInt();
int c = latestList[0].toInt();
int d = latestList[1].toInt();
if (a > c) { if (i < curList.size()) {
// 1.2.1 vs 1.2
return false; return false;
} else if (a < c) { } else if (i < latestList.size()) {
// 1.2 vs 1.2.1
return true; return true;
} else { } else {
return d > b; // 1.2 vs 1.2
return false;
} }
} }

View File

@ -1,6 +1,6 @@
# VNote Shortcuts # VNote Shortcuts
1. All the keys without special notice are **case insensitive**; 1. All the keys without special notice are **case insensitive**;
2. On macOS, `Ctrl` corresponds to `Command`; 2. On macOS, `Ctrl` corresponds to `Command` except in Vim mode.
## Normal Shortcuts ## Normal Shortcuts
- `Ctrl+E E` - `Ctrl+E E`
@ -115,7 +115,7 @@ Display shortcuts documentation.
## Navigation Mode ## Navigation Mode
Within the Captain MOde, `W` will turn VNote into **Navigation Mode**. In this mode, VNote will display at most two characters on some major widgets, and then pressing corresponding characters will jump to that widget. Within the Captain MOde, `W` will turn VNote into **Navigation Mode**. In this mode, VNote will display at most two characters on some major widgets, and then pressing corresponding characters will jump to that widget.
## Vim Mode # Vim Mode
VNote supports a simple but useful Vim mode, including **Normal**, **Insert**, **Visual**, and **VisualLine** modes. VNote supports a simple but useful Vim mode, including **Normal**, **Insert**, **Visual**, and **VisualLine** modes.
VNote supports following features of Vim: VNote supports following features of Vim:
@ -124,7 +124,7 @@ VNote supports following features of Vim:
- Marks `a-z`; - Marks `a-z`;
- Registers `"`, `_`, `+`, `a-z`(`A-Z`); - Registers `"`, `_`, `+`, `a-z`(`A-Z`);
- Jump locations list (`Ctrl+O` and `Ctrl+I`); - Jump locations list (`Ctrl+O` and `Ctrl+I`);
- Leader key - Leader key (`Space`)
- Currently `<leader>y/d/p` equals to `"+y/d/p`, which will access the system's clipboard. - Currently `<leader>y/d/p` equals to `"+y/d/p`, which will access the system's clipboard.
- `zz`, `zb`, `zt`; - `zz`, `zb`, `zt`;
- `u` and `Ctrl+R` for undo and redo; - `u` and `Ctrl+R` for undo and redo;

View File

@ -1,6 +1,6 @@
# VNote快捷键说明 # VNote快捷键说明
1. 以下按键除特别说明外,都不区分大小写; 1. 以下按键除特别说明外,都不区分大小写;
2. 在macOS下`Ctrl`对应于`Command` 2. 在macOS下`Ctrl`对应于`Command`,在Vim模式下除外。
## 常规快捷键 ## 常规快捷键
- `Ctrl+E E` - `Ctrl+E E`
@ -115,7 +115,7 @@
## 展览模式 ## 展览模式
在舰长模式中,`W`命令会进入 **展览模式**。在展览模式中VNote会在常用的主要部件上显示至多两个字母此时输入对应的字母即可跳转到该部件中从而实现快速切换焦点并触发功能。 在舰长模式中,`W`命令会进入 **展览模式**。在展览模式中VNote会在常用的主要部件上显示至多两个字母此时输入对应的字母即可跳转到该部件中从而实现快速切换焦点并触发功能。
## Vim Mode # Vim Mode
VNote支持一个简单但有用的Vim模式包括 **正常** **插入** **可视** **可视行** 模式。 VNote支持一个简单但有用的Vim模式包括 **正常** **插入** **可视** **可视行** 模式。
VNote支持以下几个Vim的特性 VNote支持以下几个Vim的特性
@ -124,7 +124,7 @@ VNote支持以下几个Vim的特性
- 标记 `a-z` - 标记 `a-z`
- 寄存器 `"`, `_`, `+`, `a-z`(`A-Z`) - 寄存器 `"`, `_`, `+`, `a-z`(`A-Z`)
- 跳转位置列表 (`Ctrl+O` and `Ctrl+I`) - 跳转位置列表 (`Ctrl+O` and `Ctrl+I`)
- 前导键 - 前导键 (`Space`)
- 目前 `<leader>y/d/p` 等同于 `"+y/d/p`, 从而可以访问系统剪切板。 - 目前 `<leader>y/d/p` 等同于 `"+y/d/p`, 从而可以访问系统剪切板。
- `zz`, `zb`, `zt`; - `zz`, `zb`, `zt`;
- `u``Ctrl+R` 撤销和重做; - `u``Ctrl+R` 撤销和重做;

View File

@ -113,8 +113,6 @@ bool VEditUtils::indentBlockAsPreviousBlock(QTextCursor &p_cursor)
changed = true; changed = true;
} }
p_cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::MoveAnchor);
return changed; return changed;
} }

View File

@ -26,6 +26,7 @@ public:
QTextCursor::MoveMode p_mode); QTextCursor::MoveMode p_mode);
// Indent current block as previous block. // Indent current block as previous block.
// Return true if some changes have been made. // Return true if some changes have been made.
// @p_cursor will be placed at the position after inserting leading spaces.
static bool indentBlockAsPreviousBlock(QTextCursor &p_cursor); static bool indentBlockAsPreviousBlock(QTextCursor &p_cursor);
// Insert a new block at current position with the same indentation as // Insert a new block at current position with the same indentation as