simplify translation methods; Ignore dependent details to prevent compilation errors

简化翻译加载方式;忽略依赖的详情以防止编译报错
This commit is contained in:
fensite 2021-10-14 09:03:05 +08:00
parent b1690dc2ec
commit 1b1ac4a0b1
3 changed files with 12 additions and 11 deletions

3
debian/control vendored
View File

@ -16,14 +16,13 @@ Build-Depends: debhelper (>=9),
libx11-dev, libx11-dev,
libqt5svg5-dev, libqt5svg5-dev,
libkf5networkmanagerqt-dev (>= 5.36.0), libkf5networkmanagerqt-dev (>= 5.36.0),
libnm-dev, libnm-dev,
libcap-dev, libcap-dev,
Standards-Version: 4.5.0 Standards-Version: 4.5.0
Rules-Requires-Root: no Rules-Requires-Root: no
Homepage: https://github.com/ukui/kylin-nm Homepage: https://github.com/ukui/kylin-nm
Vcs-Git: https://github.com/ukui/kylin-nm.git Vcs-Git: https://github.com/ukui/kylin-nm.git
Vcs-Browser: https://github.com/ukui/kylin-nm Vcs-Browser: https://github.com/ukui/kylin-nm
Package: kylin-nm Package: kylin-nm
Architecture: any Architecture: any
Depends: network-manager (>=1.2.6), Depends: network-manager (>=1.2.6),

4
debian/rules vendored
View File

@ -28,3 +28,7 @@ override_dh_auto_clean:
override_dh_auto_build: override_dh_auto_build:
dh_auto_build -- $(MAKE_OPTS) dh_auto_build -- $(MAKE_OPTS)
override_dh_shlibdeps:
dh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info

View File

@ -85,6 +85,7 @@ int main(int argc, char *argv[])
QtSingleApplication a(id, argc, argv); QtSingleApplication a(id, argc, argv);
qInstallMessageHandler(messageOutput); qInstallMessageHandler(messageOutput);
if (a.isRunning()) { if (a.isRunning()) {
qInfo() << "Kylin-Network-Manager Is Already Launched, just show";
auto connection = QDBusConnection::sessionBus(); auto connection = QDBusConnection::sessionBus();
QDBusInterface iface("com.kylin.network", QDBusInterface iface("com.kylin.network",
"/com/kylin/network", "/com/kylin/network",
@ -94,22 +95,19 @@ int main(int argc, char *argv[])
return 0; return 0;
} }
qDebug()<<"Kylin Network Manager Is Already Launched";
QApplication::setQuitOnLastWindowClosed(false); QApplication::setQuitOnLastWindowClosed(false);
// Internationalization // Internationalization
QString locale = QLocale::system().name(); QString locale = QLocale::system().name();
QTranslator trans_global; QTranslator trans_global;
if (locale == "zh_CN") { qDebug() << "QLocale " << QLocale();
trans_global.load(":/translations/kylin-nm_zh_CN.qm"); if (trans_global.load(QLocale(), "kylin-nm", "_", ":/translations/"))
{
a.installTranslator(&trans_global); a.installTranslator(&trans_global);
qDebug()<<"Translations load success";
} else {
qWarning() << "Translations load fail";
} }
if (locale == "tr_TR") {
trans_global.load(":/translations/kylin-nm_tr.qm");
a.installTranslator(&trans_global);
}
qDebug()<<"Translations Are Already Loaded";
MainWindow w; MainWindow w;
w.setProperty("useStyleWindowManager", false); //禁用拖动 w.setProperty("useStyleWindowManager", false); //禁用拖动