diff --git a/src/resources/user_stat.html b/src/resources/user_stat.html
new file mode 100644
index 00000000..3e994563
--- /dev/null
+++ b/src/resources/user_stat.html
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini
index 9c554f3c..14bb02b2 100644
--- a/src/resources/vnote.ini
+++ b/src/resources/vnote.ini
@@ -283,6 +283,9 @@ split_tag_file_list=false
; 3 - software;
windows_opengl=0
+; Whether allow VNote to send request for couting users
+allow_user_track=true
+
[editor]
; Auto indent as previous line
auto_indent=true
diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h
index 6a2f3284..a6f930a3 100644
--- a/src/vconfigmanager.h
+++ b/src/vconfigmanager.h
@@ -631,6 +631,9 @@ public:
bool getEnableSmartTable() const;
void setEnableSmartTable(bool p_enabled);
+ bool getAllowUserTrack() const;
+ void setAllowUserTrack(bool p_enabled);
+
private:
void initEditorConfigs();
@@ -2919,4 +2922,14 @@ inline void VConfigManager::setEnableSmartTable(bool p_enabled)
m_enableSmartTable = p_enabled;
setConfigToSettings("editor", "enable_smart_table", m_enableSmartTable);
}
+
+inline bool VConfigManager::getAllowUserTrack() const
+{
+ return getConfigFromSettings("global", "allow_user_track").toBool();
+}
+
+inline void VConfigManager::setAllowUserTrack(bool p_enabled)
+{
+ setConfigToSettings("global", "allow_user_track", p_enabled);
+}
#endif // VCONFIGMANAGER_H
diff --git a/src/vmainwindow.cpp b/src/vmainwindow.cpp
index 97d77d92..1b44fa5b 100644
--- a/src/vmainwindow.cpp
+++ b/src/vmainwindow.cpp
@@ -3,6 +3,7 @@
#include
#include
#include
+#include
#include "vmainwindow.h"
#include "vdirectorytree.h"
@@ -3423,6 +3424,23 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
VFile *file = vnote->getFile(docFile, true);
m_editArea->openFile(file, OpenFileMode::Read);
}
+
+ if (g_config->versionChanged()) {
+ // Ask user whether allow tracking.
+ int ret = VUtils::showMessage(QMessageBox::Information,
+ tr("Collect User Statistics"),
+ tr("VNote would like to send a request to count active users."
+ "Do you allow this request?"),
+ tr("A request to https://tajs.qq.com/stats will be sent if allowed."),
+ QMessageBox::Ok | QMessageBox::No,
+ QMessageBox::Ok,
+ this);
+ g_config->setAllowUserTrack(ret == QMessageBox::Ok);
+ }
+
+ if (g_config->getAllowUserTrack()) {
+ QTimer::singleShot(60000, this, SLOT(collectUserStat()));
+ }
});
}
@@ -3524,3 +3542,15 @@ void VMainWindow::setupFileListSplitOut(bool p_enabled)
m_nbSplitter->setStretchFactor(1, 2);
}
}
+
+void VMainWindow::collectUserStat() const
+{
+ QWebEnginePage *page = new QWebEnginePage;
+ page->load(QUrl("qrc:/resources/user_stat.html"));
+ connect(page, &QWebEnginePage::loadFinished,
+ this, [page](bool) {
+ VUtils::sleepWait(2000);
+ page->deleteLater();
+ });
+}
+
diff --git a/src/vmainwindow.h b/src/vmainwindow.h
index 13b82bc8..42072527 100644
--- a/src/vmainwindow.h
+++ b/src/vmainwindow.h
@@ -212,6 +212,8 @@ private slots:
void splitFileListOut(bool p_enabled);
+ void collectUserStat() const;
+
protected:
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
diff --git a/src/vnote.qrc b/src/vnote.qrc
index e4cc7774..622f7d8e 100644
--- a/src/vnote.qrc
+++ b/src/vnote.qrc
@@ -287,5 +287,6 @@
resources/icons/table.svg
utils/wavedrom/wavedrom.min.js
utils/wavedrom/wavedrom-theme.js
+ resources/user_stat.html