do not show welcome page repeatedly

This commit is contained in:
Le Tan 2019-05-09 19:10:12 +08:00
parent 1cd809ed8f
commit 56715bc9a5
4 changed files with 33 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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