代码拉取完成,页面将自动刷新
#include <QApplication>
#include <QLibraryInfo>
#include <QTranslator>
#include <QMessageBox>
#include <QScreen>
#include <QDebug>
#include <singleapplication.h>
#include "log.hpp"
#include "windowmanage.hpp"
#include <ui/mainwindow.h>
#include "dbus/dbusvfsinterface.h"
const QString VERSION = "1.0.9";
void installTranslator()
{
// 加载自定义翻译文件
QString tranPath("/usr/share/kylin-mobile-assistant/translations/");
QTranslator *tran = new QTranslator;
if (tran->load(QLocale(), QString("kylin-mobile-assistant"), QString("_"), tranPath)) {
QApplication::installTranslator(tran);
} else {
qWarning() << "Waring : load translation file fail";
}
// 加载qt翻译文件, 更改fileDialog英文
QString qtTransPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
QTranslator *tranQt = new QTranslator;
if (tranQt->load(QLocale(), QString("qt"), QString("_"), qtTransPath)) {
QApplication::installTranslator(tranQt);
} else {
qWarning() << "Waring : load qt translation file fail";
}
}
bool initVLC()
{
QFileInfo file("/bin/vlc");
return file.isExecutable();
}
int main(int argc, char *argv[])
{
qInstallMessageHandler(kabase::Log::logOutput);
setbuf(stdout, NULL);
// set env
#ifdef Q_OS_LINUX
qputenv("ADB_PATH", "/usr/lib/android-sdk/platform-tools/adb");
qputenv("SERVER_PATH", "/usr/share/kylin-mobile-assistant/scrcpy-server.jar");
qputenv("CONFIG_PATH", "/usr/share/kylin-mobile-assistant/config");
qputenv("KEYMAP_PATH", "/usr/share/kylin-mobile-assistant/keymap");
#endif
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
kabase::WindowManage::setScalingProperties();
kdk::QtSingleApplication app(argc, argv);
// update version
app.setApplicationVersion(VERSION);
if (app.isRunning()) {
qDebug() << "is running";
app.sendMessage("running , 4000");
return 0;
}
// 加载翻译
installTranslator();
// 加载sdk控件翻译
QTranslator trans;
QString locale = QLocale::system().name();
if (locale == "zh_CN") {
if (trans.load(":/translations/gui_zh_CN.qm")) {
app.installTranslator(&trans);
}
} else if (locale == "bo_CN") {
if (trans.load(":/translations/gui_bo_CN.qm")) {
app.installTranslator(&trans);
}
}
// 添加窗管协议
kabase::WindowManage::removeHeader(MainWindow::getInstance());
/* 移动到窗口中间 */
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
MainWindow::getInstance()->move(availableGeometry.width() / 2 - MainWindow::getInstance()->width() / 2,
availableGeometry.height() / 2 - MainWindow::getInstance()->height() / 2);
app.setActivationWindow(MainWindow::getInstance());
MainWindow::getInstance()->show();
if (!initVLC()) {
qCritical() << "vlc not installed!";
QMessageBox msgBox;
msgBox.setText(QObject::tr(
"In order to ensure the normal operation of the program, please install the VLC program first!"));
msgBox.setIcon(QMessageBox::Critical);
msgBox.exec();
MainWindow::getInstance()->close();
exit(1);
}
DbusVfsInterface vfsDbus;
QDBusConnection connection = QDBusConnection::sessionBus();
connection.registerService(KYLIN_MOBILE_SERVICE);
connection.registerObject(KYLIN_MOBILE_PATH, &vfsDbus,
QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals);
int ret = app.exec();
return ret;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。