1 Star 0 Fork 6

wang_keran001/ukui-clipboard

forked from openKylin/ukui-clipboard 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.cpp 2.25 KB
一键复制 编辑 原始数据 按行查看 历史
GRAND BEAST 提交于 2024-06-05 09:30 . 实现国际化功能
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QKeyEvent>
#include <QCommandLineOption>
#include <QCommandLineParser>
#include <QQuickWindow>
#include <QTranslator>
#include <QDebug>
#include "qtsingleapplication.h"
#include "clipboardbackend.h"
#include "windowsettings.h"
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QtSingleApplication app(argc, argv);
QCommandLineParser parser;
QCommandLineOption showWorkSpaceOption("show-menu","show contentMenu");
parser.addOption(showWorkSpaceOption);
parser.process(app);
if (app.isRunning())
{
if (parser.isSet("show-menu")) {
app.sendMessage(QApplication::arguments().length() > 1 ? QApplication::arguments().at(1) : app.applicationFilePath());
}
return EXIT_SUCCESS;
}
QTranslator translator;
if (!translator.load(QLocale::system(), QLatin1String("ukui-clipboard"),QLatin1String("_"), QLatin1String(":/"))){
// 如果指定语言的翻译文件未找到,尝试加载默认的翻译文件
if (!translator.load(QString("ukui-clipboard"))) {
qWarning() << "Failed to load translation files!";
}
}
app.installTranslator(&translator);
QQmlApplicationEngine engine;
qmlRegisterUncreatableType<ContentMenu>(
"ContentMenu", 1, 0, "ContentType",
"Not be instantiated in QML, we should only pass the enum types to QML "
"!");
ClipboardBackend backend;
QObject::connect(&app, &QtSingleApplication::messageReceived, [&backend](){
backend.open();
});
engine.rootContext()->setContextProperty("backend", &backend);
engine.addImageProvider(QLatin1String("inMemoryImages"), backend.getImageProvider());
const QUrl url(QStringLiteral("qrc:/FunctionMenuWindow.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
const QUrl url1(QStringLiteral("qrc:/ClipboardWindow.qml"));
engine.load(url1);
WindowSettings settings;
return app.exec();
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wang_keran001/ukui-clipboard.git
git@gitee.com:wang_keran001/ukui-clipboard.git
wang_keran001
ukui-clipboard
ukui-clipboard
openkylin/nile

搜索帮助