开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 3 Fork 6

TKG/QtApp

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (3)
master
breakpad
HDTest
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (3)
master
breakpad
HDTest
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (3)
master
breakpad
HDTest
QtApp
/
Application.cpp
QtApp
/
Application.cpp
Application.cpp 4.56 KB
一键复制 编辑 原始数据 按行查看 历史
golei 提交于 2020年02月25日 21:29 +08:00 . copy exe
#include "Application.h"
#include <QDebug>
#include <QDir>
#include <QDateTime>
#include <QSharedMemory>
#include <QTranslator>
#ifdef Q_OS_WIN
#define NOMINMAX
#include <crash_report_database.h>
#include <settings.h>
#include <crashpad_client.h>
#else
#include <client/crash_report_database.h>
#include <client/settings.h>
#include <client/crashpad_client.h>
#endif
#include "common/QtAppMacro.h"
#include "helper/DirHelper.h"
#include "helper/ConfigHelper.h"
#include "log/TSpdlog.h"
bool Application::setSingleApp(const char* uniqueProgram)
{
#ifdef Q_OS_WIN
static QSharedMemory shm(uniqueProgram);
if(shm.create(2) == false){
return true;
}
return false;
#else
return false;
#endif
}
bool Application::init()
{
if (QString("") == REG_QT_APP_DATA || QString("") == APP_COMPANY_NAME || QString("") == APP_COMPANY_APP_NAME) {
qDebug() << "error :please set default value";
return false;
}
QApplication::setOrganizationName(APP_COMPANY_NAME);
QApplication::setOrganizationDomain(APP_COMPANY_URL);
QApplication::setApplicationName(APP_COMPANY_APP_NAME);
return true;
}
bool Application::startCrashHandler()
{
using namespace crashpad;
std::map<std::string, std::string> annotations;
std::vector<std::string> arguments;
CrashpadClient client;
bool rc;
/*
* ENSURE THIS VALUE IS CORRECT.
*
* This is the directory you will use to store and
* queue crash data.
*/
/*
* ENSURE THIS VALUE IS CORRECT.
*
* Crashpad has the ability to support crashes both in-process
* and out-of-process. The out-of-process handler is
* significantly more robust than traditional in-process crash
* handlers. This path may be relative.
*/
#ifdef Q_OS_WIN
std::wstring db_path(DirHelper::getInstance()->dumpPath().toStdWString().c_str());
std::wstring handler_path(L"crashpad_handler.exe");
#else
std::string db_path("/Users/sl/dump");
std::string handler_path("/Users/sl/dump/crashpad_handler");
#endif
/*
* YOU MUST CHANGE THIS VALUE.
*
* Update the <Universe> and <Token> in the below
*/
std::string url("your");
annotations["format"] = "";
annotations["token"] = "855a5c717a51bb13f45b5a899b592cb4eff29e345f676a79ae2cd4487f555406";
/*
* REMOVE THIS FOR ACTUAL BUILD.
*
* To disable crashpad’s default limitation of
* 1 upload per hour, pass the --no-rate-limit
* argument to the handler
*
*/
arguments.push_back("--no-rate-limit");
base::FilePath db(db_path);
base::FilePath handler(handler_path);
std::unique_ptr<CrashReportDatabase> database =
crashpad::CrashReportDatabase::Initialize(db);
if (database == nullptr || database->GetSettings() == NULL)
return false;
/* Enable automated uploads. */
database->GetSettings()->SetUploadsEnabled(true);
rc = client.StartHandler(handler,
db,
db,
url,
annotations,
arguments,
true,
true);
if (rc == false)
return false;
/* Optional, wait for Crashpad to initialize. */
#ifdef Q_OS_WIN
rc = client.WaitForHandlerStart(INFINITE);
if (rc == false)
return false;
#endif
return true;
}
Application::Application(int &argc, char **argv):QApplication(argc,argv)
{
initDir();
initConfig();
initLog();
qDebug() << "crash init:" << startCrashHandler();
}
Application::~Application()
{
}
void Application::initDir()
{
DirHelper::getInstance();
}
void Application::initLog()
{
QString path = DirHelper::getInstance()->logPath();
path = path + QDir::separator() + "MyAPP_" + QDateTime::currentDateTime().toString("yyyyMMdd") + ".log";
TSpdlog::registerLog(path.toStdString().c_str(),path.toStdString().c_str());
TSpdlog::getInstance();
}
void Application::initConfig()
{
ConfigHelper::getInstance();
}
bool Application::addTranslation()
{
/* 翻译文件 */
QTranslator *trans = new QTranslator;
QString path;
if (ConfigHelper::getInstance()->getLanguage() == "CN") {
path = DirHelper::getInstance()->getAppPath() + "/lang_Chinese.qm";
} else {
path = DirHelper::getInstance()->getAppPath() + "/lang_English.qm";
}
if (trans->load(path) ) {
installTranslator(trans);
return true;
} else {
TSpdlog::getInstance()->otherError("translator error" + path);
return false;
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

这是一个基于qt的通用程序模板,聚合常用必要得模块:日志模块、崩溃模块、数据目录模块、配置文件模块、翻译等
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/slcode/QtApp.git
git@gitee.com:slcode/QtApp.git
slcode
QtApp
QtApp
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /