Browse Source

do not show welcome page repeatedly

Le Tan 6 years ago
parent
commit
56715bc9a5
4 changed files with 33 additions and 6 deletions
  1. 14 0
      src/vconfigmanager.cpp
  2. 3 0
      src/vconfigmanager.h
  3. 14 6
      src/vmainwindow.cpp
  4. 2 0
      src/vmainwindow.h

+ 14 - 0
src/vconfigmanager.cpp

@@ -10,6 +10,7 @@
 #include <QStandardPaths>
 #include <QCoreApplication>
 #include <QScopedPointer>
+#include <QDateTime>
 
 #include "utils/vutils.h"
 #include "vstyleparser.h"
@@ -1750,3 +1751,16 @@ void VConfigManager::updateLastUserTrackDate()
                                "last_user_track_date",
                                date.toString(Qt::ISODate));
 }
+
+QDateTime VConfigManager::getLastStartDateTime() const
+{
+    auto dateStr = getConfigFromSessionSettings("global",
+                                                "last_start_time").toString();
+    return QDateTime::fromString(dateStr, Qt::ISODate);
+}
+
+void VConfigManager::updateLastStartDateTime()
+{
+    auto dateTime = QDateTime::currentDateTime();
+    setConfigToSessionSettings("global", "last_start_time", dateTime.toString(Qt::ISODate));
+}

+ 3 - 0
src/vconfigmanager.h

@@ -640,6 +640,9 @@ public:
     QDate getLastUserTrackDate() const;
     void updateLastUserTrackDate();
 
+    QDateTime getLastStartDateTime() const;
+    void updateLastStartDateTime();
+
 private:
     void initEditorConfigs();
 

+ 14 - 6
src/vmainwindow.cpp

@@ -3456,12 +3456,7 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
         openStartupPages();
         openFiles(p_files, false, g_config->getNoteOpenMode(), false, true);
 
-        if (g_config->versionChanged()
-            || (QDate::currentDate().dayOfYear() % 64 == 1)) {
-            QString docFile = VUtils::getDocFile("welcome.md");
-            VFile *file = vnote->getFile(docFile, true);
-            m_editArea->openFile(file, OpenFileMode::Read);
-        }
+        checkIfNeedToShowWelcomePage();
 
         if (g_config->versionChanged() && !g_config->getAllowUserTrack()) {
             // Ask user whether allow tracking.
@@ -3481,6 +3476,8 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
         }
 
         m_syncNoteListToCurrentTab = true;
+
+        g_config->updateLastStartDateTime();
     });
 }
 
@@ -3617,3 +3614,14 @@ void VMainWindow::promptForVNoteRestart()
         restartVNote();
     }
 }
+
+void VMainWindow::checkIfNeedToShowWelcomePage()
+{
+    if (g_config->versionChanged()
+        || (QDate::currentDate().dayOfYear() % 64 == 1
+            && g_config->getLastStartDateTime().date() != QDate::currentDate())) {
+        QString docFile = VUtils::getDocFile("welcome.md");
+        VFile *file = vnote->getFile(docFile, true);
+        m_editArea->openFile(file, OpenFileMode::Read);
+    }
+}

+ 2 - 0
src/vmainwindow.h

@@ -333,6 +333,8 @@ private:
 
     void promptForVNoteRestart();
 
+    void checkIfNeedToShowWelcomePage();
+
     // Captain mode functions.
 
     // Popup the attachment list if it is enabled.