editor: add supports for Tencent and gitee image hosting (#1059)

* 将图床单独提取出来成为一个类

* Split the image hosting code into two classes

* change null to parent

* delect empty line,add p_,rename file and so on

* 增加腾讯图床

* add keep image scale and do not replace link

* adjust image hosting name space

* Increase edit box length

* fix some bug and add gitee image hosting

* Specification code
This commit is contained in:
冯文华 2019-11-16 14:01:32 +08:00 committed by Le Tan
parent 55c1174ae1
commit fbdc5a5406
11 changed files with 2194 additions and 436 deletions

View File

@ -1596,62 +1596,124 @@ VImageHostingTab::VImageHostingTab(QWidget *p_parent)
QTabWidget *imageHostingTabWeg = new QTabWidget(this);
QWidget *githubImageHostingTab = new QWidget();
QWidget *wechatImageHostingTab = new QWidget();
QWidget *tencentImageHostingTab = new QWidget();
QWidget *giteeImageHostingTab = new QWidget();
imageHostingTabWeg->addTab(githubImageHostingTab, tr("GitHub"));
imageHostingTabWeg->addTab(giteeImageHostingTab, tr("Gitee"));
imageHostingTabWeg->addTab(wechatImageHostingTab, tr("WeChat"));
imageHostingTabWeg->addTab(tencentImageHostingTab, tr("Tencent"));
imageHostingTabWeg->setCurrentIndex(0);
// Set the tab of GitHub image Hosting
m_personalAccessTokenEdit = new VLineEdit();
m_personalAccessTokenEdit->setToolTip(tr("GitHub personal access token"));
m_repoNameEdit = new VLineEdit();
m_repoNameEdit->setToolTip(tr("Name of GitHub repository for image hosting"));
m_userNameEdit = new VLineEdit();
m_userNameEdit->setToolTip(tr("User name of GitHub"));
m_githubPersonalAccessTokenEdit = new VLineEdit();
m_githubPersonalAccessTokenEdit->setToolTip(tr("GitHub personal access token"));
m_githubPersonalAccessTokenEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_githubRepoNameEdit = new VLineEdit();
m_githubRepoNameEdit->setToolTip(tr("Name of GitHub repository for image hosting"));
m_githubRepoNameEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_githubUserNameEdit = new VLineEdit();
m_githubUserNameEdit->setToolTip(tr("User name of GitHub"));
m_githubUserNameEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_githubKeepImgScaleCB = new QCheckBox(tr("Keep image scale(such as '=100x')"));
m_githubDoNotReplaceLinkCB = new QCheckBox(tr("Don't replace new image link"));
QFormLayout *githubLayout = new QFormLayout();
githubLayout->addRow(tr("Personal access token:"), m_personalAccessTokenEdit);
githubLayout->addRow(tr("Repo name:"), m_repoNameEdit);
githubLayout->addRow(tr("User name:"), m_userNameEdit);
githubLayout->addRow(tr("Personal access token:"), m_githubPersonalAccessTokenEdit);
githubLayout->addRow(tr("Repo name:"), m_githubRepoNameEdit);
githubLayout->addRow(tr("User name:"), m_githubUserNameEdit);
githubLayout->addRow(m_githubKeepImgScaleCB);
githubLayout->addRow(m_githubDoNotReplaceLinkCB);
githubImageHostingTab->setLayout(githubLayout);
// Set the tab of GitHub image Hosting
m_appidEdit = new VLineEdit();
m_appidEdit->setToolTip(tr("WeChat appid"));
m_secretEdit = new VLineEdit();
m_secretEdit->setToolTip(tr("Please input wechat secret"));
// Set the tab of Gitee image Hosting
m_giteePersonalAccessTokenEdit = new VLineEdit();
m_giteePersonalAccessTokenEdit->setToolTip(tr("Gitee personal access token"));
m_giteePersonalAccessTokenEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_giteeRepoNameEdit = new VLineEdit();
m_giteeRepoNameEdit->setToolTip(tr("Name of Gitee repository for image hosting"));
m_giteeRepoNameEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_giteeUserNameEdit = new VLineEdit();
m_giteeUserNameEdit->setToolTip(tr("User name of Gitee"));
m_giteeUserNameEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_giteeKeepImgScaleCB = new QCheckBox(tr("Keep image scale(such as '=100x')"));
m_giteeDoNotReplaceLinkCB = new QCheckBox(tr("Don't replace new image link"));
QFormLayout *giteeLayout = new QFormLayout();
giteeLayout->addRow(tr("Personal access token:"), m_giteePersonalAccessTokenEdit);
giteeLayout->addRow(tr("Repo name:"), m_giteeRepoNameEdit);
giteeLayout->addRow(tr("User name:"), m_giteeUserNameEdit);
giteeLayout->addRow(m_giteeKeepImgScaleCB);
giteeLayout->addRow(m_giteeDoNotReplaceLinkCB);
giteeImageHostingTab->setLayout(giteeLayout);
// Set the tab of Wechat image Hosting
m_wechatAppidEdit = new VLineEdit();
m_wechatAppidEdit->setToolTip(tr("WeChat appid"));
m_wechatAppidEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_wechatSecretEdit = new VLineEdit();
m_wechatSecretEdit->setToolTip(tr("Please input wechat secret"));
m_wechatSecretEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_markdown2WechatToolUrlEdit = new VLineEdit();
m_markdown2WechatToolUrlEdit->setToolTip(tr("Please input markdown to wechat tool's url"));
m_markdown2WechatToolUrlEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_wechatKeepImgScaleCB = new QCheckBox(tr("Keep image scale(such as '=100x')"));
m_wechatDoNotReplaceLinkCB = new QCheckBox(tr("Don't replace new image link"));
QFormLayout *wechatLayout = new QFormLayout();
wechatLayout->addRow(tr("appid:"), m_appidEdit);
wechatLayout->addRow(tr("secret:"), m_secretEdit);
wechatLayout->addRow(tr("appid:"), m_wechatAppidEdit);
wechatLayout->addRow(tr("secret:"), m_wechatSecretEdit);
wechatLayout->addRow(tr("markdown2WechatToolUrl"), m_markdown2WechatToolUrlEdit);
wechatLayout->addRow(m_wechatKeepImgScaleCB);
wechatLayout->addRow(m_wechatDoNotReplaceLinkCB);
wechatImageHostingTab->setLayout(wechatLayout);
// Set the tab of Tencent image Hosting.
m_tencentAccessDomainNameEdit = new VLineEdit();
m_tencentAccessDomainNameEdit->setToolTip(tr("Tencent access domain name"));
m_tencentAccessDomainNameEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_tencentSecretIdEdit = new VLineEdit();
m_tencentSecretIdEdit->setToolTip(tr("Tencent secret id"));
m_tencentSecretIdEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_tencentSecretKeyEdit = new VLineEdit();
m_tencentSecretKeyEdit->setToolTip(tr("Tencent secret key"));
m_tencentSecretKeyEdit->setMinimumWidth(250 * VUtils::calculateScaleFactor());
m_tencentKeepImgScaleCB = new QCheckBox(tr("Keep image scale(such as '=100x')"));
m_tencentDoNotReplaceLinkCB = new QCheckBox(tr("Don't replace new image link"));
QFormLayout *tencentLayout = new QFormLayout();
tencentLayout->addRow(tr("accessDomainName"), m_tencentAccessDomainNameEdit);
tencentLayout->addRow(tr("secretId"), m_tencentSecretIdEdit);
tencentLayout->addRow(tr("secretKey"), m_tencentSecretKeyEdit);
tencentLayout->addRow(m_tencentKeepImgScaleCB);
tencentLayout->addRow(m_tencentDoNotReplaceLinkCB);
tencentImageHostingTab->setLayout(tencentLayout);
}
bool VImageHostingTab::loadAppid()
bool VImageHostingTab::loadWechatAppid()
{
m_appidEdit->setText(g_config->getAppid());
m_wechatAppidEdit->setText(g_config->getWechatAppid());
return true;
}
bool VImageHostingTab::saveAppid()
bool VImageHostingTab::saveWechatAppid()
{
g_config->setAppid(m_appidEdit->text());
g_config->setWechatAppid(m_wechatAppidEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadSecret()
bool VImageHostingTab::loadWechatSecret()
{
m_secretEdit->setText(g_config->getSecret());
m_wechatSecretEdit->setText(g_config->getWechatSecret());
return true;
}
bool VImageHostingTab::saveSecret()
bool VImageHostingTab::saveWechatSecret()
{
g_config->setSecret(m_secretEdit->text());
g_config->setWechatSecret(m_wechatSecretEdit->text().trimmed());
return true;
}
@ -1663,88 +1725,340 @@ bool VImageHostingTab::loadMarkdown2WechatToolUrl()
bool VImageHostingTab::saveMarkdown2WechatToolUrl()
{
g_config->setMarkdown2WechatToolUrl(m_markdown2WechatToolUrlEdit->text());
g_config->setMarkdown2WechatToolUrl(m_markdown2WechatToolUrlEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadpersonalAccessToken()
bool VImageHostingTab::loadWechatKeepImgScale()
{
m_personalAccessTokenEdit->setText(g_config->getpersonalAccessToken());
m_wechatKeepImgScaleCB->setChecked(g_config->getWechatKeepImgScale());
return true;
}
bool VImageHostingTab::savepersonalAccessToken()
bool VImageHostingTab::saveWechatKeepImgScale()
{
g_config->setpersonalAccessToken(m_personalAccessTokenEdit->text());
g_config->setWechatKeepImgScale(m_wechatKeepImgScaleCB->isChecked());
return true;
}
bool VImageHostingTab::loadReposName()
bool VImageHostingTab::loadWechatDoNotReplaceLink()
{
m_repoNameEdit->setText(g_config->getReposName());
m_wechatDoNotReplaceLinkCB->setChecked(g_config->getWechatDoNotReplaceLink());
return true;
}
bool VImageHostingTab::saveReposName()
bool VImageHostingTab::saveWechatDoNotReplaceLink()
{
g_config->setReposName(m_repoNameEdit->text());
g_config->setWechatDoNotReplaceLink(m_wechatDoNotReplaceLinkCB->isChecked());
return true;
}
bool VImageHostingTab::loadUserName()
bool VImageHostingTab::loadGithubPersonalAccessToken()
{
m_userNameEdit->setText(g_config->getUserName());
m_githubPersonalAccessTokenEdit->setText(g_config->getGithubPersonalAccessToken());
return true;
}
bool VImageHostingTab::saveUserName()
bool VImageHostingTab::saveGithubPersonalAccessToken()
{
g_config->setUserName(m_userNameEdit->text());
g_config->setGithubPersonalAccessToken(m_githubPersonalAccessTokenEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadGithubReposName()
{
m_githubRepoNameEdit->setText(g_config->getGithubReposName());
return true;
}
bool VImageHostingTab::saveGithubReposName()
{
g_config->setGithubReposName(m_githubRepoNameEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadGithubUserName()
{
m_githubUserNameEdit->setText(g_config->getGithubUserName());
return true;
}
bool VImageHostingTab::saveGithubUserName()
{
g_config->setGithubUserName(m_githubUserNameEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadGithubKeepImgScale()
{
m_githubKeepImgScaleCB->setChecked(g_config->getGithubKeepImgScale());
return true;
}
bool VImageHostingTab::saveGithubKeepImgScale()
{
g_config->setGithubKeepImgScale(m_githubKeepImgScaleCB->isChecked());
return true;
}
bool VImageHostingTab::loadGithubDoNotReplaceLink()
{
m_githubDoNotReplaceLinkCB->setChecked(g_config->getGithubDoNotReplaceLink());
return true;
}
bool VImageHostingTab::saveGithubDoNotReplaceLink()
{
g_config->setGithubDoNotReplaceLink(m_githubDoNotReplaceLinkCB->isChecked());
return true;
}
bool VImageHostingTab::loadTencentAccessDomainName()
{
m_tencentAccessDomainNameEdit->setText(g_config->getTencentAccessDomainName());
return true;
}
bool VImageHostingTab::saveTencentAccessDomainName()
{
g_config->setTencentAccessDomainName(m_tencentAccessDomainNameEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadTencentSecretId()
{
m_tencentSecretIdEdit->setText(g_config->getTencentSecretId());
return true;
}
bool VImageHostingTab::saveTencentSecretId()
{
g_config->setTencentSecretId(m_tencentSecretIdEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadTencentSecretKey()
{
m_tencentSecretKeyEdit->setText(g_config->getTencentSecretKey());
return true;
}
bool VImageHostingTab::saveTencentSecretKey()
{
g_config->setTencentSecretKey(m_tencentSecretKeyEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadTencentKeepImgScale()
{
m_tencentKeepImgScaleCB->setChecked(g_config->getTencentKeepImgScale());
return true;
}
bool VImageHostingTab::saveTencentKeepImgScale()
{
g_config->setTencentKeepImgScale(m_tencentKeepImgScaleCB->isChecked());
return true;
}
bool VImageHostingTab::loadTencentDoNotReplaceLink()
{
m_tencentDoNotReplaceLinkCB->setChecked(g_config->getTencentDoNotReplaceLink());
return true;
}
bool VImageHostingTab::saveTencentDoNotReplaceLink()
{
g_config->setTencentDoNotReplaceLink(m_tencentDoNotReplaceLinkCB->isChecked());
return true;
}
bool VImageHostingTab::loadGiteePersonalAccessToken()
{
m_giteePersonalAccessTokenEdit->setText(g_config->getGiteePersonalAccessToken());
return true;
}
bool VImageHostingTab::saveGiteePersonalAccessToken()
{
g_config->setGiteePersonalAccessToken(m_giteePersonalAccessTokenEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadGiteeReposName()
{
m_giteeRepoNameEdit->setText(g_config->getGiteeReposName());
return true;
}
bool VImageHostingTab::saveGiteeReposName()
{
g_config->setGiteeReposName(m_giteeRepoNameEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadGiteeUserName()
{
m_giteeUserNameEdit->setText(g_config->getGiteeUserName());
return true;
}
bool VImageHostingTab::saveGiteeUserName()
{
g_config->setGiteeUserName(m_giteeUserNameEdit->text().trimmed());
return true;
}
bool VImageHostingTab::loadGiteeKeepImgScale()
{
m_giteeKeepImgScaleCB->setChecked(g_config->getGiteeKeepImgScale());
return true;
}
bool VImageHostingTab::saveGiteeKeepImgScale()
{
g_config->setGiteeKeepImgScale(m_giteeKeepImgScaleCB->isChecked());
return true;
}
bool VImageHostingTab::loadGiteeDoNotReplaceLink()
{
m_giteeDoNotReplaceLinkCB->setChecked(g_config->getGiteeDoNotReplaceLink());
return true;
}
bool VImageHostingTab::saveGiteeDoNotReplaceLink()
{
g_config->setGiteeDoNotReplaceLink(m_giteeDoNotReplaceLinkCB->isChecked());
return true;
}
bool VImageHostingTab::loadConfiguration()
{
if(!loadpersonalAccessToken()){
if(!loadGithubPersonalAccessToken()){
return false;
}
if(!loadReposName()){
if(!loadGithubReposName()){
return false;
}
if(!loadUserName()){
if(!loadGithubUserName()){
return false;
}
if(!loadAppid()){
if(!loadGithubKeepImgScale()){
return false;
}
if(!loadSecret()){
if(!loadGithubDoNotReplaceLink()){
return false;
}
if(!loadGiteePersonalAccessToken()){
return false;
}
if(!loadGiteeReposName()){
return false;
}
if(!loadGiteeUserName()){
return false;
}
if(!loadGiteeKeepImgScale()){
return false;
}
if(!loadGiteeDoNotReplaceLink()){
return false;
}
if(!loadWechatAppid()){
return false;
}
if(!loadWechatSecret()){
return false;
}
if(!loadMarkdown2WechatToolUrl()){
return false;
}
if(!loadWechatKeepImgScale()){
return false;
}
if(!loadWechatDoNotReplaceLink()){
return false;
}
if(!loadTencentAccessDomainName()){
return false;
}
if(!loadTencentSecretId()){
return false;
}
if(!loadTencentSecretKey()){
return false;
}
if(!loadTencentKeepImgScale()){
return false;
}
if(!loadTencentDoNotReplaceLink()){
return false;
}
return true;
}
bool VImageHostingTab::saveConfiguration()
{
if(!savepersonalAccessToken()){
if(!saveGithubPersonalAccessToken()){
return false;
}
if(!saveReposName()){
if(!saveGithubReposName()){
return false;
}
if(!saveUserName()){
if(!saveGithubUserName()){
return false;
}
if(!saveAppid()){
if(!saveGithubKeepImgScale()){
return false;
}
if(!saveSecret()){
if(!saveGithubDoNotReplaceLink()){
return false;
}
if(!saveGiteePersonalAccessToken()){
return false;
}
if(!saveGiteeReposName()){
return false;
}
if(!saveGiteeUserName()){
return false;
}
if(!saveGiteeKeepImgScale()){
return false;
}
if(!saveGiteeDoNotReplaceLink()){
return false;
}
if(!saveWechatAppid()){
return false;
}
if(!saveWechatSecret()){
return false;
}
if(!saveMarkdown2WechatToolUrl()){
return false;
}
if(!saveWechatKeepImgScale()){
return false;
}
if(!saveWechatDoNotReplaceLink()){
return false;
}
if(!saveTencentAccessDomainName()){
return false;
}
if(!saveTencentSecretId()){
return false;
}
if(!saveTencentSecretKey()){
return false;
}
if(!saveTencentKeepImgScale()){
return false;
}
if(!saveTencentDoNotReplaceLink()){
return false;
}
return true;
}

View File

@ -280,36 +280,93 @@ public:
bool saveConfiguration();
private:
bool loadpersonalAccessToken();
bool savepersonalAccessToken();
bool loadGithubPersonalAccessToken();
bool saveGithubPersonalAccessToken();
bool loadReposName();
bool saveReposName();
bool loadGithubReposName();
bool saveGithubReposName();
bool loadUserName();
bool saveUserName();
bool loadGithubUserName();
bool saveGithubUserName();
bool loadAppid();
bool saveAppid();
bool loadGithubKeepImgScale();
bool saveGithubKeepImgScale();
bool loadSecret();
bool saveSecret();
bool loadGithubDoNotReplaceLink();
bool saveGithubDoNotReplaceLink();
bool loadWechatAppid();
bool saveWechatAppid();
bool loadWechatSecret();
bool saveWechatSecret();
bool loadMarkdown2WechatToolUrl();
bool saveMarkdown2WechatToolUrl();
// personalAccessToken
VLineEdit *m_personalAccessTokenEdit;
// reposName
VLineEdit *m_repoNameEdit;
// userName
VLineEdit *m_userNameEdit;
// appid
VLineEdit *m_appidEdit;
// secret
VLineEdit *m_secretEdit;
// markdown to wechat tools url
bool loadWechatKeepImgScale();
bool saveWechatKeepImgScale();
bool loadWechatDoNotReplaceLink();
bool saveWechatDoNotReplaceLink();
bool loadTencentAccessDomainName();
bool saveTencentAccessDomainName();
bool loadTencentSecretId();
bool saveTencentSecretId();
bool loadTencentSecretKey();
bool saveTencentSecretKey();
bool loadTencentKeepImgScale();
bool saveTencentKeepImgScale();
bool loadTencentDoNotReplaceLink();
bool saveTencentDoNotReplaceLink();
bool loadGiteePersonalAccessToken();
bool saveGiteePersonalAccessToken();
bool loadGiteeReposName();
bool saveGiteeReposName();
bool loadGiteeUserName();
bool saveGiteeUserName();
bool loadGiteeKeepImgScale();
bool saveGiteeKeepImgScale();
bool loadGiteeDoNotReplaceLink();
bool saveGiteeDoNotReplaceLink();
// Github configuration edit.
VLineEdit *m_githubPersonalAccessTokenEdit;
VLineEdit *m_githubRepoNameEdit;
VLineEdit *m_githubUserNameEdit;
QCheckBox *m_githubKeepImgScaleCB;
QCheckBox *m_githubDoNotReplaceLinkCB;
// Gitee configuration edit.
VLineEdit *m_giteePersonalAccessTokenEdit;
VLineEdit *m_giteeRepoNameEdit;
VLineEdit *m_giteeUserNameEdit;
QCheckBox *m_giteeKeepImgScaleCB;
QCheckBox *m_giteeDoNotReplaceLinkCB;
// Wechat configuration edit.
VLineEdit *m_wechatAppidEdit;
VLineEdit *m_wechatSecretEdit;
VLineEdit *m_markdown2WechatToolUrlEdit;
QCheckBox *m_wechatKeepImgScaleCB;
QCheckBox *m_wechatDoNotReplaceLinkCB;
// Tencent configuration edit.
VLineEdit *m_tencentAccessDomainNameEdit;
VLineEdit *m_tencentSecretIdEdit;
VLineEdit *m_tencentSecretKeyEdit;
QCheckBox *m_tencentKeepImgScaleCB;
QCheckBox *m_tencentDoNotReplaceLinkCB;
};
class VSettingsDialog : public QDialog

View File

@ -1,12 +1,28 @@
[global]
; Wechat Image Hosting
wechat_appid=
wechat_secret=
wechat_markdown_to_wechat_tool_url=
; Github Image Hosting
github_personal_access_token=
github_repos_name=
github_user_name=
github_keep_img_scale=
github_do_not_replace_link=
; Gitee Image Hosting
gitee_personal_access_token=
gitee_repos_name=
gitee_user_name=
gitee_keep_img_scale=
gitee_do_not_replace_link=
; Wechat Image Hosting
wechat_appid=
wechat_secret=
wechat_markdown_to_wechat_tool_url=
wechat_keep_img_scale=
wechat_do_not_replace_link=
; Tencent Image Hosting
tencent_access_domain_name=
tencent_secret_id=
tencent_secret_key=
tencent_keep_img_scale=
tencent_do_not_replace_link=
; Theme name
theme=v_pure

View File

@ -79,13 +79,29 @@ void VConfigManager::initialize()
initCodeBlockCssStyles();
m_personalAccessToken = getConfigFromSettings("global", "github_personal_access_token").toString();
m_reposName = getConfigFromSettings("global", "github_repos_name").toString();
m_userName = getConfigFromSettings("global", "github_user_name").toString();
m_githubPersonalAccessToken = getConfigFromSettings("global", "github_personal_access_token").toString();
m_githubReposName = getConfigFromSettings("global", "github_repos_name").toString();
m_githubUserName = getConfigFromSettings("global", "github_user_name").toString();
m_githubKeepImgScale = getConfigFromSettings("global", "github_keep_img_scale").toBool();
m_githubDoNotReplaceLink = getConfigFromSettings("global", "github_do_not_replace_link").toBool();
m_appid = getConfigFromSettings("global", "wechat_appid").toString();
m_secret = getConfigFromSettings("global", "wechat_secret").toString();
m_giteePersonalAccessToken = getConfigFromSettings("global", "gitee_personal_access_token").toString();
m_giteeReposName = getConfigFromSettings("global", "gitee_repos_name").toString();
m_giteeUserName = getConfigFromSettings("global", "gitee_user_name").toString();
m_giteeKeepImgScale = getConfigFromSettings("global", "gitee_keep_img_scale").toBool();
m_giteeDoNotReplaceLink = getConfigFromSettings("global", "gitee_do_not_replace_link").toBool();
m_wechatAppid = getConfigFromSettings("global", "wechat_appid").toString();
m_wechatSecret = getConfigFromSettings("global", "wechat_secret").toString();
m_markdown2WechatToolUrl = getConfigFromSettings("global", "wechat_markdown_to_wechat_tool_url").toString();
m_wechatKeepImgScale = getConfigFromSettings("global", "wechat_keep_img_scale").toBool();
m_wechatDoNotReplaceLink = getConfigFromSettings("global", "wechat_do_not_replace_link").toBool();
m_tencentAccessDomainName = getConfigFromSettings("global", "tencent_access_domain_name").toString();
m_tencentSecretId = getConfigFromSettings("global", "tencent_secret_id").toString();
m_tencentSecretKey = getConfigFromSettings("global", "tencent_secret_key").toString();
m_tencentKeepImgScale = getConfigFromSettings("global", "tencent_keep_img_scale").toBool();
m_tencentDoNotReplaceLink = getConfigFromSettings("global", "tencent_do_not_replace_link").toBool();
m_theme = getConfigFromSettings("global", "theme").toString();

View File

@ -648,26 +648,69 @@ public:
bool getEnableCodeBlockCopyButton() const;
// github image hosting setting
const QString &getpersonalAccessToken() const;
void setpersonalAccessToken(const QString &p_token);
// Github image hosting setting.
const QString &getGithubPersonalAccessToken() const;
void setGithubPersonalAccessToken(const QString &p_token);
const QString &getReposName() const;
void setReposName(const QString &p_reposName);
const QString &getGithubReposName() const;
void setGithubReposName(const QString &p_reposName);
const QString &getUserName() const;
void setUserName(const QString &p_userName);
const QString &getGithubUserName() const;
void setGithubUserName(const QString &p_userName);
// wechat image hosting setting
const QString &getAppid() const;
void setAppid(const QString &p_appid);
const bool &getGithubKeepImgScale() const;
void setGithubKeepImgScale(const bool &p_githubKeepImgScale);
const QString &getSecret() const;
void setSecret(const QString &p_secret);
const bool &getGithubDoNotReplaceLink() const;
void setGithubDoNotReplaceLink(const bool &p_githubDoNotReplaceLink);
// Gitee image hosting setting.
const QString &getGiteePersonalAccessToken() const;
void setGiteePersonalAccessToken(const QString &p_token);
const QString &getGiteeReposName() const;
void setGiteeReposName(const QString &p_reposName);
const QString &getGiteeUserName() const;
void setGiteeUserName(const QString &p_userName);
const bool &getGiteeKeepImgScale() const;
void setGiteeKeepImgScale(const bool &p_giteeKeepImgScale);
const bool &getGiteeDoNotReplaceLink() const;
void setGiteeDoNotReplaceLink(const bool &p_giteeDoNotReplaceLink);
// Wechat image hosting setting.
const QString &getWechatAppid() const;
void setWechatAppid(const QString &p_appid);
const QString &getWechatSecret() const;
void setWechatSecret(const QString &p_secret);
const QString &getMarkdown2WechatToolUrl() const;
void setMarkdown2WechatToolUrl(const QString &p_markdown2WechatToolUrl);
const bool &getWechatKeepImgScale() const;
void setWechatKeepImgScale(const bool &p_wechatKeepImgScale);
const bool &getWechatDoNotReplaceLink() const;
void setWechatDoNotReplaceLink(const bool &p_wechatDoNotReplaceLink);
// Tencent image hosting setting.
const QString &getTencentAccessDomainName() const;
void setTencentAccessDomainName(const QString &p_accessDomainName);
const QString &getTencentSecretId() const;
void setTencentSecretId(const QString &p_secretId);
const QString &getTencentSecretKey() const;
void setTencentSecretKey(const QString &p_secretKey);
const bool &getTencentKeepImgScale() const;
void setTencentKeepImgScale(const bool &p_tencentKeepImgScale);
const bool &getTencentDoNotReplaceLink() const;
void setTencentDoNotReplaceLink(const bool &p_tencentDoNotReplaceLink);
private:
void initEditorConfigs();
@ -1092,15 +1135,33 @@ private:
QString m_plantUMLCmd;
// github imagebed
QString m_personalAccessToken;
QString m_reposName;
QString m_userName;
// Github image hosting.
QString m_githubPersonalAccessToken;
QString m_githubReposName;
QString m_githubUserName;
bool m_githubKeepImgScale;
bool m_githubDoNotReplaceLink;
// wechat imagebed
QString m_appid;
QString m_secret;
// Gitee image hosting.
QString m_giteePersonalAccessToken;
QString m_giteeReposName;
QString m_giteeUserName;
bool m_giteeKeepImgScale;
bool m_giteeDoNotReplaceLink;
// Wechat image hosting.
QString m_wechatAppid;
QString m_wechatSecret;
QString m_markdown2WechatToolUrl;
bool m_wechatKeepImgScale;
bool m_wechatDoNotReplaceLink;
// Tencent image hosting.
QString m_tencentAccessDomainName;
QString m_tencentSecretId;
QString m_tencentSecretKey;
bool m_tencentKeepImgScale;
bool m_tencentDoNotReplaceLink;
// Size of history.
int m_historySize;
@ -3020,31 +3081,181 @@ inline bool VConfigManager::getEnableCodeBlockCopyButton() const
return m_enableCodeBlockCopyButton;
}
inline const QString &VConfigManager::getAppid() const
inline const QString &VConfigManager::getGithubPersonalAccessToken() const
{
return m_appid;
return m_githubPersonalAccessToken;
}
inline void VConfigManager::setAppid(const QString &p_appid)
inline void VConfigManager::setGithubPersonalAccessToken(const QString &p_token)
{
if(m_appid == p_appid){
if (m_githubPersonalAccessToken == p_token) {
return;
}
m_appid = p_appid;
m_githubPersonalAccessToken = p_token;
setConfigToSettings("global", "github_personal_access_token", p_token);
}
inline const QString &VConfigManager::getGithubReposName() const
{
return m_githubReposName;
}
inline void VConfigManager::setGithubReposName(const QString &p_reposName)
{
if (m_githubReposName == p_reposName) {
return;
}
m_githubReposName = p_reposName;
setConfigToSettings("global", "github_repos_name", p_reposName);
}
inline const QString &VConfigManager::getGithubUserName() const
{
return m_githubUserName;
}
inline void VConfigManager::setGithubUserName(const QString &p_userName)
{
if (m_githubUserName == p_userName) {
return;
}
m_githubUserName = p_userName;
setConfigToSettings("global", "github_user_name", p_userName);
}
inline const bool &VConfigManager::getGithubKeepImgScale() const
{
return m_githubKeepImgScale;
}
inline void VConfigManager::setGithubKeepImgScale(const bool &p_githubKeepImgScale)
{
if (m_githubKeepImgScale == p_githubKeepImgScale) {
return;
}
m_githubKeepImgScale = p_githubKeepImgScale;
setConfigToSettings("global", "github_keep_img_scale", p_githubKeepImgScale);
}
inline const bool &VConfigManager::getGithubDoNotReplaceLink() const
{
return m_githubDoNotReplaceLink;
}
inline void VConfigManager::setGithubDoNotReplaceLink(const bool &p_githubDoNotReplaceLink)
{
if (m_githubDoNotReplaceLink == p_githubDoNotReplaceLink) {
return;
}
m_githubDoNotReplaceLink = p_githubDoNotReplaceLink;
setConfigToSettings("global", "github_do_not_replace_link", p_githubDoNotReplaceLink);
}
inline const QString &VConfigManager::getGiteePersonalAccessToken() const
{
return m_giteePersonalAccessToken;
}
inline void VConfigManager::setGiteePersonalAccessToken(const QString &p_giteePersonalAccessToken)
{
if (m_giteePersonalAccessToken == p_giteePersonalAccessToken) {
return;
}
m_giteePersonalAccessToken = p_giteePersonalAccessToken;
setConfigToSettings("global", "gitee_personal_access_token", p_giteePersonalAccessToken);
}
inline const QString &VConfigManager::getGiteeReposName() const
{
return m_giteeReposName;
}
inline void VConfigManager::setGiteeReposName(const QString &p_giteeReposName)
{
if (m_giteeReposName == p_giteeReposName) {
return;
}
m_giteeReposName = p_giteeReposName;
setConfigToSettings("global", "gitee_repos_name", p_giteeReposName);
}
inline const QString &VConfigManager::getGiteeUserName() const
{
return m_giteeUserName;
}
inline void VConfigManager::setGiteeUserName(const QString &p_giteeUserName)
{
if (m_giteeUserName == p_giteeUserName) {
return;
}
m_giteeUserName = p_giteeUserName;
setConfigToSettings("global", "gitee_user_name", p_giteeUserName);
}
inline const bool &VConfigManager::getGiteeKeepImgScale() const
{
return m_giteeKeepImgScale;
}
inline void VConfigManager::setGiteeKeepImgScale(const bool &p_giteeKeepImgScale)
{
if (m_giteeKeepImgScale == p_giteeKeepImgScale) {
return;
}
m_giteeKeepImgScale = p_giteeKeepImgScale;
setConfigToSettings("global", "gitee_keep_img_scale", p_giteeKeepImgScale);
}
inline const bool &VConfigManager::getGiteeDoNotReplaceLink() const
{
return m_giteeDoNotReplaceLink;
}
inline void VConfigManager::setGiteeDoNotReplaceLink(const bool &p_giteeDoNotReplaceLink)
{
if (m_giteeDoNotReplaceLink == p_giteeDoNotReplaceLink) {
return;
}
m_giteeDoNotReplaceLink = p_giteeDoNotReplaceLink;
setConfigToSettings("global", "gitee_do_not_replace_link", p_giteeDoNotReplaceLink);
}
inline const QString &VConfigManager::getWechatAppid() const
{
return m_wechatAppid;
}
inline void VConfigManager::setWechatAppid(const QString &p_appid)
{
if(m_wechatAppid == p_appid){
return;
}
m_wechatAppid = p_appid;
setConfigToSettings("global", "wechat_appid", p_appid);
}
inline const QString &VConfigManager::getSecret() const
inline const QString &VConfigManager::getWechatSecret() const
{
return m_secret;
return m_wechatSecret;
}
inline void VConfigManager::setSecret(const QString &p_secret)
inline void VConfigManager::setWechatSecret(const QString &p_secret)
{
if(m_secret == p_secret){
if(m_wechatSecret == p_secret){
return;
}
m_secret = p_secret;
m_wechatSecret = p_secret;
setConfigToSettings("global", "wechat_secret", p_secret);
}
@ -3062,50 +3273,109 @@ inline void VConfigManager::setMarkdown2WechatToolUrl(const QString &p_markdown2
setConfigToSettings("global", "wechat_markdown_to_wechat_tool_url", p_markdown2WechatToolUrl);
}
inline const QString &VConfigManager::getpersonalAccessToken() const
inline const bool &VConfigManager::getWechatKeepImgScale() const
{
return m_personalAccessToken;
return m_wechatKeepImgScale;
}
inline void VConfigManager::setpersonalAccessToken(const QString &p_token)
inline void VConfigManager::setWechatKeepImgScale(const bool &p_wechatKeepImgScale)
{
if (m_personalAccessToken == p_token) {
if (m_wechatKeepImgScale == p_wechatKeepImgScale) {
return;
}
m_personalAccessToken = p_token;
setConfigToSettings("global", "github_personal_access_token", p_token);
m_wechatKeepImgScale = p_wechatKeepImgScale;
setConfigToSettings("global", "wechat_keep_img_scale", p_wechatKeepImgScale);
}
inline const QString &VConfigManager::getReposName() const
inline const bool &VConfigManager::getWechatDoNotReplaceLink() const
{
return m_reposName;
return m_wechatDoNotReplaceLink;
}
inline void VConfigManager::setReposName(const QString &p_reposName)
inline void VConfigManager::setWechatDoNotReplaceLink(const bool &p_wechatDoNotReplaceLink)
{
if (m_reposName == p_reposName) {
if (m_wechatDoNotReplaceLink == p_wechatDoNotReplaceLink) {
return;
}
m_reposName = p_reposName;
setConfigToSettings("global", "github_repos_name", p_reposName);
m_wechatDoNotReplaceLink = p_wechatDoNotReplaceLink;
setConfigToSettings("global", "wechat_do_not_replace_link", p_wechatDoNotReplaceLink);
}
inline const QString &VConfigManager::getUserName() const
inline const QString &VConfigManager::getTencentAccessDomainName() const
{
return m_userName;
return m_tencentAccessDomainName;
}
inline void VConfigManager::setUserName(const QString &p_userName)
inline void VConfigManager::setTencentAccessDomainName(const QString &p_accessDomainName)
{
if (m_userName == p_userName) {
if (m_tencentAccessDomainName == p_accessDomainName) {
return;
}
m_userName = p_userName;
setConfigToSettings("global", "github_user_name", p_userName);
m_tencentAccessDomainName = p_accessDomainName;
setConfigToSettings("global", "tencent_access_domain_name", p_accessDomainName);
}
inline const QString &VConfigManager::getTencentSecretId() const
{
return m_tencentSecretId;
}
inline void VConfigManager::setTencentSecretId(const QString &p_secretId)
{
if (m_tencentSecretId == p_secretId) {
return;
}
m_tencentSecretId = p_secretId;
setConfigToSettings("global", "tencent_secret_id", p_secretId);
}
inline const QString &VConfigManager::getTencentSecretKey() const
{
return m_tencentSecretKey;
}
inline void VConfigManager::setTencentSecretKey(const QString &p_secretKey)
{
if (m_tencentSecretKey == p_secretKey) {
return;
}
m_tencentSecretKey = p_secretKey;
setConfigToSettings("global", "tencent_secret_key", p_secretKey);
}
inline const bool &VConfigManager::getTencentKeepImgScale() const
{
return m_tencentKeepImgScale;
}
inline void VConfigManager::setTencentKeepImgScale(const bool &p_tencentKeepImgScale)
{
if (m_tencentKeepImgScale == p_tencentKeepImgScale) {
return;
}
m_tencentKeepImgScale = p_tencentKeepImgScale;
setConfigToSettings("global", "tencent_keep_img_scale", p_tencentKeepImgScale);
}
inline const bool &VConfigManager::getTencentDoNotReplaceLink() const
{
return m_tencentDoNotReplaceLink;
}
inline void VConfigManager::setTencentDoNotReplaceLink(const bool &p_tencentDoNotReplaceLink)
{
if (m_tencentDoNotReplaceLink == p_tencentDoNotReplaceLink) {
return;
}
m_tencentDoNotReplaceLink = p_tencentDoNotReplaceLink;
setConfigToSettings("global", "tencent_do_not_replace_link", p_tencentDoNotReplaceLink);
}
#endif // VCONFIGMANAGER_H

File diff suppressed because it is too large Load Diff

View File

@ -13,6 +13,8 @@
#include <QApplication>
#include <vfile.h>
#include <QClipboard>
#include <QCryptographicHash>
#include <QRegExp>
class VGithubImageHosting : public QObject
{
@ -26,17 +28,17 @@ public:
// Upload a single image.
void githubImageBedUploadImage(const QString &p_username,
const QString &p_repository,
const QString &p_image_path,
const QString &p_imagePath,
const QString &p_token);
// Parameters needed to generate uploaded images.
QString githubImageBedGenerateParam(const QString p_image_path);
QString githubImageBedGenerateParam(const QString p_imagePath);
// Control image to upload.
void githubImageBedUploadManager();
// Replace old links with new ones for images.
void githubImageBedReplaceLink(const QString p_file_content, const QString p_file_path);
void githubImageBedReplaceLink(QString p_fileContent, const QString p_filePath);
// Process the image upload request to GitHub.
void handleUploadImageToGithubRequested();
@ -67,10 +69,64 @@ private:
QString currentUploadImage;
// Image upload status.
bool uploadImageStatus;
// Token returned after successful wechat authentication.
QString wechatAccessToken;
// Relative image path currently Uploaded.
QString currentUploadRelativeImagePah;
VFile *m_file;
};
class VGiteeImageHosting : public QObject
{
Q_OBJECT
public:
explicit VGiteeImageHosting(VFile *p_file, QWidget *p_parent = nullptr);
// GitHub identity authentication.
void authenticateGiteeImageHosting(const QString &p_username,
const QString &p_repository,
const QString &p_token);
// Upload a single image.
void giteeImageBedUploadImage(const QString &p_username,
const QString &p_repository,
const QString &p_imagePath,
const QString &p_token);
// Parameters needed to generate uploaded images.
QString giteeImageBedGenerateParam(const QString &p_imagePath, const QString &p_token);
// Control image to upload.
void giteeImageBedUploadManager();
// Replace old links with new ones for images.
void giteeImageBedReplaceLink(QString p_fileContent, const QString p_filePath);
// Process the image upload request to Gitee.
void handleUploadImageToGiteeRequested();
public slots:
// Gitee image hosting identity authentication completed.
void giteeImageBedAuthFinished();
// Gitee image hosting upload completed.
void giteeImageBedUploadFinished();
private:
QNetworkAccessManager manager;
QNetworkReply *reply;
QMap<QString, QString> imageUrlMap;
// Similar to "_v_image/".
QString imageBasePath;
// Replace the file content with the new link.
QString newFileContent;
// Whether the picture has been uploaded successfully.
bool imageUploaded;
// Image upload progress bar.
QProgressDialog *proDlg;
// Total number of images to upload.
int uploadImageCount;
int uploadImageCountIndex;
// Currently uploaded picture name.
QString currentUploadImage;
// Image upload status.
bool uploadImageStatus;
VFile *m_file;
};
@ -87,10 +143,10 @@ public:
void wechatImageBedUploadManager();
// Replace old links with new ones for images.
void wechatImageBedReplaceLink(const QString p_file_content);
void wechatImageBedReplaceLink(QString &p_fileContent, const QString &p_filePath);
// Upload a single image.
void wechatImageBedUploadImage(const QString p_image_path, const QString p_token);
void wechatImageBedUploadImage(const QString p_imagePath, const QString p_token);
// Process image upload request to wechat.
void handleUploadImageToWechatRequested();
@ -128,4 +184,65 @@ private:
VFile *m_file;
};
class VTencentImageHosting : public QObject
{
Q_OBJECT
public:
explicit VTencentImageHosting(VFile *p_file, QWidget *p_parent = nullptr);
QByteArray hmacSha1(const QByteArray &p_key, const QByteArray &p_baseString);
QString getAuthorizationString(const QString &p_secretId,
const QString &p_secretKey,
const QString &p_imgName);
void findAndStartUploadImage();
QByteArray getImgContent(const QString &p_imagePath);
// Control image to upload.
void tencentImageBedUploadManager();
// Replace old links with new ones for images.
void tencentImageBedReplaceLink(QString &p_fileContent, const QString &p_filePath);
// Upload a single image.
void tencentImageBedUploadImage(const QString &p_imagePath,
const QString &p_accessDomainName,
const QString &p_secretId,
const QString &p_secretKey);
// Process image upload request to tencent.
void handleUploadImageToTencentRequested();
public slots:
// Tencent image hosting upload completed.
void tencentImageBedUploadFinished();
private:
QNetworkAccessManager manager;
QNetworkReply *reply;
QMap<QString, QString> imageUrlMap;
// Similar to "_v_image/".
QString imageBasePath;
// Replace the file content with the new link.
QString newFileContent;
// Whether the picture has been uploaded successfully.
bool imageUploaded;
// Image upload progress bar.
QProgressDialog *proDlg;
// Total number of images to upload.
int uploadImageCount;
int uploadImageCountIndex;
// Currently uploaded picture name.
QString currentUploadImage;
// Image upload status
bool uploadImageStatus;
// Token returned after successful wechat authentication.
QString wechatAccessToken;
// Relative image path currently Uploaded.
QString currentUploadRelativeImagePah;
QString new_file_name;
VFile *m_file;
};
#endif // VGITHUBIMAGEHOSTING_H

View File

@ -115,7 +115,9 @@ void VMdTab::setupUI()
// The following is the image hosting initialization
vGithubImageHosting = new VGithubImageHosting(m_file, this);
vGiteeImageHosting = new VGiteeImageHosting(m_file, this);
vWechatImageHosting = new VWechatImageHosting(m_file, this);
vTencentImageHosting = new VTencentImageHosting(m_file, this);
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(m_splitter);
@ -450,8 +452,12 @@ void VMdTab::setupMarkdownViewer()
connect(m_webViewer, &VWebView::requestUploadImageToGithub,
this, &VMdTab::handleUploadImageToGithubRequested);
connect(m_webViewer, &VWebView::requestUploadImageToGitee,
this, &VMdTab::handleUploadImageToGiteeRequested);
connect(m_webViewer, &VWebView::requestUploadImageToWechat,
this, &VMdTab::handleUploadImageToWechatRequested);
connect(m_webViewer, &VWebView::requestUploadImageToTencent,
this, &VMdTab::handleUploadImageToTencentRequested);
VPreviewPage *page = new VPreviewPage(m_webViewer);
m_webViewer->setPage(page);
@ -1517,11 +1523,21 @@ void VMdTab::handleUploadImageToGithubRequested()
vGithubImageHosting->handleUploadImageToGithubRequested();
}
void VMdTab::handleUploadImageToGiteeRequested()
{
vGiteeImageHosting->handleUploadImageToGiteeRequested();
}
void VMdTab::handleUploadImageToWechatRequested()
{
vWechatImageHosting->handleUploadImageToWechatRequested();
}
void VMdTab::handleUploadImageToTencentRequested()
{
vTencentImageHosting->handleUploadImageToTencentRequested();
}
VWordCountInfo VMdTab::fetchWordCountInfo(bool p_editMode) const
{
if (p_editMode) {

View File

@ -162,12 +162,18 @@ private slots:
// Selection changed in web.
void handleWebSelectionChanged();
// Process the image upload request to GitHub
// Process the image upload request to GitHub.
void handleUploadImageToGithubRequested();
// Process image upload request to wechat
// Process the image upload request to Gitee.
void handleUploadImageToGiteeRequested();
// Process image upload request to wechat.
void handleUploadImageToWechatRequested();
// Process image upload request to tencent.
void handleUploadImageToTencentRequested();
private:
enum TabReady { None = 0, ReadMode = 0x1, EditMode = 0x2 };
@ -286,7 +292,9 @@ private:
int m_documentID;
VGithubImageHosting *vGithubImageHosting;
VGiteeImageHosting *vGiteeImageHosting;
VWechatImageHosting *vWechatImageHosting;
VTencentImageHosting * vTencentImageHosting;
};
inline VMdEditor *VMdTab::getEditor()

View File

@ -99,15 +99,30 @@ void VWebView::contextMenuEvent(QContextMenuEvent *p_event)
this, &VWebView::requestSavePage);
menu->addAction(savePageAct);
// In preview mode, add the right-click menu and upload the image to GitHub image hosting
QAction *uploadImageToGithub = new QAction(tr("Upload Image To &GitHub"),menu);
connect(uploadImageToGithub, &QAction::triggered, this, &VWebView::requestUploadImageToGithub);
menu->addAction(uploadImageToGithub);
// In preview mode, add the right-click upload menu.
QMenu *uploadImageMenu = new QMenu(tr("&Upload Image To"), menu);
// In preview mode, add the right-click menu and upload the image to Wechat image hosting
QAction *uploadImageToWechat = new QAction(tr("Upload Image To &Wechat"),menu);
// Upload the image to GitHub image hosting.
QAction *uploadImageToGithub = new QAction(tr("&GitHub"), uploadImageMenu);
connect(uploadImageToGithub, &QAction::triggered, this, &VWebView::requestUploadImageToGithub);
uploadImageMenu->addAction(uploadImageToGithub);
// Upload the image to Gitee image hosting.
QAction *uploadImageToGitee = new QAction(tr("&Gitee"), uploadImageMenu);
connect(uploadImageToGitee, &QAction::triggered, this, &VWebView::requestUploadImageToGitee);
uploadImageMenu->addAction(uploadImageToGitee);
// Upload the image to Wechat image hosting
QAction *uploadImageToWechat = new QAction(tr("&Wechat"), uploadImageMenu);
connect(uploadImageToWechat, &QAction::triggered, this, &VWebView::requestUploadImageToWechat);
menu->addAction(uploadImageToWechat);
uploadImageMenu->addAction(uploadImageToWechat);
// Upload the image to Tencent image hosting.
QAction *uploadImageToTencent = new QAction(tr("&Tencent"), uploadImageMenu);
connect(uploadImageToTencent, &QAction::triggered, this, &VWebView::requestUploadImageToTencent);
uploadImageMenu->addAction(uploadImageToTencent);
menu->addMenu(uploadImageMenu);
}
}

View File

@ -26,8 +26,12 @@ signals:
void requestUploadImageToGithub();
void requestUploadImageToGitee();
void requestUploadImageToWechat();
void requestUploadImageToTencent();
protected:
void contextMenuEvent(QContextMenuEvent *p_event);