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.
This commit is contained in:
Le Tan 2017-03-18 19:48:09 +08:00
parent fdb8c3bb3a
commit 6c95b2df8b
3 changed files with 72 additions and 60 deletions

View File

@ -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>

View File

@ -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();
}

View File

@ -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);