diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index b6c3bdde..41bddafa 100644 --- a/src/vconfigmanager.cpp +++ b/src/vconfigmanager.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #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)); +} diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index 4fd71d84..3075e1ae 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -640,6 +640,9 @@ public: QDate getLastUserTrackDate() const; void updateLastUserTrackDate(); + QDateTime getLastStartDateTime() const; + void updateLastStartDateTime(); + private: void initEditorConfigs(); diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp index f6d79c31..a5f54bdb 100644 --- a/src/vmainwindow.cpp +++ b/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); + } +} diff --git a/src/vmainwindow.h b/src/vmainwindow.h index 220cde1b..2da51331 100644 --- a/src/vmainwindow.h +++ b/src/vmainwindow.h @@ -333,6 +333,8 @@ private: void promptForVNoteRestart(); + void checkIfNeedToShowWelcomePage(); + // Captain mode functions. // Popup the attachment list if it is enabled.