代码拉取完成,页面将自动刷新
同步操作将从 openKylin/kylin-printer 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QTranslator>
#include <QLocale>
#include <QStandardPaths>
#include <QLibraryInfo>
#include <QDir>
#include <QMetaType>
#include <sys/inotify.h>
#include <fcntl.h>
#include <syslog.h>
#include <QGSettings>
#include <QDir>
#include <QObject>
#include <singleapplication.h>
#include "gsettings_monitor.h"
#include "device_monitor.h"
#include "mainwindow.h"
#include "common.h"
#include "log.h"
#include "find_and_match_ppds.h"
#include "daemonipcdbus.h"
#include "pop_window_manager.h"
#include "information_collector.h"
#include "windowmanage.hpp"
#include "base_info.h"
void addTrans()
{
//加载中文
QString qtTranslationsPath;
qtTranslationsPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);// /usr/share/qt5/translations
QString kylinPrinterTranslationsPath;
#ifndef TEST_DEBUG
if (QDir("/usr/share/kylin-printer/translations").exists()) {
kylinPrinterTranslationsPath = "/usr/share/kylin-printer/translations";
}
else {
kylinPrinterTranslationsPath = QApplication::applicationDirPath() + "/.qm";
}
#else
kylinPrinterTranslationsPath = QString(PROJECT_SOURCE_DIR) + "/translations";
#endif
qDebug () << kylinPrinterTranslationsPath;
QString locale = QLocale::system().name();
static QTranslator trans_global, trans_menu, trans_dict, trans_sdk;
if(!trans_global.load("kylin-printer_" + locale + ".qm", kylinPrinterTranslationsPath))
qDebug() << "Load translations file" <<QLocale() << "failed!";
else
QApplication::installTranslator(&trans_global);
if(!trans_dict.load("kylin-printer_dict_" + locale + ".qm", kylinPrinterTranslationsPath))
qDebug() << "Load translations file" <<QLocale() << "failed!";
else
QApplication::installTranslator(&trans_dict);
if(!trans_menu.load("qt_" + locale + ".qm", qtTranslationsPath))
qDebug() << "Load translations file" <<QLocale() << "failed!";
else
QApplication::installTranslator(&trans_menu);
if(!trans_sdk.load(":/translations/gui_" + locale + ".qm"))
qDebug() << "Load translations file" <<QLocale() << "failed!";
else
QApplication::installTranslator(&trans_sdk);
}
int main(int argc, char *argv[])
{
// 统一日志输出
#ifndef TEST_DEBUG
qInstallMessageHandler(logOutput);
#else
qInstallMessageHandler(myMessageOutput);
#endif
InformationCollector::getInstance().addMessage("打印机应用启动!");
qRegisterMetaType<ProtocolType>("ProtocolType");
qRegisterMetaType<DeviceInformation>("DeviceInformation");
qRegisterMetaType<DeviceInformation>("DeviceInformation&");
qRegisterMetaType<ppdPrinterMap>("ppdPrinterMap");
qRegisterMetaType<QString>("QString&");
//高清屏幕自适应,适配990高DPI
kabase::WindowManage::setScalingProperties();
kdk::QtSingleApplication app(argc, argv);
if (app.isRunning()) {
qDebug() << "is running";
app.sendMessage("running , 4000");
return 0;
}
QStringList cmd = app.arguments();
cmd.removeFirst();
if (checkCommand(cmd) == CHECK_FALSE) {
qDebug() << "UNKNOWN COMMAND:" << cmd;
return 0;
}
if(!GsettingsMonitor::getInstance()->gsettingsCheck())
{
app.setProperty("noChangeSystemFontSize",true);
}
addTrans();
BaseInfo::instance();
app.setApplicationName(BaseInfo::instance().getAppDisplayName());
app.setApplicationVersion(PROJECT_VERSION);
app.setWindowIcon(QIcon::fromTheme("kylin-printer"));
/* 最小化拉起 */
app.setActivationWindow(MainWindow::getInstance());
/* wayland 下最小化拉起 */
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
QObject::connect(&app, &kdk::QtSingleApplication::messageReceived, [=]() {
if (MainWindow::getInstance()->getWindowId()) {
kabase::WindowManage::activateWindow(MainWindow::getInstance()->getWindowId());
}
});
}
QObject::connect(GsettingsMonitor::getInstance(),SIGNAL(sysFontSizeUpdate(QFont)),
MainWindow::getInstance(),SLOT(setQSSFontSize(QFont)));
QObject::connect(MainWindow::getInstance(),SIGNAL(getCurFontSize()),
GsettingsMonitor::getInstance(),SLOT(update()));
// double dFontSize = GsettingsMonitor::getInstance()->initFontSize();
// qDebug() << dFontSize;
GsettingsMonitor::getInstance()->update();
DaemonIpcDbus::getInstance();
try
{
g_findAndMatchWorkThread->start();
}
catch(const std::exception& e)
{
qFatal("Failed to initial find ppd thread.");
std::cerr << e.what() << '\n';
qApp->exit(0);
}
g_findAndMatchWorkThread->updatePPDsMap();
// DeviceMonitor::getInstance()->start();
DeviceMonitor::getInstance();
MainWindow::getInstance();//->setQSSFontSize(dFontSize);
PopWindowManager::getInstance();
if(checkCommand(cmd) == MAINWINDOW)
{
(MainWindow::getInstance())->show();
}
#if 0
if(cmd.compare("show")==0)
{
wnd.show();
}else {
wnd.hide();
}
update();
#else
DeviceMonitor::getInstance()->getarg(cmd);
// DeviceMonitor::getInstance()->start();
#endif
return app.exec();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。