From 6c95b2df8b4cd9ac0f883645b9c7585b00f4a6a2 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sat, 18 Mar 2017 19:48:09 +0800 Subject: [PATCH] create notebook instead of pop up a list When there is no notebook and user clicks the VNotebookSelector combobox, just create a notebook instead of pop up a list. --- src/translations/vnote_zh_CN.ts | 119 ++++++++++++++++---------------- src/vnotebookselector.cpp | 12 +++- src/vnotebookselector.h | 1 + 3 files changed, 72 insertions(+), 60 deletions(-) diff --git a/src/translations/vnote_zh_CN.ts b/src/translations/vnote_zh_CN.ts index a2e1f352..edcf3ae6 100644 --- a/src/translations/vnote_zh_CN.ts +++ b/src/translations/vnote_zh_CN.ts @@ -236,52 +236,52 @@ VEditWindow - + Locate To Directory 定位所在目录 - + Locate the directory of current note 定位当前笔记所在目录 - + Move One Split Left 左移一个分割窗口 - + Move current tab to the split on the left 将当前标签页往左移动一个分割窗口 - + Move One Split Right 右移一个分割窗口 - + Move current tab to the split on the right 将当前标签页往右移动一个分割窗口 - + Split 分割 - + Split current window vertically 竖直分割当前窗口 - + Remove split 移除分割 - + Remove current split window 移除当前分割窗口 @@ -628,7 +628,7 @@ - + &Edit 编辑 (&E) @@ -728,148 +728,148 @@ 从文件中导入笔记到当前目录 - + Settings 设置 - + View and change settings for VNote 查看并更改VNote的配置 - + Insert &Image 插入图片 (&I) - - + + Find/Replace 查找/替换 - + Open Find/Replace dialog to search in current note 打开查找/替换对话框以在当前笔记中查找 - + Find Next 查找下一个 - + Find next occurence 查找下一处出现 - + Find Previous 查找上一个 - + Find previous occurence 查找上一处出现 - + Replace 替换 - + Replace current occurence 替换当前出现 - + Replace && Find 替换并查找 - + Replace current occurence and find the next one 替换当前出现并查找下一个 - + Replace All 全部替换 - + Replace all occurences in current note 替换当前笔记中的所有出现 - + Highlight Searched Pattern 高亮查找模式 - + Highlight all occurences of searched pattern 高亮查找模式的所有出现 - + &Expand Tab 扩展Tab (&E) - + Expand entered Tab to spaces 将输入的Tab扩展为空格 - + Expand Tab to 2 spaces 扩展Tab为2个空格 - + Expand Tab to 4 spaces 扩展Tab为4个空格 - + Expand Tab to 8 spaces 扩展Tab为8个空格 - + Highlight Selected Words 高亮选定字词 - + Highlight all occurences of selected words 高亮选定字词的所有出现 - + Import Notes From File 导入文件 - + Imported notes: %1 succeed, %2 failed. 已导入笔记: %1 成功, %2 失败。 - + Use system's background color configuration for Markdown rendering 使用系统的背景色设置对Markdown进行渲染 - + Set as the background color for Markdown rendering 使用该背景色对Markdown进行渲染 - + 2 Spaces 2个空格 @@ -899,89 +899,89 @@ 查看Qt的信息 - + Insert an image from file into current note 从文件中插入图片到当前笔记 - + 4 Spaces 4个空格 - + 8 Spaces 8个空格 - + Highlight Cursor Line 高亮光标所在行 - + Highlight current cursor line 高亮当前光标所在行 - + Tab Stop Width Tab Stop宽度 - + Tools 工具 - + Outline 大纲 - + Select Files(HTML or Markdown) To Import 选择要导入的文件 (HTML或Markdown) - + Fail to import files maybe due to name conflicts. 导入文件失败 (可能是因为名字冲突)。 - + About VNote 关于VNote - + VNote is a Vim-inspired note taking application for Markdown. Visit https://github.com/tamlok/vnote.git for more information. VNote是一个受Vim启发而开发的一个Markdown笔记软件。更多信息请访问 https://github.com/tamlok/vnote.git。 - + &Rendering Background 渲染背景 (&R) - - + + System 默认 - + &Background Color 背景颜色 (&B) - + Use system's background color configuration for editor 为编辑器使用系统的背景色设置 - + Set as the background color for editor 使用该背景色设置编辑器 @@ -1085,6 +1085,7 @@ Visit https://github.com/tamlok/vnote.git for more information. 新建或导入一个笔记本 + Add Notebook 添加笔记本 diff --git a/src/vnotebookselector.cpp b/src/vnotebookselector.cpp index 46682e0f..a70f2b8b 100644 --- a/src/vnotebookselector.cpp +++ b/src/vnotebookselector.cpp @@ -96,7 +96,7 @@ void VNotebookSelector::insertAddNotebookItem() { QListWidgetItem *item = new QListWidgetItem(); item->setIcon(QIcon(":/resources/icons/create_notebook.svg")); - item->setText("Add Notebook"); + item->setText(tr("Add Notebook")); QFont font; font.setItalic(true); item->setData(Qt::FontRole, font); @@ -356,3 +356,13 @@ bool VNotebookSelector::locateNotebook(const VNotebook *p_notebook) } return false; } + +void VNotebookSelector::showPopup() +{ + if (count() <= c_notebookStartIdx) { + // No normal notebook items. Just add notebook. + newNotebook(); + return; + } + QComboBox::showPopup(); +} diff --git a/src/vnotebookselector.h b/src/vnotebookselector.h index 3f820648..0d06c7af 100644 --- a/src/vnotebookselector.h +++ b/src/vnotebookselector.h @@ -21,6 +21,7 @@ public: inline void setEditArea(VEditArea *p_editArea); // Select notebook @p_notebook. bool locateNotebook(const VNotebook *p_notebook); + void showPopup() Q_DECL_OVERRIDE; signals: void curNotebookChanged(VNotebook *p_notebook);