Browse Source

bug-fix: prompt for new notebook after mainwindow is shown

Le Tan 8 years ago
parent
commit
1028c9a4ad
4 changed files with 21 additions and 1 deletions
  1. 2 0
      src/main.cpp
  2. 7 0
      src/vmainwindow.cpp
  3. 3 0
      src/vmainwindow.h
  4. 9 1
      src/vnotebookselector.cpp

+ 2 - 0
src/main.cpp

@@ -168,5 +168,7 @@ int main(int argc, char *argv[])
 
     w.openFiles(filePaths);
 
+    w.promptNewNotebookIfEmpty();
+
     return app.exec();
 }

+ 7 - 0
src/vmainwindow.cpp

@@ -2623,3 +2623,10 @@ void VMainWindow::flushLogFileByCaptain(void *p_target, void *p_data)
     g_logFile.flush();
 #endif
 }
+
+void VMainWindow::promptNewNotebookIfEmpty()
+{
+    if (vnote->getNotebooks().isEmpty()) {
+        notebookSelector->newNotebook();
+    }
+}

+ 3 - 0
src/vmainwindow.h

@@ -83,6 +83,9 @@ public:
 
     VCaptain *getCaptain() const;
 
+    // Prompt user for new notebook if there is no notebook.
+    void promptNewNotebookIfEmpty();
+
 private slots:
     void importNoteFromFile();
     void viewSettings();

+ 9 - 1
src/vnotebookselector.cpp

@@ -243,7 +243,9 @@ void VNotebookSelector::handleCurIndexChanged(int p_index)
                 setCurrentIndex(m_lastValidIndex);
             }
 
-            newNotebook();
+            if (!m_notebooks.isEmpty()) {
+                newNotebook();
+            }
 
             return;
         }
@@ -382,6 +384,12 @@ void VNotebookSelector::deleteNotebook(VNotebook *p_notebook, bool p_deleteFiles
             QDesktopServices::openUrl(url);
         }
     }
+
+    if (m_notebooks.isEmpty()) {
+        m_muted = true;
+        setCurrentIndex(0);
+        m_muted = false;
+    }
 }
 
 void VNotebookSelector::editNotebookInfo()