1 Star 0 Fork 13

乐一/kylin-weather

forked from openKylin/kylin-weather 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.cpp 2.45 KB
一键复制 编辑 原始数据 按行查看 历史
公子文彬 提交于 2022-06-22 18:45 . Import Upstream version 3.2.0.3
#include "controller/core/viewcontrol.h"
#include <QApplication>
#include <QObject>
#include <signal.h>
#include <QDBusInterface>
#include <single_application/single_application.hpp>
#include <window_management.hpp>
#include <log.hpp>
//初始化核心,初始化前端,启动时是否展示界面
void controlView(kdk::kabase::QtSingleApplication &a, const QStringList &args, bool isStart)
{
//实例化viewcontrol
viewControl::getInstance()->initCore(args, isStart);
QObject::connect(&a, &kdk::kabase::QtSingleApplication::messageReceived, viewControl::getInstance(),
&viewControl::toShowView);
//激活窗口
a.setActivationWindow(viewControl::getInstance()->activeWindow());
}
int main(int argc, char *argv[])
{
//适配4K屏以及分数缩放
kdk::kabase::WindowManagement::setScalingProperties();
//日志输出
qInstallMessageHandler(kdk::kabase::Log::logOutput);
kdk::kabase::QtSingleApplication a(argc, argv);
a.setWindowIcon(QIcon::fromTheme("kylin-weather"));
//单例
if (a.isRunning()) {
qDebug() << "is running";
a.sendMessage("running , 4000");
return 0;
}
//翻译
QTranslator qt_trans;
QString locale = QLocale::system().name();
QString trans_path;
if (QDir("/usr/share/kylin-weather/translations").exists()) {
trans_path = "/usr/share/kylin-weather/translations";
} else {
trans_path = qApp->applicationDirPath() + "/translations";
}
QString qt_trans_path;
qt_trans_path = QLibraryInfo::location(QLibraryInfo::TranslationsPath); // /usr/share/qt5/translations
if (!qt_trans.load("qt_" + locale + ".qm", qt_trans_path)) {
qDebug() << "Load translation file:"
<< "qt_" + locale + ".qm from" << qt_trans_path << "failed!";
} else {
a.installTranslator(&qt_trans);
}
QTranslator sdk_trans;
if (sdk_trans.load(":/translations/gui_" + locale + ".qm")) {
a.installTranslator(&sdk_trans);
}
QTranslator app_trans;
if (!app_trans.load("kylin-weather_" + locale + ".qm", trans_path)) {
qDebug() << "Load translation file:"
<< "kylin-weather_" + locale + ".qm from" << trans_path << "failed!";
} else {
a.installTranslator(&app_trans);
}
//初始化后端前端,判断启动方式,是否带参
controlView(a, a.arguments(), !(argc == 2 && QLatin1String(argv[1]) == "showmainwindow"));
return a.exec();
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hrbeu2016053109/kylin-weather.git
git@gitee.com:hrbeu2016053109/kylin-weather.git
hrbeu2016053109
kylin-weather
kylin-weather
openkylin/yangtze

搜索帮助