mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
add user track logics
This commit is contained in:
parent
1675b944c4
commit
5fff26a8b6
7
src/resources/user_stat.html
Normal file
7
src/resources/user_stat.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=66167380" charset="UTF-8"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -283,6 +283,9 @@ split_tag_file_list=false
|
|||||||
; 3 - software;
|
; 3 - software;
|
||||||
windows_opengl=0
|
windows_opengl=0
|
||||||
|
|
||||||
|
; Whether allow VNote to send request for couting users
|
||||||
|
allow_user_track=true
|
||||||
|
|
||||||
[editor]
|
[editor]
|
||||||
; Auto indent as previous line
|
; Auto indent as previous line
|
||||||
auto_indent=true
|
auto_indent=true
|
||||||
|
@ -631,6 +631,9 @@ public:
|
|||||||
bool getEnableSmartTable() const;
|
bool getEnableSmartTable() const;
|
||||||
void setEnableSmartTable(bool p_enabled);
|
void setEnableSmartTable(bool p_enabled);
|
||||||
|
|
||||||
|
bool getAllowUserTrack() const;
|
||||||
|
void setAllowUserTrack(bool p_enabled);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initEditorConfigs();
|
void initEditorConfigs();
|
||||||
|
|
||||||
@ -2919,4 +2922,14 @@ inline void VConfigManager::setEnableSmartTable(bool p_enabled)
|
|||||||
m_enableSmartTable = p_enabled;
|
m_enableSmartTable = p_enabled;
|
||||||
setConfigToSettings("editor", "enable_smart_table", m_enableSmartTable);
|
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
|
#endif // VCONFIGMANAGER_H
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <QPrinter>
|
#include <QPrinter>
|
||||||
#include <QPrintDialog>
|
#include <QPrintDialog>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QWebEnginePage>
|
||||||
|
|
||||||
#include "vmainwindow.h"
|
#include "vmainwindow.h"
|
||||||
#include "vdirectorytree.h"
|
#include "vdirectorytree.h"
|
||||||
@ -3423,6 +3424,23 @@ void VMainWindow::kickOffStartUpTimer(const QStringList &p_files)
|
|||||||
VFile *file = vnote->getFile(docFile, true);
|
VFile *file = vnote->getFile(docFile, true);
|
||||||
m_editArea->openFile(file, OpenFileMode::Read);
|
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);
|
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();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -212,6 +212,8 @@ private slots:
|
|||||||
|
|
||||||
void splitFileListOut(bool p_enabled);
|
void splitFileListOut(bool p_enabled);
|
||||||
|
|
||||||
|
void collectUserStat() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
@ -287,5 +287,6 @@
|
|||||||
<file>resources/icons/table.svg</file>
|
<file>resources/icons/table.svg</file>
|
||||||
<file>utils/wavedrom/wavedrom.min.js</file>
|
<file>utils/wavedrom/wavedrom.min.js</file>
|
||||||
<file>utils/wavedrom/wavedrom-theme.js</file>
|
<file>utils/wavedrom/wavedrom-theme.js</file>
|
||||||
|
<file>resources/user_stat.html</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user