Browse Source

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.
Le Tan 8 years ago
parent
commit
6c95b2df8b
3 changed files with 72 additions and 60 deletions
  1. 60 59
      src/translations/vnote_zh_CN.ts
  2. 11 1
      src/vnotebookselector.cpp
  3. 1 0
      src/vnotebookselector.h

+ 60 - 59
src/translations/vnote_zh_CN.ts

@@ -236,52 +236,52 @@
 <context>
     <name>VEditWindow</name>
     <message>
-        <location filename="../veditwindow.cpp" line="44"/>
+        <location filename="../veditwindow.cpp" line="45"/>
         <source>Locate To Directory</source>
         <translation>定位所在目录</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="45"/>
+        <location filename="../veditwindow.cpp" line="46"/>
         <source>Locate the directory of current note</source>
         <translation>定位当前笔记所在目录</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="50"/>
+        <location filename="../veditwindow.cpp" line="51"/>
         <source>Move One Split Left</source>
         <translation>左移一个分割窗口</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="51"/>
+        <location filename="../veditwindow.cpp" line="52"/>
         <source>Move current tab to the split on the left</source>
         <translation>将当前标签页往左移动一个分割窗口</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="56"/>
+        <location filename="../veditwindow.cpp" line="57"/>
         <source>Move One Split Right</source>
         <translation>右移一个分割窗口</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="57"/>
+        <location filename="../veditwindow.cpp" line="58"/>
         <source>Move current tab to the split on the right</source>
         <translation>将当前标签页往右移动一个分割窗口</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="67"/>
+        <location filename="../veditwindow.cpp" line="68"/>
         <source>Split</source>
         <translation>分割</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="68"/>
+        <location filename="../veditwindow.cpp" line="69"/>
         <source>Split current window vertically</source>
         <translation>竖直分割当前窗口</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="73"/>
+        <location filename="../veditwindow.cpp" line="74"/>
         <source>Remove split</source>
         <translation>移除分割</translation>
     </message>
     <message>
-        <location filename="../veditwindow.cpp" line="74"/>
+        <location filename="../veditwindow.cpp" line="75"/>
         <source>Remove current split window</source>
         <translation>移除当前分割窗口</translation>
     </message>
@@ -628,7 +628,7 @@
     </message>
     <message>
         <location filename="../vmainwindow.cpp" line="202"/>
-        <location filename="../vmainwindow.cpp" line="338"/>
+        <location filename="../vmainwindow.cpp" line="339"/>
         <source>&amp;Edit</source>
         <translation>编辑 (&amp;E)</translation>
     </message>
@@ -728,148 +728,148 @@
         <translation>从文件中导入笔记到当前目录</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="326"/>
+        <location filename="../vmainwindow.cpp" line="327"/>
         <source>Settings</source>
         <translation>设置</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="327"/>
+        <location filename="../vmainwindow.cpp" line="328"/>
         <source>View and change settings for VNote</source>
         <translation>查看并更改VNote的配置</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="342"/>
+        <location filename="../vmainwindow.cpp" line="343"/>
         <source>Insert &amp;Image</source>
         <translation>插入图片 (&amp;I)</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="349"/>
-        <location filename="../vmainwindow.cpp" line="431"/>
+        <location filename="../vmainwindow.cpp" line="350"/>
+        <location filename="../vmainwindow.cpp" line="432"/>
         <source>Find/Replace</source>
         <translation>查找/替换</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="350"/>
+        <location filename="../vmainwindow.cpp" line="351"/>
         <source>Open Find/Replace dialog to search in current note</source>
         <translation>打开查找/替换对话框以在当前笔记中查找</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="355"/>
+        <location filename="../vmainwindow.cpp" line="356"/>
         <source>Find Next</source>
         <translation>查找下一个</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="356"/>
+        <location filename="../vmainwindow.cpp" line="357"/>
         <source>Find next occurence</source>
         <translation>查找下一处出现</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="361"/>
+        <location filename="../vmainwindow.cpp" line="362"/>
         <source>Find Previous</source>
         <translation>查找上一个</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="362"/>
+        <location filename="../vmainwindow.cpp" line="363"/>
         <source>Find previous occurence</source>
         <translation>查找上一处出现</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="367"/>
+        <location filename="../vmainwindow.cpp" line="368"/>
         <source>Replace</source>
         <translation>替换</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="368"/>
+        <location filename="../vmainwindow.cpp" line="369"/>
         <source>Replace current occurence</source>
         <translation>替换当前出现</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="373"/>
+        <location filename="../vmainwindow.cpp" line="374"/>
         <source>Replace &amp;&amp; Find</source>
         <translation>替换并查找</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="374"/>
+        <location filename="../vmainwindow.cpp" line="375"/>
         <source>Replace current occurence and find the next one</source>
         <translation>替换当前出现并查找下一个</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="378"/>
+        <location filename="../vmainwindow.cpp" line="379"/>
         <source>Replace All</source>
         <translation>全部替换</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="379"/>
+        <location filename="../vmainwindow.cpp" line="380"/>
         <source>Replace all occurences in current note</source>
         <translation>替换当前笔记中的所有出现</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="383"/>
+        <location filename="../vmainwindow.cpp" line="384"/>
         <source>Highlight Searched Pattern</source>
         <translation>高亮查找模式</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="384"/>
+        <location filename="../vmainwindow.cpp" line="385"/>
         <source>Highlight all occurences of searched pattern</source>
         <translation>高亮查找模式的所有出现</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="390"/>
+        <location filename="../vmainwindow.cpp" line="391"/>
         <source>&amp;Expand Tab</source>
         <translation>扩展Tab (&amp;E)</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="391"/>
+        <location filename="../vmainwindow.cpp" line="392"/>
         <source>Expand entered Tab to spaces</source>
         <translation>将输入的Tab扩展为空格</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="399"/>
+        <location filename="../vmainwindow.cpp" line="400"/>
         <source>Expand Tab to 2 spaces</source>
         <translation>扩展Tab为2个空格</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="403"/>
+        <location filename="../vmainwindow.cpp" line="404"/>
         <source>Expand Tab to 4 spaces</source>
         <translation>扩展Tab为4个空格</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="407"/>
+        <location filename="../vmainwindow.cpp" line="408"/>
         <source>Expand Tab to 8 spaces</source>
         <translation>扩展Tab为8个空格</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="421"/>
+        <location filename="../vmainwindow.cpp" line="422"/>
         <source>Highlight Selected Words</source>
         <translation>高亮选定字词</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="422"/>
+        <location filename="../vmainwindow.cpp" line="423"/>
         <source>Highlight all occurences of selected words</source>
         <translation>高亮选定字词的所有出现</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="542"/>
+        <location filename="../vmainwindow.cpp" line="543"/>
         <source>Import Notes From File</source>
         <translation>导入文件</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="543"/>
+        <location filename="../vmainwindow.cpp" line="544"/>
         <source>Imported notes: %1 succeed, %2 failed.</source>
         <translation>已导入笔记: %1 成功, %2 失败。</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="629"/>
+        <location filename="../vmainwindow.cpp" line="630"/>
         <source>Use system&apos;s background color configuration for Markdown rendering</source>
         <translation>使用系统的背景色设置对Markdown进行渲染</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="640"/>
+        <location filename="../vmainwindow.cpp" line="641"/>
         <source>Set as the background color for Markdown rendering</source>
         <translation>使用该背景色对Markdown进行渲染</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="398"/>
+        <location filename="../vmainwindow.cpp" line="399"/>
         <source>2 Spaces</source>
         <translation>2个空格</translation>
     </message>
@@ -899,89 +899,89 @@
         <translation>查看Qt的信息</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="343"/>
+        <location filename="../vmainwindow.cpp" line="344"/>
         <source>Insert an image from file into current note</source>
         <translation>从文件中插入图片到当前笔记</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="402"/>
+        <location filename="../vmainwindow.cpp" line="403"/>
         <source>4 Spaces</source>
         <translation>4个空格</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="406"/>
+        <location filename="../vmainwindow.cpp" line="407"/>
         <source>8 Spaces</source>
         <translation>8个空格</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="414"/>
+        <location filename="../vmainwindow.cpp" line="415"/>
         <source>Highlight Cursor Line</source>
         <translation>高亮光标所在行</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="415"/>
+        <location filename="../vmainwindow.cpp" line="416"/>
         <source>Highlight current cursor line</source>
         <translation>高亮当前光标所在行</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="460"/>
+        <location filename="../vmainwindow.cpp" line="461"/>
         <source>Tab Stop Width</source>
         <translation>Tab Stop宽度</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="497"/>
+        <location filename="../vmainwindow.cpp" line="498"/>
         <source>Tools</source>
         <translation>工具</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="508"/>
+        <location filename="../vmainwindow.cpp" line="509"/>
         <source>Outline</source>
         <translation>大纲</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="527"/>
+        <location filename="../vmainwindow.cpp" line="528"/>
         <source>Select Files(HTML or Markdown) To Import</source>
         <translation>选择要导入的文件 (HTML或Markdown)</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="547"/>
+        <location filename="../vmainwindow.cpp" line="548"/>
         <source>Fail to import files maybe due to name conflicts.</source>
         <translation>导入文件失败 (可能是因为名字冲突)。</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="564"/>
+        <location filename="../vmainwindow.cpp" line="565"/>
         <source>About VNote</source>
         <translation>关于VNote</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="565"/>
+        <location filename="../vmainwindow.cpp" line="566"/>
         <source>VNote is a Vim-inspired note taking application for Markdown.
 Visit https://github.com/tamlok/vnote.git for more information.</source>
         <translation>VNote是一个受Vim启发而开发的一个Markdown笔记软件。更多信息请访问 https://github.com/tamlok/vnote.git。</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="626"/>
+        <location filename="../vmainwindow.cpp" line="627"/>
         <source>&amp;Rendering Background</source>
         <translation>渲染背景 (&amp;R)</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="628"/>
-        <location filename="../vmainwindow.cpp" line="662"/>
+        <location filename="../vmainwindow.cpp" line="629"/>
+        <location filename="../vmainwindow.cpp" line="663"/>
         <source>System</source>
         <translation>默认</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="654"/>
+        <location filename="../vmainwindow.cpp" line="655"/>
         <source>&amp;Background Color</source>
         <translation>背景颜色 (&amp;B)</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="663"/>
+        <location filename="../vmainwindow.cpp" line="664"/>
         <source>Use system&apos;s background color configuration for editor</source>
         <translation>为编辑器使用系统的背景色设置</translation>
     </message>
     <message>
-        <location filename="../vmainwindow.cpp" line="673"/>
+        <location filename="../vmainwindow.cpp" line="674"/>
         <source>Set as the background color for editor</source>
         <translation>使用该背景色设置编辑器</translation>
     </message>
@@ -1085,6 +1085,7 @@ Visit https://github.com/tamlok/vnote.git for more information.</source>
         <translation>新建或导入一个笔记本</translation>
     </message>
     <message>
+        <location filename="../vnotebookselector.cpp" line="99"/>
         <location filename="../vnotebookselector.cpp" line="161"/>
         <source>Add Notebook</source>
         <translation>添加笔记本</translation>

+ 11 - 1
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();
+}

+ 1 - 0
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);